Ex. 1 Installation Instructions For Network Simulator 2 (Ns-Allinone2.33)
Ex. 1 Installation Instructions For Network Simulator 2 (Ns-Allinone2.33)
gz) Operating System Fedora Core 9 or 10 This handout enables the participants to install network simulator 2 and tracegraph successfully in Linux Operating systems. Also the users can run the basic programs given in this handout and see the network animator and trace the results.
Here are the installation places: tcl8.4.14: /home/pradeep/ns-allinone-2.33/{bin,include,lib} tk8.4.14: /home/pradeep/ns-allinone-2.33/{bin,include,lib} otcl: /home/pradeep/ns-allinone-2.33/otcl-1.13 tclcl: /home/pradeep/ns-allinone-2.33/tclcl-1.19 ns: /home/pradeep/ns-allinone-2.33/ns-2.33/ns nam: /home/pradeep/ns-allinone-2.33/nam-1.13/nam xgraph: /home/pradeep/ns-allinone-2.33/xgraph-12.1 gt-itm: /home/pradeep/ns-allinone-2.33/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns Please put /home/pradeep/ns-allinone-2.33/bin:/home/pradeep/nsallinone-2.33/tcl8.4.14/unix:/home/pradeep/ns-allinone-2.33/tk8.4.14/unix into your PATH environment; so that youll be able to run itm/tclsh/wish/xgraph. IMPORTANT NOTICES: (1) You MUST put /home/pradeep/ns-allinone-2.33/otcl-1.13, /home/pradeep/ns-allinone-2.33/lib, into your LD_LIBRARY_PATH environment variable. If it complains about X libraries, add path to your X libraries into LD_LIBRARY_PATH. If you are using csh, you can set it like: setenv LD_LIBRARY_PATH If you are using sh, you can set it like: export LD_LIBRARY_PATH= (2) You MUST put /home/pradeep/ns-allinone-2.33/tcl8.4.14/library into your TCL_LIBRARY environmental variable. Otherwise ns/nam will complain during startup. After these steps, you can now run the ns validation suite with cd ns-2.33; ./validate For trouble shooting, please first read ns problems page http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive for related posts.
set n0 [$ns node] s set n1 [$ns node] # connection between the two nodes with bandwidth of 1 Megabits, delay of 10ms and a DropTail queue $ $ns duplex-link $n0 $n1 1Mb 10ms DropTail #Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $ $ns attach-agent $n0 $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $ $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ $ns attach-agent $n1 $null0 $ $ns connect $udp0 $null0 $ns at 0.5 "$cbr0 start" $ $ns at 4.5 "$cbr0 stop" #after 5 simulation time execute the finish procedure $ $ns at 5.0 "finish" #Starts the simulation $ns run The above example is a wired network example
# Initialize Global Variables set ns_ [new Simulator] set tracefd [open second.tr w] $ $ns_ trace-all $tracefd set namtrace [open second.nam w] $ $ns_ namtrace-all-wireless $namtrace $val(x) $val(y) # set up topography object s set topo [new Topography] $ $topo load_flatgrid $val(x) $val(y) # Create God c create-god $val(nn) # Create channel #1 and #2 set chan_1_ [new $val(chan)] s set chan_2_ [new $val(chan)] # Create node(0) "attached" to channel #1 # configure node, please note the change below. $ns_ node-config -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace ON \ -movementTrace ON \ -channel $chan_1_ s set node_(0) [$ns_ node] # node_(1) can also be created with the same configuration, or with a different # channel specified. # Uncomment below two lines will create node_(1) with a different channel. # $ns_ node-config \ # -channel $chan_2_ set node_(1) [$ns_ node] s set node_(2) [$ns_ node]
$node_(0) random-motion 0 $node_(1) random-motion 0 $ $node_(2) random-motion 0 for {set i 0} {$i < $val(nn)} {incr i} { $ns_ initial_node_pos $node_($i) 100 } # # Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes # $node_(0) set X_ 5.0 $node_(0) set Y_ 2.0 $ $node_(0) set Z_ 0.0 $node_(1) set X_ 8.0 $node_(1) set Y_ 5.0 $ $node_(1) set Z_ 0.0 $node_(2) set X_ 11.0 $node_(2) set Y_ 8.0 $ $node_(2) set Z_ 0.0 # # Now produce some simple node movements # Node_(1) starts to move towards node_(0) # $ns_ at 3.0 "$node_(2) setdest 150.0 140.0 25.0" $ns_ at 3.0 "$node_(1) setdest 50.0 40.0 25.0" $ $ns_ at 3.0 "$node_(0) setdest 48.0 38.0 5.0" # Node_(1) then starts to move away from node_(0) $ns_ at 10.0 "$node_(1) setdest 490.0 480.0 30.0" $ns_ at 20.0 "$node_(2) setdest 170.0 130.0 130.0" # Setup traffic flow between nodes # TCP connections between node_(0) and node_(1) set tcp [new Agent/TCP] $tcp set class_ 2 s set sink [new Agent/TCPSink] $ns_ attach-agent $node_(0) $tcp $ns_ attach-agent $node_(1) $sink $ $ns_ attach-agent $node_(2) $tcp $ns_ connect $tcp $sink set ftp [new Application/FTP] $ftp attach-agent $tcp $ns_ at 3.0 "$ftp start"
# # Tell nodes when the simulation ends # for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at 30.0 "$node_($i) reset"; } $ns_ at 30.0 "stop" $ns_ at 30.01 "puts \"NS EXITING...\" ; $ns_ halt" proc stop {} { global ns_ tracefd $ns_ flush-trace exec nam second.nam & close $tracefd } puts "Starting Simulation..." $ns_ run
the sequence number of the packet the packet type cbr -- CBR data stream packet DSR -- DSR routing packet (control packet generated by routing) RTS -- RTS packet generated by MAC 802.11 ARP -- link layer ARP packet SIZE: the size of packet at current layer, when packet goes down, size increases, goes up size decreases [a b c d]: a -- the packet duration in mac layer header b -- the mac address of destination c -- the mac address of source d -- the mac type of the packet body flags: [......]: [ source node ip : port_number destination node ip (-1 means broadcast) : port_number ip header ttl ip of next hop (0 means node 0 or broadcast) ]
as Application 0 (port number) on node 98 sent a CBR packet whose ID is 1812 and size is 32 bytes, at time 76.0 second, to application 0 on node 0 with TTL is 32 hops. The next hop is not decided yet. And we can also interpret the below trace
r 0.010176954 _9_ RTR -1:255 32 0] --- 1 gpsr 29 [0 ffffffff 8 800] ------- [8:255
in the same way, as The routing agent on node 9 received a GPSR broadcast (mac address 0xff, and ip address is -1, either of them means broadcast) routing packet whose ID is 1 and size is 19 bytes, at time 0.010176954 second, from node 8 (both mac and ip addresses are 8), port 255 (routing agent).