Studying TCP ' s congestion Window using NS

Source: Internet
Author: User

Studying TCP ' s congestion Window using NS

  • How to obtain TCP ' s CWND value

    • The most important value this determine the behavior of TCP is the congestion window size or traditionally Abrevi Ated as CWND

    • In NS, every Tcp-type class (Agent/tcp/tahoe, (Agent/tcp/reno, etc) have a variable NA Med

        Cwnd_   

      that contains the congestion window size of the TCP module

    • Recall that we can use the set command to return a value

    • Hence, the following command would retrieve the congestion window size of a TCP module:

        Set  TCP1  [New  Agent/tcp/reno]  set  cwnd1  [$tcp 1  set  cwnd_]      // Read variable "Cwnd_"   

  • 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"  }

          1. The procedure Plotwindow takes a paramter Tcpsource which is a TCP agent

            The procedure to plot the CWND from any number of TCP flows.

          2. 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

    • The easiest-analyze the behavior of multiple TCP is to open one file to store the progression of one TCP agent ' s VA Riable values.

    • Example:2 TCP Agents

        Set TCP1 [New Agent/tcp/reno]  ...  Set TCP2 [New Agent/tcp/reno]  ...  Set Outfile1  [Open  "WinFile1"  W]  set outfile2  [Open  "WinFile2"  W]  $ NS at "Plotwindow $tcp 1 $outfile 1  " $ns at "Plotwindow $tcp 2        $outfile 2 "     

      Plot data of TCP 1 would be store in file "WinFile1"

      Plot Data of TCP 2 would be store in file "WinFile2"

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.