Advertisement
AnindyaBiswas

NetAss two

Jul 3rd, 2022 (edited)
1,402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.72 KB | None | 0 0
  1. set ns [new Simulator]
  2. #Tell the simulator to use dynamic routing
  3. $ns rtproto Session
  4.  
  5. set f [open ass2.tr w]
  6. set nf [open ass2.nam w]
  7. $ns namtrace-all $nf
  8. $ns trace-all $f
  9.  
  10. proc finish { } {
  11.     global ns f
  12.     $ns flush-trace
  13.     close $f
  14.     exec nam ass2.nam &
  15.     exit 0
  16.     }
  17.  
  18. set n0 [$ns node]
  19. set n1 [$ns node]
  20. set n2 [$ns node]
  21. set n3 [$ns node]
  22. set n4 [$ns node]
  23. set n5 [$ns node]
  24. set n6 [$ns node]
  25. set n7 [$ns node]
  26. set n8 [$ns node]
  27. set n9 [$ns node]
  28. set n10 [$ns node]
  29.  
  30.  
  31. # Node colors
  32. $n0 color red
  33. $n10 color red
  34. $n2 color green
  35. $n9 color green
  36. $n5 color cyan
  37. $n6 color cyan
  38.  
  39.  
  40. #Duplex-links (bidirectional)
  41. $ns duplex-link $n0 $n1 20mb 10ms DropTail
  42. $ns duplex-link $n2 $n3 20mb 10ms DropTail
  43. $ns duplex-link $n3 $n4 20mb 10ms DropTail
  44. $ns duplex-link $n4 $n5 20mb 10ms DropTail
  45. $ns duplex-link $n0 $n3 20mb 10ms DropTail
  46. $ns duplex-link $n1 $n4 20mb 10ms DropTail
  47. $ns duplex-link $n7 $n8 20mb 10ms DropTail
  48. $ns duplex-link $n6 $n10 20mb 10ms DropTail
  49. $ns duplex-link $n7 $n10 20mb 10ms DropTail
  50. $ns duplex-link $n8 $n10 20mb 10ms DropTail
  51. $ns duplex-link $n9 $n10 20mb 10ms DropTail
  52.  
  53. #Simplex-links (unidirectional)
  54. $ns simplex-link $n2 $n6 10mb 5ms SFQ
  55. $ns simplex-link $n3 $n7 10mb 5ms SFQ
  56. $ns simplex-link $n8 $n4 10mb 5ms SFQ
  57. $ns simplex-link $n5 $n9 10mb 5ms SFQ
  58. $ns simplex-link $n6 $n7 10mb 5ms SFQ
  59. $ns simplex-link $n9 $n8 10mb 5ms SFQ
  60.  
  61. # Link colors
  62. $ns duplex-link-op $n7 $n8 color "magenta"
  63. $ns duplex-link-op $n3 $n4 color "magenta"
  64.  
  65. # Link Label
  66. $ns duplex-link-op $n3 $n4 label "Fail"
  67. $ns duplex-link-op $n7 $n8 label "Fail"
  68.  
  69. # fid colors
  70. $ns color 1 red
  71. $ns color 2 green
  72. $ns color 3 blue
  73.  
  74. # Orientation
  75. $ns duplex-link-op $n0 $n3 orient down
  76. $ns duplex-link-op $n1 $n4 orient down
  77.  
  78. $ns duplex-link-op $n0 $n1 orient right
  79.  
  80. $ns duplex-link-op $n2 $n3 orient right
  81. $ns duplex-link-op $n3 $n4 orient right
  82. $ns duplex-link-op $n4 $n5 orient right
  83.  
  84. $ns simplex-link-op $n6 $n7 orient right
  85. $ns duplex-link-op $n7 $n8 orient right
  86. $ns simplex-link-op $n9 $n8 orient left
  87.  
  88.  
  89. $ns duplex-link-op $n6 $n10 orient right-down
  90. $ns duplex-link-op $n7 $n10 orient right-down
  91. $ns duplex-link-op $n8 $n10 orient left-down
  92. $ns duplex-link-op $n9 $n10 orient left-down
  93.  
  94. $ns simplex-link-op $n2 $n6 orient down
  95. $ns simplex-link-op $n3 $n7 orient down
  96. $ns simplex-link-op $n8 $n4 orient up
  97. $ns simplex-link-op $n5 $n9 orient down
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. #UDP1
  107. set udp1 [new Agent/UDP]
  108. $ns attach-agent $n0 $udp1
  109. set loss1 [new Agent/LossMonitor]
  110. $ns attach-agent $n10 $loss1
  111. $ns connect $udp1 $loss1
  112. $udp1 set fid_ 1
  113.  
  114. #CBR1
  115. set cbr1 [new Application/Traffic/Exponential]
  116. $cbr1 attach-agent $udp1
  117. $cbr1 set packetSize_ 512
  118. $cbr1 set rate_ 0.4mb
  119. $cbr1 set burst_time_ 3s
  120. $cbr1 set idle_time_ 2s
  121.  
  122.  
  123. #UDP2
  124. set udp2 [new Agent/UDP]
  125. $ns attach-agent $n2 $udp2
  126. set loss2 [new Agent/LossMonitor]
  127. $ns attach-agent $n9 $loss2
  128. $ns connect $udp2 $loss2
  129. $udp2 set fid_ 2
  130.  
  131. #CBR2
  132. set cbr2 [new Application/Traffic/Exponential]
  133. $cbr2 attach-agent $udp2
  134. $cbr2 set packetSize_ 1024
  135. $cbr2 set rate_ 0.5mb
  136. $cbr2 set burst_time_ 2s
  137. $cbr2 set idle_time_ 1s
  138.  
  139.  
  140. #UDP3
  141. set udp3 [new Agent/UDP]
  142. $ns attach-agent $n5 $udp3
  143. set loss3 [new Agent/LossMonitor]
  144. $ns attach-agent $n6 $loss3
  145. $ns connect $udp3 $loss3
  146. $udp3 set fid_ 3
  147.  
  148. #CBR3
  149. set cbr3 [new Application/Traffic/Exponential]
  150. $cbr3 attach-agent $udp3
  151. $cbr3 set packetSize_ 2048
  152. $cbr3 set rate_ 0.6mb
  153. $cbr3 set burst_time_ 4s
  154. $cbr3 set idle_time_ 2s
  155.  
  156. #Schedule events for the CBR agent and the network dynamics
  157. $ns at 0.0 "$cbr1 start"
  158. $ns at 0.0 "$cbr2 start"
  159. $ns at 0.0 "$cbr3 start"
  160. $ns rtmodel-at 10.0 down $n3 $n4
  161. $ns rtmodel-at 20.0 up $n3 $n4
  162.  
  163. $ns rtmodel-at 30.0 down $n7 $n8
  164. $ns rtmodel-at 55.0 up $n7 $n8
  165.  
  166.  
  167. $ns at 100.0 "finish"
  168. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement