.pcap
) used by the libpcap
library to record captured packets to a file. The entire contents were copied from:
A capture file begins with a File Header, followed by zero or more Packet Records, one per packet.
All fields in the File Header and in Packet Records will always be saved according to the characteristics (little endian / big endian) of the capturing machine. This refers to all the fields that are saved as numbers and that span over two or more octets.
The approach of having the file saved in the native format of the generating host is more efficient because it avoids translation of data when reading / writing on the host itself, which is the most common case when generating/processing capture captures.
The packets are shown in traditional IETF diagram, with the bits numbered from the left to the right. The bit numbering does not reflect the binary value position, as IETF protocols are traditionally in big-endian network-byte order. The most significant bit is therefore on the left in this diagram as if the file is being stored on a big-endian system.
The File Header has the following format:
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Magic Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Major Version | Minor Version | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Reserved1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Reserved2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 | SnapLen | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 20 | FCS |f| LinkType | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The File Header length is 24 octets. The meaning of the fields in the File Header is:
0xA1B2C3D4
or the hexadecimal number 0xA1B23C4D
. 0xA1B2C3D4
, time stamps in Packet Records are in seconds and microseconds; 0xA1B23C4D
, time stamps in Packet Records are in seconds and nanoseconds.
These numbers can be used to distinguish sections that have been saved on little-endian
machines from the ones saved on big-endian
machines, and to heuristically identify pcap files.
2
. This value should change if the format changes in such a way that code that reads the new format could not read the old format (i.e., code to read both formats would have to check the version number and use different code paths for the two formats) and code that reads the old format could not read the new format.4
. This value should change if the format changes in such a way that code that reads the new format could read the old format without checking the version number but code that reads the old format could not read all files in the new format.0
by pcap file writers, and MUST be ignored by pcap file readers. This value was documented by some older implementations as gmt to local correction
. Some older pcap file writers stored non-zero values in this field.0
by pcap file writers, and MUST be ignored by pcap file readers. This value was documented by some older implementations as accuracy of timestamps
. Some older pcap file writers stored non-zero values in this field.28
bits, the link layer type of packets in the file.f
bit is set, then the FCS bits provide the number of bytes of FCS that are appended to each packet. 0
and 7
, with Ethernet typically having a length of 4 bytes.A Packet Record is the standard container for storing the packets coming from the network.
1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 0 | Timestamp (Seconds) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4 | Timestamp (Microseconds or nanoseconds) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 8 | Captured Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 12 | Original Packet Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 16 / / / Packet Data / / variable length / / / +---------------------------------------------------------------+
The Packet Header length is 16
octets.
The meaning of the fields in the Packet Record is:
1970-01-01 00:00:00 UTC
, and the microseconds or nanoseconds value represents the number of microseconds or nanoseconds that have elapsed since that seconds. LinkType
field specified in the file header and it is specified in the entry for that format in [LINKTYPES]
.The link below has many samples of the captures.