简体   繁体   中英

Jpcap: IP packet header length

In JPCap i obtain the header length of the IP packet by the following code

   IPPacket IP_pac = (IPPacket) packet;
   System.out.println(IP_pac.len); // header length

i obtain the data length of the IP packet by

    System.out.println(IP_pac.data.length);

Now the problem is that the IP packet(IPV4) length should b 20 bytes when the data length of the IP packet is 0.but the results display the header length of the IP packet as 60 and 54. Secondly, do i consider these lengths of IP_pac.data.length as bytes by default?

According to the API , the length is a short:

public short length

packet.data gives you a byte[] , so calling .length on this returns a int (like on all other arrays).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM