Introduction
A PCAP file is a recording of network traffic. It is the format written by tcpdump and the libpcap library, and nearly every network tool can read it. Each packet is stored exactly as it was captured, with the time it was seen.
The format is simple and has hardly changed since the late 1980s. Its successor,
pcapng (.pcapng), is now Wireshark’s
default and can also record the interfaces, comments and statistics of a capture.
Structure
The file starts with a 24-byte file
header. Its first field is the magic number 0xA1B2C3D4, written in the
byte order of the machine that made the capture. A reader that sees
D4 C3 B2 A1 knows the rest of the file is little-endian. The magic number
0xA1B23C4D means the timestamps are in nanoseconds rather than
microseconds. The rest of the header gives the version, 2.4, the snapshot length, which
is the most bytes kept from any one packet, and the
link-layer type, such as 1 for
Ethernet.
Packet records follow until the end of the file. Each is a 16-byte header, giving the timestamp in seconds and fractions, the number of bytes saved and the packet’s original length, then the saved bytes of the packet.
0Global header magic, version, snapshot length, link type24 bytes24Packet record one per captured packetrepeated+0Record header seconds, fraction, saved length, original length16 bytes+16Packet data the captured bytessaved length
Not described
Known, not yet covered
- Reference: the other vendor variants listed on the Wireshark wiki page:
Nokia (4 extra bytes in each record header), AIX (version 2.2 with RFC 1573 link types and
nanosecond times) and IXIA (a length field at the end of the file header, magics
0x1C0001ACand0x01C0001AB). - Viewer: the Nokia, AIX and IXIA variants above are not read (the viewer shows the file as bytes);
the Navtel magic
0xA12B3C4Dand the reserved magic0xA1B234CDare named, and their records are shown as bytes. - Viewer: protocols the viewer does not take apart are shown as named bytes: QUIC and TLS payloads after the keys change are encrypted, and QUIC Initial packets are not decrypted (protocols). Most other protocols (SIP, RTP, SMB, BGP, OSPF, SNMP and hundreds more) and most registered link types (Juniper, Wi-Fi vendor headers, Bluetooth LE, MTP, LAPD and so on) are named but not decoded into fields. No display filter or search over the packet list exists.
- Viewer: TCP streams are not reassembled inside the packet tree (a message split over several segments shows only its first part there); the Conversations tab follows a whole stream as text and hexadecimal instead. The whole-file tabs look at the first 500,000 packets.
Unknown
- Reference: the meaning of the CPU 1 and CPU 2 bytes of the
ss990915record header: the Wireshark wiki says it is unknown (packet records).
Links
Software
- Wireshark and TShark – free network analyser, with a window and on the command line, that opens and writes PCAP (Windows, macOS, Linux)
- tcpdump – command-line packet capture tool that writes and reads PCAP (Linux, macOS)
- Zeek – network analysis framework that reads captures (Linux, macOS)
- NetworkMiner – network forensics tool that opens PCAP files (Windows)
Developers
Reference
- pcap-savefile – the tcpdump project’s description of the file format
- PCAP Capture File Format – the IETF draft that documents the format
- Link-layer header types – the tcpdump project’s register of LINKTYPE values