PcapRecordHeader { public static PcapRecordHeader createDefaultHeader(final long timestamp) { final byte[] body = new byte[SIZE]; final Buffer buffer = Buffers.wrap(body); buffer.setUnsignedInt(0, timestamp / 1000L); buffer.setUnsignedInt(4, timestamp % 1000L * 1000L); return new PcapRecordHeader(ByteOrder.LITTLE_ENDIAN, buffer); } PcapRecordHeader(final ByteOrder byteOrder, final Buffer body);  PcapRecordHeader(final ByteOrder byteOrder, final Buffer body, final boolean nsTimestamps); static PcapRecordHeader createDefaultHeader(final long timestamp); long getTimeStampSeconds(); @Deprecated long getTimeStampMicroSeconds(); long getTimeStampMicroOrNanoSeconds(); long getTotalLength(); void setTotalLength(final long length); long getCapturedLength(); void setCapturedLength(final long length); void write(final OutputStream out); @Override String toString(); static final int SIZE; }
@Test public void testCreateDefaultHeader() { final long ts = 1378443125356L; final PcapRecordHeader header = PcapRecordHeader.createDefaultHeader(ts); assertThat(header.getTimeStampSeconds(), is(ts / 1000)); assertThat(header.getTimeStampMicroOrNanoSeconds(), is(ts % 1000 * 1000)); assertThat(header.getCapturedLength(), is(0L)); assertThat(header.getTotalLength(), is(0L)); header.setCapturedLength(123456); assertThat(header.getCapturedLength(), is(123456L)); assertThat(header.getTotalLength(), is(0L)); header.setTotalLength(555); assertThat(header.getTotalLength(), is(555L)); assertThat(header.getCapturedLength(), is(123456L)); }