NS模拟出错 20
我运行NS与网络模拟书上的一段例子程序(NAM入门那节的).结果出现下面的错误.望大侠赐教.(_o82cmdline1)invokedfromwithin"_o82cmd...
我运行NS与网络模拟书上的一段例子程序(NAM入门那节的).结果出现下面的错误.望大侠赐教.
(_o82 cmd line 1)
invoked from within
"_o82 cmd reset"
invoked from within
"catch "$self cmd $args" ret"
(procedure "_o82" line 2)
(SplitObject unknown line 2)
invoked from within
"$a reset"
(procedure "_o10" line 4)
(Node reset line 4)
invoked from within
"$Node_($nn) reset"
(procedure "_o3" line 12)
(Simulator run line 12)
invoked from within
"$ns run"
(file "nam-test2.tcl" line 78)
源代码
#创建模拟器对象
set ns [new Simulator]
#Define different colors for data flows
$ns color 1 Blue
$ns color 2 Red
#生成nam文件及动画
set nf [open /home/ns226/out.nam w]
$ns namtrace-all $nf
#定义finish过程
proc finish {} {
#清空输出缓存,关闭nam输出文件
global ns nf
$ns flush-trace
close $nf
#直接调用nam来打开out.nam进行动画播放
exec nam out.nam &
exit 0
}
#创建4个节点
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#创建节点间联接
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n3 $n2 1Mb 10ms SFQ
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n2 $n3 queuePos 0.5
#创建2个数据源(为n0和n1)和1个数据接收者(数据接收节点n3)
set cbr0 [new Application/Traffic/CBR]
$ns attach-agent $n0 $cbr0
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 set fid_ 1
set cbr1 [new Application/Traffic/CBR]
$ns attach-agent $n1 $cbr1
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr0 set fid_ 2
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
#把发送源和接收者连接起来
$ns connect $cbr0 $null0
$ns connect $cbr1 $null0
#安排两个数据源的启动时间
$ns at 0.5 "$cbr0 start"
$ns at 1.0 "$cbr1 start"
$ns at 4.0 "$cbr1 stop"
$ns at 4.5 "$cbr0 stop"
#在模拟时间的第5秒调用finish过程
$ns at 5.0 "finish"
#运行NS模拟器
$ns run 展开
(_o82 cmd line 1)
invoked from within
"_o82 cmd reset"
invoked from within
"catch "$self cmd $args" ret"
(procedure "_o82" line 2)
(SplitObject unknown line 2)
invoked from within
"$a reset"
(procedure "_o10" line 4)
(Node reset line 4)
invoked from within
"$Node_($nn) reset"
(procedure "_o3" line 12)
(Simulator run line 12)
invoked from within
"$ns run"
(file "nam-test2.tcl" line 78)
源代码
#创建模拟器对象
set ns [new Simulator]
#Define different colors for data flows
$ns color 1 Blue
$ns color 2 Red
#生成nam文件及动画
set nf [open /home/ns226/out.nam w]
$ns namtrace-all $nf
#定义finish过程
proc finish {} {
#清空输出缓存,关闭nam输出文件
global ns nf
$ns flush-trace
close $nf
#直接调用nam来打开out.nam进行动画播放
exec nam out.nam &
exit 0
}
#创建4个节点
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#创建节点间联接
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n3 $n2 1Mb 10ms SFQ
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n2 $n3 queuePos 0.5
#创建2个数据源(为n0和n1)和1个数据接收者(数据接收节点n3)
set cbr0 [new Application/Traffic/CBR]
$ns attach-agent $n0 $cbr0
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 set fid_ 1
set cbr1 [new Application/Traffic/CBR]
$ns attach-agent $n1 $cbr1
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr0 set fid_ 2
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
#把发送源和接收者连接起来
$ns connect $cbr0 $null0
$ns connect $cbr1 $null0
#安排两个数据源的启动时间
$ns at 0.5 "$cbr0 start"
$ns at 1.0 "$cbr1 start"
$ns at 4.0 "$cbr1 stop"
$ns at 4.5 "$cbr0 stop"
#在模拟时间的第5秒调用finish过程
$ns at 5.0 "finish"
#运行NS模拟器
$ns run 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询