Skip to main content

Packet

Struct Packet 

Source
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: u64

Position 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: Duration

When 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: u32

Which 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: SocketAddrV4

Who sent it.

Not what to filter a corpus on. See Packet::destination.

§destination: SocketAddrV4

Who 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: Transport

Which transport, and the fields reassembly needs from it.

§payload: Vec<u8>

The transport payload, with IP fragmentation already undone.

Implementations§

Source§

impl Packet

Source

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.

Trait Implementations§

Source§

impl Clone for Packet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Packet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Packet

Source§

impl PartialEq for Packet

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Packet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.