Identifying arp packets

85 views
Skip to first unread message

PN

unread,
Jul 20, 2017, 9:13:35 PM7/20/17
to ns-3-users
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.

Rediet

unread,
Jul 21, 2017, 5:53:10 AM7/21/17
to ns-3-users
Hello Peshal,

It seems that it's because you're trying to extract ARP header information from Wi-Fi control messages.
I just put a condition on the type of Wi-Fi packet and on the correct deserialization of the LLC header like this (at the very beginning of MacLow::StartTransmission):
  m_currentTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
 
 
LlcSnapHeader llc_test;
 
if (m_currentHdr.IsData () && m_currentPacket->PeekHeader (llc_test))
   
{
      std
::cout << "Found a LLC looking header of ";
      llc_test
.Print (std::cout);

     
if (llc_test.GetType () == 2054)
       
{

          std
::cout << " -> Found an ARP packet!";
       
}
      std
::cout << std::endl;
   
}

 
if (NeedRts ())


And the output on third.cc gives the expected output:
At time 2s client sent 1024 bytes to 10.1.2.4 port 9
Found a LLC looking header of type 0x806 -> Found an ARP packet!
Found a LLC looking header of type 0x806 -> Found an ARP packet!
Found a LLC looking header of type 0x806 -> Found an ARP packet!
Found a LLC looking header of type 0x800
At time 2.01796s server received 1024 bytes from 10.1.3.3 port 49153
At time 2.01796s server sent 1024 bytes to 10.1.3.3 port 49153
Found a LLC looking header of type 0x806 -> Found an ARP packet!
Found a LLC looking header of type 0x806 -> Found an ARP packet!
Found a LLC looking header of type 0x800
At time 2.03364s client received 1024 bytes from 10.1.2.4 port 9


Cheers,

Rediet
Reply all
Reply to author
Forward
0 new messages