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"
}- 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.
- The procedure plotWindow takes an output file ID outfile
You should first open an output file (or use "stdout") in the main program
- The procedure plotWindow takes a paramter tcpSource which is a TCP agent
- 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- This NS Prog will draw the CWND: click here
- Here is the previous example (click here) which additional code to obtain the congestion window size of the TCP module $tcp1:
- 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的更多相关文章
- TCP系列43—拥塞控制—6、Congestion Window Validation(CWV)
一.概述 在RFC2861中,区分了TCP连接数据传输的三种状态 After sending a data segment: If tcpnow - T_last >= RTO ...
- 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 r ...
- Congestion Avoidance in TCP
Congestion Avoidance in TCP Consequence of lack of congestion control When a popular resource is sha ...
- 【NS2】各种TCP版本 之 TCP Tahoe 和 TCP Reno(转载)
实验目的 学习TCP的拥塞控制机制,并了解TCP Tahoe 和 TCP Reno的运行方式. 基础知识回顾 TCP/IP (Transmission Control Protocol/Interne ...
- QUIC和TCP
作者:henrystark henrystark@126.com Blog: http://henrystark.blog.chinaunix.net/ 日期:20140626 本文遵循CC协议:署名 ...
- [转帖]直击案发现场!TCP 10倍延迟的真相是?
直击案发现场!TCP 10倍延迟的真相是? http://zhuanlan.51cto.com/art/201911/605268.htm 内核参数调优 非常重要啊. 什么是经验?就是遇到问题,解决问 ...
- TCP 协议快被淘汰了,UDP 协议才是新世代的未来?
TCP 协议可以说是今天互联网的基石,作为可靠的传输协议,在今天几乎所有的数据都会通过 TCP 协议传输,然而 TCP 在设计之初没有考虑到现今复杂的网络环境,当你在地铁上或者火车上被断断续续的网络折 ...
- Linux上TCP的几个内核参数调优
Linux作为一个强大的操作系统,提供了一系列内核参数供我们进行调优.光TCP的调优参数就有50多个.在和线上问题斗智斗勇的过程中,笔者积累了一些在内网环境应该进行调优的参数.在此分享出来,希望对大家 ...
- google 论文
从google历年所有论文的汇总来看,TOP5的分别是人工智能和机器学习.算法理论.人机交互与视觉.自然语言处理.机器感知,大家从一个侧面看出goolge research的重点了吧. Google所 ...
随机推荐
- 在c#中使用sqlite3
Sqlite3是一款优秀的数据库软件,在嵌入式设备和移动端都有使用,我司现在有些项目使用的数据库是access,说实话,对这些不太感冒,我还是喜欢优雅简单的东东,于是乘着这几天休息的时间学习了下在c# ...
- 实现Map按key或按value排序
原理思路:用List实现排序,然后将List中的值遍历存入到LinkedHashMap 实现方式: //这里将map.entrySet()转换成list List<Map.Entry<St ...
- WIndows下 Pycharm 配置Anaconda和TensorFlow
1安装PyCharm 前提安装Python,然后去官网下载PyCharm 2 安装Anaconda 在官网下载Anaconda,并安装 下载好之后就跟安装一般的软件没啥区别,选择自己安装的文件夹,下一 ...
- 【数据服务中间件】一、HttpServlet
一.概念 Servlet的框架是由两个Java包组成:javax.servlet和javax.servlet.http GenericServlet和HttpServlet 3个方法代表了Servle ...
- 让EntityFramwork自动更新表结构
在项目开发中,难免会遇到数据库表结构变化的情况,手动去维护数据库是一件繁琐的事情.好在EntityFramwork为我们这些懒人提供了可供自动更新数据结构的机制,废话不多说,直接上代码: 首先创建一个 ...
- selenium+Python(文件下载)
webdriver允许我们设置默认的文件下载路径,也就是说,文件会自动下载并保存到设置的目录中 下面以Firefox浏览器为例: from selenium import webdriver from ...
- Django 入门项目案例开发(下)——创建项目应用及模型类
关注微信公众号:FocusBI 查看更多文章:加QQ群:808774277 获取学习资料和一起探讨问题. 前面两章是在已经开发好的项目上用来描述环境和业务,这一章创建一个全新的项目来用作开发,你可以跟 ...
- 配置nginx服务器全局命令
service nginx start|stop|reload 报错:Failed to reload nginx.service: Unit not found.[解决方案] 在执行service ...
- gulp入门详情
gulp是前端开发过程中对代码进行构建的工具,是自动化项目的构建利器:她不仅能对网站资源进行优化,而且在开发过程中很多重复的任务能够使用正确的工具自动完成:使用她,我们不仅可以很愉快的编写代码,而且大 ...
- WPF 资源字典
使用好处:存储需要被本地话的内容(错误消息字符串等,实现软编码),减少重复的代码,重用样式,实现多个项目之间的共享资源;修改一个地方所有引用的地方都会被修改,方便统一风格; 使用方法,归纳起来主要有下 ...