Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. if {$argc == 3} {
  2.  
  3. set protocol [lindex $argv 0]
  4. set traffic [lindex $argv 1]
  5. set wind [lindex $argv 2]
  6. } else {
  7. puts "-->Stuff"
  8. puts "protocol"
  9. puts "traffic"
  10. puts "TCP_window"
  11. exit 1
  12. }
  13.  
  14.  
  15. set ns [new Simulator]
  16. set nf [open out.nam w]
  17. $ns namtrace-all $nf
  18.  
  19. proc fim {} {
  20. global ns nf
  21. $ns flush-trace
  22. close $nf
  23. exec nam out.nam
  24. exit 0
  25. }
  26.  
  27.  
  28. set n0 [$ns node]
  29. set n1 [$ns node]
  30.  
  31. set n2 [$ns node]
  32. set n3 [$ns node]
  33. #SATELITE HERE
  34. set n4 [$ns node]
  35. set n5 [$ns node]
  36.  
  37. set n6 [$ns node]
  38. set n7 [$ns node]
  39.  
  40.  
  41. $ns duplex-link $n0 $n2 200Mb 0.001ms DropTail
  42. $ns duplex-link $n1 $n2 200Mb 0.001ms DropTail
  43.  
  44. $ns duplex-link $n2 $n3 200Mb 0.001ms DropTail
  45. $ns duplex-link $n3 $n4 0.2Mb 0.23ms DropTail
  46.  
  47. $ns duplex-link $n4 $n5 100Mb 0.0005ms DropTail
  48.  
  49. $ns duplex-link $n5 $n6 200Mb 0.001ms DropTail
  50. $ns duplex-link $n5 $n7 200Mb 0.001ms DropTail
  51.  
  52. $ns queue-limit $n0 $n2 2098
  53. $ns queue-limit $n0 $n2 2098
  54.  
  55.  
  56.  
  57. if {$protocol == "TCP"} {
  58.  
  59. set tcp0 [new Agent/TCP]
  60. $tcp0 set window_ $wind
  61. $ns attach-agent $n0 $tcp0
  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. set null [new Agent/TCPSink]
  69. $ns attach-agent $n6 $null
  70.  
  71. $ns connect $tcp0 $null
  72. }
  73.  
  74.  
  75.  
  76.  
  77. if {$protocol == "UDP"} {
  78.  
  79. set udp0 [new Agent/UDP]
  80. $ns attach-agent $n0 $udp0
  81.  
  82. set cbr0 [new Application/Traffic/CBR]
  83. $cbr0 set packetSize_ 2097152
  84. $cbr0 set maxpkts_ 1
  85. $cbr0 attach-agent $udp0
  86.  
  87. set null0 [new Agent/NULL]
  88. $ns attach-agent $n6 $null0
  89.  
  90. $ns connect $udp0 $null0
  91. }
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. if {$traffic == "low"} {
  101.  
  102. set udpt [new Agent/UDP]
  103. $ns attach-agent $n1 $udpt
  104.  
  105. set cbrt [new Application/Traffic/CBR]
  106. $cbrt set rate_ 1
  107. $cbrt attach-agent $udpt
  108.  
  109. set nullt [new Agent/TCPSink]
  110. $ns attach-agent $n6 $nullt
  111.  
  112. $ns connect $udpt $nullt
  113. }
  114.  
  115.  
  116. if {$traffic == "high"} {
  117.  
  118. set udpt [new Agent/UDP]
  119. $ns attach-agent $n1 $udpt
  120.  
  121. set cbrt [new Application/Traffic/CBR]
  122. $cbrt set rate_ 10
  123. $cbrt attach-agent $udpt
  124.  
  125. set nullt [new Agent/TCPSink]
  126. $ns attach-agent $n6 $nullt
  127.  
  128. $ns connect $udpt $nullt
  129. }
  130.  
  131.  
  132.  
  133. $ns at 1.0 "$cbr0 start"
  134. $ns at 1.0 "$cbrt start"
  135.  
  136. $ns at 4.0 "$cbr0 stop"
  137. $ns at 4.0 "$cbrt stop"
  138.  
  139.  
  140.  
  141. $ns at 5.0 "fim"
  142. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement