IPv4PacketImpl extends AbstractPacket implements IPv4Packet { @Override public int getHeaderLength() { try { final byte b = this.headers.getByte(0); return (b & 0x0F) * 4; } catch (final IOException e) { throw new RuntimeException("unable to get the header length of the IP packet due to IOException", e); } } IPv4PacketImpl(final Packet parent, final Buffer headers, final int options, final Buffer payload); @Override int getIpChecksum(); @Override byte[] getRawSourceIP(); int getRawSourceIpInt(); @Override String getSourceIP(); @Override byte[] getRawDestinationIP(); int getRawDestinationIpInt(); @Override String getDestinationIP(); @Override void verify(); @Override long getArrivalTime(); @Override void write(final OutputStream out, final Buffer payload); @Override int getTotalIPLength(); void setTotalLength(final int length); @Override void setSourceIP(final int a, final int b, final int c, final int d); @Override void setSourceIP(final byte a, final byte b, final byte c, final byte d); @Override void setDestinationIP(final int a, final int b, final int c, final int d); @Override void setDestinationIP(final byte a, final byte b, final byte c, final byte d); @Override void setSourceIP(final String sourceIp); @Override void setDestinationIP(final String destinationIP); @Override void reCalculateChecksum(); @Override boolean verifyIpChecksum(); @Override IPv4Packet clone(); @Override Packet getNextPacket(); @Override int getVersion(); @Override int getHeaderLength(); @Override boolean isFragmented(); @Override boolean isReservedFlagSet(); @Override boolean isDontFragmentSet(); @Override boolean isMoreFragmentsSet(); @Override short getFragmentOffset(); @Override int getIdentification(); @Override String toString();  }
@Test public void testHeaderLength() throws Exception { final IPv4Packet pkt = loadIPPackets("sipp.pcap").get(0); assertThat(pkt.getHeaderLength(), is(20)); }