1 .\" Copyright (c) 1994, 1996, 1997
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that: (1) source code distributions
6 .\" retain the above copyright notice and this paragraph in its entirety, (2)
7 .\" distributions including binary code include the above copyright notice and
8 .\" this paragraph in its entirety in the documentation or other materials
9 .\" provided with the distribution, and (3) all advertising materials mentioning
10 .\" features or use of this software display the following acknowledgement:
11 .\" ``This product includes software developed by the University of California,
12 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13 .\" the University nor the names of its contributors may be used to endorse
14 .\" or promote products derived from this software without specific prior
15 .\" written permission.
16 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 .TH PCAP-SAVEFILE @MAN_FILE_FORMATS@ "24 April 2020"
22 pcap-savefile \- libpcap savefile format
24 NOTE: applications and libraries should, if possible, use libpcap to
25 read savefiles, rather than having their own code to read savefiles.
26 If, in the future, a new file format is supported by libpcap,
27 applications and libraries using libpcap to read savefiles will be able
28 to read the new format of savefiles, but applications and libraries
29 using their own code to read savefiles will have to be changed to
30 support the new file format.
32 ``Savefiles'' read and written by libpcap and applications using libpcap
33 start with a per-file header. The format of the per-file header is:
42 Major version Minor version
50 Link-layer header type
54 The per-file header length is 24 octets.
56 All fields in the per-file header are in the byte order of the host
57 writing the file. Normally, the first field in the per-file header is a
58 4-byte magic number, with the value 0xa1b2c3d4. The magic number, when
59 read by a host with the same byte order as the host that wrote the file,
60 will have the value 0xa1b2c3d4, and, when read by a host with the
61 opposite byte order as the host that wrote the file, will have the value
62 0xd4c3b2a1. That allows software reading the file to determine whether
63 the byte order of the host that wrote the file is the same as the byte
64 order of the host on which the file is being read, and thus whether the
65 values in the per-file and per-packet headers need to be byte-swapped.
67 If the magic number has the value 0xa1b23c4d (with the two nibbles of
68 the two lower-order bytes of the magic number swapped), which would be
69 read as 0xa1b23c4d by a host with the same byte order as the host that
70 wrote the file and as 0x4d3cb2a1 by a host with the opposite byte order
71 as the host that wrote the file, the file format is the same as for
72 regular files, except that the time stamps for packets are given in
73 seconds and nanoseconds rather than seconds and microseconds.
77 A 2-byte file format major version number; the current version number is
80 A 2-byte file format minor version number; the current version number is
83 A 4-byte time zone offset; this is always 0.
85 A 4-byte number giving the accuracy of time stamps in the file; this is
88 A 4-byte number giving the "snapshot length" of the capture; packets
89 longer than the snapshot length are truncated to the snapshot length, so
90 that, if the snapshot length is
94 bytes of a packet longer than
96 bytes will be saved in the capture.
98 a 4-byte number giving the link-layer header type for packets in the
100 .BR pcap-linktype (@MAN_MISC_INFO@)
103 values that can appear in this field.
105 Following the per-file header are zero or more packets; each packet
106 begins with a per-packet header, which is immediately followed by the
107 raw packet data. The format of the per-packet header is:
112 Time stamp, seconds value
114 Time stamp, microseconds or nanoseconds value
116 Length of captured packet data
118 Un-truncated length of the packet data
122 The per-packet header length is 16 octets.
124 All fields in the per-packet header are in the byte order of the host
125 writing the file. The per-packet header begins with a time stamp giving
126 the approximate time the packet was captured; the time stamp consists of
127 a 4-byte value, giving the time in seconds since January 1, 1970,
128 00:00:00 UTC, followed by a 4-byte value, giving the time in
129 microseconds or nanoseconds since that second, depending on the magic
130 number in the file header. Following that are a 4-byte value giving the
131 number of bytes of captured data that follow the per-packet header and a
132 4-byte value giving the number of bytes that would have been present had
133 the packet not been truncated by the snapshot length. The two lengths
134 will be equal if the number of bytes of packet data are less than or
135 equal to the snapshot length.