dctcp example-ns2
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的更多相关文章
- 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.运行一 ...
- Fedora 23安装 NS2 (network simulator 2)
1 实验环境 OS: Fedora 23 workstation 2 实验步骤 ( 参考了:http://www.isi.edu/nsnam/ns/ns-build.html) 本次实验的实验环境: ...
- Ubuntu10.04下安装Ns2的一系列错误及解决方案
安装之前改一下nam1.11下的agent.h文件73行 Null改为0 第一个错误: xxx configuration: Syntax error: Unterminated quoted str ...
- NS2中修改载波侦听范围和传输范围
修改这两个值是在tcl中进行的,加上 Phy/WirelessPhy set CSThresh_ 1.559e-11 ;#550m Phy/WirelessPhy set RXThresh_ 3.65 ...
- 寻找研究基于NS2研究覆盖网络的小伙伴:)
如题,本人菜鸟刚刚入门,想找些基于NS2研究覆盖网络方面的小伙伴,具体点是关于覆盖网络中QoS服务调度方法方面的,有的小伙伴可以留下联系方式,或者加我QQ:245939069 :P:P:P
- 与NS2一起度过第一个圣诞夜!(NS2入门学习参考资料)
Merry xmas! 安装好NS2后正式开始学习NS2啦,先转发一哥们的博客内容,慢慢看! 一). NS常用基本网站 1. 寻求问题答案最好的地方. http:/ ...
- 关于NS2安装的若干问题
之前就知道这个软件安装起来很恶心,因为毕竟是10年前的软件,可没想到真的好恶心...花了整整一天才装上. 我安装的版本是ns-allinone-2.28,系统版本是ubuntu14.04 其实大部分出 ...
- 网络拥塞控制与NS2仿真
准备工作: 1. 安装virtual box 虚拟机,并安装虚拟机增强功能,并配制共享文件夹. 共享文件夹自动挂载后的路径为/media/sf_xxx文件夹,xxx为所起的文件名. 解决virtual ...
- 【NS2仿真】RTP协议安装
来自: http://personales.upv.es/fboronat/Research/NS2_RTP/NS2_RTP_RTCP_module.htm 文件:http://pan.baidu.c ...
- 【工具】NS2安装记录
献给同样为了NS2抓破了头皮的同志们. 1, Get Started: http://www.isi.edu/nsnam/ns/ns-build.html#allinone Build by piec ...
随机推荐
- php 图片上传 并返回上传文件位置 支持多文件上传
<?php /** * Created by PhpStorm. * User: DY040 * Date: 2018/4/26 * Time: 13:23 */ echo '<pre&g ...
- centos安装postgresql-rpm
rpm -ivh pgdg-centos93-9.3-3.noarch.rpm确认,回车,
- APP高级抓包
1.fiddler的证书安装问题时密码问题 问题:我手机下载了fiddler证书 从设置里面安装证书 可是需要输入密码 我没有设置过密码 不知道密码是什么 请问有人遇到过这样的问题的?求解决方法 因为 ...
- 2019.04.19 读书笔记 比较File.OpenRead()和File.ReadAllBytes()的差异
最近涉及到流的获取与转化,终于要还流的债了. 百度了一下,看到这样的两条回复,于是好奇心,决定看看两种写法的源码差异. 先来看看OpenRead() public static FileStream ...
- 关于cmdbuild
哪位大神用过cmdbuild,网上的资料非常少,而且都是关于如何安装的,就在这少只又少的文章里,居然还都是互抄的,哎!!!
- docker volumes?
我发现我无法mount东西出来.都是会被host的覆盖掉的.,
- bug缺陷级别定义
缺陷定义: 出现以下缺陷测试定义为致命 bug l 系统无响应处于死机状态. l 点击某个菜单后出现“The page cannot be displayed”或者返回异常错误. l 进行某 ...
- Django 入门项目案例开发(中)
关注微信公众号:FocusBI 查看更多文章:加QQ群:808774277 获取学习资料和一起探讨问题. 昨天已经描述了如何搭建Django的开发环境,今天描述业务流程,具体我们要实现一个什么样的业务 ...
- grunt-contrib-cssmin使用指南
原文:http://riny.net/2014/grunt-cssmin/ grunt-contrib-cssmin v0.7.0 使用cssmin压缩css文件 Getting Started 这个 ...
- js 验证字符串是否全为中文
js 验证字符串是否全为中文: function isChinese(str) { var reg = /^[\u4E00-\u9FA5]+$/; if(reg.test(str)){ return ...