pub struct Packet {
pub index: u64,
pub timestamp: Duration,
pub interface: u32,
pub source: SocketAddrV4,
pub destination: SocketAddrV4,
pub transport: Transport,
pub payload: Vec<u8>,
}Expand description
One UDP datagram or TCP segment, with the addresses it travelled between.
Only IPv4 over Ethernet is modelled, and only UDP and TCP above it, because that is the whole of what a Pro DJ Link capture contains. Anything else in the file — ARP, IPv6, ICMP, a frame from a link layer we do not dissect — is not a packet in this sense and never appears.
The payload has already been IP-defragmented, so an 8 KiB NFS reply arrives here as one datagram and not as the six on the wire.
Fields§
§index: u64Position of the frame in the file, counting from one.
A defragmented datagram carries the index of its last fragment, which is the frame at which it became readable.
timestamp: DurationWhen the frame was captured, since the Unix epoch.
A pcapng simple-packet block records no time at all; those arrive as
Duration::ZERO rather than as a guess.
interface: u32Which of the capture’s interfaces recorded it; 0 for classic pcap.
Worth carrying because a capture of a bridge records the same
datagram once per interface. Two identical packets differing only here
are one datagram seen twice, not two datagrams — crate::tcp folds
them back together, but a UDP count does not, and cannot: nothing on
the wire distinguishes a duplicate from a genuine repeat.
source: SocketAddrV4Who sent it.
Not what to filter a corpus on. See Packet::destination.
destination: SocketAddrV4Who it was addressed to — the field a corpus filter belongs on.
The Pro DJ Link type byte at offset 0x0a is shared across UDP ports
and the layouts behind it are not: 0x06 is a keep-alive on 50000 and
a media response on 50002. A tool that binds one socket and sends its
keep-alives from 50002 therefore contributes packets that a
“either endpoint is 50002” filter accepts and the 50002 decoder reads
as confident nonsense. Filter on where a packet was going, which is the
only thing that decides which protocol wrote it.
transport: TransportWhich transport, and the fields reassembly needs from it.
payload: Vec<u8>The transport payload, with IP fragmentation already undone.
Implementations§
Source§impl Packet
impl Packet
Sourcepub fn udp_payload_to(&self, port: u16) -> Option<&[u8]>
pub fn udp_payload_to(&self, port: u16) -> Option<&[u8]>
The payload, if this datagram was addressed to port over UDP.
The one-packet form of crate::Capture::udp_to, and the same rule:
the destination decides, never the source.