[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] help



hello...
attached file is my script.
Why I always get this error messgae?

ns: record: can't read "dest(1)": no such variable
    while executing
"$dest($i) set bytes_"
    (procedure "record" line 10)
    invoked from within
"record"

Could anybody help me? thanks in advance...
                    
                     Jay...
set ns [new Simulator]
set bw_f [open out.bw.txt w]
proc finish {} {
  global bw_f
  close $bw_f
  exit 0
}
proc record {} {
for {set i 1} {$i < 65} {incr i} {
global dest($i)
}
global bw_f
set ns [Simulator instance]
set next_time 0.1
set now_time [$ns now]
for {set i 1} {$i < 65} {incr i} {
set by($i) [$dest($i) set bytes_]
}
for {set i 1} {$i < 65} {incr i} {
set byall [expr $byall + $by($i)]
}
puts $bw_f "$now_time [expr $byall/$next_time*8/1000000]"

for {set i 1} {$i < 65} {incr i} {
$dest($i) set bytes_ 0
}
  $ns at [expr $now_time + $next_time] "record"
}

set n(0) [$ns node]

for {set i 1} {$i < 65} {incr i} {
set n($i) [$ns node]
}

set n(99) [$ns node]

for {set i 1} {$i < 65} {incr i} {
$ns duplex-link $n($i) $n(0) 100mb 0ms DropTail
$ns queue-limit $n($i) $n(0) 100000000
}

$ns duplex-link $n(0) $n(99) 1.497296mb 0ms DropTail
$ns queue-limit $n(0) $n(99) 244

for {set i 1} {$i < 65} {incr i} {
set dest($i) [new Agent/LossMonitor]
$ns attach-agent $n(99) $dest($i)
}

for {set i 1} {$i < 65} {incr i} {

  set source($i) [new Agent/CBR/UDP]
  set traffic($i) [new Traffic/Expoo]
  $traffic($i) set packet-size 512
  $traffic($i) set burst-time 0.35s
  $traffic($i) set idle-time 0.65s
  $traffic($i) set rate 0.064mbps
  $source($i) attach-traffic $traffic($i)
  $ns connect $source($i) $dest($i)
}

for {set i 1} {$i < 65} {incr i} {
$ns attach-agent $n($i) $source($i)
}

for {set i 1} {$i < 65} {incr i} {
$source($i) set fid_ $i
}

$ns at 0.5 "record"

for {set i 1} {$i < 65} {incr i} {
$ns at 1.0 "$source($i) start"
$ns at 999.0 "$source($i) stop"
}

$ns at 1000.0 "finish"
$ns run