Blame pcap-savefile.manfile.in

Packit 209cc3
.\" Copyright (c) 1994, 1996, 1997
Packit 209cc3
.\"	The Regents of the University of California.  All rights reserved.
Packit 209cc3
.\"
Packit 209cc3
.\" Redistribution and use in source and binary forms, with or without
Packit 209cc3
.\" modification, are permitted provided that: (1) source code distributions
Packit 209cc3
.\" retain the above copyright notice and this paragraph in its entirety, (2)
Packit 209cc3
.\" distributions including binary code include the above copyright notice and
Packit 209cc3
.\" this paragraph in its entirety in the documentation or other materials
Packit 209cc3
.\" provided with the distribution, and (3) all advertising materials mentioning
Packit 209cc3
.\" features or use of this software display the following acknowledgement:
Packit 209cc3
.\" ``This product includes software developed by the University of California,
Packit 209cc3
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
Packit 209cc3
.\" the University nor the names of its contributors may be used to endorse
Packit 209cc3
.\" or promote products derived from this software without specific prior
Packit 209cc3
.\" written permission.
Packit 209cc3
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
Packit 209cc3
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
Packit 209cc3
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit 209cc3
.\"
Packit 209cc3
.TH PCAP-SAVEFILE @MAN_FILE_FORMATS@ "8 March 2015"
Packit 209cc3
.SH NAME
Packit 209cc3
pcap-savefile \- libpcap savefile format
Packit 209cc3
.SH DESCRIPTION
Packit 209cc3
NOTE: applications and libraries should, if possible, use libpcap to
Packit 209cc3
read savefiles, rather than having their own code to read savefiles.
Packit 209cc3
If, in the future, a new file format is supported by libpcap,
Packit 209cc3
applications and libraries using libpcap to read savefiles will be able
Packit 209cc3
to read the new format of savefiles, but applications and libraries
Packit 209cc3
using their own code to read savefiles will have to be changed to
Packit 209cc3
support the new file format.
Packit 209cc3
.PP
Packit 209cc3
``Savefiles'' read and written by libpcap and applications using libpcap
Packit 209cc3
start with a per-file header.  The format of the per-file header is:
Packit 209cc3
.RS
Packit 209cc3
.TS
Packit 209cc3
box;
Packit 209cc3
c s
Packit 209cc3
c | c
Packit 209cc3
c s.
Packit 209cc3
Magic number
Packit 209cc3
_
Packit 209cc3
Major version	Minor version
Packit 209cc3
_
Packit 209cc3
Time zone offset
Packit 209cc3
_
Packit 209cc3
Time stamp accuracy
Packit 209cc3
_
Packit 209cc3
Snapshot length
Packit 209cc3
_
Packit 209cc3
Link-layer header type
Packit 209cc3
.TE
Packit 209cc3
.RE
Packit 209cc3
.PP
Packit 209cc3
All fields in the per-file header are in the byte order of the host
Packit 209cc3
writing the file.  Normally, the first field in the per-file header is a
Packit 209cc3
4-byte magic number, with the value 0xa1b2c3d4.  The magic number, when
Packit 209cc3
read by a host with the same byte order as the host that wrote the file,
Packit 209cc3
will have the value 0xa1b2c3d4, and, when read by a host with the
Packit 209cc3
opposite byte order as the host that wrote the file, will have the value
Packit 209cc3
0xd4c3b2a1.  That allows software reading the file to determine whether
Packit 209cc3
the byte order of the host that wrote the file is the same as the byte
Packit 209cc3
order of the host on which the file is being read, and thus whether the
Packit 209cc3
values in the per-file and per-packet headers need to be byte-swapped.
Packit 209cc3
.PP
Packit 209cc3
If the magic number has the value 0xa1b23c4d (with the two nibbles of
Packit 209cc3
the two lower-order bytes of the magic number swapped), which would be
Packit 209cc3
read as 0xa1b23c4d by a host with the same byte order as the host that
Packit 209cc3
wrote the file and as 0x4d3cb2a1 by a host with the opposite byte order
Packit 209cc3
as the host that wrote the file, the file format is the same as for
Packit 209cc3
regular files, except that the time stamps for packets are given in
Packit 209cc3
seconds and nanoseconds rather than seconds and microseconds.
Packit 209cc3
.PP
Packit 209cc3
Following this are:
Packit 209cc3
.IP
Packit 209cc3
A 2-byte file format major version number; the current version number is
Packit 209cc3
2.
Packit 209cc3
.IP
Packit 209cc3
A 2-byte file format minor version number; the current version number is
Packit 209cc3
4.
Packit 209cc3
.IP
Packit 209cc3
A 4-byte time zone offset; this is always 0.
Packit 209cc3
.IP
Packit 209cc3
A 4-byte number giving the accuracy of time stamps in the file; this is
Packit 209cc3
always 0.
Packit 209cc3
.IP
Packit 209cc3
A 4-byte number giving the "snapshot length" of the capture; packets
Packit 209cc3
longer than the snapshot length are truncated to the snapshot length, so
Packit 209cc3
that, if the snapshot length is
Packit 209cc3
.IR N ,
Packit 209cc3
only the first
Packit 209cc3
.I N
Packit 209cc3
bytes of a packet longer than
Packit 209cc3
.I N
Packit 209cc3
bytes will be saved in the capture.
Packit 209cc3
.IP
Packit 209cc3
a 4-byte number giving the link-layer header type for packets in the
Packit 209cc3
capture; see
Packit 209cc3
.BR pcap-linktype (@MAN_MISC_INFO@)
Packit 209cc3
for the
Packit 209cc3
.B LINKTYPE_
Packit 209cc3
values that can appear in this field.
Packit 209cc3
.PP
Packit 209cc3
Following the per-file header are zero or more packets; each packet
Packit 209cc3
begins with a per-packet header, which is immediately followed by the
Packit 209cc3
raw packet data.  The format of the per-packet header is:
Packit 209cc3
.RS
Packit 209cc3
.TS
Packit 209cc3
box;
Packit 209cc3
c.
Packit 209cc3
Time stamp, seconds value
Packit 209cc3
_
Packit 209cc3
Time stamp, microseconds or nanoseconds value
Packit 209cc3
_
Packit 209cc3
Length of captured packet data
Packit 209cc3
_
Packit 209cc3
Un-truncated length of the packet data
Packit 209cc3
.TE
Packit 209cc3
.RE
Packit 209cc3
.PP
Packit 209cc3
All fields in the per-packet header are in the byte order of the host
Packit 209cc3
writing the file.  The per-packet header begins with a time stamp giving
Packit 209cc3
the approximate time the packet was captured; the time stamp consists of
Packit 209cc3
a 4-byte value, giving the time in seconds since January 1, 1970,
Packit 209cc3
00:00:00 UTC, followed by a 4-byte value, giving the time in
Packit 209cc3
microseconds or nanoseconds since that second, depending on the magic
Packit 209cc3
number in the file header.  Following that are a 4-byte value giving the
Packit 209cc3
number of bytes of captured data that follow the per-packet header and a
Packit 209cc3
4-byte value giving the number of bytes that would have been present had
Packit 209cc3
the packet not been truncated by the snapshot length.  The two lengths
Packit 209cc3
will be equal if the number of bytes of packet data are less than or
Packit 209cc3
equal to the snapshot length.
Packit 209cc3
.SH SEE ALSO
Packit 209cc3
pcap(3PCAP)