Studying TCP's Congestion Window using NS

Studying TCP‘s Congestion Window using NS



  • How to obtain TCP‘s CWND value

    • The most important value that determine the behavior of TCP is the congestion window size or traditionally abreviated as CWND
    • In NS, every TCP-type class (Agent/TCP/Tahoe, (Agent/TCP/Reno, etc) has a variable named
        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 will retrieve the congestion window size of a TCP module:
        set  tcp1  [new  Agent/TCP/Reno]
      
        set  cwnd1  [ $tcp1  set  cwnd_ ]      // read variable "cwnd_"
      


  • How to obtain TCP‘s CWND value PERIODICALLY
    • Now that we know how to read the congestion window size of a TCP module once, it is easy to make the NS simulation system repeatedly read the value (say, after every 0.1 sec of simulation time).
    • All we need to do is to schedule a read operation repeatedly
    • We have seen an 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 that the Simulator object variable be named $ns)
        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 [expr $now+0.1] "plotWindow  $tcpSource  $outfile"
        }
      
        1. The procedure plotWindow takes a paramter tcpSource which is a TCP agent

          So you can use 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 an output file (or use "stdout") in the main program


  • Examining progressing of CWND in TCP (Reno)
    • Here is the previous example (click here) which additional code to obtain the congestion window size of the TCP module $tcp1:

      (New code is colored as magenta )

        #Make a NS simulator
        set ns [new Simulator]	
      
        # Define a ‘finish‘ procedure
        proc 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 $n0 $n2   2Mb  10ms DropTail
        $ns duplex-link $n1 $n2   2Mb  10ms DropTail
        $ns duplex-link $n2 $n3 0.3Mb 200ms DropTail
        $ns duplex-link $n3 $n4 0.5Mb  40ms DropTail
        $ns duplex-link $n3 $n5 0.5Mb  30ms DropTail
      
        # Add a TCP sending module to node n0
        set tcp1 [new Agent/TCP/Reno]
        $ns attach-agent $n0 $tcp1
      
        # Add a TCP receiving module to node n4
        set sink1 [new Agent/TCPSink]
        $ns attach-agent $n4 $sink1
      
        # Direct traffic from "tcp1" to "sink1"
        $ns connect $tcp1 $sink1
      
        # Setup a FTP traffic generator on "tcp1"
        set ftp1 [new Application/FTP]
        $ftp1 attach-agent $tcp1
        $ftp1 set type_ FTP               (no necessary)
      
        # Schedule start/stop times
        $ns at 0.1   "$ftp1 start"
        $ns at 100.0 "$ftp1 stop"
      
        # Set simulation end time
        $ns at 125.0 "finish"		    (Will 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 [expr $now+0.1] "plotWindow $tcpSource  $outfile"
        }
      
        $ns  at  0.0  "plotWindow $tcp1  stdout"   // Start the 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, use 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 10 (default is 50 ?)
        # ########################################################
        $ns queue-limit $n2 $n3 10
      
        # ########################################################
        # TCP parameters:
        # ########################################################
        $tcp1 set window_ 8000
        $tcp1 set packetSize_ 552
      


  • Postscript: Analyzing multiple TCP flows
    • The easiest way to analyze the behavior of multiple TCP is to open one file to store the progression of one TCP agent‘s variable 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  0.0  "plotWindow $tcp1  $outfile1"
      
        $ns  at  0.0  "plotWindow $tcp2  $outfile2"
      

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

      Plot data of TCP 2 will 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

时间: 2024-12-24 23:53:55

Studying TCP's Congestion Window using NS的相关文章

Studying TCP's Throughput and Goodput using NS

Studying TCP's Throughput and Goodput using NS What is Throughput Throughput is the amount of data received by the destination. The Average Throughput is the throughput per unit of time Example: Suppose a TCP receiver receives 60 M Bytes of data in 1

Congestion Avoidance in TCP

Congestion Avoidance in TCP Consequence of lack of congestion control When a popular resource is shared without regulation the result is always over-utilization With the introduction of TCP in 1983, users can write networking applications that requir

【NS2】各种TCP版本 之 TCP Tahoe 和 TCP Reno(转载)

实验目的 学习TCP的拥塞控制机制,并了解TCP Tahoe 和 TCP Reno的运行方式. 基础知识回顾 TCP/IP (Transmission Control Protocol/Internet Protocol)是目前使用最广泛的一组通信协议.TCP所负责的功能包括:将自应用程序收到的信息分成许多较小的数据区段.提供连接导向的服务.提供可靠性服务.提供应用程序与应用和式之间的流量控制,并依据网络的状况提供拥塞控制. 当应用程序有数据要传送到网上去时,为了希望能和网络上其他的TCP联机公

[转帖]直击案发现场!TCP 10倍延迟的真相是?

直击案发现场!TCP 10倍延迟的真相是? http://zhuanlan.51cto.com/art/201911/605268.htm 内核参数调优 非常重要啊. 什么是经验?就是遇到问题,解决问题,总结方法.遇到的问题多了,解决的办法多了,经验自然就积累出来了.今天的文章是阿里技术专家蛰剑在工作中遇到的一个问题引发的对TCP性能和发送接收Buffer关系的系列思考(问题:应用通过专线从公司访问阿里云上的服务,专线100M,时延20ms,一个SQL查询了22M数据出现10倍+的信息延迟,不正

TCP 协议快被淘汰了,UDP 协议才是新世代的未来?

TCP 协议可以说是今天互联网的基石,作为可靠的传输协议,在今天几乎所有的数据都会通过 TCP 协议传输,然而 TCP 在设计之初没有考虑到现今复杂的网络环境,当你在地铁上或者火车上被断断续续的网络折磨时,你可能都不知道这一切可能都是 TCP 协议造成的.本文会分析 TCP 协议为什么在弱网环境下有严重的性能问题[^1]. 底层的数据传输协议在设计时必须要对带宽的利用率和通信延迟进行权衡和取舍,所以想要解决实际生产中的全部问题是不可能的,TCP 选择了充分利用带宽,为流量而设计,期望在尽可能短的

3-Transport Layer

?Please indicate the source: http://blog.csdn.net/gaoxiangnumber1 Welcome to my github: https://github.com/gaoxiangnumber1 3.1 Introduction and Transport-Layer Services A transport-layer protocol provides for logical communication between application

[转载] 协议栈优化总结

原文: http://blog.chunshengster.me/2013/12/mobile_tcp_stack_optimizing.html http://blog.chunshengster.me/2013/12/optimizing_your_linux_stack_for_maximum_mobile_web_performance.html [翻译,原文见:http://blog.cloudflare.com/optimizing-the-linux-stack-for-mobil

Android Change TCP Congestion Control

I The need of Change TCP Congestion Control in Android " TCP was originally designed for wired networks. Packet loss is considered to be the result of network congestion and the congestion window size is reduced dramatically as a precaution. However,

TCP Silly Window Syndrome

In the topic describing TCP's Maximum Segment Size (MSS) parameter, I explained the trade-off in determining the optimal size of TCP segments. If segments are too large, we risk having them become fragmented at the IP level. Too small, and we get gre