{
    "mode": "man",
    "parameter": "pcap-savefile",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/pcap-savefile/5/json",
    "generated": "2026-09-18T06:17:36Z",
    "sections": {
        "NAME": {
            "content": "pcap-savefile - libpcap savefile format\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "NOTE:  applications  and libraries should, if possible, use libpcap to read savefiles, rather\nthan having their own code to read savefiles.  If, in the future, a new file format  is  sup‐\nported by libpcap, applications and libraries using libpcap to read savefiles will be able to\nread the new format of savefiles, but applications and libraries using their own code to read\nsavefiles will have to be changed to support the new file format.\n\n``Savefiles''  read  and  written by libpcap and applications using libpcap start with a per-\nfile header.  The format of the per-file header is:\n┌───────────────────────────────┐\n│         Magic number          │\n├───────────────┬───────────────┤\n│ Major version │ Minor version │\n├───────────────┴───────────────┤\n│       Time zone offset        │\n├───────────────────────────────┤\n│      Time stamp accuracy      │\n├───────────────────────────────┤\n│        Snapshot length        │\n├───────────────────────────────┤\n│    Link-layer header type     │\n└───────────────────────────────┘\n\nThe per-file header length is 24 octets.\n\nAll fields in the per-file header are in the byte order of the host writing the  file.   Nor‐\nmally,  the  first  field  in  the  per-file  header is a 4-byte magic number, with the value\n0xa1b2c3d4.  The magic number, when read by a host with the same byte order as the host  that\nwrote  the  file,  will have the value 0xa1b2c3d4, and, when read by a host with the opposite\nbyte order as the host that wrote the file, will have  the  value  0xd4c3b2a1.   That  allows\nsoftware reading the file to determine whether the byte order of the host that wrote the file\nis  the  same as the byte order of the host on which the file is being read, and thus whether\nthe values in the per-file and per-packet headers need to be byte-swapped.\n\nIf the magic number has the value 0xa1b23c4d (with the two nibbles  of  the  two  lower-order\nbytes of the magic number swapped), which would be read as 0xa1b23c4d by a host with the same\nbyte order as the host that wrote the file and as 0x4d3cb2a1 by a host with the opposite byte\norder  as the host that wrote the file, the file format is the same as for regular files, ex‐\ncept that the time stamps for packets are given in seconds and nanoseconds rather  than  sec‐\nonds and microseconds.\n\nFollowing this are:\n\nA 2-byte file format major version number; the current version number is 2.\n\nA 2-byte file format minor version number; the current version number is 4.\n\nA 4-byte time zone offset; this is always 0.\n\nA 4-byte number giving the accuracy of time stamps in the file; this is always 0.\n\nA  4-byte  number giving the \"snapshot length\" of the capture; packets longer than the\nsnapshot length are truncated to the snapshot length, so that, if the snapshot  length\nis N, only the first N bytes of a packet longer than N bytes will be saved in the cap‐\nture.\n\na  4-byte  number  giving  the  link-layer header type for packets in the capture; see\npcap-linktype(7) for the LINKTYPE values that can appear in this field.\n\nFollowing the per-file header are zero or more packets; each packet begins with a  per-packet\nheader,  which  is immediately followed by the raw packet data.  The format of the per-packet\nheader is:\n┌───────────────────────────────────────────────┐\n│           Time stamp, seconds value           │\n├───────────────────────────────────────────────┤\n│ Time stamp, microseconds or nanoseconds value │\n├───────────────────────────────────────────────┤\n│        Length of captured packet data         │\n├───────────────────────────────────────────────┤\n│    Un-truncated length of the packet data     │\n└───────────────────────────────────────────────┘\n\nThe per-packet header length is 16 octets.\n\nAll fields in the per-packet header are in the byte order of the host writing the file.   The\nper-packet  header  begins  with a time stamp giving the approximate time the packet was cap‐\ntured; the time stamp consists of a 4-byte value, giving the time in seconds since January 1,\n1970, 00:00:00 UTC, followed by a 4-byte value, giving the time in microseconds  or  nanosec‐\nonds since that second, depending on the magic number in the file header.  Following that are\na  4-byte value giving the number of bytes of captured data that follow the per-packet header\nand a 4-byte value giving the number of bytes that would have been present had the packet not\nbeen truncated by the snapshot length.  The two lengths will be equal if the number of  bytes\nof packet data are less than or equal to the snapshot length.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pcap(3PCAP)\n\n24 April 2020                           PCAP-SAVEFILE(5)",
            "subsections": []
        }
    },
    "summary": "pcap-savefile - libpcap savefile format",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "pcap",
            "section": "3PCAP",
            "url": "https://www.chedong.com/phpMan.php/man/pcap/3PCAP/json"
        },
        {
            "name": "PCAP-SAVEFILE",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/PCAP-SAVEFILE/5/json"
        }
    ]
}