Fwd: Problem at dynamically making a link status to down ns2

Saeed Ektesabi <[email protected]> Sun, 26 Jun 2016 12:49:33 +0200
Newsgroups gmane.network.simulator.isi
Message-ID <CACc9srHpjFpeR=8887TWieSVNcUh2NRHw=7B1Mc3abqzU3PEUA@mail.gmail.com>
I have a simple network topology with about 16 nodes and links between them
which I made them using this :

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}
then there is a cbr traffic originator from node 0 to node 8 with a
simple udp traffic. Now I have a procedure that every 0.5 samples the
arrived traffic at node 8 with a LossMonitor and then based on a
threshold will remove(down) specific links within the topology.like this
 :
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)]
            $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"

Now my problem is at the line $myLink down,which gives me this error:


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"

Also other #myLink commands such as setting delay and etc works,but the
problem is with the down command. Can you tell me what is the problem?

Update: This is the whole tcl file: http://pastebin.com/4kt2TxBX