public static PcapRecordHeader createDefaultHeader ( final long timestamp ) { final byte [ ] body = new byte [ SIZE ] ; // time stamp seconds // body[0] = (byte) 0x00; // body[1] = (byte) 0x00; // body[2] = (byte) 0x00; // body[3] = (byte) 0x00; // Time stamp microseconds // body[4] = (byte) 0x00; // body[5] = (byte) 0x00; // body[6] = (byte) 0x00; // body[7] = (byte) 0x00; // The total length of the data // body[8] = (byte) 0x00; // body[9] = (byte) 0x00; // body[10] = (byte) 0x00; // body[11] = (byte) 0x00; // The length of the data captures within this frame // body[12] = (byte) 0x00; // body[13] = (byte) 0x00; // body[14] = (byte) 0x00; // body[15] = (byte) 0x00; final Buffer buffer = Buffers . wrap ( body ) ; buffer . setUnsignedInt ( 0 , timestamp / 1000L ) ; buffer . setUnsignedInt ( 4 , timestamp % 1000L * 1000L ) ; return new PcapRecordHeader ( ByteOrder . LITTLE_ENDIAN , buffer ) ; }
Create a default record header which you must alter later on to match whatever it is you are writing into the pcap stream .