Thursday, April 29, 2010

Accessing MAC pointers from higher layers in NS2

For my experiments, I wanted to access the (802.11) MAC pointer from the network layer (in this case a customized queue class) in order to use some MAC-layer statistics directly. I found that there are couple of ways of doing this.

1) The pointer "target_" points to the mac object being used in the simulation (see ns-mobilenode.tcl in ns2.XX/tcl/lib/). You can use this to refer to the variables of the Mac_80211 object. This is particularly useful if the layers are adjacent. For lower layers, I suppose you can use the uptarget_ and downtarget_ pointers (which aren't there in case of queue class).

2) You can read the mac object into a C++ file from the tcl script. Recall that ns2 does object binding in two languages, TCL and C++. Some pointers to it can be found here.