I'm performing an experiment in which I need to recognize if the packet received by mac-low.cc of the wifi module is an arp packet or not. And if it isn't, I need to print some packet details.
I printed out the content of the arp packet using packet->Print(std::cout) and saw the following information:
ns3::WifiMacHeader (QOSDATA ) ns3::LlcSnapHeader (type 0x806) ns3::ArpHeader (request source mac: 00-06-00:00:00:00:00:02 source ipv4: 10.0.0.2 dest ipv4: 10.0.0.1) ns3::WifiMacTrailer ()
The LlcSnapHeader indicates a type of 0x806 which in decimal should be 2054 (
http://www.binaryhexconverter.com/hex-to-decimal-converter). So I did the following to identify an arp packet:
LlcSnapHeader llc_test;
m_currentPacket->PeekHeader (llc_test);
if (llc_test.GetType () == 2054)
{
std::cout << "Found an ARP packet" << std::endl;
}
However, this isn't working. I tried to print out the output of llc_test.GetType () and it seems to be printing '0'. But it does this for all data packets as well.
Is there any easy way to identify whether a received packet is arp or not without actually tearing it down i.e separating the various headers? I don't want to do this since I want to let the arp packet go to higher layer functions (mac high / ip /etc) without being disturbed in any way. I just need to identify it as an arp packet.
Thanks.