set N 8
set B 250
set K 65
set RTT 0.0001 set simulationTime 1.0 set startMeasurementTime 1
set stopMeasurementTime 2
set flowClassifyTime 0.001 set sourceAlg DC-TCP-Sack
set switchAlg RED
set lineRate 10Gb
set inputLineRate 11Gb set DCTCP_g_ 0.0625
set ackRatio 1
set packetSize 1460 set traceSamplingInterval 0.0001
set throughputSamplingInterval 0.01
set enableNAM 0 set ns [new Simulator] Agent/TCP set ecn_ 1
Agent/TCP set old_ecn_ 1
Agent/TCP set packetSize_ $packetSize
Agent/TCP/FullTcp set segsize_ $packetSize
Agent/TCP set window_ 1256
Agent/TCP set slow_start_restart_ false
Agent/TCP set tcpTick_ 0.01
Agent/TCP set minrto_ 0.2 ; # minRTO = 200ms
Agent/TCP set windowOption_ 0 if {[string compare $sourceAlg "DC-TCP-Sack"] == 0} {
Agent/TCP set dctcp_ true
Agent/TCP set dctcp_g_ $DCTCP_g_;
}
Agent/TCP/FullTcp set segsperack_ $ackRatio;
Agent/TCP/FullTcp set spa_thresh_ 3000;
Agent/TCP/FullTcp set interval_ 0.04 ; #delayed ACK interval = 40ms Queue set limit_ 1000 Queue/RED set bytes_ false
Queue/RED set queue_in_bytes_ true
Queue/RED set mean_pktsize_ $packetSize
Queue/RED set setbit_ true
Queue/RED set gentle_ false
Queue/RED set q_weight_ 1.0
Queue/RED set mark_p_ 1.0
Queue/RED set thresh_ [expr $K]
Queue/RED set maxthresh_ [expr $K] DelayLink set avoidReordering_ true if {$enableNAM != 0} {
set namfile [open out.nam w]
$ns namtrace-all $namfile
} set mytracefile [open mytracefile.tr w]
set throughputfile [open thrfile.tr w] proc finish {} {
global ns enableNAM namfile mytracefile throughputfile
$ns flush-trace
close $mytracefile
close $throughputfile
if {$enableNAM != 0} {
close $namfile
exec nam out.nam &
}
exit 0
} proc myTrace {file} {
global ns N traceSamplingInterval tcp qfile MainLink nbow nclient packetSize enableBumpOnWire set now [$ns now] for {set i 0} {$i < $N} {incr i} {
set cwnd($i) [$tcp($i) set cwnd_]
set dctcp_alpha($i) [$tcp($i) set dctcp_alpha_]
} $qfile instvar parrivals_ pdepartures_ pdrops_ bdepartures_ puts -nonewline $file "$now $cwnd(0)"
for {set i 1} {$i < $N} {incr i} {
puts -nonewline $file " $cwnd($i)"
}
for {set i 0} {$i < $N} {incr i} {
puts -nonewline $file " $dctcp_alpha($i)"
} puts -nonewline $file " [expr $parrivals_-$pdepartures_-$pdrops_]"
puts $file " $pdrops_" $ns at [expr $now+$traceSamplingInterval] "myTrace $file"
} proc throughputTrace {file} {
global ns throughputSamplingInterval qfile flowstats N flowClassifyTime set now [$ns now] $qfile instvar bdepartures_ puts -nonewline $file "$now [expr $bdepartures_*8/$throughputSamplingInterval/1000000]"
set bdepartures_ 0
if {$now <= $flowClassifyTime} {
for {set i 0} {$i < [expr $N-1]} {incr i} {
puts -nonewline $file " 0"
}
puts $file " 0"
} if {$now > $flowClassifyTime} {
for {set i 0} {$i < [expr $N-1]} {incr i} {
$flowstats($i) instvar barrivals_
puts -nonewline $file " [expr $barrivals_*8/$throughputSamplingInterval/1000000]"
set barrivals_ 0
}
$flowstats([expr $N-1]) instvar barrivals_
puts $file " [expr $barrivals_*8/$throughputSamplingInterval/1000000]"
set barrivals_ 0
}
$ns at [expr $now+$throughputSamplingInterval] "throughputTrace $file"
} $ns color 0 Red
$ns color 1 Orange
$ns color 2 Yellow
$ns color 3 Green
$ns color 4 Blue
$ns color 5 Violet
$ns color 6 Brown
$ns color 7 Black for {set i 0} {$i < $N} {incr i} {
set n($i) [$ns node]
} set nqueue [$ns node]
set nclient [$ns node] $nqueue color red
$nqueue shape box
$nclient color blue for {set i 0} {$i < $N} {incr i} {
$ns duplex-link $n($i) $nqueue $inputLineRate [expr $RTT/4] DropTail
$ns duplex-link-op $n($i) $nqueue queuePos 0.25
} $ns simplex-link $nqueue $nclient $lineRate [expr $RTT/4] $switchAlg
$ns simplex-link $nclient $nqueue $lineRate [expr $RTT/4] DropTail
$ns queue-limit $nqueue $nclient $B $ns duplex-link-op $nqueue $nclient color "green"
$ns duplex-link-op $nqueue $nclient queuePos 0.25
set qfile [$ns monitor-queue $nqueue $nclient [open queue.tr w] $traceSamplingInterval] for {set i 0} {$i < $N} {incr i} {
if {[string compare $sourceAlg "Newreno"] == 0 || [string compare $sourceAlg "DC-TCP-Newreno"] == 0} {
set tcp($i) [new Agent/TCP/Newreno]
set sink($i) [new Agent/TCPSink]
}
if {[string compare $sourceAlg "Sack"] == 0 || [string compare $sourceAlg "DC-TCP-Sack"] == 0} {
set tcp($i) [new Agent/TCP/FullTcp/Sack]
set sink($i) [new Agent/TCP/FullTcp/Sack]
$sink($i) listen
} $ns attach-agent $n($i) $tcp($i)
$ns attach-agent $nclient $sink($i) $tcp($i) set fid_ [expr $i]
$sink($i) set fid_ [expr $i] $ns connect $tcp($i) $sink($i)
} for {set i 0} {$i < $N} {incr i} {
set ftp($i) [new Application/FTP]
$ftp($i) attach-agent $tcp($i)
} $ns at $traceSamplingInterval "myTrace $mytracefile"
$ns at $throughputSamplingInterval "throughputTrace $throughputfile" set ru [new RandomVariable/Uniform]
$ru set min_ 0
$ru set max_ 1.0 for {set i 0} {$i < $N} {incr i} {
$ns at 0.0 "$ftp($i) send 10000"
$ns at [expr 0.1 + $simulationTime * $i / ($N + 0.0001)] "$ftp($i) start"
$ns at [expr $simulationTime] "$ftp($i) stop"
} set flowmon [$ns makeflowmon Fid]
set MainLink [$ns link $nqueue $nclient] $ns attach-fmon $MainLink $flowmon set fcl [$flowmon classifier] $ns at $flowClassifyTime "classifyFlows" proc classifyFlows {} {
global N fcl flowstats
puts "NOW CLASSIFYING FLOWS"
for {set i 0} {$i < $N} {incr i} {
set flowstats($i) [$fcl lookup autp 0 0 $i]
}
} set startPacketCount 0
set stopPacketCount 0 proc startMeasurement {} {
global qfile startPacketCount
$qfile instvar pdepartures_
set startPacketCount $pdepartures_
} proc stopMeasurement {} {
global qfile startPacketCount stopPacketCount packetSize startMeasurementTime stopMeasurementTime simulationTime
$qfile instvar pdepartures_
set stopPacketCount $pdepartures_
puts "Throughput = [expr ($stopPacketCount-$startPacketCount)/(1024.0*1024*($stopMeasurementTime-$startMeasurementTime))*$packetSize*8] Mbps"
} $ns at $startMeasurementTime "startMeasurement"
$ns at $stopMeasurementTime "stopMeasurement" $ns at $simulationTime "finish" $ns run

dctcp example-ns2的更多相关文章

  1. ubuntu 14.04 ns2.35 ***buffer overflow detected **: ns terminated解决办法

    1.按照如下教程安装 Install With Me !: How to Install NS-2.35 in Ubuntu-13.10 / 14.04 (in 4 easy steps) 2.运行一 ...

  2. Fedora 23安装 NS2 (network simulator 2)

    1 实验环境 OS: Fedora 23 workstation 2 实验步骤 ( 参考了:http://www.isi.edu/nsnam/ns/ns-build.html) 本次实验的实验环境: ...

  3. Ubuntu10.04下安装Ns2的一系列错误及解决方案

    安装之前改一下nam1.11下的agent.h文件73行 Null改为0 第一个错误: xxx configuration: Syntax error: Unterminated quoted str ...

  4. NS2中修改载波侦听范围和传输范围

    修改这两个值是在tcl中进行的,加上 Phy/WirelessPhy set CSThresh_ 1.559e-11 ;#550m Phy/WirelessPhy set RXThresh_ 3.65 ...

  5. 寻找研究基于NS2研究覆盖网络的小伙伴:)

    如题,本人菜鸟刚刚入门,想找些基于NS2研究覆盖网络方面的小伙伴,具体点是关于覆盖网络中QoS服务调度方法方面的,有的小伙伴可以留下联系方式,或者加我QQ:245939069  :P:P:P

  6. 与NS2一起度过第一个圣诞夜!(NS2入门学习参考资料)

    Merry xmas! 安装好NS2后正式开始学习NS2啦,先转发一哥们的博客内容,慢慢看! 一). NS常用基本网站         1. 寻求问题答案最好的地方.           http:/ ...

  7. 关于NS2安装的若干问题

    之前就知道这个软件安装起来很恶心,因为毕竟是10年前的软件,可没想到真的好恶心...花了整整一天才装上. 我安装的版本是ns-allinone-2.28,系统版本是ubuntu14.04 其实大部分出 ...

  8. 网络拥塞控制与NS2仿真

    准备工作: 1. 安装virtual box 虚拟机,并安装虚拟机增强功能,并配制共享文件夹. 共享文件夹自动挂载后的路径为/media/sf_xxx文件夹,xxx为所起的文件名. 解决virtual ...

  9. 【NS2仿真】RTP协议安装

    来自: http://personales.upv.es/fboronat/Research/NS2_RTP/NS2_RTP_RTCP_module.htm 文件:http://pan.baidu.c ...

  10. 【工具】NS2安装记录

    献给同样为了NS2抓破了头皮的同志们. 1, Get Started: http://www.isi.edu/nsnam/ns/ns-build.html#allinone Build by piec ...

随机推荐

  1. 命令行下class redis not found 解决

    1.在命令行下输入 php --ini 2.在浏览器中查看 phpinfo() 可以看出,我  的phpinfo和命令行的就不是一个php.ini文件.因为我有几个版本的php , 并且在环境变量中配 ...

  2. python excel读写数据

    python 读取excel内容,包含表格日期处理 # -*- coding: utf- -*- import xlrd #读取excel表格 workbook=xlrd.open_workbook( ...

  3. 在W3C SCHOOL网站上发现一个关于Schema的错误

    原地址是http://www.w3school.com.cn/schema/schema_complex_empty.asp 下面这个例子是不正确的 xmlspy报错. 因为<xs:restri ...

  4. 2018年javaee学习目标

    我打算在本学期的学习中把java ee掌握并能熟练应用,如果可以的话还打算编写一个后台服务程序,增加自己的实战经验.

  5. github 相关操作知识

    新设备上使用github 1.要在本地创建一个ssh key ssh-keygen -t rsa -C "email address" 2.界面提示进入.ssh文件夹下,找到id_ ...

  6. 用C语言实现Ping程序功能---转

    ping命令是用来查看网络上另一个主机系统的网络连接是否正常的一个工具.ping命令的工作原理是:向网络上的另一个主机系统发送ICMP报文,如果指定系统得到了报文,它将把报文一模一样地传回给发送者,这 ...

  7. EveryThing 使用方法

    1.按照时间范围:datetimed: <*.doc|*.docx>  dm:1/2015-6/2015// 如果本地的时间设置是年份在前,那么把年份放在月份前面// d: <*.d ...

  8. ASP.Net Core MVC 网站在Windows服务器跑不起来

    1.vs远程发布到服务器,浏览器访问,报错502 2.打开错误提示提供的网址参考 3.安装runtime,sdk,Hosting Bundle Installer,其他操作 .....发现并没有什么用 ...

  9. C#语言-08.序列化与反序列化

    a. 序列化:是将对象的状态存储到特定存储介质中的过程 i. 语法:public void Serialize(序列化过程的文件流,保存的对象) b. 返序列化:是从特定存储介质中将数据重新构建对象的 ...

  10. Java基础(七)常用类

    一.Math类 1.Math类介绍 Math类属于java.lang包下面,里面包含用于执行基本数学运算的方法,如初等指数,对数,平方根和三角函数,该类被final修饰. 常用字段: 1.E 表示自然 ...