Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- set nf [open ass1.nam w]
- set f [open ass1.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 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 blue
- $n3 color green
- $n6 color green
- $n0 color red
- $n7 color blue
- $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 fid_ 1
- $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.02Mb
- $ns at 0.0 "$ftp start"
- set udp0 [new Agent/UDP]
- $ns attach-agent $n2 $udp0
- $udp0 set fid_ 2
- set cbr0 [new Application/Traffic/CBR]
- $cbr0 set packetSize_ 1024
- $cbr0 set random_ false
- $cbr0 set rate_ 0.01Mb
- $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
- $udp1 set fid_ 3
- set cbr1 [new Application/Traffic/CBR]
- $cbr1 set packetSize_ 1024
- $cbr1 set random_ false
- $cbr1 set rate_ 0.01Mb
- $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 1.0 "$cbr1 start"
- #$ns at 0.5 "$ftp stop"
- $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