SlideShare a Scribd company logo
1 of 13
Download to read offline
arXiv:1007.4065v2 [cs.NI] 26 Jul 2010

A Tutorial on the Implementation of Ad-hoc On
Demand Distance Vector (AODV) Protocol in
Network Simulator (NS-2)

Mubashir Husain Rehmani,
Sidney Doria, and Mustapha Reda Senouci

∗

Version 1

28th June 2009
∗ M. H. Rehmani is with INRIA, France, e-mail: mubashir.rehmani@inria.fr; S. Doria is
with UFCG, Brazil, e-mail: sidney@dsc.ufcg.edu.br; M. R. Senouci is with Laboratory of
Research in Artificial Intelligence, Algeria, email: mrsenouci@gmail.com; Special thanks to
Hajer Ferjani, she has a Masters Degree in Networking from the National School of Computer Science of Tunisia, CRISTAL Laboratory in 2006, Tunisia, e-mail: f.hajer@gmail.com.
The author would like to thanks Aline Carneiro Viana, who is with INRIA, France, e-mail:
aline.viana@inria.fr;

1
Contents
1 Introduction

3

2 File Dependency of AODV Protocol

3

3 Flow of AODV

3

4 Trace Format of AODV

5

5 Main Implementation Files aodv.cc and aodv.h
5.1 How to Enable Hello Packets . . . . . . . . . . . . . . .
5.2 Timers Used . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3.1 General Functions . . . . . . . . . . . . . . . . .
5.3.2 Functions for Routing Table Management . . . .
5.3.3 Functions for Neighbors Management . . . . . .
5.3.4 Functions for Broadcast ID Management . . . .
5.3.5 Functions for Packet Transmission Management
5.3.6 Functions for Packet Reception Management . .

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

6
6
7
7
7
8
9
9
9
10

6 Appendex : A Simple TCL Script to Run the AODV Protocol 11

2
Abstract
The Network Simulator (NS-2) is a most widely used network simulator. It has the capabilities to simulate a range of networks including
wired and wireless networks. In this tutorial, we present the implementation of Ad Hoc On-Demand Distance Vector (AODV) Protocol in NS-2.
This tutorial is targeted to the novice user who wants to understand the
implementation of AODV Protocol in NS-2.

1

Introduction

The Network Simulator (NS-2) [1] is a most widely used network simulator.
This tutorial presents the implementation of Ad Hoc On-Demand Distance
Vector (AODV) Protocol [2] in NS-2. The expected audience are students
who want to understand the code of AODV and researchers who want to extend the AODV protocol or create new routing protocols in NS-2. The version considered is NS-2.32 and 2.33, but it might be useful to other versions
as well. Throughout the rest of this tutorial, the under considered files are
aodv.cc, aodv.h, aodv logs.cc, aodv packet.h, aodv rqueue.cc, aodv rqueue.h,
aodv rtable.cc, aodv rtable.h which can be found in AODV folder in the NS-2
base directory.

2

File Dependency of AODV Protocol

Fig. 1 and 2 shows the file dependency of AODV Protocol [3]. As AODV is a
routing protocol, so it is derived from the class Agent, see agent.h.

Figure 1: File Reference of ‘AODV.CC’.

3

Flow of AODV

In this section, we describes the general flow of AODV protocol through a simple
example:
3
Figure 2: File Reference of ‘AODV.H’.
1. In the TCL script, when the user configures AODV as a routing protocol
by using the command,
$ns node-config -adhocRouting AODV
the pointer moves to the “start” and this “start” moves the pointer to the
Command function of AODV protocol.
2. In the Command function, the user can find two timers in the “start”
* btimer.handle((Event*) 0);
* htimer.handle((Event*) 0);
3. Let’s consider the case of htimer, the flow points to HelloTimer::handle(Event*)
function and the user can see the following lines:
agent -> sendHello();
double interval = MinHelloInterval + ((MaxHelloInterval - MinHelloInterval) * Random::uniform());
assert(interval -> = 0);
Scheduler::instance().schedule(this, &intr, interval);
These lines are calling the sendHello() function by setting the appropriate
interval of Hello Packets.
4. Now, the pointer is in AODV::sendHello() function and the user can
see Scheduler::instance().schedule(target , p, 0.0) which will schedule the
packets.
5. In the destination node AODV::recv(Packet*p, Handler*) is called, but
actually this is done after the node is receiving a packet.

4
6. AODV::recv(Packet*p, Handler*) function then calls the recvAODV(p)
function.
7. Hence, the flow goes to the AODV::recvAODV(Packet *p) function, which
will check different packets types and call the respective function.
8. In this example, flow can go to
case AODVTYPE HELLO:
recvHello(p);
break;
9. Finally, in the recvHello() function, the packet is received.

4

Trace Format of AODV

In NS-2, the general trace format is given as below:
s 0.000000000 0 RTR — 0 AODV 44 [0 0 0 0] ——- [0:255 -1:255 1 0] [0x1
1 [0 2] 4.000000] (HELLO)
s 10.000000000 0 RTR — 0 AODV 48 [0 0 0 0] ——- [0:255 -1:255 30 0]
[0x2 1 1 [1 0] [0 4]] (REQUEST)
s 21.500000000 0 RTR — 0 AODV 48 [0 0 0 0] ——- [0:255 -1:255 30 0]
[0x2 1 4 [1 0] [0 12]] (REQUEST)
r 21.501260809 2 RTR — 0 AODV 48 [0 ffffffff 0 800] ——- [0:255 -1:255
30 0] [0x2 1 4 [1 0] [0 12]] (REQUEST)
The interpretation of the following trace format is as follows:
r 21.501260809 2 RTR — 0 AODV 48 [0 ffffffff 0 800] ——- [0:255 -1:255
30 0] [0x2 1 4 [1 0] [0 12]] (REQUEST)
Node ID 2, receives a packet type REQUEST (AODV protocol), at layer
RTR (routing), at time 21.501260809. This packet have sequence number 0.
A generalized explanation of trace format [4] would be as follows :

5
Column
Number
1
2
3
4

5
6

What Happened?

Values for instance...

It shows the
cured event
Time at which
event occured?
Node at which
event occured?
Layer at which
event occured?

oc-

’s’ SEND, ’r’ RECEIVED, ’D’ DROPPED

the

10.000000000

the

Node id like 0

the

’AGT’ application layer, ’RTR’ routing layer,
’LL’ link layer, ’IFQ’ Interface queue, ’MAC’
mac layer, ’PHY’ physical layer
—
0

show flags
shows the sequence
number of packets
shows the packet
type

7

8

9

5.1

[....]

10
11

5

shows size of the
packet

show flags
[....]

’cbr’ CBR packet, ’DSR’ DSR packet, ’RTS’
RTS packet generated by MAC layer, ’ARP’
link layer ARP packet
Packet size increases when a packet moves
from an upper layer to a lower layer and decreases when a packet moves from a lower layer
to an upper layer
It shows information about packet duration,
mac address of destination, the mac address of
source, and the mac type of the packet body.
—
It shows information about source node ip :
port number, destination node ip (-1 means
broadcast) : port number, ip header ttl, and
ip of next hop (0 means node 0 or broadcast).

Main Implementation Files aodv.cc and aodv.h
How to Enable Hello Packets

By default HELLO packets are disabled in the aodv protocol. To enable broadcasting of Hello packets, comment the following two lines present in aodv.cc
#ifndef AODV LINK LAYER DETECTION
#endif LINK LAYER DETECTION and recompile ns2 by using the following
commands on the terminal:
make clean
make
sudo make install

6
5.2

Timers Used

In ns2, timers are used to delay actions or can also be used for the repetition of
a particular action like broadcasting of Hello packets after fixed time interval.
Following are the timers that are used in AODV protocol implementation:
• Broadcast Timer: This timer is responsible for purging the ID’s of Nodes
and schedule after every BCAST ID SAVE.
• Hello Timer: It is responsible for sending of Hello Packets with a delay
value equal to interval, where
double interval = MinHelloInterval + ((MaxHelloInterval - MinHelloInterval) * Random::uniform());
• Neighbor Timer: Purges all timed-out neighbor entries and schedule after
every HELLO INTERVAL .
• RouteCache Timer: This timer is responsible for purging the route from
the routing table and schedule after every FREQUENCY.
• Local Repair Timer: This timer is responsible for repairing the routes.

5.3
5.3.1

Functions
General Functions

• void recv(Packet *p, Handler *): At the network layer, the Packet is first
received at the recv() function, sended by the MAC layer in up direction.
The recv() function will check the packet type. If the packet type is AODV
type, it will decrease the TTL and call the recvAODV() function.
If the node itself generating the packet then add the IP header to handle
broadcasting, otherwise check the routing loop, if routing loop is present
then drop the packet, otherwise forward the packet.
• int command(int, const char *const *): Every object created in NS-2 establishes an instance procedure, cmd{} as a hook to executing methods
through the compiled shadow object. This procedure cmd invokes the
method command() of the shadow object automatically, passes the arguments to cmd{} as an argument vector to the command() method [5].

7
5.3.2

Functions for Routing Table Management

• void rt resolve(Packet *p): This function first set the transmit failure callback and then forward the packet if the route is up else check if I am the
source of the packet and then do a Route Request, else if the local repair
is in progress then buffer the packet.
If this function founds that it has to forward a packet for someone else
to which it does not have a route then drop the packet and send error
upstream. Now after this, the route errors are broadcasted to the upstream
neighbors.
• void rt update(aodv rt entry *rt, u int32 t seqnum,u int16 t metric, nsaddr t
nexthop,double expire time): This function is responsible for updating the
route.
• void rt down(aodv rt entry *rt): This function first confirms that the
route should not be down more than once and after that down the route.
• void local rt repair(aodv rt entry *rt, Packet *p): This function first buffer
the packet and mark the route as under repair and send a RREQ packet
by calling the sendRequest() function.
• void rt ll failed(Packet *p): Basically this function is invoked whenever
the link layer reports a route failure. This function drops the packet if
link layer is not detected. Otherwise, if link layer is detected, drop the
non-data packets and broadcast packets. If this function founds that the
broken link is closer to the destination than source then It will try to
attempt a local repair, else brings down the route.
• void handle link failure(nsaddr t id): This function is responsible for handling the link failure. It first checks the DestCount, if It is equal to 0
then remove the lost neighbor. Otherwise, if DestCount > 0 then send
the error by calling sendError() function, else frees the packet up.
• void rt purge(void): This function is responsible for purging the routing
table entries from the routing table. For each route, this function will check
whether the route has expired or not. If It founds that the valid route
is expired, It will purge all the packets from send buffer and invalidate
the route, by dropping the packets and tracing DROP RTR NO ROUTE
”NRTE” in the trace file. If It founds that the valid route is not expired
and there are packets in the sendbuffer waiting, It will forward them.
Finally, if It founds that the route is down and if there is a packet for this
destination waiting in the sendbuffer, It will call sendRequest() function.

8
• void enque(aodv rt entry *rt, Packet *p): Use to enqueue the packet.
• Packet* deque(aodv rt entry *rt): Use to dequeue the packet.

5.3.3

Functions for Neighbors Management

• void nb insert(nsaddr t id): This function is used to insert the neighbor.
• AODV Neighbor* nb lookup(nsaddr t id): This function is used to lookup
the neighbor.
• void nb delete(nsaddr t id): This function is used to delete the neighbor
and It is called when a neighbor is no longer reachable.
• void nb purge(void): This function purges all timed-out neighbor entries
and It runs every
HELLO INTERVAL * 1.5 seconds.

5.3.4

Functions for Broadcast ID Management

• void id insert(nsaddr t id, u int32 t bid): This function is used to insert
the broadcast ID of the node.
• bool id lookup(nsaddr t id, u int32 t bid): This function is used to lookup
the broadcast ID.
• void id purge(void): This function is used to purge the broadcast ID.

5.3.5

Functions for Packet Transmission Management

• void forward(aodv rt entry *rt, Packet *p, double delay): This function
is used to forward the packets.
• void sendHello(void): This function is responsible for sending the Hello
messages in a broadcast fashion.
• void sendRequest(nsaddr t dst): This function is used to send Request
messages.
• void sendReply(nsaddr t ipdst, u int32 t hop count,nsaddr t rpdst, u int32 t
rpseq,u int32 t lifetime, double timestamp): This function is used to send
Reply messages.
9
• void sendError(Packet *p, bool jitter = true): This function is used to
send Error messages.

5.3.6

Functions for Packet Reception Management

• AODV::recvAODV(Packet *p): This function classify the incoming AODV
packets. If the incoming packet is of type RREQ, RREP, RERR, HELLO,
It will call recvRequest(p), recvReply(p), recvError(p), and recvHello(p)
functions respectively.
• AODV::recvRequest(Packet *p): When a node receives a packet of type
REQUEST, it calls this function.
• AODV::recvReply(Packet *p): When a node receives a packet of type
REPLY, it calls this function.
• AODV::recvError(Packet *p): This function is called when a node receives
an ERROR message.
• AODV::recvHello(Packet *p): This function receives the HELLO packets
and look into the neighbor list, if the node is not present in the neighbor
list, It inserts the neighbor, otherwise if the neighbor is present in the
neighbor list, set its expiry time to:
CURRENT TIME + (1.5 * ALLOWED HELLO LOSS * HELLO INTERVAL),
where ALLOWED HELLO LOSS = 3 packets and HELLO INTERVAL
= 1000 ms.

References
[1] [Online]. Available: http://www.isi.edu/nsnam/ns/
[2] C. E. Perkins and E. M. Royer, “The ad hoc on-demand distance vector
protocol,” in Ad hoc Networking, Addison-Wesley, pp. 173–219, 2000.
[3] [Online]. Available: http://www-rp.lip6.fr/ns-doc/ns226-doc/html/aodv 8cc-source.htm
[4] [Online]. Available: http://www.cs.binghamton.edu/∼kliu/research/ns2code/
[5] K. Fall, “The ns manual (formerly ns notes and documentation),” 2008.

10
6

Appendex : A Simple TCL Script to Run the
AODV Protocol

# wireless-aodv.tcl
# A 3 nodes example for ad hoc simulation with AODV
# Define options
set val(chan)
Channel/WirelessChannel;# channel type
set val(prop)
Propagation/TwoRayGround;# radio-propagation model
set val(netif)
Phy/WirelessPhy ;# network interface type
set val(mac)
Mac/802 11 ;# MAC type
set val(ifq)
Queue/DropTail/PriQueue ;# interface queue type
set val(ll)
LL ;# link layer type
set val(ant)
Antenna/OmniAntenna ;# antenna model
set val(ifqlen)
50 ;# max packet in ifq
set val(nn)
3 ;# number of mobilenodes
set val(rp)
AODV ;# routing protocol
set val(x)
500 ;# X dimension of topography
set val(y)
400 ;# Y dimension of topography
set val(stop)
150 ;# time of simulation end
set ns
[new Simulator]
set tracefd
[open simple.tr w]
set namtrace
[open simwrls.nam w]
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load flatgrid $val(x) $val(y)
create-god $val(nn)
# Create nn mobilenodes [$val(nn)] and attach them to the channel.
set chan 1 [new $val(chan)]
# configure the nodes
$ns node-config -adhocRouting $val(rp) 
-llType $val(ll) 
-macType $val(mac) 
-channel $chan 1 
-ifqType $val(ifq) 
-ifqLen $val(ifqlen) 
-antType $val(ant) 
-propType $val(prop) 
-phyType $val(netif) 
-topoInstance $topo 
-agentTrace ON 
-routerTrace ON 
-macTrace OFF
-movementTrace ON 
for {set i 0} {$i <$val(nn) } { incr i } {
set node ($i) [$ns node]
}
# Provide initial location of mobilenodes
$node (0) set X 5.0
$node (0) set Y 5.0
$node (0) set Z 0.0
$node (1) set X 490.0
$node (1) set Y 285.0
$node (1) set Z 0.0
$node (2) set X 150.0
$node (2) set Y 240.0
$node (2) set Z 0.0
# Generation of movements
$ns at 10.0 “$node (0) setdest 250.0 250.0 3.0”
$ns at 15.0 “$node (1) setdest 45.0 285.0 5.0”
$ns at 110.0 “$node (0) setdest 480.0 300.0 5.0”
# Set a TCP connection between node (0) and node (1)
set tcp [new Agent/TCP/Newreno]
$tcp set class 2
set sink [new Agent/TCPSink]
$ns attach-agent $node (0) $tcp
$ns attach-agent $node (1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 “$ftp start”
# Define node initial position in nam
for {set i 0} {$i <$val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial node pos $node ($i) 30
}
# Telling nodes when the simulation ends
for {set i 0} {$i <$val(nn) } { incr i } {
$ns at $val(stop) “$node ($i) reset”;
}
# ending nam and the simulation
$ns at $val(stop) “$ns nam-end-wireless $val(stop)”
$ns at $val(stop) “stop”
$ns at 150.01“puts “end simulation” ; $ns halt”
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
}
$ns run

More Related Content

What's hot

Working with NS2
Working with NS2Working with NS2
Working with NS2chanchal214
 
Spanning Tree Protocol
Spanning Tree ProtocolSpanning Tree Protocol
Spanning Tree ProtocolManoj Gharate
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)NYversity
 
От Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовОт Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовYandex
 
Вениамин Гвоздиков: Особенности использования DTrace
Вениамин Гвоздиков: Особенности использования DTrace Вениамин Гвоздиков: Особенности использования DTrace
Вениамин Гвоздиков: Особенности использования DTrace Yandex
 
Chap 06 delivery and routing of ip packets
Chap 06 delivery and routing of ip packetsChap 06 delivery and routing of ip packets
Chap 06 delivery and routing of ip packetsNoctorous Jamal
 
Csphtp1 14
Csphtp1 14Csphtp1 14
Csphtp1 14HUST
 
От Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовОт Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовYandex
 
5 stream ciphers
5 stream ciphers5 stream ciphers
5 stream ciphersHarish Sahu
 
Bridge Protocol Data Unit (BPDU) Frame Format
Bridge Protocol Data Unit (BPDU) Frame FormatBridge Protocol Data Unit (BPDU) Frame Format
Bridge Protocol Data Unit (BPDU) Frame FormatNetProtocol Xpert
 
Simulation of a Wireless Sub Network using QualNET
Simulation of a Wireless Sub Network using QualNETSimulation of a Wireless Sub Network using QualNET
Simulation of a Wireless Sub Network using QualNETDaksh Raj Chopra
 
Part 8 : TCP and Congestion control
Part 8 : TCP and Congestion controlPart 8 : TCP and Congestion control
Part 8 : TCP and Congestion controlOlivier Bonaventure
 
Aspect Mining for Large Systems
Aspect Mining for Large SystemsAspect Mining for Large Systems
Aspect Mining for Large SystemsThomas Zimmermann
 

What's hot (20)

Working with NS2
Working with NS2Working with NS2
Working with NS2
 
Spanning Tree Protocol
Spanning Tree ProtocolSpanning Tree Protocol
Spanning Tree Protocol
 
Practice
PracticePractice
Practice
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)
 
Cp7 rpc
Cp7 rpcCp7 rpc
Cp7 rpc
 
От Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовОт Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей Родионов
 
Вениамин Гвоздиков: Особенности использования DTrace
Вениамин Гвоздиков: Особенности использования DTrace Вениамин Гвоздиков: Особенности использования DTrace
Вениамин Гвоздиков: Особенности использования DTrace
 
Chap 06 delivery and routing of ip packets
Chap 06 delivery and routing of ip packetsChap 06 delivery and routing of ip packets
Chap 06 delivery and routing of ip packets
 
Csphtp1 14
Csphtp1 14Csphtp1 14
Csphtp1 14
 
От Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей РодионовОт Java Threads к лямбдам, Андрей Родионов
От Java Threads к лямбдам, Андрей Родионов
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 
5 stream ciphers
5 stream ciphers5 stream ciphers
5 stream ciphers
 
Bridge Protocol Data Unit (BPDU) Frame Format
Bridge Protocol Data Unit (BPDU) Frame FormatBridge Protocol Data Unit (BPDU) Frame Format
Bridge Protocol Data Unit (BPDU) Frame Format
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Micro project on ARQ
Micro project on ARQMicro project on ARQ
Micro project on ARQ
 
Simulation of a Wireless Sub Network using QualNET
Simulation of a Wireless Sub Network using QualNETSimulation of a Wireless Sub Network using QualNET
Simulation of a Wireless Sub Network using QualNET
 
Part 8 : TCP and Congestion control
Part 8 : TCP and Congestion controlPart 8 : TCP and Congestion control
Part 8 : TCP and Congestion control
 
Aspect Mining for Large Systems
Aspect Mining for Large SystemsAspect Mining for Large Systems
Aspect Mining for Large Systems
 
7. protocols
7. protocols7. protocols
7. protocols
 
Chap 09 icmp
Chap 09 icmpChap 09 icmp
Chap 09 icmp
 

Viewers also liked (13)

Видове кредит
Видове кредитВидове кредит
Видове кредит
 
Location call sheet
Location call sheetLocation call sheet
Location call sheet
 
Einkauf und Lieferantenmanagement Erfolgsfaktor im Verlag
Einkauf und Lieferantenmanagement Erfolgsfaktor im VerlagEinkauf und Lieferantenmanagement Erfolgsfaktor im Verlag
Einkauf und Lieferantenmanagement Erfolgsfaktor im Verlag
 
Global Expert In Cable Joints Manufacturers & Supplier
 Global Expert In Cable Joints Manufacturers & Supplier Global Expert In Cable Joints Manufacturers & Supplier
Global Expert In Cable Joints Manufacturers & Supplier
 
Deporte para todos en Chipiona 2013 14
Deporte  para todos en Chipiona   2013 14Deporte  para todos en Chipiona   2013 14
Deporte para todos en Chipiona 2013 14
 
Семеен бюджет
Семеен бюджетСемеен бюджет
Семеен бюджет
 
Innovazione e competitività in Lombardia: il Programma Operativo Regionale
 	Innovazione e competitività in Lombardia: il Programma Operativo Regionale  	Innovazione e competitività in Lombardia: il Programma Operativo Regionale
Innovazione e competitività in Lombardia: il Programma Operativo Regionale
 
Programming Paradigms Seminar 1
Programming Paradigms Seminar 1Programming Paradigms Seminar 1
Programming Paradigms Seminar 1
 
SOS Infertilitatea 2013 Subprogramul FIV trebuie sa continue!
SOS Infertilitatea 2013 Subprogramul FIV trebuie sa continue!SOS Infertilitatea 2013 Subprogramul FIV trebuie sa continue!
SOS Infertilitatea 2013 Subprogramul FIV trebuie sa continue!
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
IED Open Day | Linee Guida
IED Open Day | Linee GuidaIED Open Day | Linee Guida
IED Open Day | Linee Guida
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
20320130405016
2032013040501620320130405016
20320130405016
 

Similar to Certification

Networking in college
Networking in collegeNetworking in college
Networking in collegeHarpreet Gaba
 
Run Run Trema Test
Run Run Trema TestRun Run Trema Test
Run Run Trema TestHiroshi Ota
 
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystemDCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystemrudndccn
 
New Scheme for Secured Routing in MANET
New Scheme for Secured Routing in MANET New Scheme for Secured Routing in MANET
New Scheme for Secured Routing in MANET IJCSEA Journal
 
IRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation ToolsIRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation ToolsIRJET Journal
 
DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN
DCCN 2016 - Tutorial 1 - Communication with LAN/WLANDCCN 2016 - Tutorial 1 - Communication with LAN/WLAN
DCCN 2016 - Tutorial 1 - Communication with LAN/WLANrudndccn
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...ijceronline
 
dnp3 Protocol Outstation Server IED RTU Simulator user manual
dnp3  Protocol Outstation Server IED RTU Simulator user manualdnp3  Protocol Outstation Server IED RTU Simulator user manual
dnp3 Protocol Outstation Server IED RTU Simulator user manualFreyrSCADA Embedded Solution
 
running stable diffusion on android
running stable diffusion on androidrunning stable diffusion on android
running stable diffusion on androidKoan-Sin Tan
 
Lab 9 instructions
Lab 9 instructionsLab 9 instructions
Lab 9 instructionstrayyoo
 
RIP Routing Information Protocol Extreme Networks
RIP Routing Information Protocol Extreme NetworksRIP Routing Information Protocol Extreme Networks
RIP Routing Information Protocol Extreme NetworksDani Royman Simanjuntak
 
ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...
ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...
ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...cscpconf
 
Technical Overview of QUIC
Technical  Overview of QUICTechnical  Overview of QUIC
Technical Overview of QUICshigeki_ohtsu
 
Cassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewCassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewJoshua McKenzie
 

Similar to Certification (20)

My paper
My paperMy paper
My paper
 
Ns2 introduction 2
Ns2 introduction 2Ns2 introduction 2
Ns2 introduction 2
 
Networking in college
Networking in collegeNetworking in college
Networking in college
 
Run Run Trema Test
Run Run Trema TestRun Run Trema Test
Run Run Trema Test
 
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystemDCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
DCCN 2016 - Tutorial 2 - 4G for SmartGrid ecosystem
 
New Scheme for Secured Routing in MANET
New Scheme for Secured Routing in MANET New Scheme for Secured Routing in MANET
New Scheme for Secured Routing in MANET
 
IRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation ToolsIRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
 
DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN
DCCN 2016 - Tutorial 1 - Communication with LAN/WLANDCCN 2016 - Tutorial 1 - Communication with LAN/WLAN
DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN
 
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 IJCER (www.ijceronline.com) International Journal of computational Engineeri... IJCER (www.ijceronline.com) International Journal of computational Engineeri...
IJCER (www.ijceronline.com) International Journal of computational Engineeri...
 
Virtual lab - Routing in Mobile Adhoc Networks
Virtual lab - Routing in Mobile Adhoc NetworksVirtual lab - Routing in Mobile Adhoc Networks
Virtual lab - Routing in Mobile Adhoc Networks
 
dnp3 Protocol Outstation Server IED RTU Simulator user manual
dnp3  Protocol Outstation Server IED RTU Simulator user manualdnp3  Protocol Outstation Server IED RTU Simulator user manual
dnp3 Protocol Outstation Server IED RTU Simulator user manual
 
running stable diffusion on android
running stable diffusion on androidrunning stable diffusion on android
running stable diffusion on android
 
Lab 9 instructions
Lab 9 instructionsLab 9 instructions
Lab 9 instructions
 
cscn1819.pdf
cscn1819.pdfcscn1819.pdf
cscn1819.pdf
 
Glomosim scenarios
Glomosim scenariosGlomosim scenarios
Glomosim scenarios
 
Ns2
Ns2Ns2
Ns2
 
RIP Routing Information Protocol Extreme Networks
RIP Routing Information Protocol Extreme NetworksRIP Routing Information Protocol Extreme Networks
RIP Routing Information Protocol Extreme Networks
 
ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...
ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...
ASSURED NEIGHBOR BASED COUNTER PROTOCOL ON MAC-LAYER PROVIDING SECURITY IN MO...
 
Technical Overview of QUIC
Technical  Overview of QUICTechnical  Overview of QUIC
Technical Overview of QUIC
 
Cassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewCassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, Overview
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Certification

  • 1. arXiv:1007.4065v2 [cs.NI] 26 Jul 2010 A Tutorial on the Implementation of Ad-hoc On Demand Distance Vector (AODV) Protocol in Network Simulator (NS-2) Mubashir Husain Rehmani, Sidney Doria, and Mustapha Reda Senouci ∗ Version 1 28th June 2009 ∗ M. H. Rehmani is with INRIA, France, e-mail: mubashir.rehmani@inria.fr; S. Doria is with UFCG, Brazil, e-mail: sidney@dsc.ufcg.edu.br; M. R. Senouci is with Laboratory of Research in Artificial Intelligence, Algeria, email: mrsenouci@gmail.com; Special thanks to Hajer Ferjani, she has a Masters Degree in Networking from the National School of Computer Science of Tunisia, CRISTAL Laboratory in 2006, Tunisia, e-mail: f.hajer@gmail.com. The author would like to thanks Aline Carneiro Viana, who is with INRIA, France, e-mail: aline.viana@inria.fr; 1
  • 2. Contents 1 Introduction 3 2 File Dependency of AODV Protocol 3 3 Flow of AODV 3 4 Trace Format of AODV 5 5 Main Implementation Files aodv.cc and aodv.h 5.1 How to Enable Hello Packets . . . . . . . . . . . . . . . 5.2 Timers Used . . . . . . . . . . . . . . . . . . . . . . . . 5.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.1 General Functions . . . . . . . . . . . . . . . . . 5.3.2 Functions for Routing Table Management . . . . 5.3.3 Functions for Neighbors Management . . . . . . 5.3.4 Functions for Broadcast ID Management . . . . 5.3.5 Functions for Packet Transmission Management 5.3.6 Functions for Packet Reception Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 6 7 7 7 8 9 9 9 10 6 Appendex : A Simple TCL Script to Run the AODV Protocol 11 2
  • 3. Abstract The Network Simulator (NS-2) is a most widely used network simulator. It has the capabilities to simulate a range of networks including wired and wireless networks. In this tutorial, we present the implementation of Ad Hoc On-Demand Distance Vector (AODV) Protocol in NS-2. This tutorial is targeted to the novice user who wants to understand the implementation of AODV Protocol in NS-2. 1 Introduction The Network Simulator (NS-2) [1] is a most widely used network simulator. This tutorial presents the implementation of Ad Hoc On-Demand Distance Vector (AODV) Protocol [2] in NS-2. The expected audience are students who want to understand the code of AODV and researchers who want to extend the AODV protocol or create new routing protocols in NS-2. The version considered is NS-2.32 and 2.33, but it might be useful to other versions as well. Throughout the rest of this tutorial, the under considered files are aodv.cc, aodv.h, aodv logs.cc, aodv packet.h, aodv rqueue.cc, aodv rqueue.h, aodv rtable.cc, aodv rtable.h which can be found in AODV folder in the NS-2 base directory. 2 File Dependency of AODV Protocol Fig. 1 and 2 shows the file dependency of AODV Protocol [3]. As AODV is a routing protocol, so it is derived from the class Agent, see agent.h. Figure 1: File Reference of ‘AODV.CC’. 3 Flow of AODV In this section, we describes the general flow of AODV protocol through a simple example: 3
  • 4. Figure 2: File Reference of ‘AODV.H’. 1. In the TCL script, when the user configures AODV as a routing protocol by using the command, $ns node-config -adhocRouting AODV the pointer moves to the “start” and this “start” moves the pointer to the Command function of AODV protocol. 2. In the Command function, the user can find two timers in the “start” * btimer.handle((Event*) 0); * htimer.handle((Event*) 0); 3. Let’s consider the case of htimer, the flow points to HelloTimer::handle(Event*) function and the user can see the following lines: agent -> sendHello(); double interval = MinHelloInterval + ((MaxHelloInterval - MinHelloInterval) * Random::uniform()); assert(interval -> = 0); Scheduler::instance().schedule(this, &intr, interval); These lines are calling the sendHello() function by setting the appropriate interval of Hello Packets. 4. Now, the pointer is in AODV::sendHello() function and the user can see Scheduler::instance().schedule(target , p, 0.0) which will schedule the packets. 5. In the destination node AODV::recv(Packet*p, Handler*) is called, but actually this is done after the node is receiving a packet. 4
  • 5. 6. AODV::recv(Packet*p, Handler*) function then calls the recvAODV(p) function. 7. Hence, the flow goes to the AODV::recvAODV(Packet *p) function, which will check different packets types and call the respective function. 8. In this example, flow can go to case AODVTYPE HELLO: recvHello(p); break; 9. Finally, in the recvHello() function, the packet is received. 4 Trace Format of AODV In NS-2, the general trace format is given as below: s 0.000000000 0 RTR — 0 AODV 44 [0 0 0 0] ——- [0:255 -1:255 1 0] [0x1 1 [0 2] 4.000000] (HELLO) s 10.000000000 0 RTR — 0 AODV 48 [0 0 0 0] ——- [0:255 -1:255 30 0] [0x2 1 1 [1 0] [0 4]] (REQUEST) s 21.500000000 0 RTR — 0 AODV 48 [0 0 0 0] ——- [0:255 -1:255 30 0] [0x2 1 4 [1 0] [0 12]] (REQUEST) r 21.501260809 2 RTR — 0 AODV 48 [0 ffffffff 0 800] ——- [0:255 -1:255 30 0] [0x2 1 4 [1 0] [0 12]] (REQUEST) The interpretation of the following trace format is as follows: r 21.501260809 2 RTR — 0 AODV 48 [0 ffffffff 0 800] ——- [0:255 -1:255 30 0] [0x2 1 4 [1 0] [0 12]] (REQUEST) Node ID 2, receives a packet type REQUEST (AODV protocol), at layer RTR (routing), at time 21.501260809. This packet have sequence number 0. A generalized explanation of trace format [4] would be as follows : 5
  • 6. Column Number 1 2 3 4 5 6 What Happened? Values for instance... It shows the cured event Time at which event occured? Node at which event occured? Layer at which event occured? oc- ’s’ SEND, ’r’ RECEIVED, ’D’ DROPPED the 10.000000000 the Node id like 0 the ’AGT’ application layer, ’RTR’ routing layer, ’LL’ link layer, ’IFQ’ Interface queue, ’MAC’ mac layer, ’PHY’ physical layer — 0 show flags shows the sequence number of packets shows the packet type 7 8 9 5.1 [....] 10 11 5 shows size of the packet show flags [....] ’cbr’ CBR packet, ’DSR’ DSR packet, ’RTS’ RTS packet generated by MAC layer, ’ARP’ link layer ARP packet Packet size increases when a packet moves from an upper layer to a lower layer and decreases when a packet moves from a lower layer to an upper layer It shows information about packet duration, mac address of destination, the mac address of source, and the mac type of the packet body. — It shows information about source node ip : port number, destination node ip (-1 means broadcast) : port number, ip header ttl, and ip of next hop (0 means node 0 or broadcast). Main Implementation Files aodv.cc and aodv.h How to Enable Hello Packets By default HELLO packets are disabled in the aodv protocol. To enable broadcasting of Hello packets, comment the following two lines present in aodv.cc #ifndef AODV LINK LAYER DETECTION #endif LINK LAYER DETECTION and recompile ns2 by using the following commands on the terminal: make clean make sudo make install 6
  • 7. 5.2 Timers Used In ns2, timers are used to delay actions or can also be used for the repetition of a particular action like broadcasting of Hello packets after fixed time interval. Following are the timers that are used in AODV protocol implementation: • Broadcast Timer: This timer is responsible for purging the ID’s of Nodes and schedule after every BCAST ID SAVE. • Hello Timer: It is responsible for sending of Hello Packets with a delay value equal to interval, where double interval = MinHelloInterval + ((MaxHelloInterval - MinHelloInterval) * Random::uniform()); • Neighbor Timer: Purges all timed-out neighbor entries and schedule after every HELLO INTERVAL . • RouteCache Timer: This timer is responsible for purging the route from the routing table and schedule after every FREQUENCY. • Local Repair Timer: This timer is responsible for repairing the routes. 5.3 5.3.1 Functions General Functions • void recv(Packet *p, Handler *): At the network layer, the Packet is first received at the recv() function, sended by the MAC layer in up direction. The recv() function will check the packet type. If the packet type is AODV type, it will decrease the TTL and call the recvAODV() function. If the node itself generating the packet then add the IP header to handle broadcasting, otherwise check the routing loop, if routing loop is present then drop the packet, otherwise forward the packet. • int command(int, const char *const *): Every object created in NS-2 establishes an instance procedure, cmd{} as a hook to executing methods through the compiled shadow object. This procedure cmd invokes the method command() of the shadow object automatically, passes the arguments to cmd{} as an argument vector to the command() method [5]. 7
  • 8. 5.3.2 Functions for Routing Table Management • void rt resolve(Packet *p): This function first set the transmit failure callback and then forward the packet if the route is up else check if I am the source of the packet and then do a Route Request, else if the local repair is in progress then buffer the packet. If this function founds that it has to forward a packet for someone else to which it does not have a route then drop the packet and send error upstream. Now after this, the route errors are broadcasted to the upstream neighbors. • void rt update(aodv rt entry *rt, u int32 t seqnum,u int16 t metric, nsaddr t nexthop,double expire time): This function is responsible for updating the route. • void rt down(aodv rt entry *rt): This function first confirms that the route should not be down more than once and after that down the route. • void local rt repair(aodv rt entry *rt, Packet *p): This function first buffer the packet and mark the route as under repair and send a RREQ packet by calling the sendRequest() function. • void rt ll failed(Packet *p): Basically this function is invoked whenever the link layer reports a route failure. This function drops the packet if link layer is not detected. Otherwise, if link layer is detected, drop the non-data packets and broadcast packets. If this function founds that the broken link is closer to the destination than source then It will try to attempt a local repair, else brings down the route. • void handle link failure(nsaddr t id): This function is responsible for handling the link failure. It first checks the DestCount, if It is equal to 0 then remove the lost neighbor. Otherwise, if DestCount > 0 then send the error by calling sendError() function, else frees the packet up. • void rt purge(void): This function is responsible for purging the routing table entries from the routing table. For each route, this function will check whether the route has expired or not. If It founds that the valid route is expired, It will purge all the packets from send buffer and invalidate the route, by dropping the packets and tracing DROP RTR NO ROUTE ”NRTE” in the trace file. If It founds that the valid route is not expired and there are packets in the sendbuffer waiting, It will forward them. Finally, if It founds that the route is down and if there is a packet for this destination waiting in the sendbuffer, It will call sendRequest() function. 8
  • 9. • void enque(aodv rt entry *rt, Packet *p): Use to enqueue the packet. • Packet* deque(aodv rt entry *rt): Use to dequeue the packet. 5.3.3 Functions for Neighbors Management • void nb insert(nsaddr t id): This function is used to insert the neighbor. • AODV Neighbor* nb lookup(nsaddr t id): This function is used to lookup the neighbor. • void nb delete(nsaddr t id): This function is used to delete the neighbor and It is called when a neighbor is no longer reachable. • void nb purge(void): This function purges all timed-out neighbor entries and It runs every HELLO INTERVAL * 1.5 seconds. 5.3.4 Functions for Broadcast ID Management • void id insert(nsaddr t id, u int32 t bid): This function is used to insert the broadcast ID of the node. • bool id lookup(nsaddr t id, u int32 t bid): This function is used to lookup the broadcast ID. • void id purge(void): This function is used to purge the broadcast ID. 5.3.5 Functions for Packet Transmission Management • void forward(aodv rt entry *rt, Packet *p, double delay): This function is used to forward the packets. • void sendHello(void): This function is responsible for sending the Hello messages in a broadcast fashion. • void sendRequest(nsaddr t dst): This function is used to send Request messages. • void sendReply(nsaddr t ipdst, u int32 t hop count,nsaddr t rpdst, u int32 t rpseq,u int32 t lifetime, double timestamp): This function is used to send Reply messages. 9
  • 10. • void sendError(Packet *p, bool jitter = true): This function is used to send Error messages. 5.3.6 Functions for Packet Reception Management • AODV::recvAODV(Packet *p): This function classify the incoming AODV packets. If the incoming packet is of type RREQ, RREP, RERR, HELLO, It will call recvRequest(p), recvReply(p), recvError(p), and recvHello(p) functions respectively. • AODV::recvRequest(Packet *p): When a node receives a packet of type REQUEST, it calls this function. • AODV::recvReply(Packet *p): When a node receives a packet of type REPLY, it calls this function. • AODV::recvError(Packet *p): This function is called when a node receives an ERROR message. • AODV::recvHello(Packet *p): This function receives the HELLO packets and look into the neighbor list, if the node is not present in the neighbor list, It inserts the neighbor, otherwise if the neighbor is present in the neighbor list, set its expiry time to: CURRENT TIME + (1.5 * ALLOWED HELLO LOSS * HELLO INTERVAL), where ALLOWED HELLO LOSS = 3 packets and HELLO INTERVAL = 1000 ms. References [1] [Online]. Available: http://www.isi.edu/nsnam/ns/ [2] C. E. Perkins and E. M. Royer, “The ad hoc on-demand distance vector protocol,” in Ad hoc Networking, Addison-Wesley, pp. 173–219, 2000. [3] [Online]. Available: http://www-rp.lip6.fr/ns-doc/ns226-doc/html/aodv 8cc-source.htm [4] [Online]. Available: http://www.cs.binghamton.edu/∼kliu/research/ns2code/ [5] K. Fall, “The ns manual (formerly ns notes and documentation),” 2008. 10
  • 11. 6 Appendex : A Simple TCL Script to Run the AODV Protocol # wireless-aodv.tcl # A 3 nodes example for ad hoc simulation with AODV # Define options set val(chan) Channel/WirelessChannel;# channel type set val(prop) Propagation/TwoRayGround;# radio-propagation model set val(netif) Phy/WirelessPhy ;# network interface type set val(mac) Mac/802 11 ;# MAC type set val(ifq) Queue/DropTail/PriQueue ;# interface queue type set val(ll) LL ;# link layer type set val(ant) Antenna/OmniAntenna ;# antenna model set val(ifqlen) 50 ;# max packet in ifq set val(nn) 3 ;# number of mobilenodes set val(rp) AODV ;# routing protocol set val(x) 500 ;# X dimension of topography set val(y) 400 ;# Y dimension of topography set val(stop) 150 ;# time of simulation end set ns [new Simulator] set tracefd [open simple.tr w] set namtrace [open simwrls.nam w] $ns trace-all $tracefd $ns namtrace-all-wireless $namtrace $val(x) $val(y) # set up topography object set topo [new Topography] $topo load flatgrid $val(x) $val(y) create-god $val(nn) # Create nn mobilenodes [$val(nn)] and attach them to the channel. set chan 1 [new $val(chan)] # configure the nodes $ns node-config -adhocRouting $val(rp) -llType $val(ll) -macType $val(mac) -channel $chan 1 -ifqType $val(ifq) -ifqLen $val(ifqlen) -antType $val(ant) -propType $val(prop) -phyType $val(netif) -topoInstance $topo -agentTrace ON -routerTrace ON -macTrace OFF
  • 12. -movementTrace ON for {set i 0} {$i <$val(nn) } { incr i } { set node ($i) [$ns node] } # Provide initial location of mobilenodes $node (0) set X 5.0 $node (0) set Y 5.0 $node (0) set Z 0.0 $node (1) set X 490.0 $node (1) set Y 285.0 $node (1) set Z 0.0 $node (2) set X 150.0 $node (2) set Y 240.0 $node (2) set Z 0.0 # Generation of movements $ns at 10.0 “$node (0) setdest 250.0 250.0 3.0” $ns at 15.0 “$node (1) setdest 45.0 285.0 5.0” $ns at 110.0 “$node (0) setdest 480.0 300.0 5.0” # Set a TCP connection between node (0) and node (1) set tcp [new Agent/TCP/Newreno] $tcp set class 2 set sink [new Agent/TCPSink] $ns attach-agent $node (0) $tcp $ns attach-agent $node (1) $sink $ns connect $tcp $sink set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 10.0 “$ftp start” # Define node initial position in nam for {set i 0} {$i <$val(nn)} { incr i } { # 30 defines the node size for nam $ns initial node pos $node ($i) 30 } # Telling nodes when the simulation ends for {set i 0} {$i <$val(nn) } { incr i } { $ns at $val(stop) “$node ($i) reset”; } # ending nam and the simulation $ns at $val(stop) “$ns nam-end-wireless $val(stop)”
  • 13. $ns at $val(stop) “stop” $ns at 150.01“puts “end simulation” ; $ns halt” proc stop {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace } $ns run