[ns] How to access mac layer in c++ of ns2
Daniel Dekst
dolkoff at yahoo.com.cn
Fri Oct 17 23:08:07 PDT 2008
Hi,
I have never done anything with TCP layer, so I'm not sure.
But a general rule I summarized is that
1) If the two layers you want to cross-access are adjacent, you can use uptarget_/downtarget_
2) If they are not, it is a bit of difficult to make the pointer clear. My method is to use tcl to get the pointer. You must have seen the usage of TclObject::lookup() many times.
My case is to let my SensorAgent to access Mac802_11, thus
in my sensor-agent.cc (can be others such as aodv.cc)
implement a command
if (strcmp(argv[1], "access-mac") == 0) {
mac_pt_ = (Mac802_11*)TclObject::lookup(argv[2]);
if (mac_pt_ == 0)
return TCL_ERROR;
return TCL_OK;
}
here mac_pt_ is defined in sensor-agent.h
Mac802_11 *mac_pt_
you may also need to declare Mac802_11 as friend class.
Once you execute the following command in your tcl file, mac_pt_ gets the right pointer and you can use it now.
$sensoragent_($i) access-mac [$node_($i) set mac_(0)]
vice versa
set mac_ [$node_($i) set mac_(0)]
$mac_ access-agent [$node_($i) agent 255]
you implement "access-agent" command in mac layer
so the point is that you need to know how to get TCP
set tcp_ ???
Best,
Pei
Basim Javed <basimjaved at gmail.com> wrote£º
I just read, and you are correct.
Could u plz also tell me how to access the TCP layer from the node pointers in C++, and how does we know that this is the current node (some thing like self)? So I want each node to access the TCP and PHY layers from within itself, and also the reverse of it: i.e. within TCP I want to access the MAC functions of the concerned node, if possible?
thanks many.
basim
Pei Huang, Ph.D. student
Dept. of Computer Science and Engineering
Michigan State University
http://dekst.awardspace.com
__________________________________________________
¸Ï¿ì×¢²áÑÅ»¢³¬´óÈÝÁ¿Ãâ·ÑÓÊÏä?
http://cn.mail.yahoo.com
More information about the Ns-users
mailing list