[ns] How to schedule an event in a proc
haicheng flammy
flammy_ns at yahoo.com
Fri Jun 17 16:20:50 PDT 2005
Hi there,
I want to schedule the UDP to send data at specified time. but all of the event [$src send 1000] happened at time 0. Why? How can I do it?
set ns [new Simulator]
set tf [open out.tr w]
$ns trace-all $tf
set n1 [$ns node]
set n2 [$ns node]
set link [$ns simplex-link $n1 $n2 100kb 0ms DropTail]
set src [new Agent/UDP]
$ns attach-agent $n1 $src
proc finish {} {
global ns tf
$ns flush-trace
close $tf
exit 0
}
proc sendpacket {} {
global ns src
$ns at 1.0 [$src send 1000]
$ns at 2.0 [$src send 1000]
$ns at 3.0 [$src send 1000]
$ns at 4.0 [$src send 1000]
$ns at 5.0 [$src send 1000]
}
set sink [new Agent/Null]
$ns attach-agent $n2 $sink
$ns connect $src $sink
$ns at 0 "sendpacket"
$ns at 10.0 "finish"
$ns run
---------------------------------
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
More information about the Ns-users
mailing list