Monday, August 8, 2011

Exchanging Cross-layer information in NS2 via the Physical Layer

Accessing Phy Layer from Routing Layer.

The following steps demonstrates how to access Physical layer information from the routing protocol. The OLSR is used as an example:

a) Include in the OLSR.h header file the mobilenode.h file

#include <mobilenode.h>

then, declare a Phy object within the OLSR class

Phy* netif_;

this is possible because, Phy class is within the phy.h file, which is included in the mobilenode.h file

b) Add the following code in the command () function in aodv.cc

int
OLSR:: command (int argc, const char * const * argv) {
. . .
. . .
else if (argc == 3) {
...
...
else if (strcmp (argv [1], "access-phy") == 0) {
netif_ = (Phy *) TclObject:: lookup (argv[2]);
if (netif_ == 0) {
fprintf (stderr, "Agent: %s lookup %s failed. \n", argv[1], argv[2]);
return TCL_ERROR;
} else {
double x, y, z;
((MobileNode*) netif_->node())->getLoc(&x, &y, &z);
printf ("This node's location: %f %f \n", x, y);
return TCL_OK;
}
}
}
. . .
. . .
}

c) Sample tcl script

# get the routing protocol
set rt [$node_ agent 255]
# get the network interface
$rt access-phy [$node_ set netif_(0)]

d) netif_ can now be used from OLSR to access physical layer information


How I installed OLSR-ETX / ML / MD module for NS-2.34

This was done after I successfully installed ns2.34

$ cd ns-allinone-2.34 /ns-2.34/

$ patch -p1 < olsr.patch


$ ./configure

$ make distclean

$ ./configure

$ make

Monday, February 14, 2011

Exchanging Cross-layer information in NS2

I used this document to achieve cross-layer exchange of info in my wireless simulation in ns2. As an example, the routing layer and mac layer will be considered. This piece of code was based on the posts on the link below, but if you copy paste the code, there will be errors, and your simulation will not run. I made some corrections on the syntax and made it work in ns2.34.

http://jsun74.blogspot.com/2010/10/cross-layer-design-in-ns2-how-can.html

the author above requests that these sites be referred to instead:

http://blog.chinaunix.net/u3/94593/showart_2199303.html
http://www.baisi.net/thread-2471888-1-2.html

1. Accessing MAC Layer from Routing Layer.

Here the 802.11 mac and AODV routing protocol are used as an example:

a) Include in the aodv.h header file the mac-802_11.h file

# Include "mac/mac-802_11.h"

then, declare a mac object within the aodv class

Mac802_11 * this_mac;

b) Add the following code in the command () function in aodv.cc

int

AODV:: command (int argc, const char * const * argv) {
. . .
. . .
else if (argc == 3) {
if (strcmp (argv [1], "index") == 0) {
index = atoi (argv [2]);
return TCL_OK;
}
else if (strcmp (argv [1], "access-mac") == 0) {
this_mac = (Mac802_11 *) TclObject:: lookup (argv [2]);
if (this_mac == 0) {
fprintf (stderr, "Agent: %s lookup %s failed. \ n", argv [1], argv[2]);
return TCL_ERROR;
}
else {
printf ("This node's mac bss_id: %d \ n", this_mac-> bss_id ());
return TCL_OK;
}
}
. . .
. . .
}

c) Sample tcl script

# get the routing layer protocol
set rt ($i) [$ node_ ($ i) agent 255]
# establish access path to the mac
$rt ($i) acess-mac [$ node_ ($ i) set mac_ (0)]

d) this_mac can now be used from aodv to access 802.11 mac information

other method exists, that would be my topic on my succeding posts.

Monday, January 24, 2011

Starting a Wireless Mesh Network Simulation

This blog was part of my daily journal when I was doing my thesis during my graduate work. It might be of help to someone doing his own.

Initially, to get the feeling of mesh networking in network in simulator 2 (ns2), I set up 5 pairs of nodes using the multi-rate implementation of 802.11b as shown below:

(4) ------------------------------------> (9)


(3) ------------------------------------> (8)


(2) ------------------------------------> (7)


(1) ------------------------------------> (6) +
|
1m
|
(0) ------------------------------------> (5) +
|<-------------- 5m ------------------> |
datarate 11mbps (mode 11mb)
basicrate 1mb
routing protocol, AODV

Sending rate increases from 0.1mb, 0.4, 0.8, 1, 1.6, 2.2 mbps at times 0, 5, 10, 15, 20, 25 s respectively.
When I set up the network above and running the simulation, the nodes seemed to drop all packets right at the routing layer. One of the error said NRTE “no route ”, something that was impossible, because when only a pair would exchange data, they could find each other.

In this case, the most probable reason that all packets got dropped was that it took longer time for the mesh network routing algorithm to converge in building the network topology. Packets got dropped because the nodes have no routes for the packets being sent, as suggested by one of the errors NRTE (no route to destination). So I went back to the 5 pair mesh network set-up.

True enough, after re-scheduling transmissions of data, and aiding the nodes to build first their routing table, all node-pairs were able to exchange data. Convergence time really was longer in the multi-rate implementation (than in the default implementation). To aid the routing algorithm in building the routing topology, for the first twenty (20) seconds of the simulation, I let one node at a time send two small dummy packets every 4 seconds. Then letting, cbr applications, burst at the 30th second. Consequently, transmission and reception of cbr packets converge between the 60th and 70th second of the simulation, i.e., when all pairs are able to transmit fairly the same amount of packets.