Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if {$argc == 3} {
- set protocolo [lindex $argv 0]
- set window [lindex $argv 1]
- set trafegoB [lindex $argv 2]
- } else {
- puts " bandwidth"
- puts " n0 --------------- n1"
- puts " 2"
- exit 1
- }
- set ns [new Simulator]
- set nf [open out.nam w]
- $ns namtrace-all $nf
- proc fim {} {
- global ns nf
- $ns flush-trace
- close $nf
- exec nam out.nam
- exit 0
- }
- set r1 [$ns node]
- set r2 [$ns node]
- set r3 [$ns node]
- set r4 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- set n4 [$ns node]
- $ns duplex-link $n1 $r1 200Mb 0.0001ms DropTail
- $ns duplex-link $n2 $r1 200Mb 0.0001ms DropTail
- $ns duplex-link $r1 $r2 200Mb 0.0001ms DropTail
- $ns duplex-link $r2 $r3 200Kb 0.023ms DropTail
- $ns duplex-link $r3 $r4 50Mb 0.00005ms DropTail
- $ns duplex-link $r4 $n3 200Mb 0.0001ms DropTail
- $ns duplex-link $r4 $n4 200Mb 0.0001ms DropTail
- $ns queue-limit $n1 $r1 100000
- $ns duplex-link-op $n1 $r1 orient right-down
- $ns duplex-link-op $n2 $r1 orient right-up
- $ns duplex-link-op $r1 $r2 orient right
- $ns duplex-link-op $r2 $r3 orient right
- $ns duplex-link-op $r3 $r4 orient right
- $ns duplex-link-op $r4 $n3 orient right-up
- $ns duplex-link-op $r4 $n4 orient right-down
- if {$protocolo == 1} {
- set tcp0 [new Agent/TCP]
- $tcp0 set window_ $window
- set tcp_end [new Agent/TCPSink]
- $ns attach-agent $n1 $tcp0
- $ns attach-agent $n3 $tcp_end
- $ns connect $tcp0 $tcp_end
- set cbr1 [new Application/Traffic/CBR]
- $cbr1 set maxpkts_ 1
- $cbr1 set packetSize_ 2097152
- $cbr1 attach-agent $tcp0
- }
- if {$protocolo == 0} {
- set udp1 [new Agent/UDP]
- $ns attach-agent $n1 $udp1
- set cbr1 [new Application/Traffic/CBR]
- $cbr1 set packetSize_ 2097152
- $cbr1 set maxpkts_ 1
- $cbr1 attach-agent $udp1
- set null1 [new Agent/Null]
- $ns attach-agent $n3 $null1
- $ns connect $udp1 $null1
- }
- set udp0 [new Agent/UDP]
- $ns attach-agent $n2 $udp0
- set cbr0 [new Application/Traffic/CBR]
- $cbr0 set rate_ $trafegoB bps
- $cbr0 attach-agent $udp0
- set null0 [new Agent/Null]
- $ns attach-agent $n4 $null0
- $ns connect $udp0 $null0
- $ns at 1.0 "$cbr0 start"
- $ns at 8.0 "$cbr0 stop"
- $ns at 0.5 "$cbr1 start"
- $ns at 8.0 "$cbr1 stop"
- $ns at 9.0 "fim"
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement