Вы находитесь на странице: 1из 5

Implementation of DSR Protocol in NS2 simulator

University of Bonn, Informatik Department IV

Venkatapathy Ragunath

Abstract-- The Dynamic Source Routing protocol (DSR) is a assumptions this protocol is implemented is explained below
simple and efficient Routing protocol designed specifically for use
in multi-hop wireless mobile nodes networks called Ad hoc 1.1 Mobil AD Hoc networks
networks. DSR allows the network to be completely self-
organizing and self-configuring, without the need for any existing
network infrastructure or administration. This paper describe Mobile Ad-hoc Networks (MANETs) are future wireless
the design of our own implementation of DSR protocol using networks consisting entirely of mobile nodes that
DSR MANET draft in NS2 simulator environment and provide a communicate on-the-move without base stations. Nodes in
summary of some the simulation and testbed implementation these networks will both generate user and application traffic
results for the protocol. and carry out network control and routing protocols. Rapidly
changing connectivity, network partitions, higher error rates,
Keywords: Ad Hoc networks, DSR, node, MANET,NS2
collision interference, and bandwidth and power constraints
INTRODUCTION together pose new problems in network controlparticularly
in the design of higher level protocols such as routing and in
T he routing protocols meant for wired networks can not be
used for mobile ad hoc networks because of the mobility
of networks. In contrast to infrastructure based networks, in ad
implementing applications with Quality of Service
hoc networks all nodes are mobile and can be connected
dynamically in an arbitrary manner. All nodes of these 1.2 NS2 Simulator
networks behave as routers and take part in discovery and NS-2 is extensively used by the networking research
maintenance of routes to other nodes in the network. Ad hoc community. It provides substantial support for simulation of
networks are very useful in emergency search-and-rescue TCP, routing, multicast protocols over wired and wireless
operations, meetings or conventions in which persons wish to (local and satellite) networks, etc. The simulator is event-
quickly share information, and data acquisition operations in driven and runs in a non real-time fashion. It consists of C++
inhospitable terrain. core methods and uses Tcl and Object Tcl shell as interface
Using DSR, the network is completely self-organizing and allowing the input file (simulation script) to describe the
self-configuring, requiring no existing network infrastructure model to simulate.Users can define arbitrary network
or administration. Network nodes cooperate to forward topologies composed of nodes, routers, links and shared
packets for each other to allow communication over multiple media. A rich set of protocol objects can then be attached to
"hops" between nodes not directly within wireless nodes, usually as agents. The simulator suite also includes a
transmission range of one another. As nodes in the network graphical visualiser called network animator (nam) to assist
move about or join or leave the network, and as wireless the users get more insights about their simulation by
visualising packet trace data.
transmission conditions such as sources of interference
change, all routing protocol is automatically determined and
maintained by the DSR routing protocol. Since the number or 1.3 DSR Protocol
sequence of intermediate hops needed to reach any destination
may change at any time, the resulting network topology may The Dynamic Source Routing Protocol is a source-routed
be quite rich and rapidly changing. on-demand routing protocol. A node maintains route caches
NS-2 is an object-oriented simulator developed as part of containing the source routes that it is aware of. The node
the VINT project at the University of California in Berkeley. updates entries in the route cache as and when it learns about
Using which new protocol (Agent) implementations can be new routes.DSR does not rely on functions like periodic
tested efficiently. routing advertisement, link status sensing or neighbor
detection packets and because of the entirely on demand
1 BASIC TECHNOLOGY behavior, the number of overhead packets caused by DSR
The basic features of these type of non administrative scales down to zero.
network, and the information about how this source-routed
on-demand routing protocol(DSR) works and under what

This work was done for the laboratory class Mobile communication and
wireless networking lab University of Bonn , Informatik Department IV
Communication Systems ,Operating Systems and Stochastic modeling
1.4 Basic mechanism initiated the copy of the original packet is saved in a local
buffer called Send Buffer. The Send Buffer contains
Route Discovery and Route Maintenance, which are the copies of each packet that cannot be transmitted by the
main mechanisms of the DSR protocol, allows the discovery sending node. The packets are kept until a source route is
and maintenance of source routes in the ad hoc networks available or a timeout or Send Buffer overflow occurs. As
works entirely on an on-demand basis. As DSR works entirely long as a packet is in the Send Buffer, the node should initiate
on demand and as nodes begin to move continuously, the new Route Discovery until time out occurs or overflow of
Routing packet overhead automatically scales to only that Buffer occurs. An exponential Back off algorithm is designed
needed to react to changes in the route currently in use. In to limit the rate at which new ROUTE Discoveries may be
response to a single Route Discovery if a node learns and initiated by any node for the same target. [1]
caches multiple routes to a destination, it can try another route
if the one it uses fails. The overhead incurred by performing a 1.4.2 DSR Route Maintenance
new Route Discovery can be avoided when the caching of
multiple routes to a destination occurs. and Mobile IP routing When a packet with a source route is forwarded, each node
and supports internetworking between different types of in the source route makes sure that the packet has been
wireless networks. [1] received by the next hop in the source route. The confirmation
of receipt will be received only by re-transmitting the packet
1.4.1 DSR Route Discovery for a number of times. [1]
Node A is the originator of a packet to the desired
The header of the packet, which originates from a source destination E. The packet has a source route through
node S to a destination node D, contains the source route, intermediate nodes B, C and D. Node A is responsible for
which gives the sequence of hops that the packet should
traverse. A suitable source route is found normally when
searching the Route Cache of routes obtained previously but if
no route is found then the Route Discovery protocol is
initiated to find a new route to D. Here S is the initiator and D Figure 2: Node C is unable to forward a packet from A to E over the next
the target. [1] Node A transmits a ROUTE REQUEST node D

receipt of the packet at B, node B at C, node C at D and node

D at E. Node B confirms receipt of packet at C by overhearing
C transmit the packet to forward it to D. The confirmation of
acknowledgement is done by passive acknowledgements or as
Figure 1: Node A is the initiator and Node E is the target
link-layer mechanisms such as option in MAC protocol. The
node receiving the packet can return a DSR specific software
message, which is received by all the nodes in the
acknowledgement if neither of the acknowledgements is
transmission range of A. Each ROUTE REQUEST message
available. This is done by setting up a bit in the packets
identifies the initiator and target of the Route Discovery and
header and then requesting a DSR specific software
also contains a unique request ID, determined by the initiator
acknowledgement by the node transmitting the packet. When
of the REQUEST. Each ROUTE REQUEST also contains a
a node is unable to deliver a packet to the next node then the
record listing the address of each intermediate node through
node sends a ROUTE ERROR message to the original sender
which this particular copy of the ROUTE REQUEST message
of the packet. The broken link is then removed from the cache
has been forwarded. The initiator of the Route Discovery
by the originator of the packet and retransmissions to the same
initializes the route record to an empty list. [1] When the
destination are done by upper layer protocols like TCP. [1]
target node receives the ROUTE REQUEST message, it
returns a ROUTE REPLY message to the ROUTE Discovery
Route maintenance is also carried out also by both ROUTE
initiator with a copy of the accumulated route record from the
REQUEST and ROUTE REPLY packets, when they traverse
ROUTE REQUEST. This route is cached in the Route Cache
form each node the data from the option header of these
when the initiator receives the ROUTE REPLY and is used in
packets which contain the link information of the nodes are
sending subsequent packets to this destination. When the
updated in the nodes route cache
target node finds a ROUTE REQUEST message from the
same initiator bearing the same request ID or if it finds its own
2 Setup and metrics
address is already listed in the route record of the ROUTE
REQUEST message, it discards the REQUEST. If the target
The simulation consist of five nodes, the source is Node
node does not find the ROUTE REQUEST message from the
Which generates a cbr traffic using udp data packet every .2
initiator, then it appends its address to the route record in the
seconds. The sink is the Node4, which constantly has to
ROUTE REQUEST message and propagates it by transmitting
it as a local broadcast packet. When Route Discovery is
receive the packets generated form the source. Node4 moves
in a linier manner form the range of node0 to range of node3
as shown in the figure 3.So every time when a data packet
arrive without the route to destination the ROUTE
REQUEST packet is created and broadcasted and when the
ROUTE REPLY arrives ,if the route is broken in between,
then a ROUTE ERROR is generated to the source node that
generated send the data packet

Figure 4: Time Vs Packet identification number

The sendbuffer behaviour can be seen form the graph

figure.5 its the same Time Vs Packet identification number
but the time taken to rejoin the transmission range is very high
so the data packets that arrive in this time are saved in send
buffer of the sender ,and when the route is discovered after the
node rejoins the data in the send buffer is send in one burst,
and then the normal data transmission starts.

Figure 3: Node A is the initiator and Node E is the target

3 Simulation results

The graph figure.4 form the simulation result trace file

show a straight line , which is generated by Time Vs Packet
identification number ,when the node leaves the transmission
range of one system then there is a dropped packet and after
few seconds the transmission begins again when the route is
discovered. In this scenario the nodes other then sink are
constant, as these are connected and static with each other, So
the discovery of route when the link is broken is done so fast
such that only one packet is dropped whose retransmission is
taken care of the upper layers

The packet drop is due to the DSR implementation in

which when forwarding towards the destination when the
node detects the link failure it drops the packet and then sends Figure 5: Time Vs Packet identification number
a route error to the source which originated the data packet

3 Code Documentation
node which originated the data packet
When a data packet arrives the ttl( ) is checked if it is
greater then one then the packet is taken for processing if not
it is dropped

Figure 7: Flow chart describing the data flow if the packet type is DSR10

Figure 6: Flow chart describing the data flow if the packet type is DSR10
4 Future development
The DSR10 packet is processed according to its type
which is determined be switch case, if it a This implementation of DSR Source routing protocol
ROUTE_REQUEST packet then the data in the option header includes most of the basic facilities described in DSR
is used for updating the route cache, and then the MANET IEEE draft, but some optimization measures like
ROUTE_REPLY packet is send to the source which initiated cached route request, and flow control are not implemented in
the ROUTE_REQUEST . If it is a ROUTE_REPLY packet this implementation.
then it updates the route cache and then starts to send the data
packet, which are stored in the send buffer. else if it is a error Packet salvaging, automatic route shortening (Gratuitous
packet then the route is deleted using the data in the option Route Reply), caching negative information, caching over
header of the ROUTE_ERROR packet and then the packet is head routing information and increased spreading of route
forwarded or dropped. This flow is clearly explained in the error packets are the other options available in draft which can
figure.6, it also contains the handlers used in the code for each be implemented in this implementation The DSR protocol
and every purpose. allows multiple routes to any destination and allows each
sender to select and control the routes used in routing its
If the packet is a normal data packet which carries the packets (in this implementation the best route is determined by
option header containing the route form the source to Dijkstra's shortest path algorithm) for example for use in load
destination, it is handled as shown in the figure.7 , when the balancing or for increased robustness. Other advantages of the
node receives the packet it checks the link of the next location DSR protocol include easily guaranteed loop-free routing,
if exists then sends the packet normally , if the link is broken support for use in networks containing unidirectional links,
use of only "soft state" in routing, and very rapid recovery
then the a ROUTE_ERROR packet is created and send to the when routes in the network change. The DSR protocol is
designed mainly for mobile ad hoc networks of up to about
two hundred nodes, and is designed to work well with even
very high rates of mobility.

5 Conclusion

DSR protocol for ad-hoc networks works fine, but even it

runs under some assumptions. This implementation works fine
with less number of nodes, when the number of nodes
increase then due to no much functionality in send buffer we
face lot of problems like upper layers start to retransmit the
packet again when it does not get an acknowledgement for the
packet. In future implementations if these optional features are
implemented then this implementation can be used for real ad
hoc network

6 Reference

[1] Charles.E.Perkins. AdHoc Networking.. Addison-

Wesley, 2001.
[2] draft-ietf-manet-dsr-09.txt
IETF MANET Working Group David B. Johnson, Rice
INTERNET-DRAFT David A. Maltz, Carnegie Mellon
University 15 April 2003 Yih-Chun Hu, Rice University