Documentation
¶
Index ¶
Constants ¶
const ( // IP_MTU_DISCOVER is the Linux socket option for MTU discovery IP_MTU_DISCOVER = 10 // IP_PMTUDISC_DO enables PMTU discovery and sets Don't Fragment bit IP_PMTUDISC_DO = 2 )
const ( // MinMTU_IPv4 is the minimum MTU for IPv4 networks (RFC 791) MinMTU_IPv4 = 576 // MinMTU_IPv6 is the minimum MTU for IPv6 networks (RFC 8200) MinMTU_IPv6 = 1280 // MaxMTU is the standard Ethernet MTU MaxMTU = 1500 // ICMPHeaderSize is the size of ICMP header ICMPHeaderSize = 8 // IPv4HeaderSize is the size of IPv4 header IPv4HeaderSize = 20 // IPv6HeaderSize is the size of IPv6 header IPv6HeaderSize = 40 )
const ( // WireGuardOverheadIPv4 is the overhead for WireGuard over IPv4 // (20 bytes IPv4 + 8 bytes UDP + 32 bytes WireGuard) WireGuardOverheadIPv4 = 60 // WireGuardOverheadIPv6 is the overhead for WireGuard over IPv6 // (40 bytes IPv6 + 8 bytes UDP + 32 bytes WireGuard) WireGuardOverheadIPv6 = 80 )
WireGuard overhead constants WireGuard adds the following overhead to each packet: - IPv4/IPv6 header (20/40 bytes) - UDP header (8 bytes) - WireGuard header (32 bytes)
Total overhead: - IPv4: 20 + 8 + 32 = 60 bytes - IPv6: 40 + 8 + 32 = 80 bytes
Variables ¶
This section is empty.
Functions ¶
func CalculateMTU ¶ added in v0.4.0
CalculateMTU returns the appropriate MTU based on whether we're testing through an existing tunnel or to a WireGuard endpoint.
When tunnelMode is true, the path MTU is returned as-is because the WireGuard overhead is already applied by the tunnel.
When tunnelMode is false, the WireGuard overhead is subtracted to give the optimal MTU setting for a new tunnel.
func CalculateWireGuardMTU ¶
CalculateWireGuardMTU calculates the optimal WireGuard interface MTU given the path MTU and IP version
Types ¶
type Discoverer ¶
type Discoverer struct {
// contains filtered or unexported fields
}
Discoverer handles MTU discovery operations
func NewDiscoverer ¶
NewDiscoverer creates a new MTU discoverer for the given target
func (*Discoverer) FindPathMTU ¶
func (d *Discoverer) FindPathMTU() (int, error)
FindPathMTU uses binary search to find the path MTU to the target