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

Problem saving output data with ns



All:

According to the Marc Greis's ns Tutorial, the following code fragment:

set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
...
proc record {} {
	#Redeclare the sink and file handle variables
	global null0 f0
	#get an instance of the simulator
	set ns [Simulator instance]
	#set the time after which the procedure should be called again
	set time 0.5
	#How many bytes have been received by the traffic sinks?
	set bw0 [$null0 set bytes_]
	#Get the current time
	set now [$ns now]
	#calculate the bandwidth (in MBit/s) and write it to the files
	puts $f0 "$now [expr $bw0/$time*8/1000000]"
	#Reset the bytes_values on the traffic sinks
	$null0 set bytes_ 0
	#Re-schedule the procedure
	$ns at [expr $now+$time] "record"
}

should find the number of bytes sent to the null agent $null0.  However, on 
execution, I receive the following error:

ns: record: can't read "bytes_": no such variable
    while executing
"subst $[subst $var]"
    (procedure "_o78" line 5)
    (SplitObject set line 5)
    invoked from within
"$null0 set bytes_"
    (procedure "record" line 9)
    invoked from within
"record"

So basically, bytes_ is not recognized as a member of class agent.  Is there 
another way of getting the size of agent?  I tried using size_ instead of 
bytes_, but received exactly the same error.  Is something else wrong with my 
syntax?

Cordially,

Allan