Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- set nf [open ass2.nam w]
- set f [open ass2.tr w]
- $ns namtrace-all $nf
- $ns trace-all $f
- $ns rtproto Session
- proc finish {} {
- global ns f
- $ns flush-trace
- close $f
- exec nam ass2.nam &
- exit 0
- }
- set n11 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- set n4 [$ns node]
- set n5 [$ns node]
- set n6 [$ns node]
- set n7 [$ns node]
- set n8 [$ns node]
- set n9 [$ns node]
- set n10 [$ns node]
- $n1 color red
- $n7 color blue
- $n3 color green
- $n6 color blue
- $n10 color green
- $n7 color blue
- $ns color 1 red
- $ns color 2 green
- $ns color 3 blue
- $ns duplex-link $n1 $n2 20Mb 10ms DropTail
- $ns duplex-link-op $n1 $n2 orient right
- $ns duplex-link $n3 $n4 20Mb 10ms DropTail
- $ns duplex-link-op $n3 $n4 orient right
- $ns duplex-link $n4 $n5 20Mb 10ms DropTail
- $ns duplex-link-op $n4 $n5 orient right
- $ns duplex-link $n5 $n6 20Mb 10ms DropTail
- $ns duplex-link-op $n5 $n6 orient right
- $ns duplex-link $n1 $n4 20Mb 10ms DropTail
- $ns duplex-link-op $n1 $n4 orient down
- $ns duplex-link $n2 $n5 20Mb 10ms DropTail
- $ns duplex-link-op $n2 $n5 orient down
- $ns duplex-link $n8 $n9 20Mb 10ms DropTail
- $ns duplex-link-op $n8 $n9 orient right
- $ns duplex-link $n7 $n11 20Mb 10ms DropTail
- $ns duplex-link-op $n11 $n7 orient left-up
- $ns duplex-link $n8 $n11 20Mb 10ms DropTail
- $ns duplex-link-op $n11 $n8 orient left-up
- $ns duplex-link $n9 $n11 20Mb 10ms DropTail
- $ns duplex-link-op $n11 $n9 orient right-up
- $ns duplex-link $n11 $n10 20Mb 10ms DropTail
- $ns duplex-link-op $n11 $n10 orient right-up
- $ns simplex-link $n3 $n7 10Mb 5ms SFQ
- $ns simplex-link-op $n3 $n7 orient down
- $ns simplex-link $n4 $n8 10Mb 5ms SFQ
- $ns simplex-link-op $n4 $n8 orient down
- $ns simplex-link $n9 $n5 10Mb 5ms SFQ
- $ns simplex-link-op $n9 $n5 orient up
- $ns simplex-link $n6 $n10 10Mb 5ms SFQ
- $ns simplex-link-op $n6 $n10 orient down
- $ns simplex-link $n7 $n8 10Mb 5ms SFQ
- $ns simplex-link-op $n7 $n8 orient right
- $ns simplex-link $n10 $n9 10Mb 5ms SFQ
- $ns simplex-link-op $n10 $n9 orient left
- set udp0 [new Agent/UDP]
- $ns attach-agent $n1 $udp0
- $udp0 set fid_ 1
- set exp0 [new Application/Traffic/Exponential]
- $exp0 set packetSize_ 512
- $exp0 set random_ false
- $exp0 set burst_time_ 3
- $exp0 set idle_time_ 2
- $exp0 set rate_ 0.4Mb
- $exp0 attach-agent $udp0
- set loss0 [ new Agent/LossMonitor ]
- $ns attach-agent $n11 $loss0
- $ns connect $udp0 $loss0
- set udp1 [new Agent/UDP]
- $ns attach-agent $n3 $udp1
- $udp1 set fid_ 2
- set exp1 [new Application/Traffic/Exponential]
- $exp1 set packetSize_ 1024i
- $exp1 set burst_time_ 2
- $exp1 set idle_time_ 1
- $exp1 set random_ false
- $exp1 set rate_ 0.5Mb
- $exp1 attach-agent $udp1
- set loss1 [ new Agent/LossMonitor ]
- $ns attach-agent $n11 $loss1
- $ns connect $udp1 $loss1
- set udp2 [new Agent/UDP]
- $ns attach-agent $n6 $udp2
- $udp2 set fid_ 3
- set exp2 [new Application/Traffic/Exponential]
- $exp2 set packetSize_ 2048
- $exp2 set burst_time_ 4
- $exp2 set idle_time_ 2
- $exp2 set random_ false
- $exp2 set rate_ 0.6Mb
- $exp2 attach-agent $udp2
- set loss2 [ new Agent/LossMonitor ]
- $ns attach-agent $n7 $loss2
- $ns connect $udp2 $loss2
- $ns at 0.0 "$exp0 start"
- $ns at 0.0 "$exp1 start"
- $ns at 0.0 "$exp2 start"
- #$ns at 0.5 "$ftp stop"
- $ns rtmodel-at 10.0 down $n4 $n5
- $ns rtmodel-at 20.0 up $n4 $n5
- $ns rtmodel-at 30.0 down $n8 $n9
- $ns rtmodel-at 55.0 up $n8 $n9
- $ns at 100.0 "finish"
- $ns run
Add Comment
Please, Sign In to add comment