PCAP-SAVEFILE(5) | File Formats Manual | PCAP-SAVEFILE(5) |
``Savefiles'' read and written by libpcap and applications using libpcap start with a per-file header. The format of the per-file header is:
Magic number | ||
Major version | Minor version | |
Time zone offset | ||
Time stamp accuracy | ||
Snapshot length | ||
Link-layer header type |
All fields in the per-file header are in the byte order of the host writing the file. The first field in the per-file header is a 4-byte magic number, with the value 0xa1b2c3d4. The magic number, when read by a host with the same byte order as the host that wrote the file, will have the value 0xa1b2c3d4, and, when read by a host with the opposite byte order as the host that wrote the file, will have the value 0xd4c3b2a1. That allows software reading the file to determine whether the byte order of the host that wrote the file is the same as the byte order of the host on which the file is being read, and thus whether the values in the per-file and per-packet headers need to be byte-swapped.
Following this are:
Following the per-file header are zero or more packets; each packet begins with a per-packet header, which is immediately followed by the raw packet data. The format of the per-packet header is:
Time stamp, seconds value |
Time stamp, microseconds value |
Length of captured packet data |
Un-truncated length of the packet data |
All fields in the per-packet header are in the byte order of the host writing the file. The per-packet header begins with a time stamp giving the approximate time the packet was captured; the time stamp consists of a 4-byte value, giving the time in seconds since January 1, 1970, 00:00:00 UTC, followed by a 4-byte value, giving the time in microseconds since that second. Following that are a 4-byte value giving the number of bytes of captured data that follow the per-packet header and a 4-byte value giving the number of bytes that would have been present had the packet not been truncated by the snapshot length. The two lengths will be equal if the number of bytes of packet data are less than or equal to the snapshot length.
21 October 2008 |