⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rsvp_merge.tcl

📁 rsvp and wfq patch for Netowrk Simulator 2
💻 TCL
字号:
## Copyright (c) 1998 The University of Bonn# All rights reserved.# # Permission to use and copy this software in source and binary forms# is hereby granted, provided that the above copyright notice, this# paragraph and the following disclaimer are retained in any copies# of any part of this software and that the University of Bonn is# acknowledged in all documentation pertaining to any such copy# or derivative work. The name of the University of Bonn may not# be used to endorse or promote products derived from this software# without specific prior written permission.## THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL # THE UNIVERSITY OF BONN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE.## This simulation scenario demonstrates merging of reservations# for a multicase session. For a detailed description, see# 'http://titan.cs.uni-bonn.de/~greis/rsvpns/rsvpns.ps'$defaultRNG seed 1set ns [new Simulator -multicast on]$ns color 0 red$ns color 1 blue$ns color 2 green$ns color 46 purpleset f0 [open out0.tr w]set f1 [open out1.tr w]set f2 [open out2.tr w]#$ns set-address-format expanded#Simulator set EnableMcast_ 1#Simulator set NumberInterfaces_ 1#Node expandaddrset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]set n4 [$ns node]set nf [open out.nam w]# Turn nam trace generation off for now$ns namtrace-all $nf$ns duplex-rsvp-link $n0 $n1 1Mb 1s 0.5 50 5000 Param Null$ns duplex-rsvp-link $n1 $n2 1Mb 1s 0.5 50 5000 Param Null$ns duplex-rsvp-link $n1 $n3 1Mb 1s 0.5 50 5000 Param Null$ns duplex-rsvp-link $n1 $n4 1Mb 1s 0.5 50 5000 Param Nullset link [$ns link $n0 $n1]set queue [$link queue]DM set PruneTimeout 60.0set mproto DMset mrthandle [$ns mrtproto $mproto {}]# Enable all upcalls on all nodesAgent/RSVP set noisy_ 255set rsvp4 [$n4 add-rsvp-agent]set rsvp3 [$n3 add-rsvp-agent]set rsvp2 [$n2 add-rsvp-agent]set rsvp1 [$n1 add-rsvp-agent]set rsvp0 [$n0 add-rsvp-agent]set group0 [Node allocaddr]set group1 [Node allocaddr]set group2 [Node allocaddr]# Create three traffic sourcesset udp0 [new Agent/UDP]$ns attach-agent $n0 $udp0$udp0 set packetSize_ 500$udp0 set fid_ 1$udp0 set dst_addr_ $group0set cbr0 [new Application/Traffic/CBR]$cbr0 set rate_ 500k$cbr0 set packetSize_ 500#$cbr0 set random_ 1$cbr0 attach-agent $udp0set udp1 [new Agent/UDP]$ns attach-agent $n0 $udp1$udp1 set packetSize_ 500$udp1 set fid_ 2$udp1 set dst_addr_ $group1set cbr1 [new Application/Traffic/CBR]$cbr1 set rate_ 500k$cbr1 set packetSize_ 500#$cbr1 set random_ 1$cbr1 attach-agent $udp1set udp2 [new Agent/UDP]$ns attach-agent $n0 $udp2$udp2 set packetSize_ 500$udp2 set fid_ 3$udp2 set dst_addr_ $group2set cbr2 [new Application/Traffic/CBR]$cbr2 set rate_ 500k$cbr2 set packetSize_ 500#$cbr2 set random_ 1$cbr2 attach-agent $udp2# Create 9 traffic sinks (three for each flow on each node)# (This could be done in a more efficient way)set null2a [new Agent/LossMonitor]$ns attach-agent $n2 $null2aset null2b [new Agent/LossMonitor]$ns attach-agent $n2 $null2bset null2c [new Agent/LossMonitor]$ns attach-agent $n2 $null2cset null3a [new Agent/LossMonitor]$ns attach-agent $n3 $null3aset null3b [new Agent/LossMonitor]$ns attach-agent $n3 $null3bset null3c [new Agent/LossMonitor]$ns attach-agent $n3 $null3cset null4a [new Agent/LossMonitor]$ns attach-agent $n4 $null4aset null4b [new Agent/LossMonitor]$ns attach-agent $n4 $null4bset null4c [new Agent/LossMonitor]$ns attach-agent $n4 $null4c$rsvp0 session $group0 1set counter 0$ns at 0.0 "record"$ns at 0.5 "$n2 join-group $null2a $group0"$ns at 0.5 "$n3 join-group $null3a $group0"$ns at 0.5 "$n4 join-group $null4a $group0"$ns at 0.5 "$n2 join-group $null2b $group1"$ns at 0.5 "$n3 join-group $null3b $group1"$ns at 0.5 "$n4 join-group $null4b $group1"$ns at 0.5 "$n2 join-group $null2c $group2"$ns at 0.5 "$n3 join-group $null3c $group2"$ns at 0.5 "$n4 join-group $null4c $group2"$ns at 1.0 "$rsvp0 sender 0 +500000 5000 32"# First the receivers reserve resources with increasing bandwidth,# then the reservations are released one by one.$ns at 300.0 "$rsvp2 reserve 0 ff +100000 100000 $n0"$ns at 600.0 "$rsvp3 reserve 0 ff +300000 100000 $n0"$ns at 900.0 "$rsvp4 reserve 0 ff +500000 100000 $n0"$ns at 1200.0 "$rsvp4 release 0"$ns at 1500.0 "$rsvp3 release 0"$ns at 1800.0 "$rsvp2 release 0"$ns at 10.0 "$cbr0 start"$ns at 2000.0 "$cbr0 stop"$ns at 10.0 "$cbr1 start"$ns at 2000.0 "$cbr1 stop"$ns at 10.0 "$cbr2 start"$ns at 2000.0 "$cbr2 stop"#$ns at 2100.0 "finish"$ns at 100.0 "finish"proc record {} {	global null2a null2b null2c ns f0 f1 f2 counter	set time 10.0	set bw0 [$null2a set bytes_]	set bw1 [$null2b set bytes_]        set bw2 [$null2c set bytes_]	set now [$ns now]	puts $f0 "$now [expr $bw0/$time*8]"	puts $f1 "$now [expr $bw1/$time*8]"	puts $f2 "$now [expr $bw2/$time*8]"	$null2a set bytes_ 0	$null2b set bytes_ 0	$null2c set bytes_ 0	$ns at [expr $now+$time] "record"	if { $counter == 10 } {		puts "Time: $now"		set counter 0	}	incr counter}proc finish {} {        global ns nf        $ns flush-trace        close $nf	puts "Done."        exit 0}$ns run

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -