我有一个简单的网络拓扑,其中有大约16个节点和它们之间的链接,我使用它来创建它们:
for {set i 0} {$i < 16} {incr i} {
set n($i) [$ns node]
}
for { set i 0 } {$i <16} {incr i} {
$ns duplex-link $n($i) $n([expr ($i+1) %16]) 1Mb 10ms DropTail
$ns duplex-link $n($i) $n([expr ($i+4) %16]) 1Mb 10ms DropTail
}
然后从节点0到节点8有一个cbr流量发起者,具有简单的udp流量。现在我有一个过程,每0.5个节点使用LossMonitor对节点8的到达流量进行采样,然后基于阈值将删除(向下)拓扑中的特定链路。如下所示:
set sink0 [new Agent/LossMonitor]
$ns attach-agent $n(8) $sink0
$ns connect $udp0 $sink0
和程序:
proc record {} {
global sink0 a sum n
set ns [Simulator instance]
set time 0.5
set bw0 [$sink0 set bytes_]
set now [$ns now]
set sum [expr $bw0+$sum]
if {$sum >= $a } {
for { set i 0 } {$i <16} {incr i} {
set myLink [[$ns link $n(0) $n(4)] link]
$myLink down (this is the error)
}
return
}
$sink0 set bytes_ 0
$ns at [expr $now+$time] "record"
}
$ns at 0.5 "record"
$ns at 5.0 "finish"
现在我的问题是$ myLink下线,这给了我这个错误:
ns: record:
(_o83 cmd line 1)
invoked from within
"_o83 cmd down"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o83" line 2)
(SplitObject unknown line 2)
invoked from within
"$myLink down"
(procedure "record" line 11)
invoked from within
"record"
其他#myLink命令(例如设置延迟等)也有效,但问题出在down命令上。 你能告诉我这是什么问题吗?
更新:这是整个tcl文件:http://pastebin.com/4kt2TxBX