Skip to main content

Module mtu

Module mtu 

Source
Expand description

§VCL MTU Negotiation

Automatic MTU (Maximum Transmission Unit) discovery and negotiation for VCL connections.

§Why MTU matters for VPN

Physical MTU:  1500 bytes (Ethernet)
IP header:       20 bytes
UDP header:       8 bytes
VCL header:      ~64 bytes
─────────────────────────
Usable payload: 1408 bytes  ← this is what fragment_size should be

If packets are larger than the path MTU they get fragmented by the OS or silently dropped — causing mysterious slowdowns in VPN tunnels.

§Example

use vcl_protocol::mtu::{MtuConfig, MtuNegotiator, PathMtu};

let config = MtuConfig::default();
let mut negotiator = MtuNegotiator::new(config);

// Probe results come in as you send test packets
negotiator.record_probe(1400, true);
negotiator.record_probe(1450, false); // dropped — too large

let mtu = negotiator.current_mtu();
println!("Path MTU: {}", mtu);

let vcl_payload = negotiator.recommended_fragment_size();
println!("Use fragment_size: {}", vcl_payload);

Structs§

MtuConfig
Configuration for MTU negotiation.
MtuNegotiator
Manages MTU discovery via binary search probing.
PathMtu
The result of MTU discovery for a network path.

Enums§

MtuState
State of the MTU negotiation process.

Constants§

ETHERNET_MTU
Standard Ethernet MTU.
IPV4_HEADER
IPv4 header size (minimum, no options).
IPV6_HEADER
IPv6 header size (fixed).
MAX_MTU
Maximum MTU we will ever probe.
MIN_MTU
Minimum safe MTU — guaranteed to work everywhere (RFC 791).
UDP_HEADER
UDP header size.
VCL_HEADER_OVERHEAD
Overhead added by VCL Protocol headers on top of IP+UDP. Ed25519 sig(64) + prev_hash(32) + nonce(24) + sequence(8) + version(1) + bincode overhead(~20)

Functions§

fragment_size_for_mtu
Compute the recommended fragment size for a known MTU and transport.