How to transmit upper layer's information to lower layers

137 views
Skip to first unread message

Wang Tao

unread,
Mar 22, 2014, 9:11:29 AM3/22/14
to ns-3-...@googlegroups.com
Dear All,

From the application layer (L7), for instance, I would like to store the information like rest bytes to send (MaxBytes - TotoalBytes), which is changing over the time.

I would like to transmit this informatiion to the lower layer, for instance, L3.

Here is my idea: (take onoffApplication as an example)

1) keep a vector to store the information I want in the onoffApplication
2) access this vector when processing lower layer's packets

But I think that this approach disobeys the philosophy of "layers" ---- lower layers may not concern the data from different layers.

Can you give me advice on how to transmit the useful information but also obey this philosophy?

Best,
Tao

Konstantinos

unread,
Mar 22, 2014, 9:52:19 AM3/22/14
to ns-3-...@googlegroups.com


On Saturday, March 22, 2014 1:11:29 PM UTC, Wang Tao wrote:
Dear All,

From the application layer (L7), for instance, I would like to store the information like rest bytes to send (MaxBytes - TotoalBytes), which is changing over the time.

I would like to transmit this information to the lower layer, for instance, L3.


This point here (use information from a layer A to layer B) is known as cross-layering. If you want to use such approach, then you simply can't obey the philosophy of layering.
You may have distinct layer, that can change, if that's 'obeying the philosophy'. 

Here is my idea: (take onoffApplication as an example)

1) keep a vector to store the information I want in the onoffApplication
2) access this vector when processing lower layer's packets

But I think that this approach disobeys the philosophy of "layers" ---- lower layers may not concern the data from different layers.
 

Can you give me advice on how to transmit the useful information but also obey this philosophy?


There are two approaches 
1) simulation only (ns-3 bound):  You can use either the tracing system or tags to pass information. For example each time a packet is left from the application, you tag the remaining packets, and you read this at lower layers. 
2) valid for real systems: create a header with the value you want and attach it to the packet. Then read it at any lower layer or any other node.

 
Best,
Tao

Wang Tao

unread,
Mar 22, 2014, 10:53:33 AM3/22/14
to ns-3-...@googlegroups.com
Hi,

Thanks for your reply.

I think it is strange that add header or tag to the packets generated by the application.

As you know, the application just generates traffic stream, so it is not proper to add header or tag to the packets.

BTW, is there any helpful user cases?

Regards,
Tao

Konstantinos

unread,
Mar 22, 2014, 11:12:12 AM3/22/14
to ns-3-...@googlegroups.com
Tags in NS-3 can be seen as "metadata" for a packet. However, since tags are only in NS-3, you need to put actual data for a real system (that's why you add the header).


On Saturday, March 22, 2014 2:53:33 PM UTC, Wang Tao wrote:
Hi,

Thanks for your reply.

I think it is strange that add header or tag to the packets generated by the application.

As you know, the application just generates traffic stream, so it is not proper to add header or tag to the packets.

But you need to get information from the application. Perhaps you can generate an "interface" to access the data and expose that to other layers, but that's clearly is against the philosophy. 

Tommaso Pecorella

unread,
Mar 22, 2014, 11:25:14 AM3/22/14
to ns-3-...@googlegroups.com
Hi,

I'd say that the "header" is not a true header in real systems. It's more like a wrapper to hold together the packet and the X-layer data. Basically it's equivalent to a tag.

T.

JaNa

unread,
Mar 22, 2014, 8:32:17 PM3/22/14
to ns-3-...@googlegroups.com
Hi all,

Greetings,

As I am doing the same thing in my study, I also Totally Agree with Tommaso and Konstantinos's 2nd idea.
I guess the best method is add a header and add data you want to the header. It is the most practical way to simulate in ns-3 and apply it to the real world application as well.

Practically I have done it on the ns-3 and it is 100% possible to achieve..


Janaka


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
Best Regards..

    """""""""""
:)   JaNa     :) 
    """""""""""

Wang Tao

unread,
Mar 23, 2014, 1:57:52 AM3/23/14
to ns-3-...@googlegroups.com
Hi,

Could you plz share the key codes with me? Or the key frameworks? I have read the ns3 source code for days, I got a mess here.

Do you mean that add header at the upper layer and read(use PeekHeader or RemoveHeader) at the lower layer?

I would like to get information from the upper layer and attach it to the options field in the ipv4 header rather than let the information be a independent header or layer to communicate. lol

Best,
Tao

JaNa

unread,
Mar 25, 2014, 3:40:00 AM3/25/14
to ns-3-...@googlegroups.com
Hi,

Well, Tao sorry for the late reply.

Actually I have to go through some chain of commands in order to get permission to release some coding to the Internet.
Though it is a Open Source project, as it is a ongoing project,  I have to inform my superiors before releasing cods to the Internet. 

Fortunately I was permitted to give you the header information and the development information of those header files. However, I am sorry that I am still restricted to release the code segments of header reading places of those information. In fact, I will give you some hints which of how to read information in the middle layers.

Well, regarding adding data to options fields of IP header is bit tricky with the data sizes and stuff.

Therefore, I designed my own class as follow and added it to the /src/internet/model

Please refer following attached files(test.h and .cc files) to get some idea about header implementation.

After that, obviously you have to modify the wscript file in the internet folder. But, if you need to access the internet data in the lower layers such as datalink and physical,  you have to do some additional modifications to the compilation structure.

To do those modifications, please follow the thread I have written in detail
https://groups.google.com/forum/#!searchin/ns-3-users/janaka/ns-3-users/xf68PTmKu84/T97pOtaVdT8J

That thread will give you an idea, how we have to arrange the wscript files in order to compile ns-3 by providing access to cross layer data.

Therefore, add the paths of the "test.cc and test.h" to a wscript file as you want to read the data in those header file.


Finally you have to have application to   access those header files and add data. Simply we created our own application as our requirement and following code segment will give you some idea how to assign data to the newly introduced header.

to get a good understanding, please navigate to
/ns-3.18/src/applications/model and read the udp-echo-client.cc

#include "ns3/test.h"

// in your function

TestHeader sr;
Ptr<Packet> p;
sr.SetSendTimeinMs(Simulator::Now().GetMilliSeconds());

p = Create<Packet> (m_size); // create the packet with a given size
p->AddHeader(sr);


That is it. So you added your header with your own data to every packet generated. now you have to read it in any layer or any end application.

Actually my implementation, we read the packet in the lowest layers as given in the pdf. file. It is a paper I have published in the SimuTools2014. However, as the project is an ongoing project, I can't release much implementation details regarding the reading in the lower layer.

but please follow following scenario and I guess you will understand how to  read the added header.

Following instructions are related to the Figure 1 of the paper.
TestHeader srHeader;
Ptr<Packet> packetTest;
packetTest = pktQ.front()->Copy(); // this is actually I copied the packet from my packet buffer.  Simply make a copy of the original data packet to avoid some serious damages to the original data packet.

//First Remove the IP header
packetTest->RemoveHeader (ipv4hdr);
if(ipv4hdr.GetProtocol ()== 17)  // if it is UDP
{
    packetTest->RemoveHeader (udpHeader); // remove UDP header
    //then is the only header you have is the header you attached to to the data packet. please plea it off and read the header
    packetTest->RemoveHeader(srHeader); // remove your header
   

    // now you can read your header details as you wish

}


I guess this answer will help you up to some extend. If you have questions regarding the process please contact me.


Cheers!!!
Janaka






test.cc
test.h
139260964720289.pdf

Wang Tao

unread,
Mar 25, 2014, 8:20:43 AM3/25/14
to ns-3-...@googlegroups.com
Hi,

Thanks for your generosity to release some key codes and hints.

It is a great treasure for me and the whole forum. lol

Best,
Tao

JaNa

unread,
Mar 25, 2014, 10:40:22 AM3/25/14
to ns-3-...@googlegroups.com
Hi,

That is no problem..

However, I  can't understand the meaning of this..

"It is a great treasure for me and the whole forum. lol"

If you feel like it is worth less, just ignore it.


Cheers,
Janaka


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Wang Tao

unread,
Mar 25, 2014, 10:44:21 AM3/25/14
to ns-3-...@googlegroups.com
Hi,

Sorry, maybe I express in a wrong way.

I just want to thank you, because your post is of great help to me. For the users in the forum, they can learn a lot from your post about cross layer's information exchange.

Best,
Tao


You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/4XdW0Xac4B0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

JaNa

unread,
Mar 25, 2014, 6:32:45 PM3/25/14
to ns-3-...@googlegroups.com
Hi,

It is OK.. No worries..

If you get any problems in following those steps please let me know..

It is my pleasure to share coding with all other researchers.. I'll share and open whole code as soon as I finish the implementation and get the green light from my superiors..


Cheers,
Janaka
Reply all
Reply to author
Forward
0 new messages