luthfiazmi

name.tcl

Apr 18th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. set val(chan) Channel/WirelessChannel ;# channel type
  2. set val(prop) Propagation/TwoRayGround ;# radio-propagation model
  3. set val(netif) Phy/WirelessPhy ;# network interface type
  4. set val(mac) Mac/802_11 ;# MAC type
  5. set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
  6. set val(ll) LL ;# link layer type
  7. set val(ant) Antenna/OmniAntenna ;# antenna model
  8. set val(ifqlen) 50 ;# max packet in ifq
  9. set val(nn) 34 ;# number of mobilenodes
  10. set val(rp) AODV ;# routing protocol
  11. set opt(x) 2000
  12. set opt(y) 1054
  13. # ======================================================================
  14. # Main Program
  15. # ======================================================================
  16.  
  17.  
  18. #
  19. # Initialize Global Variables
  20. #
  21. set ns_ [new Simulator]
  22. set tracefd [open luthfi.tr w]
  23. $ns_ trace-all $tracefd
  24.  
  25. set namf [open luthfi.nam w]
  26. $ns_ namtrace-all-wireless $namf $opt(x) $opt(y)
  27. # set up topography object
  28. set topo [new Topography]
  29.  
  30. $topo load_flatgrid $opt(x) $opt(y)
  31.  
  32. #
  33. # Create God
  34. #
  35. create-god $val(nn)
  36.  
  37. #
  38. # Create the specified number of mobilenodes [$val(nn)] and "attach" them
  39. # to the channel.
  40. # Here two nodes are created : node(0) and node(1)
  41.  
  42. # configure node
  43.  
  44. $ns_ node-config -adhocRouting $val(rp) \
  45. -llType $val(ll) \
  46. -macType $val(mac) \
  47. -ifqType $val(ifq) \
  48. -ifqLen $val(ifqlen) \
  49. -antType $val(ant) \
  50. -propType $val(prop) \
  51. -phyType $val(netif) \
  52. -channelType $val(chan) \
  53. -topoInstance $topo \
  54. -agentTrace ON \
  55. -routerTrace ON \
  56. -macTrace OFF \
  57. -movementTrace ON
  58.  
  59. for {set i 0} {$i < $val(nn) } {incr i} {
  60. set node_($i) [$ns_ node]
  61. $node_($i) random-motion 0 ;# disable random motion
  62. $ns_ initial_node_pos $node_($i) 20
  63. }
  64.  
  65.  
  66.  
  67. source mobility.tcl
  68.  
  69. set tcp [new Agent/TCP]
  70. $tcp set class_ 2
  71. set sink [new Agent/TCPSink]
  72. $ns_ attach-agent $node_(0) $tcp
  73. $ns_ attach-agent $node_(22) $sink
  74. $ns_ connect $tcp $sink
  75. set ftp [new Application/FTP]
  76. $ftp attach-agent $tcp
  77. $ns_ at 10.0 "$ftp start"
  78.  
  79. #
  80. # Tell nodes when the simulation ends
  81. #
  82. for {set i 0} {$i < $val(nn) } {incr i} {
  83. $ns_ at 100.0 "$node_($i) reset";
  84. }
  85. $ns_ at 100.0 "stop"
  86. $ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt"
  87. proc stop {} {
  88. global ns_ tracefd
  89. $ns_ flush-trace
  90. close $tracefd
  91. }
  92.  
  93. puts "Starting Simulation..."
  94. $ns_ run
Advertisement
Add Comment
Please, Sign In to add comment