Studying TCP ' s congestion Window using NS
- How to obtain TCP ' s CWND value
- How to obtain TCP ' s CWND value periodically
- Now so we know how to read the congestion window size of a TCP module once, it's easy-to-make the ns Simulation System repeatedly read the value (say, after every 0.1 sec of simulation time).
- All the We need to do are to schedule a read operation repeatedly
- We have seen a example of self-scheduling behavior in the ' 2 person talking example ' (click here)
- We can use a similar self-scheduling procedure to obtain the value of CWND repeated.
- Example:(Requires thatSimulatorObject variable be named$ns)
Proc Plotwindow {tcpsource outfile} { global ns set now [$ns now] [$tcpSource set Cwnd_] #< C10/>print time CWnd for Gnuplot to plot progressing on CWND puts $outfile "$now $cwnd" /c14> $ns at [expr $now +0.1] "Plotwindow $tcpSource $outfile" } |
- The procedure Plotwindow takes a paramter Tcpsource which is a TCP agent
The procedure to plot the CWND from any number of TCP flows.
- The procedure Plotwindow takes an output file ID outfile
You should first open a output file (or use "stdout") in the main program
- examining progressing of CWND in TCP (Reno)
- Here's the previous example (click here) which additional code to obtain theCongestion Window Sizeof the TCP module$tcp 1:
(New code is colored as magenta )
#Make a NS simulatorSet NS [New Simulator]# Define A ' finish ' procedureProc Finish {} {exit 0}# Create the nodes:Set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set N4 [$ns node] set N5 [$ns node]# Create the Links:$ns duplex-link $n 0 $n 2 2Mb 10ms droptail $ns duplex-link $n 1 $n 2 2Mb 10ms droptail $ns duplex-link $n 2 $n 3 0.3Mb 200ms droptail $ns duplex-link $n 3 $n 4 0.5Mb 40ms droptail $ns duplex-link $n 3 $n 5 0.5Mb 30ms Droptail# ADD A TCP sending module to node N0Set TCP1 [New Agent/tcp/reno] $ns attach-agent $n 0 $tcp 1# ADD A TCP receiving module to node N4Set SINK1 [New Agent/tcpsink] $ns attach-agent $n 4 $sink 1# Direct traffic from ' TCP1 ' to ' Sink1 '$ns Connect $tcp 1 $sink 1# Setup A FTP traffic generator on "TCP1"Set FTP1 [New Application/ftp] $ftp 1 attach-agent $tcp 1 $ftp 1 set type_ FTP (no necessary)# Schedule Start/stop Times$ns at 0.1 "$ftp 1 start" $ns at 100.0 "$ftp 1 Stop"# Set Simulation End Time$ns at 125.0 "Finish" (would invoke "Exit 0")################################################## # # Obtain CWND from TCP agent ################################ ################## proc Plotwindow {tcpsource outfile} {Global NS set now [$ns now] set CWnd [$tcpSource set Cwnd_] # # #Print time CWND for gnuplot to plot progressing on CWnd puts $outfile "$now $cwnd" $ns at [ex PR $now +0.1] "Plotwindow $tcpSource $outfile"} $ns at 0.0 "Plotwindow $tcp 1 stdout" //Start T He probe ! # RUN Simulation!!!!$ns Run |
- Example Program: (Demo above code)
- This NS Prog prints the (time, CWnd) to the Terminal:click here
- This NS Prog prints the (time, CWnd) to the output file ' winfile ': click here
To run the program with the command:
NS RENO2.TCL
To plot the window progressing from ' Winfile ', do:
- Unix>> gnuplot
-
- gnuplot>> Plot "winfile" using 1:2 title "Flow 1" with lines 1
- Note:
In case you wonder why the CWND plot look so different, it's because the setting of some parameters.
ADD the following statements to the simulation to get the one I-used in class:
# ######################################################## # Set Queue Size of link (n2-n3) to ten (default is 50?) # ######################################################## $ns queue-limit $n 2 $n 3 # ############### ######################################### # TCP parameters: # ######################################### ############### $tcp 1 set window_ 8000 $tcp 1 set packetsize_ 552 |
- This NS Prog would draw the Cwnd:click here
- Postscript:analyzing multiple TCP flows
Http://www.mathcs.emory.edu/~cheung/Courses/558-old/Syllabus/90-NS/3-Perf-Anal/TCP-CWND.html
Studying TCP ' s congestion Window using NS