📄 verify-cwnd-positive.tcl
字号:
set pace_mode 2set MainBW "1000Mb"set SideBW "4000Mb"set noiseBW "100Mb"set TCP_Variant "Agent/TCP/Fast"set TCP_ACK_Variant "Agent/TCPSink/Sack1"set TCP_Option 1set MainBuffer 261set PacedFlowNumber 0set UnpacedFlowNumber 5set MaxWindow 100000set EndTime 200 #constantsset MSS 1448set SideDelay "5ms"set MainDelay "50ms"#Create a simulator objectset ns [new Simulator]set flownumber(1) $PacedFlowNumberset flownumber(2) $UnpacedFlowNumberset pace(1) $pace_modeset pace(2) 0set offset(1) 0set offset(2) $flownumber(1)set rng [new RNG]$rng seed 2set ran [new RandomVariable/Uniform]$ran use-rng $rng$ran set min_ 0$ran set max_ 0.12proc access { j i} { global offset return [expr $offset($j)+$i]}proc check {mode} { global ns flownumber tcp ftp future ran MSS set nowtime [$ns now] for {set i 0} {$i < $flownumber($mode)} {incr i 1} { set item [access $mode $i] if {$future($item) < $nowtime && [$tcp($item) set seqno_] <= [expr [$tcp($item) set maxseq_]+1] } { set future($item) [expr $nowtime+[expr [$ran value]+0.000000001]] set size [expr $MSS*300] $ns at $future($item) "$ftp($item) send $size" } }#check every second $ns at [expr $nowtime+1] "check $mode"}#Define a 'finish' procedureproc finish {} {global ns win flownumber $ns flush-trace for {set j 1} {$j < 3 } {incr j 1} { for {set i 0} {$i < $flownumber($j)} {incr i 1} { close $win([access $j $i]) } } exit 0}#Create four nodesset bs [$ns node]set br [$ns node]#Creaote links between the nodes$ns duplex-link $bs $br $MainBW $MainDelay DropTail#Set Queue Size of link (bs-br) to $ns queue-limit $bs $br $MainBuffer#set queue [open queue.trace w]#$ns trace-queue $bs $br $queue#setup noise trffic, which should be 10% of the bottleneck capacityset noiseSnd [$ns node]set noiseRcv [$ns node]$ns duplex-link $noiseSnd $bs $SideBW $SideDelay DropTail$ns duplex-link $br $noiseRcv $SideBW $SideDelay DropTailset noiseSrc [new Agent/UDP]set noiseSink [new Agent/UDP]$ns attach-agent $noiseSnd $noiseSrc$ns attach-agent $noiseRcv $noiseSink$ns connect $noiseSrc $noiseSinkset noise [new Application/Traffic/Exponential]$noise set packetSize_ $MSS$noise set burst_time_ 500ms$noise set idle_time_ 500ms$noise set rate_ $noiseBW$noise attach-agent $noiseSrc$ns at 0.0 "$noise start"#Setup Paced TCP connectionsfor {set j 1} {$j < 3 } {incr j 1} { for {set i 0} {$i < $flownumber($j)} {incr i 1} { #setup topology set item [access $j $i] set sendNode($item) [$ns node] set rcvNode($item) [$ns node] $ns duplex-link $sendNode($item) $bs $SideBW $SideDelay DropTail $ns queue-limit $sendNode($item) $bs $MaxWindow $ns duplex-link $br $rcvNode($item) $SideBW $SideDelay DropTail $ns queue-limit $br $rcvNode($item) $MaxWindow #setup sender side set tcp($item) [new $TCP_Variant] $tcp($item) set packetSize_ $MSS $tcp($item) set window_ $MaxWindow $tcp($item) set timestamps_ true $tcp($item) set partial_ack_ true $ns attach-agent $sendNode($item) $tcp($item) #setup receiver side set sink($item) [new $TCP_ACK_Variant] $sink($item) set generateDSacks_ true $sink($item) set ts_echo_rfc1323_ true $ns attach-agent $rcvNode($item) $sink($item) #logical connection $ns connect $tcp($item) $sink($item) #Setup a FTP over TCP connection set ftp($item) [new Application/FTP] $ftp($item) attach-agent $tcp($item) $ftp($item) set type_ FTP #for flow identification $tcp($item) set fid_ $j #for analysis set win($item) [open win$j\_$i.trace w] $tcp($item) attach $win($item) $tcp($item) set windowOption_ $TCP_Option $tcp($item) set low_window_ 14 $tcp($item) set bs_beta_ 0.875 $tcp($item) set bs_max_increment_ 32 $tcp($item) set bs_min_increment_ 0.01 $tcp($item) set bs_log_factor_ 4 $tcp($item) set bs_fast_convergence_ 1 set future($item) 0 $ns at [$ran value] "$ftp($item) start" $ns at $EndTime "$ftp($item) stop" }}#Call the finish procedure after 5 seconds of simulation time$ns at $EndTime+1 "finish"#Run the simulation$ns run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -