Source:
public synchronized void skipNextPacket() throws IOException, BadPcapFileException { ByteBuffer pcapPacketHeader; long includedPacketLength; SeekableByteChannel fileChannel = getFileChannel(); if (fileChannel.size() - fileChannel.position() == 0) { return; } if (fileChannel.size() - fileChannel.position() < PcapFileValues.PCAPNG_PACKET_HEADER_SIZE) { return; } pcapPacketHeader = ByteBuffer.allocate(PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); pcapPacketHeader.clear(); pcapPacketHeader.order(getByteOrder()); fileChannel.read(pcapPacketHeader); pcapPacketHeader.flip(); int blockType = pcapPacketHeader.getInt(); if (blockType == PcapFileValues.PCAPNG_IDB) { pcapPacketHeader.getInt(); pcapPacketHeader.position(PcapFileValues.INTERFACE_DESCRIPTION_SIZE); long dataLinkType = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getShort()); setDataLinkTypeNg(fInterfaceID, dataLinkType); pcapPacketHeader.getShort(); long snapShotLength = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getInt()); setSnapshotLengthNg(fInterfaceID, snapShotLength); fInterfaceID++; } switch (blockType) { case PcapFileValues.PCAPNG_PB: case PcapFileValues.PCAPNG_EPB: pcapPacketHeader.position(PcapFileValues.PCAPNG_PACKET_CAPTURE_LENGTH_POS); includedPacketLength = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getInt()); if (getFileChannel().size() - getFileChannel().position() < includedPacketLength) { throw new BadPcapFileException("A packet header is invalid."); } getFileChannel().position(getFileChannel().position() + includedPacketLength); TreeMap<Long, Long> fileIndex = getFileIndex(); fileIndex.put(getCurrentRank(), getFileChannel().position()); setCurrentRank(getCurrentRank() + 1); break; default: break; } }

Target:
public synchronized void skipNextPacket() throws IOException, BadPcapFileException { ByteBuffer pcapPacketHeader; long includedPacketLength; SeekableByteChannel fileChannel = getFileChannel(); if (fileChannel.size() - fileChannel.position() == 0) { return; } if (fileChannel.size() - fileChannel.position() < PcapFileValues.PCAPNG_PACKET_HEADER_SIZE) { return; } pcapPacketHeader = ByteBuffer.allocate(PcapFileValues.PCAPNG_PACKET_HEADER_SIZE); pcapPacketHeader.order(getByteOrder()); fileChannel.read(pcapPacketHeader); pcapPacketHeader.flip(); int blockType = pcapPacketHeader.getInt(); if (blockType == PcapFileValues.PCAPNG_IDB) { pcapPacketHeader.getInt(); pcapPacketHeader.position(PcapFileValues.INTERFACE_DESCRIPTION_SIZE); long dataLinkType = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getShort()); setDataLinkTypeNg(fInterfaceID, dataLinkType); pcapPacketHeader.getShort(); long snapShotLength = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getInt()); setSnapshotLengthNg(fInterfaceID, snapShotLength); fInterfaceID++; } switch (blockType) { case PcapFileValues.PCAPNG_PB: case PcapFileValues.PCAPNG_EPB: pcapPacketHeader.position(PcapFileValues.PCAPNG_PACKET_CAPTURE_LENGTH_POS); includedPacketLength = ConversionHelper.unsignedIntToLong(pcapPacketHeader.getInt()); if (getFileChannel().size() - getFileChannel().position() < includedPacketLength) { throw new BadPcapFileException("A packet header is invalid."); } getFileChannel().position(getFileChannel().position() + includedPacketLength); TreeMap<Long, Long> fileIndex = getFileIndex(); fileIndex.put(getCurrentRank(), getFileChannel().position()); setCurrentRank(getCurrentRank() + 1); break; default: break; } }