1PCAP-SAVEFILE(5)              File Formats Manual             PCAP-SAVEFILE(5)
2
3
4

NAME

6       pcap-savefile - libpcap savefile format
7

DESCRIPTION

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       The per-file header length is 24 octets.
35
36       All  fields  in  the  per-file header are in the byte order of the host
37       writing the file.  Normally, the first field in the per-file header  is
38       a  4-byte  magic  number, with the value 0xa1b2c3d4.  The magic number,
39       when read by a host with the same byte order as the host that wrote the
40       file, will have the value 0xa1b2c3d4, and, when read by a host with the
41       opposite byte order as the host that wrote  the  file,  will  have  the
42       value  0xd4c3b2a1.   That allows software reading the file to determine
43       whether the byte order of the host that wrote the file is the  same  as
44       the  byte  order  of the host on which the file is being read, and thus
45       whether the values in the per-file and per-packet headers  need  to  be
46       byte-swapped.
47
48       If  the  magic number has the value 0xa1b23c4d (with the two nibbles of
49       the two lower-order bytes of the magic number swapped), which would  be
50       read  as 0xa1b23c4d by a host with the same byte order as the host that
51       wrote the file and as 0x4d3cb2a1 by a host with the opposite byte order
52       as  the  host  that  wrote the file, the file format is the same as for
53       regular files, except that the time stamps for  packets  are  given  in
54       seconds and nanoseconds rather than seconds and microseconds.
55
56       Following this are:
57
58              A  2-byte  file format major version number; the current version
59              number is 2.
60
61              A 2-byte file format minor version number; the  current  version
62              number is 4.
63
64              A 4-byte time zone offset; this is always 0.
65
66              A  4-byte number giving the accuracy of time stamps in the file;
67              this is always 0.
68
69              A 4-byte number giving the "snapshot  length"  of  the  capture;
70              packets  longer  than  the  snapshot length are truncated to the
71              snapshot length, so that, if the snapshot length is N, only  the
72              first  N  bytes of a packet longer than N bytes will be saved in
73              the capture.
74
75              a 4-byte number giving the link-layer header type for packets in
76              the  capture; see pcap-linktype(7) for the LINKTYPE_ values that
77              can appear in this field.
78
79       Following the per-file header are zero or  more  packets;  each  packet
80       begins  with  a per-packet header, which is immediately followed by the
81       raw packet data.  The format of the per-packet header is:
82
83              ┌──────────────────────────────────────────────┐
84              │          Time stamp, seconds value           │
85              ├──────────────────────────────────────────────┤
86              │Time stamp, microseconds or nanoseconds value │
87              ├──────────────────────────────────────────────┤
88              │       Length of captured packet data         │
89              ├──────────────────────────────────────────────┤
90              │   Un-truncated length of the packet data     │
91              └──────────────────────────────────────────────┘
92       The per-packet header length is 16 octets.
93
94       All fields in the per-packet header are in the byte order of  the  host
95       writing  the file.  The per-packet header begins with a time stamp giv‐
96       ing the approximate time the packet was captured; the time  stamp  con‐
97       sists  of  a  4-byte value, giving the time in seconds since January 1,
98       1970, 00:00:00 UTC, followed by a 4-byte  value,  giving  the  time  in
99       microseconds  or  nanoseconds since that second, depending on the magic
100       number in the file header.  Following that are a  4-byte  value  giving
101       the  number of bytes of captured data that follow the per-packet header
102       and a 4-byte value giving the number of  bytes  that  would  have  been
103       present  had the packet not been truncated by the snapshot length.  The
104       two lengths will be equal if the number of bytes  of  packet  data  are
105       less than or equal to the snapshot length.
106

SEE ALSO

108       pcap(3PCAP)
109
110
111
112                                 24 April 2020                PCAP-SAVEFILE(5)
Impressum