Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. if {$argc == 3} {
  2. set tcp [lindex $argv 0]
  3. set rate [lindex $argv 1]
  4. set window [lindex $argv 2]
  5.  
  6. }
  7. set ns [new Simulator]
  8.  
  9. $ns color 1 Yellow
  10. $ns color 2 Blue
  11.  
  12. set nt [open out.tr w]
  13. set nf [open out.nam w]
  14. $ns trace-all $nt
  15. $ns namtrace-all $nf
  16. proc fim {} {
  17. global ns nf
  18. $ns flush-trace
  19. close $nf
  20. exec nam out.nam
  21. exit 0
  22. }
  23.  
  24. set n0 [$ns node] ;#EMISSOR A
  25. set n1 [$ns node] ;#EMISSOR B
  26. set n2 [$ns node] ;#1
  27. set n3 [$ns node] ;#2
  28. set n4 [$ns node] ;#SATELITE
  29. set n5 [$ns node] ;#3
  30. set n6 [$ns node] ;#4
  31. set n7 [$ns node] ;#RECETOR A
  32. set n8 [$ns node] ;#RECETOR B
  33.  
  34. $ns duplex-link $n0 $n2 200Mb 0.001ms DropTail
  35. $ns duplex-link $n1 $n2 200Mb 0.001ms DropTail
  36. $ns duplex-link $n2 $n3 200Mb 0.001ms DropTail
  37. $ns duplex-link $n3 $n4 200Kb 0.117ms DropTail
  38. $ns duplex-link $n4 $n5 200Kb 0.117ms DropTail
  39. $ns duplex-link $n5 $n6 50Mb 0.0005ms DropTail
  40. $ns duplex-link $n6 $n7 200Mb 0.001ms DropTail
  41. $ns duplex-link $n6 $n8 200Mb 0.001ms DropTail
  42.  
  43. $ns duplex-link-op $n2 $n0 orient left-up
  44. $ns duplex-link-op $n2 $n1 orient left-down
  45. $ns duplex-link-op $n2 $n3 orient right
  46. $ns duplex-link-op $n3 $n4 orient right-up
  47. $ns duplex-link-op $n4 $n5 orient right-down
  48. $ns duplex-link-op $n5 $n6 orient right
  49. $ns duplex-link-op $n6 $n7 orient right-up
  50. $ns duplex-link-op $n6 $n8 orient right-down
  51.  
  52. $ns queue-limit $n0 $n2 2100
  53. if {$tcp == "TCP"} {
  54. set tcp0 [new Agent/TCP]
  55. $ns attach-agent $n0 $tcp0
  56. $tcp0 set window_ $window
  57.  
  58. set tcp_end [new Agent/TCPSink]
  59. $ns attach-agent $n7 $tcp_end
  60.  
  61. $ns connect $tcp0 $tcp_end
  62.  
  63. set cbr0 [new Application/Traffic/CBR]
  64. $cbr0 set packetSize_ 2097152
  65. $cbr0 set maxpkts_ 1
  66. $cbr0 attach-agent $tcp0
  67. }
  68. if {$tcp == "UDP"} {
  69. set tcp0 [new Agent/UDP]
  70. $ns attach-agent $n0 $tcp0
  71.  
  72. set udp_end1 [new Agent/Null]
  73. $ns attach-agent $n7 $udp_end1
  74.  
  75. $ns connect $tcp0 $udp_end1
  76.  
  77. set cbr0 [new Application/Traffic/CBR]
  78. $cbr0 set packetSize_ 2097152
  79. $cbr0 set maxpkts_ 1
  80. $cbr0 attach-agent $tcp0
  81. }
  82.  
  83. set udp0 [new Agent/UDP]
  84. $ns attach-agent $n1 $udp0
  85.  
  86. set udp_end [new Agent/Null]
  87. $ns attach-agent $n8 $udp_end
  88.  
  89. $ns connect $udp0 $udp_end
  90.  
  91. set cbr1 [new Application/Traffic/CBR]
  92. $cbr1 set rate_ $rate
  93. $cbr1 attach-agent $udp0
  94.  
  95. $ns at 1.0 "$cbr0 start"
  96. $ns at 1.0 "$cbr1 start"
  97. $ns at 4.0 "$cbr0 stop"
  98. $ns at 4.0 "$cbr1 stop"
  99.  
  100. $ns at 5.0 "fim"
  101.  
  102. $tcp0 set class_ 1
  103. $udp0 set class_ 2
  104.  
  105. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement