Problem when removing my defined header

37 views
Skip to first unread message

tabrizl...@gmail.com

unread,
Jun 30, 2019, 7:51:20 AM6/30/19
to ns-3-users
Dear All,

I have defined a new simple mac header class called AsimpleMacHeader which you can find in the attached files. I have defined m_source_addr and m_destination_addr and the corresponding set and get functions. I don't know why when I remove it from a packet, the destination address is different from what I had set. I even checked addheader and removeheader in the same place, and noticed that there is something wrong with using the removeheader function. For example, if you put the following inside your sources, you will see that the destination address is different from what you set:

AsimpleMacHeader hdrx;
  hdrx.SetDestinationAddr (Mac48Address ("ff:ff:ff:ff:ff:ff"));
  hdrx.SetSourceAddr (Mac48Address ("00:00:00:00:00:02"));
  Ptr<Packet> newPacket0 = packet->Copy();
  newPacket0->AddHeader(hdrx);

  AsimpleMacHeader hdry;
  uint32_t temp = newPacket0->RemoveHeader (hdry);
  NS_LOG_INFO(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> temp = " << (long int ) temp << ", " << hdry.GetSourceAddr() << hdry.GetDestinationAddr());

(hdry.GetDestinationAddr() returns this address: 00:00:00:00:00:00)

I have not been able to find the reason. Could you please help me?

Thanks.
Tab
asimple-mac-header.cc
asimple-mac-header.h

tabrizl...@gmail.com

unread,
Aug 4, 2019, 2:14:38 AM8/4/19
to ns-3-users
I found the reason. I was not computing the serializedsize correctly. Also, the Serialize and Deserialize functions were not defined correctly.

Tab.
Reply all
Reply to author
Forward
0 new messages