ddn.net.dtls.pmtud

Path MTU Discovery for DTLS (RFC 8899 PLPMTUD).

Implements Packetization Layer Path MTU Discovery to dynamically discover the optimal path MTU for each peer. Uses probe packets of increasing size to detect the maximum transmission unit without relying on ICMP messages.

The PLPMTUD state machine (RFC 8899 §5):

DISABLED → BASE (start probing at MIN_PROBE_SIZE) BASE → SEARCHING (binary search between min and max) SEARCHING → COMPLETE (found optimal MTU) SEARCHING → BASE (probe lost, reduce MTU) COMPLETE → SEARCHING (periodic re-probe)

Thread safety: NOT thread-safe. All access must be serialized by the owning DtlsEngine.

Types 4

enumPmtudState : ubyte

PLPMTUD state machine states (RFC 8899 §5).

DISABLED
BASE
SEARCHING
COMPLETE
ERROR

Per-peer PLPMTUD state.

Tracks the current MTU probe state for a single remote endpoint. The engine creates one instance per connected peer when PLPMTUD is enabled.

Fields
size_t probeSize
size_t confirmedMtu
size_t minMtu
size_t maxMtu
size_t probeSuccessCount
size_t probeAttemptCount
MonoTime lastProbeSent
size_t searchMin
size_t searchMax

Result of a PMTU probe check.

Fields
bool shouldProbe
size_t probeSize
Duration timeout

PLPMTUD engine for DTLS.

Manages per-peer MTU discovery state and determines when to send probe packets and at what size. The engine calls checkProbe() for each peer periodically and sends probe packets when indicated.

Fields
bool enabled_
Duration probeTimeout_
size_t minProbeSize_
size_t maxProbeSize_
size_t requiredSuccesses_
size_t maxAttempts_
Methods
bool enabled() @property const @safe pure nothrow @nogcReturns: true if PLPMTUD is enabled.
void enable(bool on) @safe pure nothrow @nogcEnables or disables PLPMTUD.
PmtudPeerState createPeerState(DatagramEndpoint peer, size_t baseMtu) @safe pure nothrow @nogcCreates initial PMTU state for a new peer.
PmtudProbeResult checkProbe(ref PmtudPeerState state, MonoTime now) @safe pure nothrow @nogcChecks if a probe should be sent for the given peer.
bool recordProbeSuccess(ref PmtudPeerState state) @safe pure nothrow @nogcRecords a successful probe acknowledgment.
size_t recordProbeFailure(ref PmtudPeerState state) @safe pure nothrow @nogcRecords a probe failure (timeout).
size_t effectiveMtu(ref const PmtudPeerState state) const @safe pure nothrow @nogcReturns the effective MTU for a peer.
void resetPeerState(ref PmtudPeerState state, size_t baseMtu) @safe pure nothrow @nogcResets a peer's PMTU state (e.g., after path change).
Constructors
this(Duration probeTimeout = dur!"msecs"(DtlsPmtud.PROBE_TIMEOUT_MS), size_t minProbeSize = DtlsPmtud.MIN_PROBE_SIZE, size_t maxProbeSize = DtlsPmtud.MAX_PROBE_SIZE, size_t requiredSuccesses = DtlsPmtud.PROBE_COUNT, size_t maxAttempts = DtlsPmtud.MAX_PROBE_ATTEMPTS)Constructs a PLPMTUD engine with configurable parameters.