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.
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