blob: c20e003a8fe45063e59adbcf5c701b8b77426f37 [file] [log] [blame]
JP Abgrall511eca32014-02-12 13:46:45 -08001'\" t
2.\" @(#) $Header: /tcpdump/master/libpcap/pcap-savefile.manfile.in,v 1.2 2008-10-24 07:33:50 guy Exp $
3.\"
4.\" Copyright (c) 1994, 1996, 1997
5.\" The Regents of the University of California. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that: (1) source code distributions
9.\" retain the above copyright notice and this paragraph in its entirety, (2)
10.\" distributions including binary code include the above copyright notice and
11.\" this paragraph in its entirety in the documentation or other materials
12.\" provided with the distribution, and (3) all advertising materials mentioning
13.\" features or use of this software display the following acknowledgement:
14.\" ``This product includes software developed by the University of California,
15.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16.\" the University nor the names of its contributors may be used to endorse
17.\" or promote products derived from this software without specific prior
18.\" written permission.
19.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22.\"
23.TH PCAP-SAVEFILE @MAN_FILE_FORMATS@ "21 October 2008"
24.SH NAME
25pcap-savefile \- libpcap savefile format
26.SH DESCRIPTION
27NOTE: applications and libraries should, if possible, use libpcap to
28read savefiles, rather than having their own code to read savefiles.
29If, in the future, a new file format is supported by libpcap,
30applications and libraries using libpcap to read savefiles will be able
31to read the new format of savefiles, but applications and libraries
32using their own code to read savefiles will have to be changed to
33support the new file format.
34.PP
35``Savefiles'' read and written by libpcap and applications using libpcap
36start with a per-file header. The format of the per-file header is:
37.RS
38.TS
39box;
40c s
41c | c
42c s.
43Magic number
44_
45Major version Minor version
46_
47Time zone offset
48_
49Time stamp accuracy
50_
51Snapshot length
52_
53Link-layer header type
54.TE
55.RE
56.PP
57All fields in the per-file header are in the byte order of the host
58writing the file. Normally, the first field in the per-file header is a
594-byte magic number, with the value 0xa1b2c3d4. The magic number, when
60read by a host with the same byte order as the host that wrote the file,
61will have the value 0xa1b2c3d4, and, when read by a host with the
62opposite byte order as the host that wrote the file, will have the value
630xd4c3b2a1. That allows software reading the file to determine whether
64the byte order of the host that wrote the file is the same as the byte
65order of the host on which the file is being read, and thus whether the
66values in the per-file and per-packet headers need to be byte-swapped.
67.PP
68If the magic number has the value 0xa1b23c4d (with the two nibbles of
69the two lower-order bytes of the magic number swapped), which would be
70read as 0xa1b23c4d by a host with the same byte order as the host that
71wrote the file and as 0x4d3cb2a1 by a host with the opposite byte order
72as the host that wrote the file, the file format is the same as for
73regular files, except that the time stamps for packets are given in
74seconds and nanoseconds rather than seconds and microseconds.
75.PP
76Following this are:
77.IP
78A 2-byte file format major version number; the current version number is
792.
80.IP
81A 2-byte file format minor version number; the current version number is
824.
83.IP
84A 4-byte time zone offset; this is always 0.
85.IP
86A 4-byte number giving the accuracy of time stamps in the file; this is
87always 0.
88.IP
89A 4-byte number giving the "snapshot length" of the capture; packets
90longer than the snapshot length are truncated to the snapshot length, so
91that, if the snapshot length is
92.IR N ,
93only the first
94.I N
95bytes of a packet longer than
96.I N
97bytes will be saved in the capture.
98.IP
99a 4-byte number giving the link-layer header type for packets in the
100capture; see
101.BR pcap-linktype (@MAN_MISC_INFO@)
102for the
103.B LINKTYPE_
104values that can appear in this field.
105.PP
106Following the per-file header are zero or more packets; each packet
107begins with a per-packet header, which is immediately followed by the
108raw packet data. The format of the per-packet header is:
109.RS
110.TS
111box;
112c.
113Time stamp, seconds value
114_
115Time stamp, microseconds or nanoseconds value
116_
117Length of captured packet data
118_
119Un-truncated length of the packet data
120.TE
121.RE
122.PP
123All fields in the per-packet header are in the byte order of the host
124writing the file. The per-packet header begins with a time stamp giving
125the approximate time the packet was captured; the time stamp consists of
126a 4-byte value, giving the time in seconds since January 1, 1970,
12700:00:00 UTC, followed by a 4-byte value, giving the time in
128microseconds or nanoseconds since that second, depending on the magic
129number in the file header. Following that are a 4-byte value giving the
130number of bytes of captured data that follow the per-packet header and a
1314-byte value giving the number of bytes that would have been present had
132the packet not been truncated by the snapshot length. The two lengths
133will be equal if the number of bytes of packet data are less than or
134equal to the snapshot length.
135.SH SEE ALSO
136pcap(3PCAP), pcap-linktype(@MAN_MISC_INFO@)