Hi,
 According to NS manual ( http://www.isi.edu/nsnam/ns/doc/node251.html )
add-rule command of DelayBox class sets a delay for packets flowing from src
to dst but when I run the following script, d0 (DelayBox object) causes a
delay for all packets in both directions. from src to dst and dst to src.
does anyone know why this happens?

Thanks,
Mobin


set ns [new Simulator]

# NAM file
set nf [open outtcp2.nam w]
$ns namtrace-all $nf

# finish procedure
proc finish {} {
 global ns nf
 $ns flush-trace
 close $nf
 exec nam outtcp2.nam &
 exit 0
}


# create nodes
set n0 [$ns node]
set n1 [$ns node]
set db0 [$ns DelayBox]

$ns duplex-link $n0 $db0 1Mb 100ms DropTail
$ns duplex-link $n1 $db0 1Mb 100ms DropTail

# create TCP agents
set src [new Agent/TCP/FullTcp]
set sink [new Agent/TCP/FullTcp]

$ns attach-agent $n0 $src
$ns attach-agent $n1 $sink

$src set fid_ 0
$src set fid_ 0

$ns connect $src $sink

# set up TCP-level connections
$sink listen
$src set window_ 100

# create traffic generator
set ftp0 [new Application/FTP]
$ftp0 attach-agent $src

# setup DelayBox
set delay_ms [new RandomVariable/Uniform];
$delay_ms set min_ 2000
$delay_ms set max_ 2000


$db0 add-rule [$n0 id] [$n1 id] $delay_ms


# run NS
$ns at 0.5 "$ftp0 start"
$ns at 10.0 "finish"
$ns run

Reply via email to