nquic_pmtud (nquic v1.0.0)

View Source

Datagram Packetization Layer PMTU Discovery (DPLPMTUD) per RFC 8899.

Pure functional state machine for path MTU discovery. The caller (nquic_protocol or nquic_conn_statem) drives transitions by calling on_probe_acked/1, on_probe_lost/1, on_timeout/1, etc.

States: disabled, base, searching, search_complete, error.

Summary

Functions

Disable PMTUD. Resets to BASE_PLPMTU.

Enable PMTUD. Transitions from disabled to searching.

Generate a probe frame list (PING + PADDING to target size). Returns {ok, Frames, Size, State} where Size is the target probe size and State has probe_pending cleared, or {error, no_probe_needed}.

Get the current effective MTU.

Get the size of the next probe packet.

Get the current DPLPMTUD state.

Get the timer interval in milliseconds, or infinity if no timer needed.

Whether a probe packet should be sent now.

Create a new PMTUD state (disabled).

Create a new PMTUD state with a custom max MTU.

Called when black hole is detected (sustained loss after MTU increase).

Called when a probe packet was acknowledged.

Called when a probe packet was lost (not acked within timeout).

Called on reprobe timer expiry. Triggers a new search from current MTU.

Types

pmtud_state()

-type pmtud_state() ::
          #pmtud{state :: disabled | base | searching | search_complete | error,
                 current_mtu :: pos_integer(),
                 probe_size :: non_neg_integer(),
                 probe_count :: non_neg_integer(),
                 search_low :: pos_integer(),
                 search_high :: pos_integer(),
                 probe_pending :: boolean(),
                 last_probe_time :: non_neg_integer()}.

Functions

disable(S)

-spec disable(pmtud_state()) -> pmtud_state().

Disable PMTUD. Resets to BASE_PLPMTU.

enable/1

-spec enable(pmtud_state()) -> pmtud_state().

Enable PMTUD. Transitions from disabled to searching.

generate_probe/1

-spec generate_probe(pmtud_state()) ->
                        {ok, [nquic_frame:t()], pos_integer(), pmtud_state()} | {error, no_probe_needed}.

Generate a probe frame list (PING + PADDING to target size). Returns {ok, Frames, Size, State} where Size is the target probe size and State has probe_pending cleared, or {error, no_probe_needed}.

get_current_mtu/1

-spec get_current_mtu(pmtud_state()) -> pos_integer().

Get the current effective MTU.

get_probe_size/1

-spec get_probe_size(pmtud_state()) -> non_neg_integer().

Get the size of the next probe packet.

get_state/1

-spec get_state(pmtud_state()) -> disabled | base | searching | search_complete | error.

Get the current DPLPMTUD state.

get_timer_ms/1

-spec get_timer_ms(pmtud_state()) -> pos_integer() | infinity.

Get the timer interval in milliseconds, or infinity if no timer needed.

needs_probe/1

-spec needs_probe(pmtud_state()) -> boolean().

Whether a probe packet should be sent now.

new()

-spec new() -> pmtud_state().

Create a new PMTUD state (disabled).

new(MaxMTU)

-spec new(pos_integer()) -> pmtud_state().

Create a new PMTUD state with a custom max MTU.

on_black_hole(S)

-spec on_black_hole(pmtud_state()) -> pmtud_state().

Called when black hole is detected (sustained loss after MTU increase).

on_probe_acked/1

-spec on_probe_acked(pmtud_state()) -> pmtud_state().

Called when a probe packet was acknowledged.

on_probe_lost/1

-spec on_probe_lost(pmtud_state()) -> pmtud_state().

Called when a probe packet was lost (not acked within timeout).

on_timeout/1

-spec on_timeout(pmtud_state()) -> pmtud_state().

Called on reprobe timer expiry. Triggers a new search from current MTU.