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.
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.
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteYour code was very helpful..Can u help me to in transmitting the information from the mac layer to application layer??
The process should be the same.
ReplyDeleteIn step 1.a, instead of including the mac-802_11.h file into the aodv.h, include it in the header-file of your application.
# Include "mac/mac-802_11.h"
then, declare a mac object within the aodv class
Mac802_11 * this_mac;
then follow the same steps.
hiiii..
Deletethis is very helpful link i got it through a lot of browsing .....
have can i transmit the mac layer information to transport layer of tcp
plzzzzzzzzzz
ah, correction above
ReplyDeleteit should be:
then, declare a mac object within your application class
Mac802_11 * this_mac;
then follow the same steps.
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteYour code is very helpful to me. I'm working on IEEE802.11e EDCA and my cross layer is between the Udp class and the Mac802_11e class. I follow all above instructions but I got an error when I include in the udp.h header file the mac-802_11e.h file which is :
In file included from apps/udp.h:27,
from apps/udp.cc:24:
./mac/802_11e/mac-802_11e.h: At global scope:
./mac/802_11e/mac-802_11e.h:120: error: ‘ETHER_ADDR_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h:121: error: ‘ETHER_ADDR_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h:122: error: ‘ETHER_ADDR_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h: In member function ‘u_int32_t EDCA_PHY_MIB::getHdrLen11()’:
./mac/802_11e/mac-802_11e.h:160: error: ‘ETHER_FCS_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h: At global scope:
./mac/802_11e/mac-802_11e.h:209: error: expected class-name before ‘{’ token
./mac/802_11e/mac-802_11e.h:234: error: ‘MacState’ has not been declared
./mac/802_11e/mac-802_11e.h:235: error: ‘MacState’ has not been declared
./mac/802_11e/mac-802_11e.h:390: error: ‘MacState’ does not name a type
./mac/802_11e/mac-802_11e.h:391: error: ‘MacState’ does not name a type
./mac/802_11e/mac-802_11e.h: In member function ‘int Mac802_11e::initialized()’:
./mac/802_11e/mac-802_11e.h:304: error: ‘Mac’ has not been declared
make: *** [apps/udp.o] Error 1
and this error belongs to #include "mac/mac-802_11.h" line,
So would help me if you have an idea about how to fix this error, please? I'm stuck in this error from long time.
Thanks for your help in advance.
hi Red rose,
Deletecan u help me how to make cross layer between transport and physical layers...how to call propagation.cc file in snoop.cc file .am beginner of ns2..am waiting for ur help.thanks in advance.
by
shiny
Hi Shiny John,
DeleteI'm also a beginner of ns2, I used above short tutorial to make the cross layer, so why you don't use it? I think you should do the same:
The process should be the same:
1. Include the header file of propagation.cc which is as I think should be propagation.h in the snoop.h
# Include "../propagation.h"
then, declare an object of propagation class within the snoop.cc class
propagation *test;
then you have to follow the same steps in the tcl file. Actually, I follow same steps but I am stuck in errors as you can see the above error. You can also use the following link, (https://github.com/smtatapudi/ns2-contrib) they are following same procedure as mentioned above in their project. I'm still stuck in errors and if I successfully manage to do the cross layer, I will help you in details for your case.
See also this link, it belongs for the same author and it may help you http://wmnatupdiliman.blogspot.com/2011/08/exchanging-cross-layer-information-in.html
Deletehi sir, i am a beginner of ns2 i am trying to implement cross layer i am getting an like like you only .what the solution for that please help me for my research
Deletehi rose .. help me in how to write a program for cross layer design
ReplyDeleteHi...
ReplyDeleteThis is really a helpful one. I would really appreciate your effort.
But, I'd like to ask if we can follow the same steps to implement the cross layer (for example, phy to transport layer) other than the one in this post?
Thanks
Hi frndz,
ReplyDeleteI have tried to make a cross layer between snoop.cc and mac-802_11.cc by following the above steps. I got error when i add mac object this_mac. help me frndz to clear the following error
In file included from tcp/snoop.cc:41:
tcp/snoop.h:136: error: ISO C++ forbids declaration of ‘mac802_11’ with no type
tcp/snoop.h:136: error: expected ‘;’ before ‘*’ token
tcp/snoop.cc: In member function ‘virtual int Snoop::command(int, const char* const*)’:
tcp/snoop.cc:154: error: overloaded function with no contextual type information
tcp/snoop.cc:158: error: ‘this_mac’ was not declared in this scope
make: *** [tcp/snoop.o] Error 1
Thanks in advance
Hello sir,
ReplyDeleteThis code is very helpful.can u help me how to invoke RTS packet transmission from mac layer to routing(AODV) layer?
Good day Dear,
ReplyDeleteI am trying to access the Mac Layer from the Routing layer of AODV. I followed all the steps but I think i have a problem with the last one, when i try to add the last step to my tcl script in order to get the right pointer, I am getting the following error
can't read "rt(0)_o17": no such variable
while executing
"set rt($i)[$node_($i) agent 255]"
("for" body line 5)
..........
My question is what rt stands for? is it the AODVagent?
Regards!
Hi when i use your steps for cross layer from mac.h to tcp.c
ReplyDeletei get the following error while using make
In file included from ./mobile/energy-model.h:48:0,
from ./common/node.h:59,
from ./mac/channel.h:47,
from ./mac/phy.h:60,
from ./mac/mac.h:48,
from ./tcp/tcp.h:40,
from ./trace/basetrace.h:41,
from queue/errmodel.h:47,
from queue/errmodel.cc:54:
./trace/trace.h:70:2: error: ‘BaseTrace’ does not name a type
What might the problem be?
i have included in tcp.h
#include "mac/mac.h"
Mac *m;
and
in tcp.cc
int TcpAgent::command(int argc, const char*const* argv)
{
//edited here following your steps
}
Regards...
How can i pass information from mac layer to transport layer.....means cross layering between mac.cc and tcp.cc
Delete./mac/802_11e/mac-802_11e.h: At global scope:
ReplyDelete./mac/802_11e/mac-802_11e.h:120: error: ‘ETHER_ADDR_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h:121: error: ‘ETHER_ADDR_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h:122: error: ‘ETHER_ADDR_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h: In member function ‘u_int32_t EDCA_PHY_MIB::getHdrLen11()’:
./mac/802_11e/mac-802_11e.h:160: error: ‘ETHER_FCS_LEN’ was not declared in this scope
./mac/802_11e/mac-802_11e.h: At global scope:
./mac/802_11e/mac-802_11e.h:209: error: expected class-name before ‘{’ token
./mac/802_11e/mac-802_11e.h:234: error: ‘MacState’ has not been declared
./mac/802_11e/mac-802_11e.h:235: error: ‘MacState’ has not been declared
./mac/802_11e/mac-802_11e.h:390: error: ‘MacState’ does not name a type
./mac/802_11e/mac-802_11e.h:391: error: ‘MacState’ does not name a type
./mac/802_11e/mac-802_11e.h: In member function ‘int Mac802_11e::initialized()’:
./mac/802_11e/mac-802_11e.h:304: error: ‘Mac’ has not been declared
make: *** [apps/udp.o] Error 1
please help for this error
hiii every one i want to implement cross layer information exchange between transport and network layer???????
ReplyDeleteAny type of help or suggestion .....anyone ????
hiii every one i want to implement cross layer information exchange between transport and network layer???????
ReplyDeleteAny type of help or suggestion .....anyone ????
Hi, please help me with this.
ReplyDeleteWhen I use this code for cross layer communication, I always get this error with the mac layer access syntax-
$rt access-mac [$node_ set mac]
The error is as follows:
[root@localhost ex]# ns simple.tcl
invalid command name ""
while executing
"$rt access-mac $node_"
(file "simple.tcl" line 23)
And also I've declared the mac object in aodv class even then error is still there.
Then I modified the mac variable in simple.tcl file to that these such errors showed :
[root@localhost ex]# ns simple.tcl
can't read "mac_": no such variable
while executing
"subst $[subst $var]"
(procedure "_o22" line 5)
(SplitObject set line 5)
invoked from within
"$node_ set mac_"
invoked from within
"$rt access-mac [$node_ set mac_]"
(file "simple.tcl" line 23)
Kindly please suggest any solution to this error.
Thank you!!
hi i need to transmit information from application to network layer, and network layer to application layer leaving transport layer , can you send the code and help me?????
ReplyDeleteHello,
ReplyDeleteI ran all the steps but I got the following error. How can I solve it?
#Error:-----------------
(_o17 cmd line 1)
invoked from within
"_o17 cmd acess-mac _o19"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o17" line 2)
(SplitObject unknown line 2)
invoked from within
"$rt($i) acess-mac [$node_($i) set mac_(0)]"
("for" body line 7)
invoked from within
"for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
# get the routing layer protocol
set rt($i) [$n..."
------------------------
Best regards.