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. C#串口通讯中常用的16进制的字节转换

    1.对于通讯协议的十六进制数值进行简单转换 //二进制转十进制Console.WriteLine("二进制 111101 的十进制表示: "+Convert.ToInt32(&qu ...

  2. hive DML

    1.load files into tables 把文件中的数据加载到表中(表必须先建好) 语法是: load data [local] inpath 'filepath' [overwrite] i ...

  3. Java生成树关系的菜单

    1.菜单bean public class Menu { private String id; private String menuname; private String parentid; pr ...

  4. Android SurfaceFlinger

    Android 系统启动过程Activity 创建过程Activity 与 Window 与 View 之间的关系 Android 系统从按下开机键到桌面,从桌面点击 App 图标到 Activity ...

  5. ScriptManager.RegisterStartupScript失效的解决方案

    在项目中一个页面使用System.Web.UI.ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "success ...

  6. 转 功能强大的shell:if条件语句

    原文 http://blog.zol.com.cn/2322/article_2321767.html 功能强大的shell:if条件语句 if语句测试条件,测试条件返回真(0)或假(1)后,可相应执 ...

  7. Codeforces 809D. Hitchhiking in the Baltic States

    Description 给出 \(n\) 个数 \(a_i\),每一个数有一个取值 \([l_i,r_i]\) ,你来确定每一个数,使得 \(LIS\) 最大 题面 Solution 按照平时做法,设 ...

  8. 【idea--git】

    http://blog.csdn.net/autfish/article/details/52513465 工作中多人使用版本控制软件协作开发,常见的应用场景归纳如下: 假设小组中有两个人,组长小张, ...

  9. Java中final修饰参数的作用

    在方法参数前面加final关键字就是为了防止数据在方法体中被修改. 主要分两种情况:第一,用final修饰基本数据类型:第二,用final修饰引用类型. 第一种情况,修饰基本类型(非引用类型).这时参 ...

  10. Quartz.Net定时任务简单实用(实例)

    一.Quartz.Net是什么? Quartz.Net是一个定时任务框架 二.有Timer了,为什么需要用Quartz.Net? Quartz.Net比Timer使用起来更灵活.例如:每个月最后一个星 ...