Skip to main content

PathMtuState

Struct PathMtuState 

Source
pub struct PathMtuState { /* private fields */ }
Expand description

Path MTU tracking for a single session.

Destination side: observes path_mtu from incoming SessionDatagram envelopes and generates PathMtuNotification messages back to the source.

Source side: applies received PathMtuNotification to limit outbound datagram size. Decrease is immediate; increase requires 3 consecutive notifications.

Implementations§

Source§

impl PathMtuState

Source

pub fn new() -> Self

Create path MTU state with no initial measurement.

Source

pub fn current_mtu(&self) -> u16

Current effective path MTU (source-side, for sending).

Source

pub fn last_observed_mtu(&self) -> u16

Last observed incoming path MTU (destination-side).

Source

pub fn update_interval_from_srtt(&mut self, srtt_ms: f64)

Update notification interval from SRTT: max(10s, 5 * SRTT).

Source

pub fn seed_source_mtu(&mut self, outbound_mtu: u16)

Seed source-side current_mtu from outbound transport MTU.

Called on each send. Only decreases (never increases) the current_mtu so the destination’s PathMtuNotification can still raise it later. Ensures current_mtu doesn’t stay at u16::MAX before any notification arrives from the destination.

Source

pub fn observe_incoming_mtu(&mut self, path_mtu: u16)

Observe the path_mtu from an incoming SessionDatagram envelope.

Called on the destination (receiver) side for every session message.

Source

pub fn should_send_notification(&self, now: Instant) -> bool

Check if a PathMtuNotification should be sent.

Send on first measurement, on decrease (immediate), or periodic confirmation at the notification interval.

Source

pub fn build_notification(&mut self, now: Instant) -> Option<u16>

Build a PathMtuNotification from current state.

Returns the path_mtu value to send. Caller handles encoding.

Source

pub fn apply_notification(&mut self, reported_mtu: u16, now: Instant) -> bool

Apply a received PathMtuNotification.

  • Decrease: immediate (take the lower value).
  • Increase: require 3 consecutive notifications with the same higher value, spanning at least 2 * notification_interval.

Returns true if the effective MTU changed.

Trait Implementations§

Source§

impl Default for PathMtuState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more