Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- set f [open out.tr w]
- set nf [open output.nam w]
- $ns namtrace-all $nf
- $ns trace-all $f
- $ns color 1 Blue
- $ns color 2 Red
- proc finish { } {
- global ns f
- $ns flush-trace
- close $f
- exec nam output.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]
- $n0 color red
- $n1 color blue
- $n2 color green
- $n3 color yellow
- $n4 color cyan
- $n5 color magenta
- $n6 color orange
- $ns duplex-link $n0 $n1 1mb 10ms DropTail
- $ns duplex-link $n2 $n4 1mb 10ms DropTail
- $ns duplex-link $n3 $n5 1mb 10ms DropTail
- $ns simplex-link $n4 $n6 5mb 10ms DropTail
- $ns duplex-link $n0 $n6 1mb 10ms DropTail
- $ns duplex-link $n1 $n4 1mb 10ms DropTail
- $ns duplex-link $n0 $n5 1mb 10ms DropTail
- $ns duplex-link $n1 $n3 1mb 10ms DropTail
- $ns duplex-link $n2 $n6 1mb 10ms DropTail
- # Orientation
- $ns duplex-link-op $n0 $n1 orient right-down
- $ns duplex-link-op $n2 $n4 orient left-up
- $ns duplex-link-op $n0 $n5 orient right
- # Color
- $ns duplex-link-op $n2 $n4 color "red"
- $ns duplex-link-op $n0 $n1 color "blue"
- $ns duplex-link-op $n3 $n5 color "yellow"
- $ns simplex-link-op $n4 $n6 color "green"
- $ns duplex-link-op $n1 $n4 color "magenta"
- $ns duplex-link-op $n1 $n3 color "pink"
- # Labelling connections(relayout first, then play)
- $ns duplex-link-op $n0 $n5 label "n0 - n5 duplex"
- $ns duplex-link-op $n2 $n4 label "n2 - n4 duplex"
- $ns duplex-link-op $n3 $n5 label "n3 - n5 duplex"
- $ns simplex-link-op $n2 $n6 label "n2 - n6 simplex"
- #TCP
- set tcp [new Agent/TCP]
- $ns attach-agent $n2 $tcp
- set sink [new Agent/TCPSink]
- $ns attach-agent $n5 $sink
- $ns connect $tcp $sink
- $tcp set fid_ 1
- $tcp set packetSize_ 500
- #FTP
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- $ftp set type_ FTP
- $ns at 0.0 "$ftp start"
- #UDP
- set udp [new Agent/UDP]
- $ns attach-agent $n3 $udp
- set null [new Agent/Null]
- $ns attach-agent $n6 $null
- $ns connect $udp $null
- $udp set fid_ 2
- #CBR
- set cbr [new Application/Traffic/CBR]
- $cbr attach-agent $udp
- $cbr set packetSize_ 1000
- $cbr set rate_ 0.1mb
- #$cbr set random_ false
- $ns at 0.0 "$cbr start"
- $ns at 20.0 "finish"
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement