【发布时间】:2018-03-21 15:50:47
【问题描述】:
我提到了一个 ns2 的程序,当我将这个 -> $ns at 0.5 “$cbr0 start” 更改为 this->$ns at 0.5 “$cbr0 start” 时,该程序给了我分段错误(核心转储) . “”有问题吗?如果我将“”更改为“”以下是错误
错误
(_o5 命令行 1) 从内部调用 "_o5 cmd at 0.5 "_o84 start"" 从内部调用 "catch "$self cmd $args" ret" 从内部调用 "如果 [catch "$self cmd $args" ret] { 设置 cls [$self 信息类] 全局错误信息 设置已保存信息 $errorInfo 错误“调用类 $cls 时出错:$args”$...” (程序“_o5”第 2 行) (SplitObject 未知第 2 行) 从内部调用 "_o5 在 0.5 “o84 开始”" (“eval”正文第 1 行) 从内部调用 “在 $args 处评估 $scheduler” (程序“_o3”第 3 行) (第 3 行的模拟器) 从内部调用 "$ns 在 0.5 "$cbr0 开始"" (文件“b.tcl”第 71 行)
代码:
set ns [new Simulator]
#Define different colors for data flow
$ns color 1 Blue
$ns color 2 Red
#open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#define a finish procedure
proc finish {} {
global ns nf
$ns flush-trace
#close the trace file
close $nf
#execute nam on the trace file
exec nam out.nam&
exit 0
}
#create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#create links between nodes
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n3 $n2 1Mb 10ms SFQ
#orientation
$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
#Monitors the queue for the link betweeen node 2 & 3
$ns duplex-link-op $n2 $n3 queuePos 0.5
#Create udp agent and attatch it to node 0
set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0
#Create CBR traffic source & attatch it to upd0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#Create udp agent and attatch it to node 1
set udp1 [new Agent/UDP]
$udp1 set class_ 2
$ns attach-agent $n1 $udp1
#Create CBR traffic source & attatch it to upd1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr0 attach-agent $udp1
#Create a CBR traffic source & attatch it to udp 1
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
#connect the traffic source with the traffic sink
$ns connect $udp0 $null0
$ns connect $udp1 $null0
#Schedule events for the CBR agent
$ns at 0.5 “$cbr0 start”
$ns at 1.0 “$cbr1 start”
$ns at 4.0 “$cbr1 stop”
$ns at 4.5 “$cbr0 stop”
#call finish after 5 seconds of simulation time
$ns at 5.0 “finish”
#Run the simulator
$ns run
【问题讨论】:
-
有问题吗?
-
分段错误核心转储
标签: ns2