• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Use of NS-2 to simulate MANET routing algorithms
 

Use of NS-2 to simulate MANET routing algorithms

on

  • 4,836 views

 

Statistics

Views

Total Views
4,836
Views on SlideShare
4,825
Embed Views
11

Actions

Likes
1
Downloads
338
Comments
1

2 Embeds 11

http://www.linkedin.com 8
https://www.linkedin.com 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Hello, this is a really nice presentation. I wanted to ask something, which version of ns are you using? Because I'm trying to find the files you mention 'util/scenariogen', etc. and I can't.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Use of NS-2 to simulate MANET routing algorithms Use of NS-2 to simulate MANET routing algorithms Presentation Transcript

    • Università degli Studi di Catania Corso di Laurea Magistrale in Ingegneria InformaticaUse of NS-2 to simulate MANET routing algorithms Architectures and tecnologies for telecommunications systems Prof. Eng. Giacomo Morabito Giancarlo Romeo O55 000031
    • Ad hoc networks “A mobile ad hoc network, is a self-configuring infrastructureless network of mobile devices connected by wireless links”. Route Discovery Forward Route Error Broken Link Source node Destination node Mobile Ad hoc NETworkThere is no static infrastructure such as base station. If two hosts are notwithin radio range, all message communication between them must pass through one or more intermediate hosts that double as routers.
    • Ad hoc routing protocols TargetsMinimize number of exchanged messages to St eveSimplify processing and routing operationsKeeping updated the network scenarioPrevent loops inside the network
    • Ad hoc routing protocols: pro-active vs. reactive Pro-active (table-driven) Maintains fresh lists of destinations and their routes by periodically distributing routing tables throughout the network. The main disadvantages of such algorithms are: 1. Respective amount of data for maintenance. 2. Slow reaction on restructuring and failures. Reactive (on-demand)Finds a route on demand by flooding the network with Route Request packets. The main disadvantagesof such algorithms are:1. High latency time in route finding.2. Excessive flooding can lead to network clogging.
    • DSDV (Destination-Sequenced Distance Vector)DSDV is a table-driven routing scheme for ad hoc mobile networksbased on the Bellman-Ford algorithm. AdvantagesGuarantees for loop free paths (sequence numbers).Since each node knows the complete topology, a node can immediately find thebest route to a destination. Disadvantages Requires a regular update of its routing tables, which uses up battery power and a small amount of bandwidth even when the network is idle. (full dumps and smaller incremental updates).
    • AODV (Ad hoc On-Demand Distance Vector)AODV is a reactive routing protocol, meaning that it establishes a routeto a destination only on-demand. AdvantagesGuarantees for loop free paths (sequence numbers).Low bandwidth utilization for path keeping. DisadvantagesThe connection setup delay is higher (route discovery).
    • Network Simulator 2 (ns-2)NS-2 is a discrete event simulator targeted at networking research. Nsprovides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks. Transmission ranges Mobile node Timeline
    • Scenarios Parameters v Area v Free space where mobile nodes move on. v Nodes v Number of mobile nodes in the area. Mobile node v v y Speed Min and max speed of nodes [in m/s]. v v v Simulation time Duration of simulation [in s]. x util/scenariogenA program that creates TCL script for modeling mobile scenario. $ util/scenariogen -v 2 -n $opt(nn) -s 1 -m $opt(minspeed) -M $opt(maxspeed) -t 300 -P 1 -p 2.0 -x $opt(x) -y $opt(y) > scenarios/scenario.tcl
    • Propagation model Two-ray ground reflection model direct ray Power received at distance d Tx Rx ht hr ground reflect ray d threshold.ccA C++ program that calculates the thresholds for transmission receipt using the relation between variousphysical parameters (distance, effect, propagation model etc.) related to transmissions in ns-2. Distance in meters$ ./util/threshold -m TwoRayGround 120 Propagation model
    • CS Threshold and RX ThresholdNS2 mainly uses thresholds to determine whether one frame Physical transmission modelingis received correctly by the receiver. CSThresh_ MAC tags Good frame corrupted frame If signal strenght of the frame is less than CSThresh_, the frame is discarded in PHY module and not will be visible to MAC layer. RXThresh_ RxThresh_ CSThresh_ If signal strenght of the frame is stronger than RXThresh_, the frame is discarded in received correctly. Otherwise, the frame is tagged as corrupted and MAC layer will discard it. PHY module discards frame
    • Traffic Communication model stackParameters Tx RxProtocol Application FTP FTP Type of communication protocol. (e.g. TCP)Nodes Agent TCP TCP Sink Number of mobile nodes.Connections create-connection Number of connections between mobile nodes. MAC / PHY Layer util/trafficgen.tclAn OTCL script that creates traffic between nodes in ns-2.$ util/trafficgen.tcl -nn $opt(nn) -cn $opt(cn) > traffic/traffic.tcl
    • util/trafficgen.tcl Main Procedures/tcp-connectwhile {$ftp_cnt < $opt(cn)} { proc tcp_connect {src dst} { set src [expr int(rand() * $opt(nn))] global ftp_cnt opt; puts "n# Node $src connecting through TCP to Node $dst." while 1 { set dst [expr int(rand() * $opt(nn))] # create TCP Agent and attach it to the source node if {$src != $dst} { puts "set tcp_($ftp_cnt) [new Agent/TCP]" break puts "$ns_ attach-agent $node_($src) $tcp_($ftp_cnt)" } } puts "$tcp_($ftp_cnt) set window_ $opt(winsize)" puts "$tcp_($ftp_cnt) set packetSize_ $opt(pktsize)" Connects source and destination tcp_connect $src $dst} # create TCPSink Agent and attach it to the destination node puts "set sink_($ftp_cnt) [new Agent/TCPSink]" puts "$ns_ attach-agent $node_($dst) $sink_($ftp_cnt)" # create a connection between source and destination Tx Rx puts "$ns_ connect $tcp_($ftp_cnt) $sink_($ftp_cnt)" Application FTP FTP # create an FTP Application and attach it to the source node puts "set ftp_($ftp_cnt) [new Application/FTP]" puts "$ftp_($ftp_cnt) attach-agent $tcp_($ftp_cnt)" puts "set ftp_($ftp_cnt) [$tcp_($ftp_cnt) attach-source FTP]" Agent TCP TCP Sink # starts the FTPs transmission puts "$ns_ at 0 "$ftp_($ftp_cnt) start"" incr ftp_cnt create-connection }
    • sim.tcl Optionsset opt(chan) Channel/WirelessChannel ;# channel typeset opt(prop) Propagation/TwoRayGround ;# radio-propagation model Physical configurationset opt(ant) Antenna/OmniAntenna ;# antenna typeset opt(ll) LL ;# link layer typeset opt(ifq)set opt(ifqlen) Queue/DropTail/PriQueue ;# interface queue typeset opt(netif) 50 ;# max packet in ifqset opt(mac) Phy/WirelessPhy ;# network interface typeset opt(rp) Mac/802_11 ;# MAC typeset opt(nn) DSDV ;# ad-hoc routing protocolset opt(pktsize) 300 ;# number of mobilenodes Proceduresproc finish {} {...}proc getargs {argc argv} {...}proc usage {} {...}
    • sim.tcl Maingetargs $argc $argvset ns_ [new Simulator]set tracef [open traces/$opt(sim)/[string tolower $opt(rp)]/trace_$opt(par).tr w] Open trace file$ns_ trace-all $tracefset topo [new Topography]$topo load_flatgrid $opt(x) $opt(y)set god_ [create-god $opt(nn)]$ns_ node-config -adhocRouting $opt(rp) -llType $opt(ll) Node configuration -macType $opt(mac) -ifqType $opt(ifq) -ifqLen $opt(ifqlen) -antType $opt(ant) -propType $opt(prop) -phyType $opt(netif) -topoInstance $topo -channel [new $opt(chan)]
    • sim.tcl Mainfor {set i 0} {$i < $opt(nn)} {incr i} { set node_($i) [$ns_ node] Initialize nodes $node_($i) random-motion 0 $ns_ initial_node_pos $node_($i) 10}source scenarios/$opt(sim)/scenario_$opt(par).tclsource traffic/sim$sim/traffic.tcl Import scenario and traffic files$ns_ at $opt(duration) "finish"$ns_ run
    • allsim.tclArchitecture allsim.tcl util sim.tcl traces_analizer.awk 3. run-simulations 4. analize-traces scenariogen trafficgen.tcl1. create-scenarios 2. create-traffic Optionsset opt(nn) 100 ;# number of nodesset opt(x) 500 ;# area widthset opt(y) 500 ;# area lengthset opt(cn) 30 ;# number of connectionsset opt(nsim) 5 ;# number of simulationsset opt(rp) {AODV DSDV} ;# routing protocolsset opt(minspeed) {0.1 5.1 10.1 15.1 20.1} ;# minimum speedset opt(maxspeed) {5.0 10.0 15.0 20.0 25.0} ;# maximum speed
    • allsim.tcl Procedures: create-scenariosproc create-scenarios {} { global opt Number of simulations file mkdir scenarios for {set sim 1} {$sim <= $opt(nsim)} {incr sim} { puts "Creating simulation n.$sim" file mkdir scenarios/sim$sim for {set j 0} {$j < 5} {incr j} { puts " Creating scenario (m=[lindex $opt(minspeed) $j] m/s, M=[lindex $opt(maxspeed) $j] m/s)" puts " => Writing "scenarios/sim$sim/scenario_[expr $j+1].tcl"" exec util/scenariogen -v 2 -n $opt(nn) -s 1 -m [lindex $opt(minspeed) $j] -M [lindex $opt(maxspeed) $j] -t 300 -P 1 -p 2.0 -x $opt(x) -y $opt(y) > scenarios/$sim/scenario_[expr $j+1].tcl } } Creates scenarios puts "Scenarios have been successfully created!n" puts "Press any key to continue..." gets stdin -}
    • allsim.tcl Procedures: create-trafficproc create-traffic {} { global opt Number of simulations file mkdir traffic for {set sim 1} {$sim <= $opt(nsim)} {incr sim} { puts "Creating simulation n.$sim" file mkdir traffic/sim$sim puts " Creating traffic (nn=$opt(nn), cn=$opt(cn))" puts " => writing "traffic/sim$sim/traffic.tcl"n" exec ns util/trafficgen.tcl -nn $opt(nn) -cn $opt(cn) > traffic/sim$sim/traffic.tcl Creates traffic } puts "Traffic has been successfully created!" puts "nPress any key to continue..." gets stdin -}
    • allsim.tcl Procedures: run-simulationsproc run-simulations {} { Number of global opt simulations for {set sim 1} {$sim <= $opt(nsim)} {incr sim} { puts "Running simulation n.$sim" foreach rp $opt(rp) { puts " Simulating $rp algorithm" for {set j 0} {$j < 5} {incr j} { puts " Running simulation (speed=[lindex $opt(minspeed) $j]-[lindex $opt(maxspeed) $j])" puts " => writing "traces/sim$sim/$rp/trace_[expr $j+1].tr"" catch {exec ns sim.tcl -nn $opt(nn) -rp $rp -x $opt(x) -y $opt(y) -sim $sim -par [expr $j+1]} } } } Runs simulation on NS2 puts "Simulations have been successfully executed!" puts "nPress any key to continue..." gets stdin -}
    • allsim.tcl Procedures: analize-tracesproc analize-traces {} { global opt puts "Analyzing traces" file mkdir results foreach rp $opt(rp) { puts " Analyzing $rp algorithm" file mkdir results/[string tolower $rp] for {set j 0} {$j < 5} {incr j} { set resultsf [open results/[string tolower $rp]/results_[expr $j+1].txt w] puts " => writing "results/[string tolower $rp]/results_[expr $j+1].txt"" for {set sim 1} {$sim <= $opt(nsim)} {incr sim} { puts $resultsf [exec awk -f util/traces_analizer.awk traces/$sim/[string tolower $rp]/trace_[expr $j+1].tr] } close $resultsf Filters trace files with awk and computes throughput } } puts "Calculating throughput has been successfully executed!" puts "nPress any key to continue..." gets stdin -}
    • allsim.tcl Mainwhile 1 { exec clear >@ stdout Usage puts "Welcome to NS2 Ad-hoc Network Simulator" puts "-- Speed ------------------------------n" puts "Simulation info:" $ tclsh allsim.tcl puts " Nodes: tt $opt(nn)" puts " Grid: tt $opt(x) m x $opt(y) m" puts " Connections: tt $opt(cn)" puts " Algorithms: tt $opt(rp)" puts "nCommand menu:" puts " 1. Create scenarios (varying max speed 5-25 m/s)" puts " 2. Create traffic" puts " 3. Run simulation on NS2" puts " 4. Analize traces" puts "n 0. Exit" puts "nWhat dou you choose?" gets stdin i switch $i { 1 {create-scenarios} Interactive menu 2 {create-traffic} 3 {run-simulations} 4 {analize-traces} 0 {exit 0} Running allsim.tcl script screenshot }}
    • Simulations/SpeedNodes: 100 Speed: {5.0 10.0 15.0 20.0 25.0} m/sConnections: 30Area: 500m x 500mCSThreshold: 120mRXThreshold: 80m AODV DSDV 792K 800Kb 727K 640Kb high link failures 531K Throughput 480Kb 406K 353K 321K 320Kb 208K 160Kb 91K 81K 56K +overhead 0Kb 5 m/s 10 m/s 15 m/s 20 m/s 25 m/s Nodes speed
    • Simulations/Nodes 10 m/sConnections: 30 Nodes: {50 75 100 125 150}Area: 500m x 500mCSThreshold: 120mRXThreshold: 80m AODV DSDV 591K 580K high link failures 600Kb 482K 480Kb 458K 428K Throughput 360Kb 226K 240K 240Kb 193K 146K +overhead 134K 120Kb 0Kb 50 75 100 125 150 Number of nodes
    • Simulations/Nodes 20 m/sConnections: 30 Nodes: {50 75 100 125 150}Area: 500m x 500mCSThreshold: 120mRXThreshold: 80m AODV DSDV 400Kb 364K 363K 362K high link failures 332K 329K 320Kb Throughput 240Kb 160Kb 68K +overhead 80Kb 51K 47K 59K 35K 0Kb 50 75 100 125 150 Number of nodes
    • Simulations/Nodes 10-20 m/sConnections: 30 Nodes: {50 75 100 125 150}Area: 500m x 500mCSThreshold: 120mRXThreshold: 80m AODV 10 m/s DSDV 10 m/s AODV 20 m/s DSDV 20 m/s 591K 580K 600Kb high link failures 482K 480Kb 458K 428K 364K 363K 362K Throughput 360Kb 332K 329K 226K 240K 240Kb 193K 134K 146K 120Kb +overhead 68K 59K 51K 35K 47K 0Kb 50 75 100 125 150 Number of nodes
    • Simulations/RangeNodes: 100 Range: {130 ... 120 100 80 60 40}Connections: 30Area: 500m x 500mCSThreshold: 120mRXThreshold: 80m AODV DSDV 600K high link failures tx range too small 480K Throughput 360K 240K 120K +overhead 0K 130 125 124 123 122 121 120 115 110 100 80 60 40 Range
    • DSDV vs. AODV DSDV AODV Worst throughput: high Better throughput: low bandwidth utilization for link bandwidth utilization for link keeping. keeping.Low latency: the connection setup High latency: the connection setup delay is lower (update table). delay is higher (route discovery).