anik314159

Ass2.tcl final

Jul 24th, 2022 (edited)
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.38 KB | None | 0 0
  1. set ns [new Simulator]
  2. set nf [open ass2.nam w]
  3. set f [open ass2.tr w]
  4. $ns namtrace-all $nf
  5. $ns trace-all $f
  6.  
  7. $ns rtproto Session
  8. proc finish {} {
  9.  
  10. global ns f
  11. $ns flush-trace
  12. close $f
  13.  
  14. exec nam ass2.nam &
  15. exit 0
  16. }
  17.  
  18.  
  19. set n11 [$ns node]
  20. set n1 [$ns node]
  21. set n2 [$ns node]
  22. set n3 [$ns node]
  23. set n4 [$ns node]
  24. set n5 [$ns node]
  25. set n6 [$ns node]
  26. set n7 [$ns node]
  27. set n8 [$ns node]
  28. set n9 [$ns node]
  29. set n10 [$ns node]
  30.  
  31. $n1 color red
  32. $n7 color blue
  33. $n3 color green
  34. $n6 color blue
  35. $n10 color green
  36. $n7 color blue
  37.  
  38. $ns color 1 red
  39. $ns color 2 green
  40. $ns color 3 blue
  41.  
  42. $ns duplex-link $n1 $n2 20Mb 10ms DropTail
  43. $ns duplex-link-op $n1 $n2 orient right
  44. $ns duplex-link $n3 $n4 20Mb 10ms DropTail
  45. $ns duplex-link-op $n3 $n4 orient right
  46. $ns duplex-link $n4 $n5 20Mb 10ms DropTail
  47. $ns duplex-link-op $n4 $n5 orient right
  48. $ns duplex-link $n5 $n6 20Mb 10ms DropTail
  49. $ns duplex-link-op $n5 $n6 orient right
  50. $ns duplex-link $n1 $n4 20Mb 10ms DropTail
  51. $ns duplex-link-op $n1 $n4 orient down
  52. $ns duplex-link $n2 $n5 20Mb 10ms DropTail
  53. $ns duplex-link-op $n2 $n5 orient down
  54. $ns duplex-link $n8 $n9 20Mb 10ms DropTail
  55. $ns duplex-link-op $n8 $n9 orient right
  56.  
  57. $ns duplex-link $n7 $n11 20Mb 10ms DropTail
  58. $ns duplex-link-op $n11 $n7 orient left-up
  59.  
  60.  
  61. $ns duplex-link $n8 $n11 20Mb 10ms DropTail
  62. $ns duplex-link-op $n11 $n8 orient left-up
  63. $ns duplex-link $n9 $n11 20Mb 10ms DropTail
  64. $ns duplex-link-op $n11 $n9 orient right-up
  65. $ns duplex-link $n11 $n10 20Mb 10ms DropTail
  66. $ns duplex-link-op $n11 $n10 orient right-up
  67.  
  68.  
  69. $ns simplex-link $n3 $n7 10Mb 5ms SFQ
  70. $ns simplex-link-op $n3 $n7 orient down
  71. $ns simplex-link $n4 $n8 10Mb 5ms SFQ
  72. $ns simplex-link-op $n4 $n8 orient down
  73. $ns simplex-link $n9 $n5 10Mb 5ms SFQ
  74. $ns simplex-link-op $n9 $n5 orient up
  75. $ns simplex-link $n6 $n10 10Mb 5ms SFQ
  76. $ns simplex-link-op $n6 $n10 orient down
  77. $ns simplex-link $n7 $n8 10Mb 5ms SFQ
  78. $ns simplex-link-op $n7 $n8 orient right
  79. $ns simplex-link $n10 $n9 10Mb 5ms SFQ
  80. $ns simplex-link-op $n10 $n9 orient left
  81.  
  82.  
  83. set udp0 [new Agent/UDP]
  84. $ns attach-agent $n1 $udp0
  85. $udp0 set fid_ 1
  86. set exp0 [new Application/Traffic/Exponential]
  87. $exp0 set packetSize_ 512
  88. $exp0 set random_ false
  89. $exp0 set burst_time_ 3
  90. $exp0 set idle_time_ 2
  91. $exp0 set rate_ 0.4Mb
  92. $exp0 attach-agent $udp0
  93.  
  94. set loss0 [ new Agent/LossMonitor ]
  95. $ns attach-agent $n11 $loss0
  96. $ns connect $udp0 $loss0
  97.  
  98. set udp1 [new Agent/UDP]
  99. $ns attach-agent $n3 $udp1
  100. $udp1 set fid_ 2
  101. set exp1 [new Application/Traffic/Exponential]
  102. $exp1 set packetSize_ 1024i
  103. $exp1 set burst_time_ 2
  104. $exp1 set idle_time_ 1
  105. $exp1 set random_ false
  106. $exp1 set rate_ 0.5Mb
  107. $exp1 attach-agent $udp1
  108.  
  109. set loss1 [ new Agent/LossMonitor ]
  110. $ns attach-agent $n11 $loss1
  111. $ns connect $udp1 $loss1
  112.  
  113. set udp2 [new Agent/UDP]
  114. $ns attach-agent $n6 $udp2
  115. $udp2 set fid_ 3
  116. set exp2 [new Application/Traffic/Exponential]
  117. $exp2 set packetSize_ 2048
  118. $exp2 set burst_time_ 4
  119. $exp2 set idle_time_ 2
  120.  
  121. $exp2 set random_ false
  122. $exp2 set rate_ 0.6Mb
  123. $exp2 attach-agent $udp2
  124.  
  125. set loss2 [ new Agent/LossMonitor ]
  126. $ns attach-agent $n7 $loss2
  127. $ns connect $udp2 $loss2
  128.  
  129.  
  130.  
  131. $ns at 0.0 "$exp0 start"
  132. $ns at 0.0 "$exp1 start"
  133. $ns at 0.0 "$exp2 start"
  134. #$ns at 0.5 "$ftp stop"
  135. $ns rtmodel-at 10.0 down $n4 $n5
  136. $ns rtmodel-at 20.0 up $n4 $n5
  137.  
  138. $ns rtmodel-at 30.0 down $n8 $n9
  139. $ns rtmodel-at 55.0 up $n8 $n9
  140.  
  141.  
  142.  
  143.  
  144.  
  145. $ns at 100.0 "finish"
  146. $ns run
Add Comment
Please, Sign In to add comment