[ns] A question about ns2 TCP cwnd
Ming Zhang
mzhang at cise.ufl.edu
Mon Nov 10 11:55:06 PST 2008
Hi all,
I am a new comer to ns2. I am struggling with a problem for few days and
really hope that someone here could help me out. Thanks in advance!
I would like to monitor TCP cwnd change in ns2. So I set up a simple
topology: 3 wired nodes 0-->1-->2 are linked together and there is a TCP
flow from 0 to 2 (relayed by 1). A FTP server is on top of TCP at 0, which
generates the traffic. I intentionally set link 0->1 with much higher
bandwidth (e.g., 2Mb) than that of 1->2 (e.g., 0.2Mb). I expect that packets
may be dropped (or cause timeout) at the intermediate node 1 because 0 could
send more packets to 1 than 1 could forward to 2. Then, TCP should change
its cwnd to force node 0 to slow down.
However, I could not see the sawtooth graph of cwnd at 0.
Then I set the queue size of link 1->2 to be 10 - now I could see that cwnd
changes as what I expect. However, if I set the queue size to be 20, the
sawtooth is gone and cwnd just keeps rising to a very large number again.
My question is that:
1. Which layer is the 1->2 queue size setting? MAC layer?
2. Why will the size 10 and 20 make different stories?
Any suggestion is welcome!
My TCL script is attached as follows:
set ns [new Simulator]
set nd [open out.tr w]
$ns trace-all $nd
set wnd_trace [open cwnd.tr w]
proc record {} {
global ns tcp wnd_trace
set time 0.1
set curr_cwnd [$tcp set cwnd_]
set now [$ns now]
puts $wnd_trace "$now $curr_cwnd "
$ns at [expr $now+$time] "record"
}
proc finish {} {
global ns nd wnd_trace
$ns flush-trace
close $nd
close $wnd_trace
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
$ns duplex-link $n0 $n1 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 0.2Mb 10ms DropTail
$ns queue-limit $n1 $n2 20
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n2 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
$ns at 1.0 "$ftp start"
$ns at 1.1 "record"
$ns at 100.0 "$ftp stop"
$ns at 100.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n2 $sink"
$ns at 101.0 "finish"
$ns run
More information about the Ns-users
mailing list