The pcap Packet Capture Format


The de facto standard network packet capture format is libpcap (pcap), which is used in packet analyzers such as tcpdump/WinDump and Wireshark. The pcap file format is a binary format, with support for nanosecond-precision timestamps. Although this format varies somewhat from implementation to implementation, all pcap files have the general structure shown in Fig. 1.

The general structure of pcap files
Fig. 1. The general structure
of pcap files

The global header contains the magic number, GMT offset, timestamp precision, the maximum length of captured packets (in octets), and the data link type. This information is followed by zero or more records of captured packet data. Each captured packet starts with the timestamp in seconds, the timestamp in microseconds, the number of octets of packet saved in file, and the actual length of the packet.

Some of the notable variants of pcap are Wireshark’s nanosecond libpcap (nseclibpcap), the modified tcpdump-libpcap (modlibpcap), Nokia’s tcpdump-libpcap (nokialibpcap), and various Linux implementations.

While pcap is supported in Wireshark/TShark as well, their default format is now the pcap Next Generation Capture File Format (pcap-ng).