Re: [ns] timer on tcl

2009-05-25 Thread Mats Folke

Hi!

The timer method is probably not executed because the finish-method gets 
scheduled first. Both methods should execute at 50s, but for some reason 
"finish" ends up ahead in the scheduler. My suggestion is to set the 
finish-time at 50.1s. 

Good luck!

Mats Folke

El hadi Cherkaoui wrote:
> hi all,
> 
> i want ot creat a timer on tcl
> 
> set ns [new Simulator]
> set bw bw2.dat
> set f [open $bw w]
> 
> proc timer {} {
> 
>   global ns f
>   set time 10
>   set now [$ns now]
> 
>   set cost [expr floor( rand() * 40) + 20]   ;# exemple
>   puts $f "$now : $cost"
>   $ns at [expr $now+$time] "timer"
> 
> 
> }
> 
> proc finish {} {
>     puts "Stop simulation"
>     global ns f
>     $ns flush-trace
>     close $f
>     exit 0
> }
> 
> $ns at 0.0 "timer"
> $ns at 50  "finish"
> $ns run
> 
> 
> i have 5 values every 10s but the simulation doesn't take 50 s why ?



-- 
Mats Folke, M.Sc., Lic.Eng.
Research Engineer

Ericsson AB Office: +46 10 7171385
Ericsson Research   Fax: +46 920 99621
P.O. Box 920Mobile: +46 76 1271385
SE-971 28 Luleå
Sweden



Re: [ns] timer on tcl

2009-05-25 Thread Vincent Chimaobi Emeakaroha

Hi

how do you mean that the simulation doesn't take 50s? Bear in mind that
simulation time ist not equal to clock time!! So you don't expect your
simulation to last exactly 50s clock time. This is actually the essence
of simulation.

greetings
Vincent.

El hadi Cherkaoui wrote:
> hi all,
> 
> i want ot creat a timer on tcl 
> 
> set ns [new Simulator]
> set bw bw2.dat
> set f [open $bw w]
> 
> proc timer {} {
>   
>   global ns f
>   set time 10
>   set now [$ns now]
>  
>   set cost [expr floor( rand() * 40) + 20]   ;# exemple 
>   puts $f "$now : $cost"
>   $ns at [expr $now+$time] "timer"
> 
> 
> } 
> 
> proc finish {} {
> puts "Stop simulation"
> global ns f
> $ns flush-trace
> close $f
> exit 0
> }
> 
> $ns at 0.0 "timer"
> $ns at 50  "finish"
> $ns run 
> 
> 
> i have 5 values every 10s but the simulation doesn't take 50 s why ?
> 
> 
> 
>