IPv4PacketImpl extends AbstractPacket implements IPv4Packet { @Override public int getTotalIPLength() { return this.headers.getUnsignedShort(2); } 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 testIpLengths() throws Exception { final List<IPv4Packet> ipPackets = loadIPPackets("sipp.pcap"); assertThat(ipPackets.get(0).getTotalIPLength(), is(533)); assertThat(ipPackets.get(1).getTotalIPLength(), is(334)); assertThat(ipPackets.get(2).getTotalIPLength(), is(493)); assertThat(ipPackets.get(3).getTotalIPLength(), is(384)); assertThat(ipPackets.get(4).getTotalIPLength(), is(533)); assertThat(ipPackets.get(5).getTotalIPLength(), is(334)); assertThat(ipPackets.get(6).getTotalIPLength(), is(493)); assertThat(ipPackets.get(7).getTotalIPLength(), is(384)); assertThat(ipPackets.get(8).getTotalIPLength(), is(384)); assertThat(ipPackets.get(9).getTotalIPLength(), is(326)); assertThat(ipPackets.get(10).getTotalIPLength(), is(533)); assertThat(ipPackets.get(11).getTotalIPLength(), is(334)); assertThat(ipPackets.get(12).getTotalIPLength(), is(493)); assertThat(ipPackets.get(13).getTotalIPLength(), is(384)); assertThat(ipPackets.get(14).getTotalIPLength(), is(384)); assertThat(ipPackets.get(15).getTotalIPLength(), is(326)); assertThat(ipPackets.get(16).getTotalIPLength(), is(533)); assertThat(ipPackets.get(17).getTotalIPLength(), is(334)); }
@Test public void testIpLengthsSllFramed() throws Exception { final List<IPv4Packet> ipPackets = loadIPPackets("sipp_sll.pcap"); assertThat(ipPackets.get(0).getTotalIPLength(), is(533)); assertThat(ipPackets.get(1).getTotalIPLength(), is(334)); assertThat(ipPackets.get(2).getTotalIPLength(), is(493)); assertThat(ipPackets.get(3).getTotalIPLength(), is(384)); assertThat(ipPackets.get(4).getTotalIPLength(), is(533)); assertThat(ipPackets.get(5).getTotalIPLength(), is(334)); assertThat(ipPackets.get(6).getTotalIPLength(), is(493)); assertThat(ipPackets.get(7).getTotalIPLength(), is(384)); assertThat(ipPackets.get(8).getTotalIPLength(), is(384)); assertThat(ipPackets.get(9).getTotalIPLength(), is(326)); assertThat(ipPackets.get(10).getTotalIPLength(), is(533)); assertThat(ipPackets.get(11).getTotalIPLength(), is(334)); assertThat(ipPackets.get(12).getTotalIPLength(), is(493)); assertThat(ipPackets.get(13).getTotalIPLength(), is(384)); assertThat(ipPackets.get(14).getTotalIPLength(), is(384)); assertThat(ipPackets.get(15).getTotalIPLength(), is(326)); assertThat(ipPackets.get(16).getTotalIPLength(), is(533)); assertThat(ipPackets.get(17).getTotalIPLength(), is(334)); }