Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- set tracefile [open lab2.tr w]
- $ns trace-all $tracefile
- set namfile [open lab2.nam w]
- $ns namtrace-all $namfile
- set n0[$ns node]
- set n1[$ns node]
- set n2[$ns node]
- set n3[$ns node]
- set n4[$ns node]
- $ns duplex-link $n0 $n4 1Mb 10ms DropTail
- $ns duplex-link $n1 $n4 1Mb 10ms DropTail
- $ns duplex-link $n4 $n3 1Mb 10ms DropTail
- $ns duplex-link $n4 $n2 1Mb 10ms DropTail
- set tcp [new Agent/TCP]
- $ns attach-agent $n0 $tcp
- set sink [new Agent/TCPSink]
- $ns attach-agent $n3 $sink
- $ns connect $tcp $sink
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- set udp [new Agent/UDP]
- $ns atatch-agent $1 $udp
- set null [new Agent/NULL]
- $ns attach-agent $2 $null
- $ns connect $udp $null
- set cbr [new Application/Traffic/CBR]
- $cbr set packetSize_ 500
- $cbr set interval_ 0.005
- $cbr attach-agent $udp
- $ns at 0.0 "$cbr start"
- $ns at 0.0 "$ftp start"
- $ns at 9.0 "$cbr stop"
- $ns at 9.0 "$ftp stop"
- proc finish {} {
- global ns namfile tracefile
- $ns flush-trace
- close $tracefile
- close $namfile
- exec nam lab1.nam &
- exit 0
- }
- $ns at 10.0 "finish"
- $ns run
Advertisement
RAW Paste Data
Copied
Advertisement