Simulating a Mobile Adhoc Network


After completing this experiment you will be able to:

  • Understand about the basics of Mobile Ad-hoc Networks (MANETs) and different routing protocols
  • Setup a network with wireless nodes using ns2
  • Get familiar with the different characteristics of MANET through simulations

Time Required

Around 3.00 hours

Ad Hoc Network

Ad-hoc networks are temporary network. They do not need any external infrastructure like base stations and physical wires.

Mobile Ad-hoc NETwork (MANET)

MANET automatically configure a network among mobile devices. Each devices moves independently in any direction. Each node acts as a router.

A typical MANET is shown in the figure-01 below:

A typical MANET Figure-01: Mobile Ad-hoc Network (MANETs)


Routing is the selection of path or a route in a network for forwarding packets. The objective of routing packets in a network is to determine the best possible path in terms of minimising the number of hops (path length), delay, packet loss, cost etc.

Routing in MANET

MANETs are formed dynamically by connecting arbitrary wireless mobile nodes, without using existing infrastructure. So, routing in MANET is different from traditional routing. Each node in MANET function like a host and a router. The nodes also used in forwarding/receiving their own packets. The nodes also take part in forwarding other's node packet. Therefore, MANET provides limited physical security as compared to the traditional network.

Routing protocols for MANET

Routing protocols for a MANET can be classified as:

Proactive (table-driven) : DSDV, OLSR etc.

Reactive (on-demand): AODV, DSR etc.

Hybrid: ZRP

  • Proactive routing protocols determine path in advance and periodically exchange routing data to maintain the path.
  • Reactive routing protocols, on the other hand, determine a route to some destination node only when it is required to send some data to that node. If at any time a path fails, an alternative path is determined again.
  • Hybrid routing takes the advantages of both table driven and on-demand algorithms.

Destination-Sequenced Distance-Vector (DSDV) algorithm:

The procedure for DSDV [1] is :

  1. Each mobile node maintains a routing table with an entry of routing information from all its neighbors.
  2. Each routing information in a routing table specifies.
    • the destination identifier
    • the next hop on the route to the destination
    • the distance (in terms of hops) to the destination
    • a sequence number by monotonically increasing each time the node sends an update message to its neighbors. A route will be replaced only when the destination sequence number is less than the new one or two routes have the same sequence number but one has a lower metric.
  3. After generating a new routing table, each node broadcasts this table to all its neighbors.
  4. Based on the received tables, each mobile node update their tables, until routing information is stable.

Dynamic source routing (DSR)

The DSR [v] protocol is composed of two mechanisms that work together to allow the discovery and maintenance of source routes in the ad hoc network:

1. Route Discovery: Route discovery is used only when source wants to send a packet to destination and does not know a route to destination. A mobile node A wants to send a packet to a destination node B, then obtain a source route to B.

2. Route Maintenance : Route Maintenance is the mechanism by which a source node A is able to detect, while using a source route to B. If the network topology has changed and the route is broken then the source route attempts to use any other route to destination if it exist or can invoke route discovery again to find a new route. Route Maintenance is used only when source is actually sending packets to destination.

Both Route Discovery and Route Maintenance each operate entirely on demand. When the destination node is reached, it returns a reply containing the route to the source node. The reply then travels in the reverse direction of the discovered route or on a path already known by the destination, to the source. The source node, on receiving the reply, will place the route in its route cache.

Application of MANET

The applications of MANET are:[iv]

- Military or police exercises.

- Disaster relief operations.

- Mine site operations.

- Robot data acquisition. etc.


The following are the advantages of MANETs:[iv]

-MANETs provide different access to information and also services of geographic position.

-MANETs work without any pre-existing infrastructure.

-MANETs can be set up at any place and time.


Some of the disadvantages of MANETs are:[iv]

-Limited resources.

-Limited physical security.

-Intrinsic mutual trust vulnerable to attacks.

-Lack of authorization facilities.

-Volatile network topology makes it hard to detect malicious nodes.

-Security protocols for wired networks cannot work for ad hoc networks.

Simulating a MANET using Network Simulator 2

The Network Simulator simulate following steps for MANET:

1.The command required to configure a mobile node :

$ns_ node-config -adhocRouting $val(rp) \
		-llType $val(ll) \ # LinkLayer
		-macType $val(mac) \ #MAC type 
		-ifqType $val(ifq) \ #interface queue type
		-ifqLen $val(ifqlen) \ #interface queue length
		-antType $val(ant) \ #antenna type
		-propType $val(prop) \ #propagation model
		-phyType $val(netif) \ #network interface type
		-topoInstance $topo \ #topography instance
		-agentTrace ON \ #tracing at agent level
		-routerTrace ON \ #tracing at router level
		-macTrace ON \ #tracing at mac level
		-movementTrace ON \ #mobile node movement
		-channel $chan_1_ 

The four last option in node configuration can either be ON or OFF based on the condition of the mobile nodes. The agent trace will give the trace of TCP, routerTrace provides tracing of packets used in routing, macTrace is used to trace MAC protocol packets and movementTrace is used to allow tracing the motion of nodes for nam.

2. Create some mobile nodes and assign them to the channels:

for {set i 0} {$i < $val(nn)} {incr i} {
	set node_($i) [$ns_ node]   
	$node_($i) random-motion 0;		

3. Assigning mobility to the node.

4. Specifying routing protocols.

set val(rp)             AODV; #for AODV
set val(rp)             DSR; #for DSR
Decrease font size Increase font size List of experiments