📄 rsvp_distinct.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.## A simulation scenario which demonstrates distinct reservations for# the same session (i.e. reservations for different senders for the# same session which are added up). For a detailed description, see# 'http://titan.cs.uni-bonn.de/~greis/rsvpns/rsvpns.ps'.$defaultRNG seed 1set ns [new Simulator]$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]set n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]set n4 [$ns node]# Keep nam trace generation off for nowset nf [open /tmp/out.nam w]#$ns namtrace-all $nf$ns duplex-rsvp-link $n0 $n1 1Mb 1s 0.5 200 5000 Param Null$ns duplex-rsvp-link $n1 $n2 1Mb 1s 0.5 200 5000 Param Null$ns duplex-rsvp-link $n1 $n3 1Mb 1s 0.5 200 5000 Param Null$ns duplex-rsvp-link $n1 $n4 1Mb 1s 0.5 200 5000 Param Null# Enable 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]# Create three traffic sources# set cbr2 [new Agent/CBR]set udp2 [new Agent/UDP]$ns attach-agent $n2 $udp2$udp2 set packetSize_ 500$udp2 set fid_ 1set cbr2 [new Application/Traffic/CBR]#$cbr2 set interval_ 0.008$cbr2 set rate_ 500k$cbr2 set random_ 1$cbr2 set packetSize_ 500$cbr2 attach-agent $udp2# set cbr3 [new Agent/CBR]set udp3 [new Agent/UDP]$ns attach-agent $n3 $udp3$udp3 set packetSize_ 500$udp3 set fid_ 1set cbr3 [new Application/Traffic/CBR]#$cbr3 set interval_ 0.008$cbr3 set rate_ 500k$cbr3 set random_ 1$cbr3 set packetSize_ 500$cbr3 attach-agent $udp3# set cbr4 [new Agent/CBR]set udp4 [new Agent/UDP]$ns attach-agent $n4 $udp4$udp4 set packetSize_ 500$udp4 set fid_ 1set cbr4 [new Application/Traffic/CBR]$cbr4 set packetSize_ 500#$cbr4 set interval_ 0.008$cbr4 set rate_ 500k$cbr4 set random_ 1$cbr4 attach-agent $udp4# Create three traffic sinksset sink2 [new Agent/LossMonitor]$ns attach-agent $n0 $sink2set sink3 [new Agent/LossMonitor]$ns attach-agent $n0 $sink3set sink4 [new Agent/LossMonitor]$ns attach-agent $n0 $sink4$ns connect $udp2 $sink2$ns connect $udp3 $sink3$ns connect $udp4 $sink4# Create the same session on all sender nodes$rsvp2 session $n0 1$rsvp3 session $n0 1$rsvp4 session $n0 1set counter 0# Start the procedure which logs the rate for the incoming flow on node 0$ns at 0.0 "record"$ns at 1.0 "$rsvp2 sender 0 +500000 5000 32"$ns at 3.0 "$rsvp3 sender 0 +500000 5000 32"$ns at 5.0 "$rsvp4 sender 0 +500000 5000 32"# Perform test reservations$ns at 300.0 "$rsvp0 reserve 0 ff +100000 100000 $n2"$ns at 600.0 "$rsvp0 reserve 0 ff +500000 100000 $n3"$ns at 900.0 "$rsvp0 reserve 0 ff +400000 100000 $n3"$ns at 1200.0 "$rsvp0 reserve 0 ff +100000 100000 $n3"$ns at 1500.0 "$rsvp0 reserve 0 ff +300000 100000 $n4"$ns at 10.0 "$cbr2 start"$ns at 2000.0 "$cbr2 stop"$ns at 10.0 "$cbr3 start"$ns at 2000.0 "$cbr3 stop"$ns at 10.0 "$cbr4 start"$ns at 2000.0 "$cbr4 stop"$ns at 2100.0 "finish"proc record {} { global sink2 sink3 sink4 ns f0 f1 f2 counter set time 10.0 set bw0 [$sink2 set bytes_] set bw1 [$sink3 set bytes_] set bw2 [$sink4 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]" $sink2 set bytes_ 0 $sink3 set bytes_ 0 $sink4 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 + -