1PCAP-SAVEFILE(5) File Formats Manual PCAP-SAVEFILE(5)
2
3
4
6 pcap-savefile - libpcap savefile format
7
9 NOTE: applications and libraries should, if possible, use libpcap to
10 read savefiles, rather than having their own code to read savefiles.
11 If, in the future, a new file format is supported by libpcap, applica‐
12 tions and libraries using libpcap to read savefiles will be able to
13 read the new format of savefiles, but applications and libraries using
14 their own code to read savefiles will have to be changed to support the
15 new file format.
16
17 ``Savefiles'' read and written by libpcap and applications using libp‐
18 cap start with a per-file header. The format of the per-file header
19 is:
20
21 ┌──────────────────────────────┐
22 │ Magic number │
23 ├──────────────┬───────────────┤
24 │Major version │ Minor version │
25 ├──────────────┴───────────────┤
26 │ Time zone offset │
27 ├──────────────────────────────┤
28 │ Time stamp accuracy │
29 ├──────────────────────────────┤
30 │ Snapshot length │
31 ├──────────────────────────────┤
32 │ Link-layer header type │
33 └──────────────────────────────┘
34 All fields in the per-file header are in the byte order of the host
35 writing the file. The first field in the per-file header is a 4-byte
36 magic number, with the value 0xa1b2c3d4. The magic number, when read
37 by a host with the same byte order as the host that wrote the file,
38 will have the value 0xa1b2c3d4, and, when read by a host with the oppo‐
39 site byte order as the host that wrote the file, will have the value
40 0xd4c3b2a1. That allows software reading the file to determine whether
41 the byte order of the host that wrote the file is the same as the byte
42 order of the host on which the file is being read, and thus whether the
43 values in the per-file and per-packet headers need to be byte-swapped.
44
45 Following this are:
46
47 A 2-byte file format major version number; the current version
48 number is 2.
49
50 A 2-byte file format minor version number; the current version
51 number is 4.
52
53 A 4-byte time zone offset; this is always 0.
54
55 A 4-byte number giving the accuracy of time stamps in the file;
56 this is always 0.
57
58 A 4-byte number giving the "snapshot length" of the capture;
59 packets longer than the snapshot length are truncated to the
60 snapshot length, so that, if the snapshot length is N, only the
61 first N bytes of a packet longer than N bytes will be saved in
62 the capture.
63
64 a 4-byte number giving the link-layer header type for packets in
65 the capture; see pcap-linktype(7) for the LINKTYPE_ values that
66 can appear in this field.
67
68 Following the per-file header are zero or more packets; each packet
69 begins with a per-packet header, which is immediately followed by the
70 raw packet data. The format of the per-packet header is:
71
72 ┌───────────────────────────────────────┐
73 │ Time stamp, seconds value │
74 ├───────────────────────────────────────┤
75 │ Time stamp, microseconds value │
76 ├───────────────────────────────────────┤
77 │ Length of captured packet data │
78 ├───────────────────────────────────────┤
79 │Un-truncated length of the packet data │
80 └───────────────────────────────────────┘
81 All fields in the per-packet header are in the byte order of the host
82 writing the file. The per-packet header begins with a time stamp giv‐
83 ing the approximate time the packet was captured; the time stamp con‐
84 sists of a 4-byte value, giving the time in seconds since January 1,
85 1970, 00:00:00 UTC, followed by a 4-byte value, giving the time in
86 microseconds since that second. Following that are a 4-byte value giv‐
87 ing the number of bytes of captured data that follow the per-packet
88 header and a 4-byte value giving the number of bytes that would have
89 been present had the packet not been truncated by the snapshot length.
90 The two lengths will be equal if the number of bytes of packet data are
91 less than or equal to the snapshot length.
92
94 pcap(3PCAP), pcap-linktype(7)
95
96
97
98 21 October 2008 PCAP-SAVEFILE(5)