Advertisement
AnindyaBiswas

NetAss juan

Jun 29th, 2022 (edited)
1,479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.29 KB | None | 0 0
  1. set ns [new Simulator]
  2.  
  3. #Tell the simulator to use dynamic routing
  4. $ns rtproto Session
  5.  
  6. set f [open ass1.tr w]
  7. set nf [open ass1.nam w]
  8. $ns namtrace-all $nf
  9. $ns trace-all $f
  10.  
  11. proc finish { } {
  12.     global ns f
  13.     $ns flush-trace
  14.     close $f
  15.     exec nam ass1.nam &
  16.     exit 0
  17.     }
  18.  
  19. set n0 [$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.  
  30. # Node colors
  31. #$n0 color white
  32. $n0 color red
  33. $n1 color cyan
  34. $n2 color green
  35. $n5 color green
  36. $n6 color cyan
  37. $n9 color red
  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.  
  49. #Simplex-links (unidirectional)
  50. $ns simplex-link $n2 $n6 10mb 5ms SFQ
  51. $ns simplex-link $n3 $n7 10mb 5ms SFQ
  52. $ns simplex-link $n8 $n4 10mb 5ms SFQ
  53. $ns simplex-link $n5 $n9 10mb 5ms SFQ
  54. $ns simplex-link $n6 $n7 10mb 5ms SFQ
  55. $ns simplex-link $n9 $n8 10mb 5ms SFQ
  56.  
  57. # Orientation
  58. $ns duplex-link-op $n0 $n1 orient right
  59. $ns duplex-link-op $n2 $n3 orient right
  60. $ns duplex-link-op $n3 $n4 orient right
  61. $ns duplex-link-op $n4 $n5 orient right
  62. $ns duplex-link-op $n0 $n3 orient down
  63. $ns duplex-link-op $n1 $n4 orient down
  64. $ns duplex-link-op $n7 $n8 orient right
  65.  
  66. $ns simplex-link-op $n2 $n6 orient down
  67. $ns simplex-link-op $n3 $n7 orient down
  68. $ns simplex-link-op $n8 $n4 orient up
  69. $ns simplex-link-op $n5 $n9 orient down
  70. $ns simplex-link-op $n6 $n7 orient right
  71. $ns simplex-link-op $n9 $n8 orient left
  72.  
  73. # Link colors
  74. $ns duplex-link-op $n3 $n4 color "magenta"
  75. $ns duplex-link-op $n7 $n8 color "magenta"
  76.  
  77. # Link Label
  78. $ns duplex-link-op $n3 $n4 label "fail"
  79. $ns duplex-link-op $n7 $n8 label "fail"
  80.  
  81. # fid colors
  82. $ns color 1 Red
  83. $ns color 2 Blue
  84. $ns color 3 green
  85.  
  86.  
  87. #TCP
  88. set tcp [new Agent/TCP]
  89. $ns attach-agent $n0 $tcp
  90. set sink [new Agent/TCPSink]
  91. $ns attach-agent $n9 $sink
  92. $ns connect $tcp $sink
  93. $tcp set fid_ 1
  94. $tcp set packetSize_ 1024
  95.  
  96. #FTP
  97. set ftp [new Application/FTP]
  98. $ftp attach-agent $tcp
  99. $ftp set rate_ 0.02mb
  100. $ftp set type_ FTP
  101. $ftp set random_ true
  102. $ns at 0.0 "$ftp start"
  103.  
  104. #UDP1
  105. set udp1 [new Agent/UDP]
  106. $ns attach-agent $n1 $udp1
  107. set null1 [new Agent/Null]
  108. $ns attach-agent $n6 $null1
  109. $ns connect $udp1 $null1
  110. $udp1 set fid_ 2
  111.  
  112. #CBR1
  113. set cbr1 [new Application/Traffic/CBR]
  114. $cbr1 attach-agent $udp1
  115. $cbr1 set packetSize_ 512
  116. $cbr1 set rate_ 0.01mb
  117. $cbr1 set random_ false
  118.  
  119.  
  120.  
  121. #UDP2
  122. set udp2 [new Agent/UDP]
  123. $ns attach-agent $n2 $udp2
  124. set null2 [new Agent/Null]
  125. $ns attach-agent $n5 $null2
  126. $ns connect $udp2 $null2
  127. $udp2 set fid_ 3
  128.  
  129. #CBR2
  130. set cbr2 [new Application/Traffic/CBR]
  131. $cbr2 attach-agent $udp2
  132. $cbr2 set packetSize_ 512
  133. $cbr2 set rate_ 0.01mb
  134. $cbr2 set random_ true
  135.  
  136. #Schedule events for the CBR agent and the network dynamics
  137. $ns at 0.0 "$cbr1 start"
  138. $ns at 0.0 "$cbr2 start"
  139. $ns rtmodel-at 5.0 down $n3 $n4
  140. $ns rtmodel-at 55.0 up $n3 $n4
  141. $ns rtmodel-at 20.0 down $n7 $n8
  142. $ns rtmodel-at 40.0 up $n7 $n8
  143. $ns at 100.0 "$cbr1 stop"
  144. $ns at 100.0 "$cbr2 stop"
  145.  
  146. $ns at 100.0 "finish"
  147. $ns run
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement