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. init_config_file.lua

    --[[ 读取限流配置 --]] --获取共享内存 local limit_req_store = ngx.shared.limit_req_store --初始化拒绝 URI 列表 reject_u ...

  2. PHP设置时区

    <?php//设置默认的时区date_default_timezone_set('Asia/Shanghai');//输出1396193923对应的日期echo date("Y-m-d ...

  3. Cloudera Manager安装之时间服务器和时间客户端(Ubuntu14.04)(二)

    第二步: Cloudera Manager安装之时间服务器和时间客户端(二) 找一台机器作为时间服务器 我这里,放到ubuntucmbigdata1这台机器! 注意,之前是已经做了集群时间同步了. 在 ...

  4. Kafka 0.9 新消费者API

    kafka诞生之初,它自带一个基于scala的生产者和消费者客户端.但是慢慢的我们认识到这些API有很多限制.比如,消费者有一个“高级”API支持分组和异常控制,但是不支持很多更复杂的应用场景:它也有 ...

  5. 028-applicationContext.xml配置文件

    版本一 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http: ...

  6. C# ASP.NET Core使用HttpClient的同步和异步请求

    引用 Newtonsoft.Json // Post请求 public string PostResponse(string url,string postData,out string status ...

  7. php数组操作,js数组操作

    俩语言一块儿学老混.整理一下. php: 1.声明: 1)$arr1 = array('key1' => 'value1', 'key2' => 'value2' ...);//关联数组, ...

  8. (转载).NET的五层架构

    我们刚开始学习架构的时候,首先会想到分层的概念,分层架构比较经典的是三层架构,那么,什么是三层架构呢?它包括表现层,业务层,数据访问层:而对于一个新手来说,从抽象意义上的三层架构,逻辑上就划分为三个层 ...

  9. 修改django 后台admin用户的密码

    python manage.py shellfrom django.contrib.auth.models import User from django.contrib.auth.models im ...

  10. Maven运行时找不到xml文件和properties文件的问题解决

    使用Maven构建的项目,包下面的xml文件和properties属性文件默认在运行tomcat插件是不会生成文件到target里面的,需要自己配置 一.第一种解决方法也是最常用的解决方法 在pom. ...