Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if {$argc == 3} {
- set tcp [lindex $argv 0]
- set rate [lindex $argv 1]
- set window [lindex $argv 2]
- }
- set ns [new Simulator]
- $ns color 1 Yellow
- $ns color 2 Blue
- set nt [open out.tr w]
- set nf [open out.nam w]
- $ns trace-all $nt
- $ns namtrace-all $nf
- proc fim {} {
- global ns nf
- $ns flush-trace
- close $nf
- exec nam out.nam
- exit 0
- }
- set n0 [$ns node] ;#EMISSOR A
- set n1 [$ns node] ;#EMISSOR B
- set n2 [$ns node] ;#1
- set n3 [$ns node] ;#2
- set n4 [$ns node] ;#SATELITE
- set n5 [$ns node] ;#3
- set n6 [$ns node] ;#4
- set n7 [$ns node] ;#RECETOR A
- set n8 [$ns node] ;#RECETOR B
- $ns duplex-link $n0 $n2 200Mb 0.001ms DropTail
- $ns duplex-link $n1 $n2 200Mb 0.001ms DropTail
- $ns duplex-link $n2 $n3 200Mb 0.001ms DropTail
- $ns duplex-link $n3 $n4 200Kb 0.117ms DropTail
- $ns duplex-link $n4 $n5 200Kb 0.117ms DropTail
- $ns duplex-link $n5 $n6 50Mb 0.0005ms DropTail
- $ns duplex-link $n6 $n7 200Mb 0.001ms DropTail
- $ns duplex-link $n6 $n8 200Mb 0.001ms DropTail
- $ns duplex-link-op $n2 $n0 orient left-up
- $ns duplex-link-op $n2 $n1 orient left-down
- $ns duplex-link-op $n2 $n3 orient right
- $ns duplex-link-op $n3 $n4 orient right-up
- $ns duplex-link-op $n4 $n5 orient right-down
- $ns duplex-link-op $n5 $n6 orient right
- $ns duplex-link-op $n6 $n7 orient right-up
- $ns duplex-link-op $n6 $n8 orient right-down
- $ns queue-limit $n0 $n2 2100
- if {$tcp == "TCP"} {
- set tcp0 [new Agent/TCP]
- $ns attach-agent $n0 $tcp0
- $tcp0 set window_ $window
- set tcp_end [new Agent/TCPSink]
- $ns attach-agent $n7 $tcp_end
- $ns connect $tcp0 $tcp_end
- set cbr0 [new Application/Traffic/CBR]
- $cbr0 set packetSize_ 2097152
- $cbr0 set maxpkts_ 1
- $cbr0 attach-agent $tcp0
- }
- if {$tcp == "UDP"} {
- set tcp0 [new Agent/UDP]
- $ns attach-agent $n0 $tcp0
- set udp_end1 [new Agent/Null]
- $ns attach-agent $n7 $udp_end1
- $ns connect $tcp0 $udp_end1
- set cbr0 [new Application/Traffic/CBR]
- $cbr0 set packetSize_ 2097152
- $cbr0 set maxpkts_ 1
- $cbr0 attach-agent $tcp0
- }
- set udp0 [new Agent/UDP]
- $ns attach-agent $n1 $udp0
- set udp_end [new Agent/Null]
- $ns attach-agent $n8 $udp_end
- $ns connect $udp0 $udp_end
- set cbr1 [new Application/Traffic/CBR]
- $cbr1 set rate_ $rate
- $cbr1 attach-agent $udp0
- $ns at 1.0 "$cbr0 start"
- $ns at 1.0 "$cbr1 start"
- $ns at 4.0 "$cbr0 stop"
- $ns at 4.0 "$cbr1 stop"
- $ns at 5.0 "fim"
- $tcp0 set class_ 1
- $udp0 set class_ 2
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement