Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- set nf [open ass1.nam w]
- $ns namtrace-all $nf
- $ns rtproto Session
- proc finish {} {
- global ns nf
- $ns flush-trace
- close $nf
- exec nam ass1.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]
- $n1 color red
- $n2 color cyan
- $n3 color green
- $n6 color green
- $n0 color red
- $n7 color cyan
- $ns color 1 red
- $ns color 2 blue
- $ns color 3 green
- $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 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 $n0 10Mb 5ms SFQ
- $ns simplex-link-op $n6 $n0 orient down
- $ns simplex-link $n7 $n8 10Mb 5ms SFQ
- $ns simplex-link-op $n7 $n8 orient right
- $ns simplex-link $n0 $n9 10Mb 5ms SFQ
- $ns simplex-link-op $n0 $n9 orient left
- set tcp [new Agent/TCP]
- $ns attach-agent $n1 $tcp
- set sink [new Agent/TCPSink]
- $ns attach-agent $n0 $sink
- $ns connect $tcp $sink
- $tcp set packetSize_ 1024
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- $ftp set type_ FTP
- $ftp set random_ false
- $ftp set rate_ 0.02
- $ftp set fid_ 1
- $ns at 0.0 "$ftp start"
- set udp0 [new Agent/UDP]
- $ns attach-agent $n2 $udp0
- set cbr0 [new Application/Traffic/CBR]
- $cbr0 set packetSize_ 512
- $cbr0 set random_ false
- $cbr0 set rate_ 0.01
- $cbr0 set fid_ 2
- $cbr0 attach-agent $udp0
- set null0 [new Agent/Null]
- $ns attach-agent $n7 $null0
- $ns connect $udp0 $null0
- set udp1 [new Agent/UDP]
- $ns attach-agent $n3 $udp1
- set cbr1 [new Application/Traffic/CBR]
- $cbr1 set packetSize_ 512
- $cbr1 set random_ true
- $cbr1 set rate_ 0.01
- $cbr1 set fid_ 3
- $cbr1 attach-agent $udp1
- set null1 [new Agent/Null]
- $ns attach-agent $n6 $null1
- $ns connect $udp1 $null1
- $ns at 0.0 "$cbr0 start"
- $ns at 0.0 "$cbr1 start"
- $ns rtmodel-at 5.0 down $n4 $n5
- $ns rtmodel-at 55.0 up $n4 $n5
- $ns rtmodel-at 20.0 down $n8 $n9
- $ns rtmodel-at 40.0 up $n8 $n9
- $ns at 100.0 "finish"
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement