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