anik314159

Ass2.tcl

Jul 24th, 2022 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 2.43 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 $n3 $n4 20Mb 10ms DropTail
  44. $ns duplex-link $n4 $n5 20Mb 10ms DropTail
  45. $ns duplex-link $n5 $n6 20Mb 10ms DropTail
  46. $ns duplex-link $n1 $n4 20Mb 10ms DropTail
  47. $ns duplex-link $n2 $n5 20Mb 10ms DropTail
  48. $ns duplex-link $n8 $n9 20Mb 10ms DropTail
  49.  
  50. $ns duplex-link $n7 $n11 20Mb 10ms DropTail
  51. $ns duplex-link $n8 $n11 20Mb 10ms DropTail
  52. $ns duplex-link $n9 $n11 20Mb 10ms DropTail
  53. $ns duplex-link $n11 $n10 20Mb 10ms DropTail
  54.  
  55.  
  56. $ns simplex-link $n3 $n7 10Mb 5ms SFQ
  57. $ns simplex-link $n4 $n8 10Mb 5ms SFQ
  58. $ns simplex-link $n9 $n5 10Mb 5ms SFQ
  59. $ns simplex-link $n6 $n10 10Mb 5ms SFQ
  60. $ns simplex-link $n7 $n8 10Mb 5ms SFQ
  61. $ns simplex-link $n10 $n9 10Mb 5ms SFQ
  62.  
  63. $ns attach-agent $n1 $udp0
  64. $udp0 set fid_ 1
  65. set cbr0 [new Application/Traffic/CBR]
  66. $cbr0 set packetSize_ 512
  67. $cbr0 set random_ false
  68. $cbr0 set rate_ 0.4Mb
  69. $cbr0 attach-agent $udp0
  70.  
  71. set null0 [ new Agent/Null ]
  72. $ns attach-agent $n11 $null0
  73. $ns connect $udp0 $null0
  74.  
  75. set udp1 [new Agent/UDP]
  76. $ns attach-agent $n3 $udp1
  77. $udp1 set fid_ 2
  78. set cbr1 [new Application/Traffic/CBR]
  79. $cbr1 set packetSize_ 1024i
  80. $cbr1 set random_ false
  81. $cbr1 set rate_ 0.5Mb
  82. $cbr1 attach-agent $udp1
  83.  
  84. set null1 [ new Agent/Null ]
  85. $ns attach-agent $n11 $null1
  86. $ns connect $udp1 $null1
  87.  
  88. set udp2 [new Agent/UDP]
  89. $ns attach-agent $n6 $udp2
  90. $udp1 set fid_ 3
  91. set cbr2 [new Application/Traffic/CBR]
  92. $cbr2 set packetSize_ 2048
  93. $cbr2 set random_ false
  94. $cbr2 set rate_ 0.6Mb
  95. $cbr2 attach-agent $udp2
  96.  
  97. set null2 [ new Agent/Null ]
  98. $ns attach-agent $n7 $null2
  99. $ns connect $udp2 $null2
  100.  
  101.  
  102.  
  103. $ns at 0.0 "$cbr0 start"
  104. $ns at 0.0 "$cbr1 start"
  105. $ns at 0.0 "$cbr2 start"
  106. $ns rtmodel-at 10.0 down $n4 $n5
  107. $ns rtmodel-at 20.0 up $n4 $n5
  108.  
  109. $ns rtmodel-at 30.0 down $n8 $n9
  110. $ns rtmodel-at 55.0 up $n8 $n9
  111.  
  112. $ns at 100.0 "finish"
  113. $ns run
Add Comment
Please, Sign In to add comment