|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Path MTU Discovery controller for QUIC (RFC 8899 DPLPMTUD) More...
#include <pmtud_controller.h>

Public Member Functions | |
| pmtud_controller () | |
| Default constructor with default configuration. | |
| pmtud_controller (pmtud_config config) | |
| Constructor with custom configuration. | |
| auto | current_mtu () const noexcept -> size_t |
| Get current validated MTU. | |
| auto | min_mtu () const noexcept -> size_t |
| Get minimum MTU. | |
| auto | max_mtu () const noexcept -> size_t |
| Get maximum MTU being probed. | |
| auto | state () const noexcept -> pmtud_state |
| Get current PMTUD state. | |
| auto | is_enabled () const noexcept -> bool |
| Check if PMTUD is enabled. | |
| auto | is_search_complete () const noexcept -> bool |
| Check if MTU search is complete. | |
| void | enable () |
| Enable PMTUD and start probing. | |
| void | disable () |
| Disable PMTUD. | |
| void | reset () |
| Reset to initial state. | |
| auto | should_probe (std::chrono::steady_clock::time_point now) const noexcept -> bool |
| Check if a probe should be sent. | |
| auto | probe_size () const noexcept -> std::optional< size_t > |
| Get the size for next probe packet. | |
| void | on_probe_sent (size_t size, std::chrono::steady_clock::time_point sent_time) |
| Record that a probe was sent. | |
| void | on_probe_acked (size_t size) |
| Handle probe acknowledgment. | |
| void | on_probe_lost (size_t size) |
| Handle probe loss. | |
| void | on_packet_too_big (size_t reported_mtu) |
| Handle ICMP Packet Too Big message. | |
| auto | next_timeout () const noexcept -> std::optional< std::chrono::steady_clock::time_point > |
| Get next timeout deadline for PMTUD. | |
| void | on_timeout (std::chrono::steady_clock::time_point now) |
| Handle timeout event. | |
Private Member Functions | |
| void | start_search () |
| Start probing from base MTU. | |
| auto | calculate_next_probe_size () const noexcept -> size_t |
| Calculate next probe size using binary search. | |
| void | complete_search () |
| Transition to search_complete state. | |
| void | handle_black_hole () |
| Handle black hole detection. | |
Private Attributes | |
| pmtud_config | config_ |
| Configuration. | |
| pmtud_state | state_ {pmtud_state::disabled} |
| Current state. | |
| size_t | current_mtu_ |
| Current validated MTU. | |
| size_t | search_low_ |
| Lower bound for binary search (known good MTU) | |
| size_t | search_high_ |
| Upper bound for binary search (target MTU) | |
| size_t | probing_mtu_ {0} |
| Current probe size being tested. | |
| size_t | probe_count_ {0} |
| Number of probes sent at current size. | |
| size_t | consecutive_failures_ {0} |
| Number of consecutive probe failures (for black hole detection) | |
| std::chrono::steady_clock::time_point | last_probe_time_ |
| Time of last probe sent. | |
| std::chrono::steady_clock::time_point | search_complete_time_ |
| Time when search was completed (for re-validation) | |
| bool | probe_in_flight_ {false} |
| Whether a probe is currently in flight. | |
Static Private Attributes | |
| static constexpr size_t | kBlackHoleThreshold = 6 |
| Threshold for black hole detection. | |
Path MTU Discovery controller for QUIC (RFC 8899 DPLPMTUD)
Implements Datagram Packetization Layer PMTU Discovery (DPLPMTUD) as specified in RFC 8899 for use with QUIC (RFC 9000 Section 14).
The controller maintains a state machine that:
Definition at line 74 of file pmtud_controller.h.
| kcenon::network::protocols::quic::pmtud_controller::pmtud_controller | ( | ) |
Default constructor with default configuration.
Definition at line 30 of file pmtud_controller.cpp.
|
explicit |
Constructor with custom configuration.
| config | Configuration parameters |
Definition at line 35 of file pmtud_controller.cpp.
References config.
|
nodiscardprivatenoexcept |
Calculate next probe size using binary search.
Definition at line 315 of file pmtud_controller.cpp.
References config_, kcenon::network::protocols::quic::pmtud_config::probe_step, search_high_, and search_low_.
Referenced by on_packet_too_big(), on_probe_acked(), on_probe_lost(), and start_search().

|
private |
Transition to search_complete state.
Definition at line 329 of file pmtud_controller.cpp.
References probe_count_, probing_mtu_, kcenon::network::protocols::quic::search_complete, search_complete_time_, and state_.
Referenced by on_probe_acked(), and on_probe_lost().

|
inlinenodiscardnoexcept |
Get current validated MTU.
Definition at line 96 of file pmtud_controller.h.
References current_mtu_.
Referenced by kcenon::network::protocols::quic::connection::enable_pmtud(), and kcenon::network::protocols::quic::connection::path_mtu().

| void kcenon::network::protocols::quic::pmtud_controller::disable | ( | ) |
Disable PMTUD.
Stops probing and reverts to minimum MTU.
Definition at line 58 of file pmtud_controller.cpp.
References config_, current_mtu_, kcenon::network::protocols::quic::disabled, kcenon::network::protocols::quic::pmtud_config::min_mtu, probe_in_flight_, probing_mtu_, and state_.
Referenced by kcenon::network::protocols::quic::connection::disable_pmtud().

| void kcenon::network::protocols::quic::pmtud_controller::enable | ( | ) |
Enable PMTUD and start probing.
Transitions from disabled state to base state and begins the MTU discovery process.
Definition at line 43 of file pmtud_controller.cpp.
References kcenon::network::protocols::quic::base, config_, consecutive_failures_, current_mtu_, kcenon::network::protocols::quic::disabled, kcenon::network::protocols::quic::pmtud_config::max_probe_mtu, kcenon::network::protocols::quic::pmtud_config::min_mtu, probe_count_, probe_in_flight_, search_high_, search_low_, start_search(), and state_.
Referenced by kcenon::network::protocols::quic::connection::enable_pmtud().


|
private |
Handle black hole detection.
Definition at line 337 of file pmtud_controller.cpp.
References config_, consecutive_failures_, current_mtu_, kcenon::network::protocols::quic::error, kcenon::network::protocols::quic::pmtud_config::max_probe_mtu, kcenon::network::protocols::quic::pmtud_config::min_mtu, probe_count_, probe_in_flight_, probing_mtu_, search_high_, search_low_, and state_.
Referenced by on_packet_too_big(), and on_probe_lost().

|
inlinenodiscardnoexcept |
Check if PMTUD is enabled.
Definition at line 136 of file pmtud_controller.h.
References kcenon::network::protocols::quic::disabled, and state_.
Referenced by kcenon::network::protocols::quic::connection::pmtud_enabled().

|
inlinenodiscardnoexcept |
Check if MTU search is complete.
Definition at line 145 of file pmtud_controller.h.
References kcenon::network::protocols::quic::search_complete, and state_.
|
inlinenodiscardnoexcept |
Get maximum MTU being probed.
Definition at line 114 of file pmtud_controller.h.
References config_, and kcenon::network::protocols::quic::pmtud_config::max_probe_mtu.
|
inlinenodiscardnoexcept |
Get minimum MTU.
Definition at line 105 of file pmtud_controller.h.
References config_, and kcenon::network::protocols::quic::pmtud_config::min_mtu.
Referenced by kcenon::network::protocols::quic::connection::disable_pmtud().

|
nodiscardnoexcept |
Get next timeout deadline for PMTUD.
Definition at line 256 of file pmtud_controller.cpp.
References kcenon::network::protocols::quic::base, config_, kcenon::network::protocols::quic::pmtud_config::confirmation_interval, kcenon::network::protocols::quic::disabled, kcenon::network::protocols::quic::error, last_probe_time_, probe_in_flight_, kcenon::network::protocols::quic::pmtud_config::probe_interval, kcenon::network::protocols::quic::pmtud_config::probe_timeout, kcenon::network::protocols::quic::search_complete, search_complete_time_, kcenon::network::protocols::quic::searching, and state_.
| void kcenon::network::protocols::quic::pmtud_controller::on_packet_too_big | ( | size_t | reported_mtu | ) |
Handle ICMP Packet Too Big message.
| reported_mtu | MTU reported in the ICMP message |
Called when an ICMP PTB message is received. Updates the MTU immediately if the reported value is smaller.
Definition at line 233 of file pmtud_controller.cpp.
References calculate_next_probe_size(), config_, current_mtu_, handle_black_hole(), kcenon::network::protocols::quic::pmtud_config::min_mtu, probe_count_, probing_mtu_, kcenon::network::protocols::quic::search_complete, search_high_, kcenon::network::protocols::quic::searching, and state_.

| void kcenon::network::protocols::quic::pmtud_controller::on_probe_acked | ( | size_t | size | ) |
Handle probe acknowledgment.
| size | Size of the probed packet that was acknowledged |
Called when a probe packet is acknowledged by the peer. If the probed size is larger than current MTU, updates the validated MTU and continues searching.
Definition at line 147 of file pmtud_controller.cpp.
References kcenon::network::protocols::quic::base, calculate_next_probe_size(), complete_search(), config_, consecutive_failures_, current_mtu_, kcenon::network::protocols::quic::error, probe_count_, probe_in_flight_, kcenon::network::protocols::quic::pmtud_config::probe_step, probing_mtu_, kcenon::network::protocols::quic::search_complete, search_complete_time_, search_high_, search_low_, kcenon::network::protocols::quic::searching, and state_.

| void kcenon::network::protocols::quic::pmtud_controller::on_probe_lost | ( | size_t | size | ) |
Handle probe loss.
| size | Size of the probe packet that was lost |
Called when a probe packet is declared lost. Adjusts the search range and may retry probing.
Definition at line 189 of file pmtud_controller.cpp.
References kcenon::network::protocols::quic::base, calculate_next_probe_size(), complete_search(), config_, consecutive_failures_, current_mtu_, kcenon::network::protocols::quic::error, handle_black_hole(), kBlackHoleThreshold, kcenon::network::protocols::quic::pmtud_config::max_probes, kcenon::network::protocols::quic::pmtud_config::min_mtu, probe_count_, probe_in_flight_, kcenon::network::protocols::quic::pmtud_config::probe_step, probing_mtu_, kcenon::network::protocols::quic::search_complete, search_high_, search_low_, kcenon::network::protocols::quic::searching, and state_.
Referenced by on_timeout().


| void kcenon::network::protocols::quic::pmtud_controller::on_probe_sent | ( | size_t | size, |
| std::chrono::steady_clock::time_point | sent_time ) |
Record that a probe was sent.
| size | Size of the probe packet sent |
| sent_time | Time the probe was sent |
Definition at line 138 of file pmtud_controller.cpp.
References last_probe_time_, probe_count_, probe_in_flight_, and probing_mtu_.
| void kcenon::network::protocols::quic::pmtud_controller::on_timeout | ( | std::chrono::steady_clock::time_point | now | ) |
Handle timeout event.
| now | Current time |
Called when the PMTUD timer expires. May trigger probe retransmission or state transitions.
Definition at line 288 of file pmtud_controller.cpp.
References config_, kcenon::network::protocols::quic::disabled, last_probe_time_, on_probe_lost(), probe_in_flight_, kcenon::network::protocols::quic::pmtud_config::probe_timeout, probing_mtu_, and state_.

|
nodiscardnoexcept |
Get the size for next probe packet.
Definition at line 117 of file pmtud_controller.cpp.
References kcenon::network::protocols::quic::base, current_mtu_, kcenon::network::protocols::quic::disabled, probing_mtu_, kcenon::network::protocols::quic::search_complete, kcenon::network::protocols::quic::searching, and state_.
| void kcenon::network::protocols::quic::pmtud_controller::reset | ( | ) |
Reset to initial state.
Clears all state and restarts discovery from minimum MTU.
Definition at line 66 of file pmtud_controller.cpp.
References config_, consecutive_failures_, current_mtu_, kcenon::network::protocols::quic::disabled, kcenon::network::protocols::quic::pmtud_config::max_probe_mtu, kcenon::network::protocols::quic::pmtud_config::min_mtu, probe_count_, probe_in_flight_, probing_mtu_, search_high_, search_low_, and state_.
|
nodiscardnoexcept |
Check if a probe should be sent.
| now | Current time |
Definition at line 78 of file pmtud_controller.cpp.
References kcenon::network::protocols::quic::base, kcenon::network::protocols::quic::disabled, kcenon::network::protocols::quic::error, kcenon::network::protocols::quic::search_complete, and kcenon::network::protocols::quic::searching.
|
private |
Start probing from base MTU.
Definition at line 306 of file pmtud_controller.cpp.
References calculate_next_probe_size(), config_, current_mtu_, kcenon::network::protocols::quic::pmtud_config::max_probe_mtu, probe_count_, probing_mtu_, search_high_, search_low_, kcenon::network::protocols::quic::searching, and state_.
Referenced by enable().


|
inlinenodiscardnoexcept |
Get current PMTUD state.
Definition at line 127 of file pmtud_controller.h.
References state_.
|
private |
Configuration.
Definition at line 284 of file pmtud_controller.h.
Referenced by calculate_next_probe_size(), disable(), enable(), handle_black_hole(), max_mtu(), min_mtu(), next_timeout(), on_packet_too_big(), on_probe_acked(), on_probe_lost(), on_timeout(), reset(), and start_search().
|
private |
Number of consecutive probe failures (for black hole detection)
Definition at line 305 of file pmtud_controller.h.
Referenced by enable(), handle_black_hole(), on_probe_acked(), on_probe_lost(), and reset().
|
private |
Current validated MTU.
Definition at line 290 of file pmtud_controller.h.
Referenced by current_mtu(), disable(), enable(), handle_black_hole(), on_packet_too_big(), on_probe_acked(), on_probe_lost(), probe_size(), reset(), and start_search().
|
staticconstexprprivate |
Threshold for black hole detection.
Definition at line 317 of file pmtud_controller.h.
Referenced by on_probe_lost().
|
private |
Time of last probe sent.
Definition at line 308 of file pmtud_controller.h.
Referenced by next_timeout(), on_probe_sent(), and on_timeout().
|
private |
Number of probes sent at current size.
Definition at line 302 of file pmtud_controller.h.
Referenced by complete_search(), enable(), handle_black_hole(), on_packet_too_big(), on_probe_acked(), on_probe_lost(), on_probe_sent(), reset(), and start_search().
|
private |
Whether a probe is currently in flight.
Definition at line 314 of file pmtud_controller.h.
Referenced by disable(), enable(), handle_black_hole(), next_timeout(), on_probe_acked(), on_probe_lost(), on_probe_sent(), on_timeout(), and reset().
|
private |
Current probe size being tested.
Definition at line 299 of file pmtud_controller.h.
Referenced by complete_search(), disable(), handle_black_hole(), on_packet_too_big(), on_probe_acked(), on_probe_lost(), on_probe_sent(), on_timeout(), probe_size(), reset(), and start_search().
|
private |
Time when search was completed (for re-validation)
Definition at line 311 of file pmtud_controller.h.
Referenced by complete_search(), next_timeout(), and on_probe_acked().
|
private |
Upper bound for binary search (target MTU)
Definition at line 296 of file pmtud_controller.h.
Referenced by calculate_next_probe_size(), enable(), handle_black_hole(), on_packet_too_big(), on_probe_acked(), on_probe_lost(), reset(), and start_search().
|
private |
Lower bound for binary search (known good MTU)
Definition at line 293 of file pmtud_controller.h.
Referenced by calculate_next_probe_size(), enable(), handle_black_hole(), on_probe_acked(), on_probe_lost(), reset(), and start_search().
|
private |
Current state.
Definition at line 287 of file pmtud_controller.h.
Referenced by complete_search(), disable(), enable(), handle_black_hole(), is_enabled(), is_search_complete(), next_timeout(), on_packet_too_big(), on_probe_acked(), on_probe_lost(), on_timeout(), probe_size(), reset(), start_search(), and state().