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

SEE ALSO

104       pcap(3PCAP), pcap-linktype(7)
105
106
107
108                                 8 March 2015                 PCAP-SAVEFILE(5)
Impressum