Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1.  
  2. if {$argc == 3} {
  3. set protocolo [lindex $argv 0]
  4. set window [lindex $argv 1]
  5. set trafegoB [lindex $argv 2]
  6. } else {
  7. puts " bandwidth"
  8. puts " n0 --------------- n1"
  9. puts " 2"
  10. exit 1
  11. }
  12.  
  13.  
  14.  
  15. set ns [new Simulator]
  16.  
  17.  
  18. set nf [open out.nam w]
  19. $ns namtrace-all $nf
  20.  
  21.  
  22.  
  23. proc fim {} {
  24. global ns nf
  25. $ns flush-trace
  26. close $nf
  27. exec nam out.nam
  28. exit 0
  29. }
  30.  
  31. set r1 [$ns node]
  32. set r2 [$ns node]
  33. set r3 [$ns node]
  34. set r4 [$ns node]
  35. set n1 [$ns node]
  36. set n2 [$ns node]
  37. set n3 [$ns node]
  38. set n4 [$ns node]
  39.  
  40. $ns duplex-link $n1 $r1 200Mb 0.0001ms DropTail
  41. $ns duplex-link $n2 $r1 200Mb 0.0001ms DropTail
  42. $ns duplex-link $r1 $r2 200Mb 0.0001ms DropTail
  43. $ns duplex-link $r2 $r3 200Kb 0.023ms DropTail
  44. $ns duplex-link $r3 $r4 50Mb 0.00005ms DropTail
  45. $ns duplex-link $r4 $n3 200Mb 0.0001ms DropTail
  46. $ns duplex-link $r4 $n4 200Mb 0.0001ms DropTail
  47.  
  48. $ns queue-limit $n1 $r1 100000
  49.  
  50. $ns duplex-link-op $n1 $r1 orient right-down
  51. $ns duplex-link-op $n2 $r1 orient right-up
  52. $ns duplex-link-op $r1 $r2 orient right
  53. $ns duplex-link-op $r2 $r3 orient right
  54. $ns duplex-link-op $r3 $r4 orient right
  55. $ns duplex-link-op $r4 $n3 orient right-up
  56. $ns duplex-link-op $r4 $n4 orient right-down
  57.  
  58.  
  59. if {$protocolo == 1} {
  60. set tcp0 [new Agent/TCP]
  61. $tcp0 set window_ $window
  62. set tcp_end [new Agent/TCPSink]
  63. $ns attach-agent $n1 $tcp0
  64. $ns attach-agent $n3 $tcp_end
  65. $ns connect $tcp0 $tcp_end
  66.  
  67. set cbr1 [new Application/Traffic/CBR]
  68. $cbr1 set maxpkts_ 1
  69. $cbr1 set packetSize_ 2097152
  70. $cbr1 attach-agent $tcp0
  71.  
  72. }
  73.  
  74. if {$protocolo == 0} {
  75. set udp1 [new Agent/UDP]
  76. $ns attach-agent $n1 $udp1
  77.  
  78. set cbr1 [new Application/Traffic/CBR]
  79. $cbr1 set packetSize_ 2097152
  80. $cbr1 set maxpkts_ 1
  81. $cbr1 attach-agent $udp1
  82.  
  83.  
  84. set null1 [new Agent/Null]
  85. $ns attach-agent $n3 $null1
  86.  
  87. $ns connect $udp1 $null1
  88. }
  89.  
  90.  
  91. set udp0 [new Agent/UDP]
  92. $ns attach-agent $n2 $udp0
  93.  
  94. set cbr0 [new Application/Traffic/CBR]
  95. $cbr0 set rate_ $trafegoB bps
  96. $cbr0 attach-agent $udp0
  97.  
  98.  
  99. set null0 [new Agent/Null]
  100. $ns attach-agent $n4 $null0
  101.  
  102. $ns connect $udp0 $null0
  103.  
  104. $ns at 1.0 "$cbr0 start"
  105. $ns at 8.0 "$cbr0 stop"
  106. $ns at 0.5 "$cbr1 start"
  107. $ns at 8.0 "$cbr1 stop"
  108.  
  109.  
  110.  
  111. $ns at 9.0 "fim"
  112. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement