Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. # Some constants
  2. set area_width 100
  3. set area_height 100
  4. set stop_time 20
  5.  
  6. # MAC stuff
  7. Mac/802_11 set dataRate_ 2.0e6
  8. Mac/802_11 set RTSThreshold_ 3000
  9.  
  10. # Define the simulator
  11. set simulator [new Simulator]
  12.  
  13. set trace_file [open out.tr w]
  14.  
  15. $simulator trace-all $trace_file
  16.  
  17. #Open the NAM trace file
  18. set nam_file [open out.nam w]
  19. $simulator namtrace-all $nam_file
  20.  
  21. #Adjusting the topography
  22. set topography [new Topography]
  23. $topography load_flatgrid $area_width $area_height
  24.  
  25. # General Operations Director
  26. create-god 2
  27.  
  28. # Some configuration just as same as the expamle 'ex6sta.tcl'
  29. $simulator node-config -adhocRouting DumbAgent
  30. -llType LL
  31. -macType Mac/802_11
  32. -ifqType Queue/DropTail/PriQueue
  33. -ifqLen 50
  34. -antType Antenna/OmniAntenna
  35. -propType Propagation/FreeSpace
  36. -phyType Phy/WirelessPhy
  37. -channelType Channel/WirelessChannel
  38. -topoInstance $topography
  39. -agentTrace ON
  40. -routerTrace OFF
  41. -macTrace OFF
  42. -movementTrace OFF
  43.  
  44. set host(1) [ $simulator node ]
  45. set host(2) [ $simulator node ]
  46.  
  47. $host(1) set X_ 20
  48. $host(1) set Y_ 20
  49. $host(1) set Z_ 0.0
  50.  
  51. $host(2) set X_ 70
  52. $host(2) set Y_ 70
  53. $host(2) set Z_ 0.0
  54.  
  55. # Connection 1 UDP
  56. set udp [new Agent/UDP]
  57. $simulator attach-agent $host(1) $udp
  58. set sink [new Agent/Null]
  59. $simulator attach-agent $host(2) $sink
  60. $simulator connect $udp $sink
  61. set cbr [new Application/Traffic/CBR]
  62. $cbr set packetSize_ 1000
  63. $cbr set interval_ 0.005
  64. $cbr attach-agent $udp
  65. $simulator at 5.0 "$cbr start"
  66.  
  67. # invoking finish procedure
  68. $simulator at $stop_time "finish"
  69.  
  70. proc finish {} {
  71. global simulator host cbr nam_file trace_file
  72. $host(1) reset
  73. $host(2) reset
  74. $cbr stop
  75. $simulator flush-trace
  76. close $nam_file
  77. close $trace_file
  78. $simulator halt
  79. puts "Finished"
  80. }
  81.  
  82. puts "Starting Simulation..."
  83. $simulator run
  84.  
  85. # Some constants
  86. set area_width 100
  87. set area_height 100
  88. set stop_time 20
  89.  
  90. # MAC stuff
  91. Mac/802_11 set dataRate_ 2.0e6
  92. Mac/802_11 set RTSThreshold_ 3000
  93.  
  94. # Define the simulator
  95. set simulator [new Simulator]
  96.  
  97. set trace_file [open out.tr w]
  98.  
  99. $simulator trace-all $trace_file
  100.  
  101. #Open the NAM trace file
  102. set nam_file [open out.nam w]
  103.  
  104. $simulator namtrace-all-wireless $nam_file $area_width $area_height
  105.  
  106.  
  107. #Adjusting the topography
  108. set topography [new Topography]
  109. $topography load_flatgrid $area_width $area_height
  110.  
  111. # General Operations Director
  112. create-god 2
  113.  
  114. # Some configuration just as same as the expamle 'ex6sta.tcl'
  115. $simulator node-config -adhocRouting DumbAgent
  116. -llType LL
  117. -macType Mac/802_11
  118. -ifqType Queue/DropTail/PriQueue
  119. -ifqLen 50
  120. -antType Antenna/OmniAntenna
  121. -propType Propagation/FreeSpace
  122. -phyType Phy/WirelessPhy
  123. -channelType Channel/WirelessChannel
  124. -topoInstance $topography
  125. -agentTrace ON
  126. -routerTrace ON
  127. -macTrace ON
  128. -movementTrace ON
  129.  
  130. set host(1) [ $simulator node ]
  131. set host(2) [ $simulator node ]
  132.  
  133. $host(1) set X_ 20
  134. $host(1) set Y_ 20
  135. $host(1) set Z_ 0.0
  136.  
  137. $host(2) set X_ 70
  138. $host(2) set Y_ 70
  139. $host(2) set Z_ 0.0
  140. $simulator initial_node_pos $host(1) 30
  141. $simulator initial_node_pos $host(2) 30
  142. # Connection 1 UDP
  143. set udp [new Agent/UDP]
  144. $simulator attach-agent $host(1) $udp
  145. set sink [new Agent/Null]
  146. $simulator attach-agent $host(2) $sink
  147. $simulator connect $udp $sink
  148. set cbr [new Application/Traffic/CBR]
  149. $cbr set packetSize_ 1000
  150. $cbr set interval_ 0.005
  151. $cbr attach-agent $udp
  152. $simulator at 5.0 "$cbr start"
  153.  
  154. # invoking finish procedure
  155. $simulator at $stop_time "finish"
  156.  
  157. proc finish {} {
  158. global simulator host cbr nam_file trace_file
  159. $host(1) reset
  160. $host(2) reset
  161. $cbr stop
  162. $simulator flush-trace
  163. close $nam_file
  164. close $trace_file
  165. $simulator halt
  166. puts "Finished"
  167. }
  168.  
  169. puts "Starting Simulation..."
  170. $simulator run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement