Skip to main content

MtuNegotiator

Struct MtuNegotiator 

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

Manages MTU discovery via binary search probing.

The caller is responsible for actually sending probe packets — this struct tracks state and interprets results.

Implementations§

Source§

impl MtuNegotiator

Source

pub fn new(config: MtuConfig) -> Self

Create a new negotiator with the given config.

Source

pub fn start_discovery(&mut self) -> usize

Start MTU discovery. Returns the size of the first probe packet to send.

The caller should send a packet of exactly this size and then call record_probe() with the result.

Source

pub fn record_probe(&mut self, size: usize, success: bool) -> Option<usize>

Record the result of a probe.

size — the probe packet size that was sent. successtrue if the probe was acknowledged, false if it was dropped/timed out.

Returns the next probe size to send, or None if discovery is complete.

Source

pub fn check_probe_timeout(&self) -> Option<usize>

Check if a pending probe has timed out.

If it has, call record_probe(size, false) to register the failure. Returns the timed-out probe size if applicable.

Source

pub fn current_mtu(&self) -> usize

Returns the current best known MTU.

Source

pub fn state(&self) -> &MtuState

Returns the current negotiation state.

Source

pub fn is_complete(&self) -> bool

Returns true if MTU discovery is complete.

Source

pub fn recommended_fragment_size(&self) -> usize

Returns the recommended fragment_size for VCLConfig based on the current MTU, subtracting all protocol headers.

Source

pub fn set_mtu(&mut self, mtu: usize)

Force-set the MTU without probing (e.g. from OS PMTUD or known config).

Source

pub fn fallback_to_min(&mut self)

Fall back to the minimum safe MTU.

Source

pub fn path_mtu(&self) -> PathMtu

Returns a PathMtu snapshot of the current state.

Source

pub fn total_probes(&self) -> u64

Returns total probes sent.

Source

pub fn successful_probes(&self) -> u64

Returns total successful probes.

Source

pub fn probe_history(&self) -> &[(usize, bool)]

Returns the full probe history as (size, success) pairs.

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> 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