#[repr(C)]pub struct PacketHeader {
pub version: u8,
pub session_id: SessionId,
pub stream_id: StreamId,
pub sequence: SequenceNumber,
pub flags: PacketFlags,
pub ack_delay: u16,
pub epoch: u8,
pub path_id: u8,
}Expand description
Packet header — 45 bytes on the wire (the AEAD AAD).
Serialised by PacketHeader::to_wire as an explicit, fixed big-endian
(network byte order) image, version first — declaration order == wire
order, no reordering, no reversed arrays:
off 0 version u8 (= WIRE_VERSION)
off 1 session_id [u8;32]
off 33 stream_id u16 be
off 35 sequence u32 be
off 39 flags u16 be
off 41 ack_delay u16 be
off 43 epoch u8
off 44 path_id u8The whole 45-byte image is the AEAD AAD, so flipping any byte (version
included) fails decryption. The recv path additionally drops a frame whose
version != WIRE_VERSION. Frozen by core/tests/wire_vectors/packet_header.bin;
grammar in docs/protocol/PROTOCOL.md § 4.2.
Fields§
§version: u8On-wire packet-format version. Pinned to WIRE_VERSION; the first wire
byte (see PacketHeader::to_wire).
session_id: SessionId256-bit session identifier, used as encryption salt
stream_id: StreamIdStream within session (0 = control)
sequence: SequenceNumberPer-stream sequence number
flags: PacketFlagsPacket flags
ack_delay: u16Delay between processing packet and sending ACK (in microseconds)
epoch: u8Rekey generation. Zero at session establishment, incremented in lock- step on each in-band rekey (Phase 1.5).
path_id: u8Multi-path leg identifier (Phase 4.2). 0 = single-leg default.
Implementations§
Source§impl PacketHeader
impl PacketHeader
Sourcepub fn new(
session_id: SessionId,
stream_id: StreamId,
sequence: SequenceNumber,
flags: PacketFlags,
) -> Self
pub fn new( session_id: SessionId, stream_id: StreamId, sequence: SequenceNumber, flags: PacketFlags, ) -> Self
Create a new packet header (version = WIRE_VERSION, epoch = 0,
path_id = 0, ack_delay = 0).
Sourcepub fn with_epoch(self, epoch: u8) -> Self
pub fn with_epoch(self, epoch: u8) -> Self
Set the rekey epoch — used by Session::rekey (Phase 1.5).
Sourcepub fn with_path_id(self, path_id: u8) -> Self
pub fn with_path_id(self, path_id: u8) -> Self
Set the path id — used by the multi-path scheduler (Phase 4.2).
Trait Implementations§
Source§impl Clone for PacketHeader
impl Clone for PacketHeader
Source§fn clone(&self) -> PacketHeader
fn clone(&self) -> PacketHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PacketHeader
Source§impl Debug for PacketHeader
impl Debug for PacketHeader
impl Eq for PacketHeader
Source§impl PartialEq for PacketHeader
impl PartialEq for PacketHeader
Source§fn eq(&self, other: &PacketHeader) -> bool
fn eq(&self, other: &PacketHeader) -> bool
self and other values to be equal, and is used by ==.