Tcl Dynamicly在ns2中将链接状态设置为“关闭”
我有一个简单的网络拓扑,大约有16个节点和它们之间的链接,我使用以下方法制作它们:Tcl Dynamicly在ns2中将链接状态设置为“关闭”,tcl,ns2,Tcl,Ns2,我有一个简单的网络拓扑,大约有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
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
}
程序如下:
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命令(如设置延迟等)也可以工作,但问题在于down命令。
你能告诉我有什么问题吗
更新:这是整个tcl文件:实际的错误消息真的没有帮助:“
ns:record:
”?:-(这是我在运行模拟后得到的错误的完整副本。$ns saeed_ek.tcl
正在创建一个结果:out_dv.nam 549.7kB,out_dv.tr 214.3kB。请运行nam out_dv.nam
。错误:任何错误的模拟.tcl都可能会抛出类似的错误。是的,但奇怪的是,现在模拟器on在3停止(这是达到阈值的时间),我看不到任何需要的链接下降。@Knudlarsen在这种情况下,它需要一个真正理解ns2产生的错误消息的人。我不知道您的代码是否是惯用的;我看不出它显然是错的(假设链接
方法在按描述使用时做了一些合理的事情)但我是一个普通的Tcl程序员,不是ns2或oTcl(ns2使用的OO扩展-它现在是oTcl唯一剩下的普通用户)的用户。实际的错误消息真的没有帮助:“ns:record:
”?:-(这是我在运行模拟后得到的错误的完整副本。$ns saeed_ek.tcl
正在创建一个结果:out_dv.nam 549.7kB,out_dv.tr 214.3kB。请运行nam out_dv.nam
。错误:任何错误的模拟.tcl都可能会抛出类似的错误。是的,但奇怪的是,现在模拟器on在3停止(这是达到阈值的时间),我看不到任何需要的链接下降。@Knudlarsen在这种情况下,它需要一个真正理解ns2产生的错误消息的人。我不知道您的代码是否是惯用的;我看不出它显然是错的(假设link
方法在按描述使用时做了一些合理的事情),但我是一名普通的Tcl程序员,不是ns2或oTcl(ns2使用的OO扩展-它现在是oTcl唯一剩下的普通用户)的用户。
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"
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"