[ns] How to access mac layer in c++ of ns2
Daniel Dekst
dolkoff at yahoo.com.cn
Thu Oct 16 06:09:02 PDT 2008
Hi,
Yes, if we want to use mac functions, we first need to include mac header file
#include<mac-802_11.h>
But a problem is that we need to acquire the pointer of Class Mac802_11 so that we can access the variables or functions.
For physical layer you want to know, it is easy.
You can see in node.h it provides a list of phys, so if you acquire the pointer of the list, then you can use it.
in your .h
#include<mobilenode>
in your Class
MobileNode* node_;
then in your .cc you can
WirelessPhy* physicalLayer = (WirelessPhy*) (node_->ifhead()).lh_first;
physicalLayer->node_off();
Best,
Pei
Basim Javed <basimjaved at gmail.com> wrote£º
hi
As I know of, u can access the MAC layer, by declaring the mac header files where u want to use the mac functions. Similarly u should be able to use functions of any layer.
I wonder what is the idea behind your approach...plz tell more about it, as it looks ok to me, as well.
best
basima
2008/10/16 Daniel Dekst <dolkoff at yahoo.com.cn>
Hi, everyone,
I know how to access physical layer since Class Node provides a variable ifhead_ for list of phys.
So
WirelessPhy* physicalLayer = (WirelessPhy*)(node_->ifhead()).lh_first;
works.
But it does not provide list of mac, thus can I access mac layer similar as above?
I know tcl may work by calling mac layer and then again use tcl to return the desired value, but is there any method to access it directly using c++?
Best,
Pei
Pei Huang, Ph.D. student
Dept. of Computer Science and Engineering
Michigan State University
http://dekst.awardspace.com
---------------------------------
ÑÅ»¢ÓÊÏ䣬ÄúµÄÖÕÉúÓÊÏ䣡
More information about the Ns-users
mailing list