Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- $ns rtproto Session
- set f [open tes.tr w]
- set nf [open tes.nam w]
- $ns namtrace-all $nf
- $ns trace-all $f
- proc finish { } {
- global ns f
- $ns flush-trace
- close $f
- exec nam tes.nam &
- exit 0
- }
- set n0 [$ns node]
- $n0 color "Blue"
- set n1 [$ns node]
- $n1 color "Green"
- set n2 [$ns node]
- $n2 color "Yellow"
- set n3 [$ns node]
- $ns color 1 "Green"
- $ns color 2 "Red"
- $ns duplex-link $n0 $n1 10mb 10ms DropTail
- $ns duplex-link $n1 $n2 10Mb 10ms DropTail
- $ns duplex-link $n2 $n3 10Mb 10ms DropTail
- $ns duplex-link $n3 $n0 10Mb 100ms DropTail
- $ns duplex-link-op $n0 $n1 color "Red"
- #TCP
- set tcp [new Agent/TCP]
- $ns attach-agent $n0 $tcp
- #Sink
- set sink [new Agent/TCPSink]
- $ns attach-agent $n1 $sink
- $ns connect $tcp $sink
- $tcp set fid_ 1
- $tcp set packetSize_ 1024
- #FTP
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- #dosen't varry
- $ftp set rate_ 0.001mb
- #udp
- set udp [new Agent/UDP]
- $ns attach-agent $n2 $udp
- #null
- set null [new Agent/Null]
- $ns attach-agent $n0 $null
- #connection
- $ns connect $udp $null
- $udp set fid_ 2
- #CBR
- set cbr [new Application/Traffic/CBR]
- $cbr attach-agent $udp
- $cbr set packetSize_ 1024
- $cbr set rate_ 5mb
- #$ns at 0 "$ftp start"
- $ns at 0 "$cbr start"
- $ns rtmodel-at 2 down $n1 $n0
- $ns at 10 "finish"
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement