Skip to content

Parses PCAP byte streams into packet events.

read_pcap [emit_file_headers=bool]

The read_pcap operator converts raw bytes representing a PCAP file into events.

Emit a pcap.file_header event that represents the PCAP file header. If present, the parser injects this additional event before the subsequent stream of packets.

Emitting this extra event makes it possible to seed write_pcap with a file header from the input. This allows you to preserve timestamp formatting (microseconds vs. nanoseconds) and byte order in packet headers.

When the parser processes a concatenated stream of PCAP files, emit_file_headers=true also re-emits every intermediate file header as a separate event.

Use this option when you want to reproduce the original trace layout.

The operator emits events with the following schemas.

Contains the global header for one PCAP trace.

FieldTypeDescription
magic_numberuint64The PCAP magic number.
major_versionuint64The major PCAP format version.
minor_versionuint64The minor PCAP format version.
reserved1uint64Reserved header field.
reserved2uint64Reserved header field.
snaplenuint64The maximum captured packet size.
linktypeuint64The link-layer type for subsequent packets.

Contains one captured packet from the trace.

FieldTypeDescription
timestamptimeThe time when the packet was captured.
linktypeuint64The link-layer type of the packet.
original_packet_lengthuint64The length of the original packet.
captured_packet_lengthuint64The length of the captured packet.
datablobThe captured packet payload.
from_file "/tmp/trace.pcap" {
read_pcap
}

Capture packets from en1 and preserve file headers

Section titled “Capture packets from en1 and preserve file headers”
from_nic "en1" {
read_pcap emit_file_headers=true
}

Last updated: