Format:pcapng
| Magic | 0A 0D 0D 0A at offset 0; byte-order magic 4D 3C 2B 1A (LE) or 1A 2B 3C 4D (BE) at offset 8 |
|---|---|
| Extensions | .pcapng, .ntar |
| Endianness | per section, set by the Section Header Block |
| On this wiki | Facts · Code · Notes · Topics |
The block-structured capture format that replaced pcap: a Section Header Block (type 0x0A0D0D0A, byte-order magic 0x1A2B3C4D), Interface Description Blocks and Enhanced Packet Blocks, each block length-prefixed, 32-bit aligned and carrying options.
Overview
pcapng (PCAP Next Generation) stores several interfaces with different link types, per-packet comments and options, name resolution records and TLS decryption secrets in one file. The reference is draft-ietf-opsawg-pcapng (https://github.com/ietf-opsawg-wg/draft-ietf-opsawg-pcap). Older libpcap-style files are described on Format:pcap (libpcap savefile).
Block frame
Every block is u32 block_type; u32 total_length; body (padded to a multiple of 4 bytes); u32 total_length. The repeated trailing length allows reading backwards. total_length includes both length fields and the type; a reader skips unknown blocks with it. Options inside a block are u16 code; u16 length; value padded to 4, ended by code 0 (opt_endofopt).
Section Header Block (SHB), 0x0A0D0D0A
Layout: type 0x0A0D0D0A, total length, byte-order magic 0x1A2B3C4D (read as written by the section's machine, so the bytes tell the byte order), u16 major, u16 minor (the current version is 1.0 per the IETF draft), i64 section_length (signed; -1, 0xFFFFFFFFFFFFFFFF, means the size is not specified and the section can only be skipped by parsing its blocks; otherwise a multiple of 4 excluding the SHB itself), options. The file must start with an SHB; more than one may follow, each with its own byte order. The type value 0x0A0D0D0A is a palindrome of CR/LF bytes chosen so that the file is recognisable in any byte order and so that a text-mode transfer (LF to CRLF changes) is detected. Related reserved patterns 0x0A0D0AXX, 0xXX0A0D0A, 0xXX0A0D0D and 0x0D0D0AXX flag files corrupted by HTTP or FTP text-mode transfers.
Interface Description Block (IDB), 0x00000001
u16 linktype; u16 reserved; u32 snaplen; options. Link type numbers are the same LINKTYPE_ registry as in pcap. Option if_name is code 2 (as listed in the draft's table); if_tsresol is code 9: if the top bit is 0 the remainder is a negative power of ten (6 = microseconds, the default when the option is absent), if 1 a negative power of two.
Enhanced Packet Block (EPB), 0x00000006
u32 interface_id; u32 timestamp_high; u32 timestamp_low; u32 captured_len; u32 original_len; packet data padded to 4; options. The 64-bit timestamp counts units of the interface's if_tsresol since 1970-01-01 UTC.
Other block types
| Type | Block |
|---|---|
| 0x00000002 | Packet Block (obsolete) |
| 0x00000003 | Simple Packet Block (no timestamp, no interface id) |
| 0x00000004 | Name Resolution Block |
| 0x00000005 | Interface Statistics Block |
| 0x00000007 | IRIG timestamp block (also used by the Hone socket aggregation event) |
| 0x00000009 | systemd Journal Export Block |
| 0x0000000A | Decryption Secrets Block (for example TLS key log data) |
| 0x00000BAD / 0x40000BAD | Custom block (rewriters may copy / should not copy) |
| 0x00000201 to 0x00000213 | Sysdig blocks |
| 0x80000000 to 0xFFFFFFFF | local use |
Layouts from the draft (commit 207d00185e, read):
- Simple Packet Block (3):
original_len u32, then packet data padded to 4. No interface id and no timestamp: it always belongs to the first IDB. The captured length is implied by the block length (limited by the snaplen). - Name Resolution Block (4): a list of records
u16 type; u16 length; value padded to 4ended by nrb_record_end: 0 end, 1 IPv4 (4 address octets, then zero-terminated name(s)), 2 IPv6 (16 octets then names), 3 EUI-48, 4 EUI-64. IP octets are in network order regardless of the section's byte order. Usually near the start but may appear anywhere and repeat. - Interface Statistics Block (5):
interface_id u32; timestamp_high u32; timestamp_low u32; options. Options: 2 isb_starttime (u64), 3 isb_endtime, 4 isb_ifrecv, 5 isb_ifdrop, 6 isb_filteraccept, 7 isb_osdrop, 8 isb_usrdeliv, each 8 bytes. Usually at the end of the file, may appear several times per interface. - Decryption Secrets Block (0x0A): see the section above.
Identifying and converting
First four bytes 0A 0D 0D 0A means pcapng whatever the file name. Wireshark's editcap writes pcapng by default and -F <capture type> selects another output type (wireshark/wireshark editcap.c: help text "set the output file type; default is pcapng" at line 1181, default assigned at lines 2167-2169, an invalid type name rejected at lines 1974-1980), so tools that only know classic pcap can be fed a converted copy. tshark has the same option: wireshark/wireshark tshark.c at c502e3e820 prints "-F <output file type> set the output file type; default is pcapng." (line 541) and sets the default file type to pcapng (line 2011). Unverified: the tcpdump option (not read).
Decryption Secrets Block (DSB), 0x0000000A
Layout: u32 type 0x0000000A; u32 total_length; u32 secrets_type; u32 secrets_length; secrets data (padded to 4); options; u32 total_length. secrets_length excludes padding. No DSB-specific options are defined. DSBs should precede the packets that need them (tools may ignore later ones). Secrets types in the draft (draft-ietf-opsawg-pcapng, commit 207d00185e, read):
| Secrets Type | ASCII | Content |
|---|---|---|
| 0x544c534b | TLSK | TLS key log lines, see Format:SSLKEYLOGFILE |
| 0x5353484b | SSHK | SSH key log: lines cookie type key, cookie = hex 16-byte KEXINIT cookie, type SHARED_SECRET or PRIVATE_KEY
|
| 0x55414b4c | UAKL | OPC UA key log (server_key_<channel>_<token>: HEX style lines)
|
| 0x57474b4c | WGKL | WireGuard key log (LOCAL_STATIC_PRIVATE_KEY = base64 ...)
|
| 0x5a4e574b | ZNWK | ZigBee NWK key: 16-byte AES-128 key, then PAN id u16 little-endian, padding |
| 0x5a415053 | ZAPS | ZigBee APS key: 16-byte key, PAN id, two short addresses (u16 LE, lower first) |
| 0x45535053 | ESPS | ESP security associations as CSV |
Lines of the text types end in LF or CRLF. Key logs of long-term keys (WireGuard static keys) are sensitive: store only test keys. Wireshark's editcap can embed or extract a DSB: editcap.c (wireshark c502e3e820, lines 1186-1188) lists --inject-secrets <type>,<file> ("--inject-secrets help" lists the secret types) and --extract-secrets, and line 1190 --discard-all-secrets.
Code & repositories
- https://github.com/ietf-opsawg-wg/draft-ietf-opsawg-pcap @
207d00185e028e13fc22b9f0b051da8767768fe5· license: BSD-3-Clause (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
IETF drafts for pcap, pcapng and the LINKTYPE registry (markdown sources, linktypes.csv).
Tested on: source read, not run: source only · checked 2026-10-18; last activity 2026-10-13
Pitfalls
- Do not assume one byte order for the whole file: a new SHB can change it.
- Timestamp resolution is per interface, not per file.
- Options and packet data are padded to 4 bytes but total_length is the real, padded size.