An ad hoc web is a aggregation of radio nomadic nodes dynamically organizing a impermanent web without the usage of any bing web substructure or centralized disposal. A figure of routing protocols like Dynamic Source Routing ( DSR ) , Ad Hoc On-Demand Distance Vector Routing ( AODV ) , Destination-Sequenced Distance-Vector ( DSDV ) and Temporally Ordered Routing Algorithm ( TORA ) have been implemented. In this undertaking an effort has been made to compare the public presentation of two outstanding on-demand reactive routing protocols for nomadic ad hoc webs: DSR and AODV, along with the traditional proactive DSDV protocol. A simulation theoretical account with MAC and physical bed theoretical accounts is used to analyze interlayer interactions and their public presentation deductions. The On-demand protocols, AODV and DSR perform better than the table-driven DSDV protocol. Although DSR and AODV portion similar on-demand behaviour, the differences in the protocol mechanics can take to important public presentation derived functions. The public presentation derived functions are analyzed utilizing changing web burden, mobility, and web size.


Wireless networking is an emerging engineering that allows users to entree information and services electronically, irrespective of their geographic place. Wireless webs can be classified in two types: –

Wireless webs

Infrastructured webs.

Infrastructured web consists of a web with fixed and wired gateways. A nomadic host communicates with a span in the web ( called base station ) within its communicating radius. The nomadic unit can travel geographically while it is pass oning. When it goes out of scope of one base station, it connects with new base station and starts pass oning through it. This is called handoff. In this attack the base Stationss are fixed.

Infrastructureless ( Ad hoc ) webs.

In ad hoc webs all nodes are nomadic and can be connected dynamically in an arbitrary mode. All nodes of these webs behave as routers and take portion in find and care of paths to other nodes in the web. Ad hoc webs are really utile in exigency search-and-rescue operations, meetings or conventions in which individuals wish to rapidly portion information, and informations acquisition operations in inhospitable terrain.

These ad-hoc routing protocols can be divided into two classs:

Table-driven routing protocols.

In table goaded routing protocols, consistent and up-to-date routing information to all nodes is maintained at each node.

On-Demand routing protocols.

In On-Demand routing protocols, the paths are created as and when required. When a beginning wants to direct to a finish, it invokes the path find mechanisms to happen the way to the finish.

In recent old ages, a assortment of new routing protocols targeted specifically at this environment have been developed. There are four multi-hop radio ad hoc web routing protocols that cover a scope of design picks:

Destination-Sequenced Distance-Vector ( DSDV )

Temporally Ordered Routing Algorithm ( TORA )

Dynamic Source Routing ( DSR )

Ad Hoc On-Demand Distance Vector Routing ( AODV ) .

While DSDV is a table-driven routing protocol, TORA, DSR, AODV, autumn under the On-demand routing protocols class.


This study are based on the TCP Performance in IEEE 802.11 based Ad Hoc Networks with Multiple Wireless Lossy Links. On the hereafter work, to include more accurate analysis of assorted routing protocols including DSR and AODV in TCP theoretical account [ 1 ] . They believe that it is worthwhile to analyze the path failure presentment clip and route re-establishment clip for assorted routing protocols. The clip taken to retrieve a path between the beginning and the finish is a random variable that is dependent on the mobility, traffic form and web topology, etc.

Main Objective

To compare the public presentation of on-demand reactive routing protocols for nomadic ad hoc webs along with the traditional other proactive protocol. A simulation theoretical account with MAC and physical bed theoretical accounts is used to analyze interlayer interactions and their public presentation deductions


Make usage routing protocols for nomadic ad hoc webs: DSDV, DSR, AODV and TORA with MAC and physical bed theoretical accounts and to analyze interlayer interactions and their public presentation deductions.


Description of the Ad-hoc Routing Protocols

Destination-Sequenced Distance-Vector ( DSDV )

Algorithm is based on the thought of the classical Bellman-Ford Routing Algorithm with certain betterments.

Every nomadic station maintains a routing tabular array that lists all available finishs, the figure of hops to make the finish and the sequence figure assigned by the finish node. The sequence figure is used to separate stale paths from new 1s and therefore avoid the formation of cringles. The Stationss sporadically transmit their routing tabular arraies to their immediate neighbours. A station besides transmits its routing tabular array if a important alteration has occurred in its tabular array from the last update sent. So, the update is both time-driven and event-driven.

The routing table updates can be sent in two ways: – a “ full shit ” or an incremental update. A full shit sends the full routing tabular array to the neighbours and could cross many packages whereas in an incremental update merely those entries from the routing tabular array are sent that has a metric alteration since the last update and it must suit in a package. If there is infinite in the incremental update package so those entries may be included whose sequence figure has changed. When the web is comparatively stable, incremental updates are sent to avoid excess traffic and full shit are comparatively infrequent. In a fast-changing web, incremental packages can turn large so full mopess will be more frequent.

Temporally Ordered Routing Algorithm ( TORA )

TORA is a distributed routing protocol based on a “ nexus reversal ” algorithm. It is designed to detect paths on demand, provide multiple paths to a finish, set up paths rapidly, and minimise communicating operating expense by placing algorithmic reaction to topological alterations when possible. Route optimality ( shortest-path routing ) is considered of secondary importance, and longer paths are frequently used to avoid the operating expense of detecting newer paths.

The actions taken by TORA can be described in footings of H2O fluxing downhill towards a finish node through a web of tubings that theoretical accounts the routing province of the existent web. The tubes represent links between nodes in the web, the junctions of tubes represent the nodes, and the H2O in the tubes represents the packages fluxing towards the finish. Each node has a tallness with regard to the finish that is computed by the routing protocol. If a tubing between nodes A and B becomes blocked such that H2O can no longer flux through it, the tallness of A is set to a tallness greater than that of any of its staying neighbours, such that H2O will now flux back out of A ( and towards the other nodes that had been routing packages to the finish via A ) .

When a node discovers that a path to a finish is no longer valid, it adjusts its tallness so that it is a local upper limit with regard to its neighbours and transmits an Update package. If the node has no neighbours of finite tallness with regard to this finish, so the node alternatively attempts to detect a new path as described above. When a node detects a web divider, it generates a Clear package that resets routing province and removes invalid paths from the web.

Dynamic Source Routing ( DSR )

The cardinal distinguishing characteristic of DSR is the usage of beginning routing. That is, the transmitter knows the complete hop-by-hop path to the finish. These paths are stored in a path cache. The informations packages carry the beginning path in the package heading. When a node in the ad hoc web efforts to direct a information package to a finish for which it does non already cognize the path, it uses a path find procedure to dynamically find such a path. Route find plants by deluging the web with path petition ( RREQ ) packages. Each node having an RREQ rebroadcasts it, unless it is the finish or it has a path to the finish in its path cache. Such a node answers to the RREQ with a path answer ( RREP ) package that is routed back to the original beginning. RREQ and RREP packages are besides beginning routed. The RREQ builds up the way traversed across the web. The RREP routes itself back to the beginning by tracking this way backward. The path carried back by the RREP package is cached at the beginning for future usage.

If any nexus on a beginning path is broken, the beginning node is notified utilizing a path mistake ( RERR ) package. The beginning removes any path utilizing this nexus from its cache. A new path find procedure must be initiated by the beginning if this path is still needed. DSR makes really aggressive usage of beginning routing and path caching. No particular mechanism to observe routing cringles is needed. Besides, any forwarding node caches the beginning path in a package it forwards for possible hereafter usage.

Ad Hoc On-Demand Distance Vector Routing ( AODV )

AODV portions DSR ‘s on-demand features in that it besides discovers paths on an as needful footing via a similar path find procedure. However, AODV adopts a really different mechanism to keep routing information. It uses traditional routing tabular arraies, one entry per finish. This is in contrast to DSR, which can keep multiple path cache entries for each finish. Without beginning routing, AODV relies on routing table entries to propagate an RREP back to the beginning and, later, to route informations packages to the finish. AODV uses sequence Numberss maintained at each finish to find freshness of routing information and to forestall routing cringles. All routing packages carry these sequence Numberss.

An of import characteristic of AODV is the care of timer-based provinces in each node, sing use of single routing table entries. A routing table entry is expired if non used late. A set of predecessor nodes is maintained for each routing table entry, bespeaking the set of neighbouring nodes which use that entry to route informations packages. These nodes are notified with RERR packages when the next-hop nexus interruptions. Each predecessor node, in bend, forwards the RERR to its ain set of predecessors, therefore efficaciously wipe outing all paths utilizing the broken nexus. In contrast to DSR, RERR packets in AODV are intended to inform all beginnings utilizing a nexus when a failure occurs. Route mistake extension in AODV can be visualized conceptually as a tree whose root is the node at the point of failure and all beginnings utilizing the failed nexus as the foliages.



A elaborate simulation theoretical account based on NS-2 is used in the rating. In a recent paper the Monarch research group at Carnegie-Mellon University developed support for imitating multihop radio webs complete with physical, informations nexus, and average entree control ( MAC ) bed theoretical accounts on ns-2. The Distributed Coordination Function ( DCF ) of IEEE 802.11 for radio LANs is used as the MAC bed protocol. An unslotted bearer sense multiple entree ( CSMA ) technique with hit turning away ( CSMA/CA ) is used to convey the information packages. The wireless theoretical account uses features similar to a commercial wireless interface, Lucent ‘s WaveLAN. WaveLAN is modeled as a shared-media wireless with a nominal spot rate of 2 Mb/s and a nominal wireless scope of 250 m.

The protocols maintain a send buffer of 64 packages. It contains all informations packages waiting for a path, such as packages for which path find has started, but no answer has arrived yet. To forestall buffering of packages indefinitely, packages are dropped if they wait in the send buffer for more than 30 s. All packages ( both informations and routing ) sent by the routing bed are queued at the interface waiting line until the MAC bed can convey them. The interface waiting line has a maximal size of 50 packages and is maintained as a precedence waiting line with two priori-ties each served in FIFO order. Routing packages get higher precedence than informations packages.

The Traffic and Mobility Models

Continuous spot rate ( CBR ) traffic beginnings are used. The source-destination braces are dispersed indiscriminately over the web. Merely 512-byte informations packages are used. The figure of source-destination braces and the package directing rate in each brace is varied to alter the offered burden in the web.

The mobility theoretical account uses the random waypoint theoretical account in a rectangular field. The field constellations used is: 500 m x 500 thousand field with 50 nodes. Here, each package starts its journey from a random location to a random finish with a randomly chosen velocity ( uniformly distributed between 0-20 m/s ) . Once the finish is reached, another random finish is targeted after a intermission. The intermission clip, which affects the comparative velocities of the Mobiles, is varied. Simulations are run for 100 fake seconds. Identical mobility and traffic scenarios are used across protocols to garner just consequences.

Performance Prosodies

Three of import public presentation prosodies are evaluated:

Package bringing fraction – The ratio of the informations packages delivered to the finishs to those generated by the CBR beginnings.

Average end-to-end hold of informations packages – This includes all possible holds caused by buffering during route find latency, line uping at the interface waiting line, retransmission holds at the MAC, and extension and transportation times.

Normalized routing burden – The figure of routing packages transmitted per informations package delivered at the finish. Each hop-wise transmittal of a routing package is counted as one transmittal.

The first two prosodies are the most of import for best-effort traffic. The routing burden metric evaluates the efficiency of the routing protocol. Note, nevertheless, that these prosodies are non wholly independent. For illustration, lower package bringing fraction means that the hold metric is evaluated with fewer samples. In the conventional wisdom, the longer the way lengths, the higher the chance of a package bead. Therefore, with a lower bringing fraction, samples are normally biased in favour of smaller way lengths and therefore hold less hold.


Installing ns-2

Ns-2 web simulator was installed from the website hypertext transfer protocol: //

Installation of NS-2 could be a spot drawn-out and a time-consuming procedure. It involved downloading and puting up a 250 MB bundle. However, acquiring the simulator to work was the first measure involved in transporting out the simulations. In this undertaking we are utilizing version Ns2.30

Understanding the rudimentss involved in ns-2 simulations

A really good tutorial to understand basic NS-2 simulations is available at the web site:

hypertext transfer protocol: //

CMU ‘s radio extensions to ns-2

CMU ‘s radio extension to ns-2 ( incorporated in the current release ns-2.1b9a ) provides the execution of the DSR, AODV, DSDV, TORA routing protocols.

NAM is the basic visual image tool used for ns-2 simulations. However, it does n’t back up the ad-hoc simulations. Ad-hockey is a Perl/Tk plan that supports the visual image of ad-hoc simulations. Unfortunately, I could n’t acquire the Ad-hockey visualiser tool to work because of its compatibility issues with the new versions of Perl/Tk faculty.

Generating traffic and mobility theoretical accounts

Traffic theoretical accounts

Random traffic connexions of TCP and CBR can be setup between nomadic nodes utilizing a traffic-scenario generator book. This traffic generator book is available under ~ns/indep-utils/cmu-scen-gen and is called cbrgen.tcl. It can be used to make CBR and TCP traffics connexions between radio mobilenodes. So the bid line looks like the followers:

ns cbrgen.tcl [ -type cbr|tcp ] [ -nn nodes ] [ -seed seed ] [ -mc connexions ] [ -rate rate ]

For the simulations carried out, traffic theoretical accounts were generated for 50 nodes with cosmic background radiation traffic beginnings, with maximal connexions of 10,20,30,40 at a rate of 8kbps.

Mobility theoretical accounts

The node-movement generator is available under ~ns/indep-utils/cmu-scen-gen/setdest directory and consists of setdest { .cc, .h } and Makefile. The bid would look like

./setdest [ -n num_of_nodes ] [ -p pausetime ] [ -s maxspeed ] [ -t simtime ] [ -x maxx ] [ -y maxy ] & gt ; [ outdir/movement-file ]

Mobility theoretical accounts were created for the simulations utilizing 50 nodes, with intermission times of 0,10,20,40,100 seconds, maximal velocity of 20m/s, topology boundary of 500×500 and simulation clip of 100secs.

Note: Simulations could be carried out with more complex scenarios utilizing higher traffic rates. However, the simulations take much longer to finish and the hint file generated by each tally ends up to more than 50 Mb of user infinite.

Simulation codification

Writing the Tcl codification to put up the radio simulation constituents: web constituents types, parametric quantities like the type of aerial, the radio-propagation theoretical account, the type of ad-hoc routing protocol, traffic theoretical accounts and node motion theoretical accounts used by nomadic nodes etc. The documented codification is available in the Appendix.

Parsing the Simulation hint files

After each simulation, hint files entering the traffic and node motions are generated. These files need to be parsed in order to pull out the information needed to mensurate the public presentation prosodies. The new hint format was used for parsing.

The new hint format looks like:

s -t 0.267662078 -Hs 0 -Hd -1 -Ni 0 -Nx 5.00 -Ny 2.00 -Nz 0.00 -Ne -1.000000 -Nl RTR -Nw — – -Ma 0 -Md 0 -Ms 0 -Mt 0 -Ii 20 -Is 0.255 -Id -1.255 -It

Here, we see that a package was sent ( s ) at clip ( T ) 0.267662078 sec, from beginning node ( Hs ) 0 to finish node ( Hd ) 1. The beginning node Idaho ( Ni ) is 0, it ‘s x-co-ordinate ( Nx ) is 5.00, it ‘s y-co-ordinate ( Ny ) is 2.00, it ‘s z-co-ordinate ( Nz ) is 0.00, it ‘s energy degree ( Ne ) is 1.000000, the hint degree ( Nl ) is RTR and the node event ( Nw ) is clean. The MAC degree information is given by continuance ( Ma ) 0, finish Ethernet reference ( Md ) 0, the beginning Ethernet reference ( Ms ) is 0 and Ethernet type ( Mt ) is 0.

The IP package degree information like package Idaho ( Ii ) , beginning address.source port figure is given by ( Is ) while the finish address.destination port figure is ( Id ) .

Measuring Packet bringing fraction ( pdf ) :

Calculate the figure of “ sent packages ” that have the hint signifier:

/^s *- Nl AGT. *-Is ( d { 1,3 } ) .d { 1,3 } -Id ( d { 1,3 } ) .d { 1,3 } . *-It cosmic background radiation. *-Ii ( d { 1,6 } ) /

AGT = & gt ; Agent Level Trace

Calculate the figure of “ standard packages ” of the hint signifier:

/^r -t ( d { 1,3 } .d { 9 } ) . *-Nl AGT. *-Is ( d { 1,3 } ) .d { 1,3 } -Id ( d { 1,3 } ) .d { 1,3 } . *-It cosmic background radiation. *-Ii ( d { 1,6 } ) /

package bringing fraction ( pdf % ) = ( received packets/ sent packages ) *100

Evaluating Average End-End package bringing clip:

For each package with Idaho ( Ii ) of hint degree ( AGT ) and type ( cosmic background radiation ) , calculate the send ( s ) clip ( T ) and the receive ( R ) clip ( T ) and mean it.

Measuring Normalized routing burden:

Calculate the routing package sent:

/^ [ s|f ] . *-Nl RTR. *-It ( ? : AODV|DSR|message ) -Il ( d { 1,4 } ) /

f= & gt ; frontward

RTR= & gt ; Routing Trace Level

Normalized routing burden = ( routing packages sent ) / receives.


Figure 1

Figure 2

Performance comparing of the protocols:

First, an effort was made to compare all the 4 protocols under the same simulation environment. However, simulations could n’t be successfully carried out for the TORA routing protocol, as NS-2 repeatedly gave a coach mistake while running the TORA simulations. For all the simulations, the same motion theoretical accounts were used, the figure of traffic beginnings was fixed at 20, the maximal velocity of the nodes was set to 20m/s and the intermission clip was varied as 0s, 10s, 20s, 40s and 100s.

Figures 1 and 2 highlight the comparative public presentation of the three routing protocols. All of the protocols deliver a greater per centum of the originated informations packages when there is small node mobility ( i.e. , at big intermission clip ) , meeting to 100 % bringing when there is no node gesture.

Packet bringing Comparison:

The On-demand protocols, DSR and AODV performed peculiarly good, presenting over 85 % of the informations packages irrespective of mobility rate.

Average End-End Package bringing:

The mean end-to-end hold of package bringing was higher in DSDV as compared to both DSR and AODV.

In drumhead, both the On-demand routing protocols, AODV and DSR outperformed the Table-driven routing protocol ; DSDV and the grounds are discussed subsequently.

Next, since both AODV and DSR did better, an effort was made to measure the public presentation difference between the two by changing the Mobility form and Number of traffic beginnings.

Changing Mobility and Number of Sources to see the public presentation difference between DSR and AODV

Now, once more simulations were carried out with the figure of traffic beginnings as 10, 20, 30 and 40. The intermission clip was varied as 0 ( high mobility ) , 10, 20, 40,100 ( no mobility ) and the packages were sent at a rate of 4 packets/sec.

Packet bringing Comparison:

The package bringing fractions for DSR and AODV are similar with 10 beginnings ( Fig. 3a ) . However, with 20, 30 and 40 beginnings, AODV outperforms DSR by about 15 per centum ( Fig. 3c and 3d ) at lower intermission times ( higher mobility ) .

Normalized Routing Load Comparison:

In all instances, DSR demonstrates significantly lower routing load than AODV ( Fig. 4 ) , with the factor increasing with a turning figure of beginnings.

Figure 3 ( a )

Figure 4 ( a )

Figure 3 ( B )

Figure 4 ( B )

Figure 3 ( degree Celsius )

Figure 4 ( degree Celsius )

Figure 3 ( vitamin D )

Figure 4 ( vitamin D )

In drumhead, when the figure of beginnings is low, the public presentation of DSR and AODV is similar regardless of mobility. With big Numberss of beginnings, AODV starts surpassing DSR for high-mobility scenarios. As the information from the varying beginnings demonstrate, AODV starts surpassing DSR at a lower burden with a larger figure of nodes. DSR ever demonstrates a lower routing load than AODV. The major part to AODV ‘s routing over-head is from path petitions, while path answers constitute a big fraction of DSR ‘s routing operating expense. Furthermore, AODV has more path petitions than DSR, and the converse is true for path answers.

7. Observation

The simulation consequences bring out some of import characteristic differences between the routing protocols.

The presence of high mobility implies frequent nexus failures and each routing protocol reacts otherwise during nexus failures. The different basic working mechanisms of these protocols leads to the differences in the public presentation

DSDV fails to meet below lower intermission times. At higher rates of mobility ( lower intermission times ) , DSDV does ill, dropping to a 70 % package de-livery ratio. About all of the dropped packages are lost because a stale routing table entry directed them to be forwarded over a broken nexus. As described in the earlier subdivision, DSDV maintains merely one path per finish and accordingly, each package that the MAC bed is unable to present is dropped since there are no alternate paths.

For DSR and AODV, package bringing ratio is independent of offered traffic burden, with both protocols presenting between 85 % and 100 % of the packages in all instances.

Since DSDV uses the table-driven attack of keeping routing information, it is non every bit adaptative to the path alterations that occur during high mobility. In contrast, the lazy attack used by the on-demand protocols, AODV and DSR to construct the routing information as and when they are created make them more adaptative and consequence in better public presentation ( high package bringing fraction and lower mean end-to-end package holds ) .

Next the simulation consequences of figure 3 and 4, that compare the public presentations of AODV and DSR lead us to the undermentioned decisions.

7.1 Effect of Mobility:

In the presence of high mobility, nexus failures can go on really often. Link failures trigger new path finds in AODV since it has at most one path per finish in its routing tabular array. Therefore, the frequence of path finds in AODV is straight relative to the figure of route interruptions. The reaction of DSR to associate failures in comparing is mild and causes route find less frequently. The ground is the copiousness of cached paths at each node. Therefore, the path find is delayed in DSR until all cached paths fail. But with high mobility, the opportunity of the caches being stale is rather high in DSR. Finally when a path find is initiated, the big figure of answers received in response is associated with high MAC operating expense and cause increased intervention to informations traffic. Hence, the cache triteness and high MAC overhead together consequence in important debasement in public presentation for DSR in high mobility scenarios.

In lower mobility scenarios, DSR frequently performs better than AODV, because the opportunities of find the path in one of the caches is much higher. However, due to the constrained simulation environment ( lesser simulation clip and lesser mobility theoretical accounts ) , the better public presentation of DSR over AODV could n’t be observed.

7.2 Routing Load Consequence:

DSR about ever has a lower routing load than AODV. This can be attributed to the caching scheme used by DSR. By virtuousness of aggressive caching, DSR is more likely to happen a path in the cache, and therefore resorts to route find less often than AODV.

8. Decision

This undertaking compared the public presentation of DSDV, AODV and DSR routing protocols for Ad hoc webs utilizing ns-2 simulations. Unfortunately, TORA simulations could n’t be successfully carried out.

DSDV uses the proactive table-driven routing scheme while both AODV and DSR use the reactive On-demand routing scheme. Both AODV and DSR perform better under high mobility simulations than DSDV. High mobility consequences in frequent nexus failures and the operating expense involved in updating all the nodes with the new routing information as in DSDV is much more than that involved AODV and DSR, where the paths are created as and when required.

DSR and AODV both use on-demand path find, but with different routing mechanics. In peculiar, DSR uses beginning routing and path caches, and does non depend on any periodic or timer-based activities. DSR exploits hoarding sharply and maintains multiple paths per finish. AODV, on the other manus, uses routing tabular arraies, one path per finish, and finish sequence Numberss, a mechanism to forestall cringles and to find freshness of paths. The general observation from the simulation is that for application-oriented prosodies such as package bringing fraction and hold AODV, outperforms DSR in more “ nerve-racking ” state of affairss ( i.e. , smaller figure of nodes and lower burden and/or mobility ) , with widening public presentation spreads with increasing emphasis ( e.g. , more burden, higher mobility ) . DSR, nevertheless, systematically generates less routing burden than AODV. The hapless public presentations of DSR are chiefly attributed to aggressive usage of caching, and deficiency of any mechanism to run out stale paths or find the freshness of paths when multiple picks are available. Aggressive caching, nevertheless, seems to assist DSR at low tonss and besides keeps its routing burden down.

9. Future Work

In the hereafter, extended complex simulations could be carried out utilizing this undertaking codification, in order to derive a more in-depth public presentation analysis of the ad hoc routing protocols. TORA protocol public presentation could be studied excessively.


[ 1 ] . Xia Li, Peng-Yong Kong, and Kee-Chaing Chua, TCP Performance in IEEE 802.11 based Ad Hoc Networks with Multiple Wireless Lossy Links

[ 2 ] . Samir R.Das, Charles E. Perkins, Elizabeth M. Royer. Performance comparing of Two On-demand Routing Protocols for Ad Hoc Networks.

[ 3 ] J.Broch, D.A. Maltz, D.B.Johnson, Y-C. Hu and J.Jetcheva. A public presentation comparing of multi-hop radio ad hoc web routing protocols.

B. Appendix

1. Simulation Code


# Define options

# ======================================================================

set opt ( chan ) Channel/WirelessChannel

set opt ( prop ) Propagation/TwoRayGround

set opt ( netif ) Phy/WirelessPhy

set opt ( mac ) Mac/802_11

set opt ( ifq ) Queue/DropTail/PriQueue

set opt ( ll ) LL

set opt ( ant ) Antenna/OmniAntenna

set opt ( x ) 500 ; # X dimension of the topography

set opt ( Y ) 500 ; # Y dimension of the topography

set opt ( ifqlen ) 50 ; # soap package in ifq

set opt ( seed ) 0.0

set opt ( tr ) ; # hint file

set opt ( adhocRouting ) DSDV

set opt ( nn ) 50 ; # how many nodes are simulated

set opt ( cp ) ” scenarios/cbr-50-5-4 ”

set opt ( Sc ) ” scenarios/temp1 ”

set opt ( halt ) 100.0 ; # simulation clip


# Main Program

# ======================================================================

# Initialize Global Variables

# create simulator case

set ns_ [ new Simulator ]

# set radio channel, radio-model and topography objects

set wtopo [ new Topography ]

# create hint object for N and nam

set tracefd [ unfastened $ opt ( tr ) tungsten ]

$ ns_ trace-all $ tracefd

# use new hint file format

$ ns_ use-newtrace

# define topology

$ wtopo load_flatgrid $ opt ( x ) $ opt ( Y )

# Create God

set god_ [ create-god $ opt ( nn ) ]

# specify how node should be created

# planetary node puting

$ ns_ node-config -adhocRouting $ opt ( adhocRouting )

-llType $ opt ( ll )

-macType $ opt ( mac )

-ifqType $ opt ( ifq )

-ifqLen $ opt ( ifqlen )

-antType $ opt ( emmet )

-propType $ opt ( prop )

-phyType $ opt ( netif )

-channelType $ opt ( chan )

-topoInstance $ wtopo

-agentTrace ON

-routerTrace ON

-macTrace OFF

# Create the specified figure of nodes [ $ opt ( nn ) ] and “ attach ” them

# to the channel.

for { set I 0 } { $ I & lt ; $ opt ( nn ) } { incr I } {

set node_ ( $ I ) [ $ ns_ node ]

$ node_ ( $ I ) random-motion 0 ; # disable random gesture


# Define node motion theoretical account

puts “ Loading connexion form… ”

beginning $ opt ( cp )

# Define traffic theoretical account

puts “ Loading scenario file… ”

beginning $ opt ( Sc )

# Define node initial place in nam

for { set I 0 } { $ I & lt ; $ opt ( nn ) } { incr I } {

# 20 defines the node size in nam, must set it harmonizing to your scenario

# The map must be called after mobility theoretical account is defined

$ ns_ initial_node_pos $ node_ ( $ I ) 20


# Tell nodes when the simulation ends

for { set I 0 } { $ I & lt ; $ opt ( nn ) } { incr I } {

$ ns_ at $ opt ( halt ) .000000001 “ $ node_ ( $ I ) reset ” ;


# Tell nam the simulation halt clip

# $ ns_ at $ opt ( halt ) ” $ ns_ nam-end-wireless $ opt ( halt ) ”

$ ns_ at $ opt ( halt ) .000000001 “ puts ” NS EXITING… ” ; $ ns_ arrest ”

puts “ Get downing Simulation… ”

$ ns_ tally

2. Java parser codification:

import java.util. * ;

import java.lang. * ;

import * ;

public category parsetrace {

public inactive nothingness chief ( Stringing args [ ] ) {

Stringing s, thisLine, currLine, thisLine1 ;

int j=0 ;

FileInputStream five, fin1 ;

FileOutputStream fout, fout1 ;

concluding int FILES = 45 ;

concluding int MAX_PACKETS = 400000 ;

seek {

int i=0, sends=0, receives=0 ;

int drops=0, packet_id=0, highest_packet_id = 0 ;

int line_count=0, current_line=0, routing_packets=0 ;

int count=0 ;

float pdfraction, time=0, packet_duration=0, end_to_end_delay=0 ;

float avg_end_to_end_delay=0 ;

float start_time [ ] = new float [ MAX_PACKETS ] ;

float end_time [ ] = new float [ MAX_PACKETS ] ;

float sent_packets [ ] = new float [ MAX_PACKETS ] ;

float received_packets [ ] = new float [ MAX_PACKETS ] ;

Stringing items [ ] = new String [ 100 ] ;

// initialise the start clip

for ( i=0 ; i & lt ; MAX_PACKETS ; i++ )

start_time [ I ] = 0 ;

fout =new FileOutputStream ( “ traceoutput.txt ” ) ;

DataOutputStream op = new DataOutputStream ( fout ) ;

for ( int h=0 ; h & lt ; FILES+1 ; h++ ) {

j=0 ;

sends=0 ; receives=0 ; routing_packets=0 ;

highest_packet_id = 0 ;

end_to_end_delay=0 ;

for ( i=0 ; i & lt ; MAX_PACKETS ; i++ )

{ start_time [ I ] = 0 ; end_time [ I ] =0 ; }

five = new FileInputStream ( “ final_sources ” +h+ ” .tr ” ) ;

DataInputStream Br = new DataInputStream ( five ) ;

while ( ( thisLine = br.readLine ( ) ) ! = nothing ) {

// scan it line by line

java.util.StringTokenizer st = new java.util.StringTokenizer ( thisLine, “ “ ) ;

i=0 ;

while ( st.hasMoreElements ( ) )

items [ i++ ] = st.nextToken ( ) ;

if ( tokens [ 0 ] .equals ( “ s ” ) || tokens [ 0 ] .equals ( “ R ” ) || tokens [ 0 ] .equals ( “ f ” ) )


// parse the clip

if ( tokens [ 1 ] .equals ( “ -t ” ) ) clip = Float.valueOf ( tokens [ 2 ] ) .floatValue ( ) ;

// parse the packet_id

if ( tokens [ 39 ] .equals ( “ -Ii ” ) ) packet_id = Integer.valueOf ( tokens [ 40 ] ) .intValue ( ) ;

/// cipher the sent packages

if ( tokens [ 0 ] .equals ( “ s ” ) & A ; & A ; tokens [ 18 ] .equals ( “ AGT ” ) & A ; & A ; tokens [ 34 ] .equals ( “ cosmic background radiation ” ) )

sends++ ;

// happen the figure of packages in the simulation

if ( packet_id & gt ; highest_packet_id ) highest_packet_id = packet_id ;

// set the start clip, merely if its non already put

if ( start_time [ packet_id ] == 0 ) start_time [ packet_id ] = clip ;

// cipher the receives and end-end hold

if ( tokens [ 0 ] .equals ( “ R ” ) & A ; & A ; tokens [ 18 ] .equals ( “ AGT ” ) & A ; & A ; tokens [ 34 ] .equals ( “ cosmic background radiation ” ) )


receives++ ;

end_time [ packet_id ] = clip ;


else end_time [ packet_id ] = -1 ;

// cipher the routing packages

if ( ( tokens [ 0 ] .equals ( “ s ” ) || tokens [ 0 ] .equals ( “ f ” ) ) & A ; & A ; tokens [ 18 ] .equals ( “ RTR ” )

& A ; & A ; ( tokens [ 34 ] .equals ( “ AODV ” ) || tokens [ 34 ] .equals ( “ DSR ” )

|| items [ 34 ] .equals ( “ message ” ) ) )

routing_packets++ ;



// cipher the package continuance for all the packages

for ( packet_id = 0 ; packet_id & lt ; = highest_packet_id ; packet_id++ ) {

packet_duration = end_time [ packet_id ] – start_time [ packet_id ] ;

if ( packet_duration & gt ; 0 ) end_to_end_delay += packet_duration ;


// calculate the mean end-end package hold

avg_end_to_end_delay = end_to_end_delay / ( receives ) ;

// cipher the package bringing fraction

pdfraction = ( ( float ) receives/ ( float ) ( sends ) ) *100 ;

System.out.println ( “
sends “ +sends ) ;

System.out.println ( “ receives “ +receives ) ;

System.out.println ( “ routing operating expense ( packages ) “ + routing_packets ) ;

System.out.println ( “ Normalized routing burden “ + ( float ) routing_packets/ ( float ) receives ) ;

System.out.println ( “ pdfraction “ +pdfraction ) ;

System.out.println ( “ Avg End-End hold “ +avg_end_to_end_delay ) ;

op.writeBytes ( “ “ +sends ) ;

op.writeBytes ( “ “ +receives ) ;

op.writeBytes ( “ “ + routing_packets ) ;

op.writeBytes ( “ “ + ( float ) routing_packets/ ( float ) receives ) ;

op.writeBytes ( “ “ +pdfraction ) ;

op.writeBytes ( “ “ +avg_end_to_end_delay ) ;

op.writeChar ( ‘
‘ ) ;



gimmick ( Exception e ) {

e.printStackTrace ( ) ;


} }