Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- #Tell the simulator to use dynamic routing
- $ns rtproto Session
- set f [open ass2.tr w]
- set nf [open ass2.nam w]
- $ns namtrace-all $nf
- $ns trace-all $f
- proc finish { } {
- global ns f
- $ns flush-trace
- close $f
- exec nam ass2.nam &
- exit 0
- }
- set n0 [$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]
- # Node colors
- $n0 color red
- $n10 color red
- $n2 color green
- $n9 color green
- $n5 color cyan
- $n6 color cyan
- #Duplex-links (bidirectional)
- $ns duplex-link $n0 $n1 20mb 10ms DropTail
- $ns duplex-link $n2 $n3 20mb 10ms DropTail
- $ns duplex-link $n3 $n4 20mb 10ms DropTail
- $ns duplex-link $n4 $n5 20mb 10ms DropTail
- $ns duplex-link $n0 $n3 20mb 10ms DropTail
- $ns duplex-link $n1 $n4 20mb 10ms DropTail
- $ns duplex-link $n7 $n8 20mb 10ms DropTail
- $ns duplex-link $n6 $n10 20mb 10ms DropTail
- $ns duplex-link $n7 $n10 20mb 10ms DropTail
- $ns duplex-link $n8 $n10 20mb 10ms DropTail
- $ns duplex-link $n9 $n10 20mb 10ms DropTail
- #Simplex-links (unidirectional)
- $ns simplex-link $n2 $n6 10mb 5ms SFQ
- $ns simplex-link $n3 $n7 10mb 5ms SFQ
- $ns simplex-link $n8 $n4 10mb 5ms SFQ
- $ns simplex-link $n5 $n9 10mb 5ms SFQ
- $ns simplex-link $n6 $n7 10mb 5ms SFQ
- $ns simplex-link $n9 $n8 10mb 5ms SFQ
- # Link colors
- $ns duplex-link-op $n7 $n8 color "magenta"
- $ns duplex-link-op $n3 $n4 color "magenta"
- # Link Label
- $ns duplex-link-op $n3 $n4 label "Fail"
- $ns duplex-link-op $n7 $n8 label "Fail"
- # fid colors
- $ns color 1 red
- $ns color 2 green
- $ns color 3 blue
- # Orientation
- $ns duplex-link-op $n0 $n3 orient down
- $ns duplex-link-op $n1 $n4 orient down
- $ns duplex-link-op $n0 $n1 orient right
- $ns duplex-link-op $n2 $n3 orient right
- $ns duplex-link-op $n3 $n4 orient right
- $ns duplex-link-op $n4 $n5 orient right
- $ns simplex-link-op $n6 $n7 orient right
- $ns duplex-link-op $n7 $n8 orient right
- $ns simplex-link-op $n9 $n8 orient left
- $ns duplex-link-op $n6 $n10 orient right-down
- $ns duplex-link-op $n7 $n10 orient right-down
- $ns duplex-link-op $n8 $n10 orient left-down
- $ns duplex-link-op $n9 $n10 orient left-down
- $ns simplex-link-op $n2 $n6 orient down
- $ns simplex-link-op $n3 $n7 orient down
- $ns simplex-link-op $n8 $n4 orient up
- $ns simplex-link-op $n5 $n9 orient down
- #UDP1
- set udp1 [new Agent/UDP]
- $ns attach-agent $n0 $udp1
- set loss1 [new Agent/LossMonitor]
- $ns attach-agent $n10 $loss1
- $ns connect $udp1 $loss1
- $udp1 set fid_ 1
- #CBR1
- set cbr1 [new Application/Traffic/Exponential]
- $cbr1 attach-agent $udp1
- $cbr1 set packetSize_ 512
- $cbr1 set rate_ 0.4mb
- $cbr1 set burst_time_ 3s
- $cbr1 set idle_time_ 2s
- #UDP2
- set udp2 [new Agent/UDP]
- $ns attach-agent $n2 $udp2
- set loss2 [new Agent/LossMonitor]
- $ns attach-agent $n9 $loss2
- $ns connect $udp2 $loss2
- $udp2 set fid_ 2
- #CBR2
- set cbr2 [new Application/Traffic/Exponential]
- $cbr2 attach-agent $udp2
- $cbr2 set packetSize_ 1024
- $cbr2 set rate_ 0.5mb
- $cbr2 set burst_time_ 2s
- $cbr2 set idle_time_ 1s
- #UDP3
- set udp3 [new Agent/UDP]
- $ns attach-agent $n5 $udp3
- set loss3 [new Agent/LossMonitor]
- $ns attach-agent $n6 $loss3
- $ns connect $udp3 $loss3
- $udp3 set fid_ 3
- #CBR3
- set cbr3 [new Application/Traffic/Exponential]
- $cbr3 attach-agent $udp3
- $cbr3 set packetSize_ 2048
- $cbr3 set rate_ 0.6mb
- $cbr3 set burst_time_ 4s
- $cbr3 set idle_time_ 2s
- #Schedule events for the CBR agent and the network dynamics
- $ns at 0.0 "$cbr1 start"
- $ns at 0.0 "$cbr2 start"
- $ns at 0.0 "$cbr3 start"
- $ns rtmodel-at 10.0 down $n3 $n4
- $ns rtmodel-at 20.0 up $n3 $n4
- $ns rtmodel-at 30.0 down $n7 $n8
- $ns rtmodel-at 55.0 up $n7 $n8
- $ns at 100.0 "finish"
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement