[email protected] SAT Infosys - Coimbatore 9944219934 NETWORK SIMULATOR (NS-2) Workshop Mannual R.Thirukkumaran S.Anjali SAT Infosys Coimbatore 1 LD_LIBRARY_PATH.34.34/otcl-1.4.15/unix:/usr/local/ns-allinone-2.34/tk8.Coimbatore 9944219934 NS-2 INSTALLATION package to /usr/local Copy ns-allinone-2.34 To install type the command .13 export TCL_LIBRARY=/usr/local /ns-allinone2.15/library 2 .com SAT Infosys .4.tar.34/bin export LD_LIBRARY_PATH=/usr/local/ns-allinone2.34 cd /usr/local/ns-allinone-2.4. TCL_LIBRARY environment variables and paste in /etc/profile file. Example: Set the Environment variable export PATH=$PATH:/usr/local/ns-allinone2.gz folder Right click & do extract here It will create
[email protected]/tcl8.34/lib: /usr/local/ns-allinone-2.34 folder folder Open the terminal and Go to ns-allinone-2.34/tcl8.15/unix:/usr/local/ns-allinone2.anjali./install Open another terminal : Set the Environment variable open the /etc/profile file gedit /etc/profile Enter these variable in End of file export PATH=$PATH: export LD_LIBRARY_PATH= export TCL_LIBRARY= From this output itself we have to copy the value of PATH. txt w] puts $test "Testing message" close $test --------------------------------------set test1 [open file1.Coimbatore 9944219934 TCL COMMANDS set a 10 set b 15 puts $a puts "the value of a = $a" puts "the value of b = $b" ---------------------------------------set c [expr $a + $b] puts "the value of c = $c" set d [expr [expr $b
[email protected] r] while { [ eof $test1 ]== 0 } { gets $test1 line puts $line } 3 .anjali.$a] * $c] puts "the value of d = $d" ----------------------------------------proc display {} { puts "this is the testing message" } display ----------------------------------------proc add {x y} { set z [expr $x + $y] puts "the value of $x + $y = $z" } add 10 20 ----------------------------------------proc print { k } { for {set i 0} {$i < $k} {incr i} { puts "node_($i)" puts "n$i" } } print 10 ----------------------------------------set test [open file1.com SAT Infosys . tr w] $ns_ $ns_ set $ns_ trace-all $tracefd use-newtrace namtrace [open wireless.global node setting $ns_ node-config -adhocRouting $val(routing) \ -llType LL \ -macType Mac/802_11 \ -ifqType $qtype \ -ifqLen 50 \ -antType Antenna/OmniAntenna \ -propType Propagation/TwoRayGround \ -phyType Phy/WirelessPhy \ -channelType Channel/WirelessChannel \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF # Create the specified number of nodes for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] } #Define node position for {set i 0} {$i < $val(nn)} {incr i} { $ns_ initial_node_pos $node_($i) 30 } $ns_ at $val(stop).nam w] namtrace-all-wireless $namtrace $val(x) $val(y) set god_ [create-god $val(nn)] # define how node should be created .000 "$ns_ halt" $ns_ run 4
[email protected] 9944219934 WIRELESS set set set set set set #set val(x) val(y) val(nn) val(stop) val(routing) qtype qtype LAB 500 500 3 200 - 1 NODE CREATION AODV Queue/DropTail/PriQueue CMUPriQueue Set ns_ [new Simulator] set topo [new Topography] $topo load_flatgrid $val(x) $val(y) set tracefd [open wireless.com SAT Infosys . 0 $node_(0) set Y_ 50.0 $node_(1) set Z_ 0.0 $node_(2) set Y_ 50.0 $node_(1) set X_ 150.0 "$cbr0 stop" 5 .Coimbatore 9944219934 WIRELESS LAB - 2 Mobile Node Position #Static (Fixed) Topology $node_(0) set X_ 50.com SAT Infosys .0 $node_(2) set X_ 300.1 #Application start time $ns_ at 10.0 WIRELESS LAB - 3 UDP DATA TRAFFIC #create UDP Source set udp0 [new Agent/UDP] $ns_ attach-agent $node_(0) $udp0 #create UDP Destination set null0 [new Agent/Null] $ns_ attach-agent $node_(1) $null0 #connecting UDP Source & Destination $ns_ connect $udp0 $null0 #create application traffic set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 $cbr0 set packetSize_ 512 $cbr0 set rate_ 100Kb #$cbr0 set interval_ 0.anjali.0 $node_(0) set Z_ 0.0 "$cbr0 start" #Application Stop time $ns_ at 50.0 $node_(2) set Z_
[email protected] $node_(1) set Y_ 50.
[email protected] "$node_(1) setdest #Random Topology 450 100 50" 250 100 50" #To apply random movement we need command #Syntax setdest setdest –n Nunmber of node –p pause time -M Max_Speed total_simulation_time –x x-axis-value –y y-axis-value -t #Example setdest -n 20 -p 10 -M 20 -t 100 -x 500 -y 500 >scen-20-20 setdest -n 30 -p 10 -M 20 -t 100 -x 500 -y 500 >scen-30-20 setdest -n 40 -p 10 -M 20 -t 100 -x 500 -y 500 >scen-40-20 6 .0 "$ftp0 stop" WIRELESS LAB - 5 Movement Generation #Mobile Node Manual Movement $ns_ at 3.0 "$ftp0 start" $ns_ at 90.Coimbatore 9944219934 WIRELESS LAB - 4 TCP DATA TRAFFIC #create TCP Source set tcp0 [new Agent/TCP] $ns_ attach-agent $node_(1) $tcp0 #create TCP Destination set sink0 [new Agent/TCPSink] $ns_ attach-agent $node_(2) $sink0 $ns_ connect $tcp0 $sink0 #create application traffic set ftp0 [new Application/FTP] $ftp0 attach-agent $tcp0 #Application start & stop time $ns_ at 60.com SAT Infosys .0 "$node_(2) setdest $ns_ at 3.anjali. 7 . Source port number -Id: dest address.dest port number -It: packet type -Il: packet size -If: flow id -Ii: unique id -Iv: ttl value Field 7: Packet info at “Application level” which consists of the type of application like arp. AODV etc.anjali. the type of adhoc routing protocol like DSDV.00 -Nz 0.Coimbatore 9944219934 WIRELESS LAB - 6 Trace File Analysis New Wireless Trace Format s -t 163. MAC -Nw: reason for the event Field 5: packet info at MAC level -Ma: duration -Md: dest’s ethernet address -Ms: src’s ethernet address -Mt: ethernet type Field 6: Packet information at IP level -Is: source address.satinfo@gmail. such as AGT.0 –Id 2. The field consists of a leading –P and the list of tags for different applications. RTR.0 -It cbr -Il 200 -If 1 -Ii 77 -Iv 32 -Pn cbr -Pi 32 -Pf 0 -Po 0 Field 0: event type s: send r: receive d: drop f: forward Filed 1: General tag -t: time Field 3: Next hop info -Hs: id for this node -Hd: id for next hop towards the destination Field 4: Node property type tag -Ni: node id -Nx –Ny -Nz: node’s x/y/z coordinate -Ne: node energy level -Nl: trace level. tcp.000000 -Nl AGT -Nw --.001503520 -Hs 0 -Hd -2 -Ni 0 -Nx 300.00 -Ny 500.com SAT Infosys . DSR.00 -Ne -1.-Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0. Coimbatore 9944219934 #gawk –f wireless.6 \ -initialEnergy 10 \ 8 .com RUN AWK SCRIPT SAT Infosys
[email protected] Energy Model $ns_ node-config -adhocRouting $val(routing) \ -llType LL \ -macType Mac/802_11 \ -ifqType Queue/DropTail/PriQueue \ -ifqLen 100 \ -antType Antenna/OmniAntenna \ -propType Propagation/TwoRayGround \ -phyType Phy/WirelessPhy \ -channelType Channel/WirelessChannel \ -energyModel EnergyModel \ -rxPower 0.awk wireless.anjali.3 \ -txPower 0.tr Xgraph xgraph –x “no of Nodes” –y “PDR” –t “Title” –geometry “600x600” –lw 2 aodv_pdr dsdv_pdr Wireless LAB . Protocol Comparison Performance Comparison of Aodhoc Routing Protocol(AODV. Topology Area – 500m x 500m.DSDV. By varying speed of the mobiles nodes 9 . PauseTime – 10s.Coimbatore 9944219934 Wireless LAB - 8 . By varying number of mobiles nodes By varying the No of nodes in the given topology area Analyse the protocols behavior. Simulation Time
[email protected]) 1.com SAT Infosys . Create Udp Data Source for Node 5 to Node 10. AODV No of Nodes 20 30 40 50 Packet Delivery Ratio(PDR) End-to-End Delay OverHead DSDV No of Nodes 20 30 40 50 Packet Delivery Ratio(PDR) End-to-End Delay OverHead DSR No of Nodes 20 30 40 50 Packet Delivery Ratio(PDR) End-to-End Delay OverHead #Creating scenario for various no of mobile nodes setdest setdest setdest setdest -n 20 -p 10 -M 20 -t 200 -x 500 -y 500 >scen-20-20 -n 30 -p 10 -M 20 -t 200 -x 500 -y 500 >scen-30-20 -n 40 -p 10 -M 20 -t 200 -x 500 -y 500 >scen-40-20 -n 50 -p 10 -M 20 -t 200 -x 500 -y 500 >scen-50-20 2. Max Speed – 20ms. PauseTime – 10s. AODV Speed(m/s) 5 10 15 20 Packet Delivery Ratio(PDR) End-to-End Delay OverHead DSDV Speed(m/s) 5 10 15 20 Packet Delivery Ratio(PDR) End-to-End Delay OverHead DSR Speed(m/s) 5 10 15 20 Packet Delivery Ratio(PDR) End-to-End Delay OverHead #Creating scenario for various Mobile speed – No of nodes as 50 setdest setdest setdest setdest -n 50 -p 10 -M 5 -t 200 -x 500 -y 500 >scen-50-5 -n 50 -p 10 -M 10 -t 200 -x 500 -y 500 >scen-50-10 -n 50 -p 10 -M 15 -t 200 -x 500 -y 500 >scen-50-15 -n 50 -p 10 -M 20 -t 200 -x 500 -y 500 >scen-50-20 10 .anjali. Number of nodes – 50. Topology Area – 500m x 500m. Create Udp Data Source for Node 5 to Node
[email protected] 9944219934 By varying speed of the mobile nodes in the given topology area and for fixed number of mobile nodes Analyse the protocols behavior.com SAT Infosys . Simulation Time 200Secs.