decapsulate
Decapsulates packet data at link, network, and transport layer.
Description
The decapsulate
function decodes binary PCAP packet data by extracting link,
network, and transport layer information. The function takes a packet
record
as argument as produced by the PCAP parser, which may
look like this:
This entire record serves as input to decapsulate
since the linktype
determines how to intepret the binary data
field containing the raw packet
data.
With decapsulate
, we aim to provide a minimal packet parsing up to the
transport layer so that you can work with packets in pipelines and implement use
cases such as alert-based PCAP. The goal is not to comprehensively parse all
protocol fields at great depth. If this is your objective, consider
Zeek, Suricata, or
Wireshark.
VLAN Tags
The decapsulate
function also extracts
802.1Q VLAN tags into a nested
vlan
record, consisting of an outer
and inner
field for the respective
tags. The value of the VLAN tag corresponds to the 12-bit VLAN identifier (VID).
Special values include 0
(frame does not carry a VLAN ID) and 0xFFF
(reserved value; sometimes wildcard match).
Examples
Decapsulate packets from a PCAP file
If the trace contains 802.1Q traffic, then the output includes a vlan
record: