struct

Filament::Capture::RawPacket

Inherits Struct < Value < Object

Represents a single captured network packet with all the information we need to dissect and analyze it. This is a value type (struct) for performance, since we'll create millions of these during a typical analysis run.

packet = RawPacket.new(
  data: raw_bytes,
  timestamp: Time.utc,
  original_length: 1514_u32,
  capture_length: 1514_u32,
  interface_id: 0_u32,
  link_type: LinkType::Ethernet
)
puts packet.truncated? # => false

Constructors

Instance methods

bytes_missing

How many bytes of the original packet are missing due to snap length truncation? Returns 0 if the full packet was captured.

Source
capture_length

How many bytes were actually captured. Equal to data.size, but stored explicitly for clarity and to match the PCAP format.

Source
captured_length

Alias for captured_length

Source
data

The raw packet bytes, starting with the link-layer header. This slice may be shorter than the original packet if snapping occurred.

Source
full_capture?

Was the entire packet captured without truncation?

Source
interface_id

Which interface captured this packet. For classic PCAP this is always 0 (there's only one interface). For pcapng, each interface gets a sequential ID.

Source
network_payload

Returns the packet data starting after the link-layer header. This gives you the network layer (usually IP) payload directly. Returns nil if the packet is too short to contain even a complete link-layer header.

Source
original_length

The original length of the packet on the wire, before any truncation due to snap length.

Source
timestamp

When the packet was captured. For file-based captures this comes from the packet header timestamp. For live captures it's set by the capture engine.

Source
timestamp_nsec

Returns the timestamp as nanoseconds since the Unix epoch. Maximum precision available from the capture.

Source
timestamp_usec

Returns the timestamp as microseconds since the Unix epoch. Useful for high-precision timing calculations.

Source
to_s(io : IO) : Nil

Returns a concise summary string for logging and debugging.

Source
truncated?

Was this packet truncated? Returns true if the captured data is shorter than what was actually on the wire.

Source