Advertisement
filipao223

ex1.tcl

Oct 4th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 2.39 KB | None | 0 0
  1. set ns [new Simulator]
  2.  
  3. set nf [open out.nam w]
  4. $ns namtrace-all $nf
  5.  
  6. proc fim {} {
  7.  
  8.     global ns nf
  9.     $ns flush-trace
  10.     close $nf
  11.     exec nam out.nam
  12.     exit 0
  13. }
  14.  
  15. set n0 [$ns node]
  16. set n1 [$ns node]
  17. set n2 [$ns node]
  18. set n3 [$ns node]
  19.  
  20. #Routers
  21.  
  22. set n4 [$ns node]
  23. set n5 [$ns node]
  24.  
  25. $ns duplex-link $n0 $n4 0.05Mb 0.0001ms DropTail
  26. $ns duplex-link $n1 $n4 0.05Mb 0.0001ms DropTail
  27. $ns duplex-link $n2 $n5 0.05Mb 0.0001ms DropTail
  28. $ns duplex-link $n3 $n5 0.05Mb 0.0001ms DropTail
  29.  
  30. #Routers
  31. $ns duplex-link $n4 $n5 0.06Mb 10ms DropTail
  32.  
  33. #Orientaçoes
  34. $ns duplex-link-op $n0 $n4 orient right-down
  35. $ns duplex-link-op $n1 $n4 orient right-up
  36. $ns duplex-link-op $n2 $n5 orient left-down
  37. $ns duplex-link-op $n3 $n5 orient left-up
  38.  
  39. $ns duplex-link-op $n4 $n5 orient right
  40.  
  41. $ns duplex-link-op $n4 $n5 queuePos 0.5
  42.  
  43. #Novo agente UDP
  44. set udp0 [new Agent/UDP]
  45. $ns attach-agent $n0 $udp0
  46.  
  47. #Novo CBR
  48. set cbr0 [new Application/Traffic/CBR]
  49. $cbr0 set packetSize_ 20
  50. $cbr0 set interval_ 0.005s
  51. $cbr0 attach-agent $udp0
  52.  
  53. #Novo agenteUDP
  54. set udp1 [new Agent/UDP]
  55. $ns attach-agent $n1 $udp1
  56.  
  57. #Novo CBR
  58. set cbr1 [new Application/Traffic/CBR]
  59. $cbr1 set packetSize_ 20
  60. $cbr1 set interval_ 0.005s
  61. $cbr1 attach-agent $udp1
  62.  
  63. #Novo agente UDP
  64. set udp2 [new Agent/UDP]
  65. $ns attach-agent $n2 $udp2
  66.  
  67. #Novo CBR
  68. set cbr2 [new Application/Traffic/CBR]
  69. $cbr2 set packetSize_ 20
  70. $cbr2 set interval_ 0.005s
  71. $cbr2 attach-agent $udp2
  72.  
  73. #Novo agenteUDP
  74. set udp3 [new Agent/UDP]
  75. $ns attach-agent $n3 $udp3
  76.  
  77. #Novo CBR
  78. set cbr3 [new Application/Traffic/CBR]
  79. $cbr3 set packetSize_ 20
  80. $cbr3 set interval_ 0.005s
  81. $cbr3 attach-agent $udp3
  82.  
  83. #Novo Null
  84. set null0 [new Agent/Null]
  85. $ns attach-agent $n0 $null0
  86. #Novo Null
  87. set null1 [new Agent/Null]
  88. $ns attach-agent $n1 $null1
  89. #Novo Null
  90. set null2 [new Agent/Null]
  91. $ns attach-agent $n2 $null2
  92. #Novo Null
  93. set null3 [new Agent/Null]
  94. $ns attach-agent $n3 $null3
  95.  
  96. $ns connect $udp0 $null2
  97. $ns connect $udp2 $null1
  98. $ns connect $udp1 $null3
  99. $ns connect $udp3 $null0
  100.  
  101. $udp0 set class_ 1
  102. $udp1 set class_ 2
  103. $udp2 set class_ 3
  104. $udp3 set class_ 4
  105.  
  106. $ns color 1 red
  107. $ns color 2 blue
  108. $ns color 3 green
  109. $ns color 4 yellow
  110.  
  111. $ns at 0.5 "$cbr0 start"
  112. $ns at 0.5 "$cbr1 start"
  113. $ns at 0.5 "$cbr2 start"
  114. $ns at 0.5 "$cbr3 start"
  115. $ns at 4.5 "$cbr0 stop"
  116. $ns at 4.5 "$cbr1 stop"
  117. $ns at 4.5 "$cbr2 stop"
  118. $ns at 4.5 "$cbr3 stop"
  119.  
  120.  
  121. $ns at 5.0 "fim"
  122.  
  123. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement