简体   繁体   English

jpcap:IP数据包头长度

[英]Jpcap: IP packet header length

In JPCap i obtain the header length of the IP packet by the following code 在JPCap中,我通过以下代码获得IP数据包的标头长度

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

i obtain the data length of the IP packet by 我通过以下方式获取IP数据包的数据长度

    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? 现在的问题是,当IP数据包的数据长度为0时,IP数据包(IPV4)的长度应为b 20个字节。但是结果显示IP数据包的标头长度为60和54。第二,我是否考虑了这些长度IP_pac.data.length默认为字节数?

According to the API , the length is a short: 根据API ,长度很短:

public short length

packet.data gives you a byte[] , so calling .length on this returns a int (like on all other arrays). packet.data为您提供一个byte[] ,因此在此方法上调用.length返回一个int (就像在所有其他数组上一样)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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