Lab 4: Using NS
实验过程
- 编写tcl脚本
- 使用ns运行tcl脚本模拟网络,并利用nam生成动画
- 解析上一步产生的trace数据,计算丢包率
- 使用解析后的数据画图
- 分析原理
实验环境
Linux Ubuntu 18.04 with bash
安装依赖
sudo apt-get install ns2 (ns)
sudo apt-get install tcl (tclsh)
sudo apt-get install nam (nam)
sudo apt-get install original-awk (awk)
sudo apt-get install gnuplot-qt
开始实验
编写tcl脚本
set ns [new Simulator]
#open a nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#open a trace file
set tf [open out.tr w]
$ns trace-all $tf
#finish procedure
proc finish {} {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam out.nam &
exit 0
}
#create nodes
set node(ht