Network Simulator (Ns-2) Workshop Mannual: SAT Infosys
Network Simulator (Ns-2) Workshop Mannual: SAT Infosys
com
9944219934
R.Thirukkumaran S.Anjali
SAT Infosys
Coimbatore
9944219934
NS-2
INSTALLATION
package to /usr/local
folder folder
To install type the command ./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, LD_LIBRARY_PATH, TCL_LIBRARY environment variables and paste in /etc/profile file.
Example: Set the Environment variable export PATH=$PATH:/usr/local/ns-allinone2.34/tcl8.4.15/unix:/usr/local/ns-allinone2.34/tk8.4.15/unix:/usr/local/ns-allinone-2.34/bin export LD_LIBRARY_PATH=/usr/local/ns-allinone2.34/lib: /usr/local/ns-allinone-2.34/otcl-1.13 export TCL_LIBRARY=/usr/local /ns-allinone2.34/tcl8.4.15/library
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 - $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.txt w] puts $test "Testing message" close $test --------------------------------------set test1 [open file1.txt r] while { [ eof $test1 ]== 0 } { gets $test1 line puts $line }
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
Set ns_ [new Simulator] set topo [new Topography] $topo load_flatgrid $val(x) $val(y) set tracefd [open wireless.tr w] $ns_ $ns_ set $ns_ trace-all $tracefd use-newtrace namtrace [open wireless.nam w] namtrace-all-wireless $namtrace $val(x)
$val(y)
set god_ [create-god $val(nn)] # define how node should be created - 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).000 "$ns_ halt" $ns_ run 4
9944219934
WIRELESS
LAB
$node_(0) set X_ 50.0 $node_(0) set Y_ 50.0 $node_(0) set Z_ 0.0 $node_(1) set X_ 150.0 $node_(1) set Y_ 50.0 $node_(1) set Z_ 0.0 $node_(2) set X_ 300.0 $node_(2) set Y_ 50.0 $node_(2) set Z_ 0.0
WIRELESS
LAB
#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.1 #Application start time $ns_ at 10.0 "$cbr0 start" #Application Stop time $ns_ at 50.0 "$cbr0 stop"
9944219934
WIRELESS
LAB
#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.0 "$ftp0 start" $ns_ at 90.0 "$ftp0 stop"
WIRELESS
LAB
5 Movement Generation
#Mobile Node Manual Movement $ns_ at 3.0 "$node_(2) setdest $ns_ at 3.0 "$node_(1) setdest #Random Topology 450 100 50" 250 100 50"
setdest
-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
9944219934
WIRELESS
LAB
New Wireless Trace Format s -t 163.001503520 -Hs 0 -Hd -2 -Ni 0 -Nx 300.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl AGT -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 0.0 Id 2.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: nodes x/y/z coordinate -Ne: node energy level -Nl: trace level, such as AGT, RTR, MAC -Nw: reason for the event Field 5: packet info at MAC level -Ma: duration -Md: dests ethernet address -Ms: srcs ethernet address -Mt: ethernet type Field 6: Packet information at IP level -Is: source address. 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, tcp, the type of adhoc routing protocol like DSDV, DSR, AODV etc. The field consists of a leading P and the list of tags for different applications.
9944219934
9944219934
Wireless LAB
- Protocol Comparison
1. By varying number of mobiles nodes By varying the No of nodes in the given topology area Analyse the protocols behavior. Topology Area 500m x 500m, Max Speed 20ms, PauseTime 10s, Simulation Time 200Secs. 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
-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
9944219934
By varying speed of the mobile nodes in the given topology area and for fixed number of mobile nodes Analyse the protocols behavior. Topology Area 500m x 500m, Number of nodes 50, PauseTime 10s, Simulation Time 200Secs. Create Udp Data Source for Node 5 to Node 10.
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
-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