AODV Protocol Modification
In this post, you can learn
What is the AODV protocol
How to measure the energy, node position and node speed during AODV transmission
To understand and implement the promiscuous mode in AODV
Introduction
A mobile Adhoc network is a self-configurable multi-hop wireless network that does not depend on pre-existing infrastructure such as access points. A MANET contains several wireless nodes where each node may move randomly, choose to communicate with any node in its range directly. In order to communicate with any node not in its range, intermediate nodes act as routers to forward the packet to the destination. The characteristics of MANETs are energy-constrained, multi-hop, dynamic topology, no central authority and device heterogeneity. A node can join any network and can leave the network at any time. Due to this higher mobility, MANETs exhibit a dynamic nature in forming the topology. Basically, a MANET is self-organised, self-managed, decentralised network with no trusted third parties. Some of the applications where MANET is showing competence are military operations, emergency services, commercial environments, context aware services, linking up the internet and intranet etc [6]. But lack of central administration, security is a major concern in MANETs like nodes can behave mischievously, they may be selfish, or they try to intercept the communication. Some of the Attacks on MANETs include grey-hole attack, black-hole attack, worm-hole attack etc. The routing protocols of the network layer should address the above stated issues. Several security methods have been designed for MANETs, but most of them need an external entity to perform authentication mechanisms [13]. Many approaches have been proposed to provide security in MANETs for sensitive information.
Similarly, many routing protocols on different trust variants like bandwidth, energy utilised, processing speed, end-to-end delay, etc, are considered in many algorithms. Our approach is to route a packet to a trusted node via a trusted path using the packet forwarding ratio. We are coupling our trust model to the AODV routing protocol of MANETs. The following sections explain fundamentals in MANETs routing, our trust model and experimental results.
Routing protocols in MANETs can be classified into reactive, proactive and hybrid protocols [2]. Proactive routing protocols are table-driven, and in contras,t reactive protocols are on demand, routing information is updated only when needed. Hybrid approach is a mix of both versions [9]. The following figure lists out the classification.
Finding the node speed, Position and energy of a node
In this Chapter, the runtime information like energy, position of the nodes and speed of the nodes is computed/calculated at a particular instant of time. We have taken the AODV protocol as it is easier to configure, and it is simple to change the parameters.
When deciding to use the AODV protocol, the first step is to understand the protocol by learning it through the C++ source files that were available with the ns2 source.
Here are the locations of the AODV source codes
ns-allinone-2.35/ns-2.35/aodv/
|-- aodv.cc
|-- aodv.h
|-- aodv_logs.cc
|-- aodv_logs.o
|-- aodv.o
|-- aodv_packet.h
|-- aodv_rqueue.cc
|-- aodv_rqueue.h
|-- aodv_rqueue.o
|-- aodv_rtable.cc
|-- aodv_rtable.h
`-- aodv_rtable.o
There are .cc, .h and .o files. The .cc and .h are the source files and .o is the object file.
The header (.h) files are provided to know the functionalities of a given protocol or algorithm by specifying the data members and member functions of a given class with only definitions. The C Source files implement the functions defined in the header files.
The runtime information for a mobile node is specified in ~/ns-allinone-2.35/ns-2.35/common/mobilenode.h which has a list of functions as specified below. These functions may be included inside the AODV source files and find the required information.
Some functions of mobilenode.h
inline MobileNode*& next() { return next_; }
inline double X() { return X_; }
inline double Y() { return Y_; }
inline double Z() { return Z_; }
inline double speed() { return speed_; }
inline double dX() { return dX_; }
inline double dY() { return dY_; }
inline double dZ() { return dZ_; }
inline double destX() { return destX_; }
inline double destY() { return destY_; }
inline double radius() { return radius_; }
inline double getUpdateTime() { return position_update_time_; }
For our case 1, we are going to modify two files in the ~ns-2.35/aodv/ folder.
aodv.h
aodv.cc
Step 1: Make an entry in aodv.h
Source File : ~ns-2.35/aodv/aodv.h
Include the following header line in aodv.h in the beginning section of the file.
#include <mobilenode.h>
In the AODV class, declare the following variables (in protected scope)
double xpos; // To define the x,y and z position
double ypos;
double zpos;
double iEnergy; //to get the energy at a given instant of time
int node_speed; //to find the node speed
MobileNode *iNode; //to create a node
FILE *fp; //to get all the above information in a file for plotting
Step 2: Make an entry in aodv.cc constructor
Source File: aodv.cc
Declare the following variables inside the aodv constructor, these following variables were initialized in the aodv.h
xpos = 0.0;
ypos = 0.0;
zpos = 0.0;
node_speed = 0;
iEnergy=0.0;
fp=fopen("pradeep.csv","w");//CSV files are easily handled by spreadsheets
MobileNode *iNode;
Step 3: Make an entry in aodv.cc
In the AODV protocol, runtime information is required during packet forwarding. AODV has a forward() function that handles the code related to packet forwarding. So the function from the mobilenode.h will be called or used inside the forward() function of AODV. Locate the forward() function implementation and paste the following code
Finally, access the required functions from mobilenode.h. Paste the following lines in the void AODV::forward(aodv_rt_entry *rt, Packet *p, double delay) {
//Code by pradeepkumar
/***This code retrieves node position*****/
iNode = (MobileNode*) (Node::get_node_by_address(index));
((MobileNode *) iNode)->getLoc(&xpos,&ypos,&zpos);
//Position of %d , X, Y, Z
fprintf(fp,"%d,%f,%f,%f,", index, xpos, ypos, zpos);
/***This code retrieves the nodes velocity*****/
iNode = (MobileNode*) (Node::get_node_by_address(index));
((MobileNode *) iNode)->getVelo(&xpos, &ypos, &zpos);
//Velocity of %d , X, Y, Z
fprintf(fp,"%d,%f,%f,%f,", index, xpos, ypos, zpos);
/***This code retrieves the nodes Energy Value*****/
iNode = (MobileNode*) (Node::get_node_by_address(index));
node_speed = ((MobileNode *) iNode)->speed();
iEnergy=iNode->energy_model()->energy();
//Velocity of %d , Node Speed in m/s Energy in joules
fprintf(fp,"%d,%d,%f,", index, node_speed,iEnergy);
Step 4:
Recompile NS2 to reflect the changes done above. To recompile ns2, the detailed steps are given in Appendix A.
The simple step to recompile is,
Go to the terminal and go to the folder ~ns-2.35/
Give the command make
To verify these changes, run any Wireless TCL file with AODV as the protocol and include it with energy model codes.
Here is a simple example to test the above modification.
Once the above script runs, a file “pradeep.csv” would be created in the folder where this tcl file was interpreted.
The content of pradeep.csv is given below. All the values are separated by comma,
The first column is the index of the node, since there are 2 nodes (0 and 1 is the index)
2nd, 3rd and 4th column represents the position of the nodes
5th, 6th and 7th column represents the velocity of the node with position
8th column represents the speed in m/s
9th columns represents the energy.
0,22.511258,22.511258,0.000000,3.535534,3.535534,0.000000,5,1.618279,
0,22.511258,22.511258,0.000000,3.535534,3.535534,0.000000,5,1.618279,
0,22.552380,22.552380,0.000000,3.535534,3.535534,0.000000,5,1.614935,
0,22.552380,22.552380,0.000000,3.535534,3.535534,0.000000,5,1.614935,
0,22.575435,22.575435,0.000000,3.535534,3.535534,0.000000,5,1.613255,
1,136.365972,133.336188,0.000000,-6.332378,-7.739573,0.000000,10,1.893608,
1,136.331714,133.294317,0.000000,-6.332378,-7.739573,0.000000,10,1.893128,
1,136.298089,133.253220,0.000000,-6.332378,-7.739573,0.000000,10,1.892712,
Promiscuous Mode in AODV protocol
Promiscuous Mode in AODV
In a network, promiscuous mode allows a network device to intercept and read each network packet that arrives in its entirety. This mode of operation is sometimes given to a network snoop server that captures and saves all packets for analysis (for example, for monitoring network usage). It's often used to monitor network activity. Promiscuous mode is happening at the Mac laye,r and with the help of mac only, the promiscuous mode can be achieved in the AODV protocol.
Files to be modified are
~ns-2.35/aodv/aodv.h
~ns-2.35/aodv/aodv.cc
~ns-2.35/lib/tcl/ns-mobilenode.tcl
Step 1:
Source File: ~ns-2.35/aodv/aodv.h
Tap is a class that belongs to the mac and it is used to tap a packet when it is forwarded or transmitted. To make it happen with AODV, the aodv class should be the child class of Tap
Make AODV agent a child class of Tap (you should have a member function tap), and define the Mac variable
#include <mac.h> //added at the beginning of the aodv.h
class AODV: public Tap, public Agent {
public:
void tap(const Packet *p);
......
protected:
Mac *mac_;
FILE *fs; //to store the tapped packet information for analysis
int count;
......
}
Step 2:
Source File: ~ns-2.35/aodv/aodv.cc
In the constructor of AODV protocol, add these two lines
fs = fopen(“promis.csv”,”w”); //already the new FILE is added in the aodv.h file
count =0; //initialize the count value to 0
Define TCL command "install-tap" and implement AODV::tap()
Only when the ‘install-tap’ command is implemented, the tapping of packets will happen. To know more about, how to implement a command, refer Chapter 3 (Creation of a new agent). Already AODV command() is implemented with various commands, the new command have to be appended along with it as given below
int AODV::command(int argc, const char*const* argv) {
......
else if(argc == 3) {
......
//addition of install-tap command
else if (strcmp(argv[1], "install-tap") == 0) {
mac_ = (Mac*)TclObject::lookup(argv[2]);
if (mac_ == 0) return TCL_ERROR;
mac_->installTap(this);
return TCL_OK;
}
}
return Agent::command(argc, argv);
}
void AODV::tap(const Packet *p) {
//The following statement will print the node_id and the count packets. The last value of the corresponding node_id will be taken as the node’s tapped value.
fprintf(fs,”Node id-%d, %d”, index,count++);
}
Step 3:
Source File: ~ns-2.35/lib/tcl/ns-mobilenode.tcl
Node/MobileNode instproc add-target { agent port } {
$self instvar dmux_ imep_ toraDebug_ mac_
......
# Special processing for AODV
set aodvonly [string first "AODV" [$agent info class]]
if {$aodvonly != -1 } {
$agent if-queue [$self set ifq_(0)] ; # ifq between LL and MAC
$agent install-tap $mac_(0); # this is the place where we call the command install-tap for tapping the packets, the same line can be overridden inside the Tcl source file also.
......
}
Step 4:
Recompile NS2 by typing the command make at the ~ns-2.35/ folder and test the mode.
For testing the above, a Tcl script with AODV protocol have to be developed and to be plotted. The Listing 6.1 – Wireless network with 2 nodes was tried for this and here is the sample output for this.
In this the Node 0 consumes 1117 packets and Node 1 consumes (1133-1118) 16 packets as the node 0 is the sender node and node1 is the receiver node.
Node id-> 0, 1115
Node id-> 0, 1116
Node id-> 0, 1117
Node id-> 1, 1118
Node id-> 1, 1119
Node id-> 1, 1120
Node id-> 1, 1121
Node id-> 1, 1122
Node id-> 1, 1123
Node id-> 1, 1124
Node id-> 1, 1125
Node id-> 1, 1126
Node id-> 1, 1127
Node id-> 1, 1128
Node id-> 1, 1129
Node id-> 1, 1130
Node id-> 1, 1131
Node id-> 1, 1132
Node id-> 1, 1133
Using this promiscuous code, the network usage can be calculated.
Conclusion
This chapter deals with the two different modifications of the existing protocol in NS2. The AODV protocol is a simple and efficient in handling energy and is easy to customise. The AODV protocol is chosen for these two case studies. However, the readers are advised to try these two case studies for other protocols like DSR, DSDV and TORA. The results of all these can also be compared.
Comments
Post a Comment