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

Re: Question on your sample code






The code seems to be OK. I bet you are using an Agent/Null for sink and
sink1. Use something like Agent/LossMonitor instead.

/FCD 
 
----------------------------------------------------------------------
Fernando Cela
email: [email protected]                     phone: +46 31 772 1709




On Tue, 27 Jul 1999, yangh wrote:

> Hi,
> 
> I got your mail address from the ns-user list.  I tried codes you posted
> on the list, but there is an error.  Hope you could help me on that.
> 
> I tried the code about the 'record' procedure. I want to access the bytes_
> , but got the error.
> 
> Here is the partial codes I wrote:
> 
> proc record {} {
>         global sink sink1 f88 f99
>         #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 bytrec0 [$sink set bytes_]
>         set bytrec1 [$sink1 set bytes_]
>         #Get the current time
>         set now [$ns now]
>         #Calculate the bandwidth (in MBit/s) and write it to the files
>         #puts $f88 "$now [expr $bytrc0/1000]"
>         puts $f99 "$now [expr $bytrc1/1000]"
>         #Reset the bytes_ values on the traffic sinks
>         $sink set bytes_ 0
>         $sink1 set bytes_ 0
>         #Re-schedule the procedure
>         $ns at [expr $now+$time] "record"
> }
> 
> But I got the error like this:
> 
> ns: record: can't read "bytes_": no such variable
>     while executing
> "subst $[subst $var]"
>     (procedure "_o116" line 5)
>     (SplitObject set line 5)
>     invoked from within
> "$sink set bytes_"
>     (procedure "record" line 8)
>     invoked from within
> "record"
> 
> Hope you could give me some hints.  Thank you for your help and time.
> 
> 
> ==========================================================================
> Yang Huang                                           ___   ___
> Computer Engineering                          /  /  /__   /
> University of Southern California            /__/  ___/  /__
> [email protected]
> ==========================================================================
> 
>