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:
packet.data
gives you abyte[]
, so calling.length
on this returns aint
(like on all other arrays).