|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
QUIC congestion control (RFC 9002 Section 7) More...
#include <congestion_controller.h>

Public Member Functions | |
| congestion_controller () | |
| Default constructor. | |
| congestion_controller (size_t max_datagram_size) | |
| Constructor with custom max datagram size. | |
| auto | can_send (size_t bytes=0) const noexcept -> bool |
| Check if we can send more data. | |
| auto | available_window () const noexcept -> size_t |
| Get available congestion window. | |
| auto | on_packet_sent (size_t bytes) -> void |
| Record bytes sent. | |
| auto | on_packet_acked (const sent_packet &packet, std::chrono::steady_clock::time_point ack_time) -> void |
| Handle packet acknowledgment (RFC 9002 Section 7.3) | |
| auto | on_packet_lost (const sent_packet &packet) -> void |
| Handle packet loss (RFC 9002 Section 7.3.2) | |
| auto | on_congestion_event (std::chrono::steady_clock::time_point sent_time) -> void |
| Handle congestion event (RFC 9002 Section 7.3.2) | |
| auto | on_ecn_congestion (std::chrono::steady_clock::time_point sent_time) -> void |
| Handle ECN congestion signal (RFC 9002 Section 7.1) | |
| auto | on_persistent_congestion (const rtt_estimator &rtt) -> void |
| Handle persistent congestion detection (RFC 9002 Section 7.6) | |
| auto | cwnd () const noexcept -> size_t |
| Get current congestion window. | |
| auto | ssthresh () const noexcept -> size_t |
| Get slow start threshold. | |
| auto | bytes_in_flight () const noexcept -> size_t |
| Get bytes in flight. | |
| auto | state () const noexcept -> congestion_state |
| Get current congestion state. | |
| auto | max_datagram_size () const noexcept -> size_t |
| Get max datagram size. | |
| auto | set_max_datagram_size (size_t size) -> void |
| Set max datagram size. | |
| auto | reset () -> void |
| Reset congestion controller to initial state. | |
Private Member Functions | |
| auto | is_in_recovery (std::chrono::steady_clock::time_point sent_time) const noexcept -> bool |
| Check if currently in recovery period. | |
Private Attributes | |
| congestion_state | state_ {congestion_state::slow_start} |
| Current congestion state. | |
| size_t | cwnd_ |
| Congestion window in bytes. | |
| size_t | ssthresh_ {std::numeric_limits<size_t>::max()} |
| Slow start threshold. | |
| size_t | bytes_in_flight_ {0} |
| Bytes currently in flight. | |
| size_t | max_datagram_size_ |
| Maximum datagram size. | |
| std::chrono::steady_clock::time_point | congestion_recovery_start_ |
| Start of the current congestion recovery period. | |
| size_t | initial_window_ |
| Initial window size (for reset) | |
| size_t | minimum_window_ |
| Minimum window size. | |
Static Private Attributes | |
| static constexpr double | kLossReductionFactor = 0.5 |
| Loss reduction factor (RFC 9002 Section 7.3.2) | |
| static constexpr size_t | kDefaultMaxDatagramSize = 1200 |
| Default max datagram size (QUIC minimum guaranteed MTU) | |
| static constexpr size_t | kInitialWindowPackets = 10 |
| Number of datagrams for initial window. | |
| static constexpr size_t | kMinimumWindowPackets = 2 |
| Minimum window in packets. | |
QUIC congestion control (RFC 9002 Section 7)
Implements the NewReno congestion control algorithm as specified in RFC 9002. Manages the congestion window, slow start threshold, and bytes in flight.
Definition at line 42 of file congestion_controller.h.
| kcenon::network::protocols::quic::congestion_controller::congestion_controller | ( | ) |
Default constructor.
Initializes with default parameters:
Definition at line 28 of file congestion_controller.cpp.
|
explicit |
Constructor with custom max datagram size.
| max_datagram_size | Maximum datagram size in bytes |
Definition at line 33 of file congestion_controller.cpp.
References cwnd_, initial_window_, kInitialWindowPackets, kMinimumWindowPackets, max_datagram_size_, and minimum_window_.
|
nodiscardnoexcept |
Get available congestion window.
Definition at line 52 of file congestion_controller.cpp.
References bytes_in_flight_, and cwnd_.
|
inlinenodiscardnoexcept |
Get bytes in flight.
Definition at line 143 of file congestion_controller.h.
References bytes_in_flight_.
|
nodiscardnoexcept |
Check if we can send more data.
| bytes | Number of bytes to send (default 0 means any) |
Definition at line 43 of file congestion_controller.cpp.
|
inlinenodiscardnoexcept |
Get current congestion window.
Definition at line 125 of file congestion_controller.h.
References cwnd_.
|
nodiscardprivatenoexcept |
Check if currently in recovery period.
Definition at line 181 of file congestion_controller.cpp.
References kcenon::network::protocols::quic::recovery.
|
inlinenodiscardnoexcept |
Get max datagram size.
Definition at line 161 of file congestion_controller.h.
References max_datagram_size_.
| auto kcenon::network::protocols::quic::congestion_controller::on_congestion_event | ( | std::chrono::steady_clock::time_point | sent_time | ) | -> void |
Handle congestion event (RFC 9002 Section 7.3.2)
| sent_time | Time the packet was sent |
Called when ECN or persistent congestion is detected.
Definition at line 125 of file congestion_controller.cpp.
References kcenon::network::protocols::quic::recovery.
| auto kcenon::network::protocols::quic::congestion_controller::on_ecn_congestion | ( | std::chrono::steady_clock::time_point | sent_time | ) | -> void |
Handle ECN congestion signal (RFC 9002 Section 7.1)
| sent_time | Time the packet was sent that triggered the ECN-CE signal |
Called when ECN-CE marks are detected in ACK_ECN frame. ECN congestion is treated similarly to packet loss but provides more responsive congestion detection without waiting for packet loss.
Only one congestion response is triggered per RTT to avoid over-reaction to multiple ECN-CE marks within the same round trip.
Definition at line 146 of file congestion_controller.cpp.
References kcenon::network::protocols::quic::recovery.
Referenced by kcenon::network::protocols::quic::connection::handle_loss_detection_result().

| auto kcenon::network::protocols::quic::congestion_controller::on_packet_acked | ( | const sent_packet & | packet, |
| std::chrono::steady_clock::time_point | ack_time ) -> void |
Handle packet acknowledgment (RFC 9002 Section 7.3)
| packet | Acknowledged packet information |
| ack_time | Time the ACK was received |
Definition at line 66 of file congestion_controller.cpp.
References kcenon::network::protocols::quic::congestion_avoidance, kcenon::network::protocols::quic::recovery, and kcenon::network::protocols::quic::slow_start.
Referenced by kcenon::network::protocols::quic::connection::handle_loss_detection_result().

| auto kcenon::network::protocols::quic::congestion_controller::on_packet_lost | ( | const sent_packet & | packet | ) | -> void |
Handle packet loss (RFC 9002 Section 7.3.2)
| packet | Lost packet information |
Definition at line 113 of file congestion_controller.cpp.
Referenced by kcenon::network::protocols::quic::connection::handle_loss_detection_result().

| auto kcenon::network::protocols::quic::congestion_controller::on_packet_sent | ( | size_t | bytes | ) | -> void |
Record bytes sent.
| bytes | Number of bytes sent |
Definition at line 61 of file congestion_controller.cpp.
| auto kcenon::network::protocols::quic::congestion_controller::on_persistent_congestion | ( | const rtt_estimator & | rtt | ) | -> void |
Handle persistent congestion detection (RFC 9002 Section 7.6)
| rtt | RTT estimator for PTO calculation |
Definition at line 172 of file congestion_controller.cpp.
References kcenon::network::protocols::quic::slow_start.
| auto kcenon::network::protocols::quic::congestion_controller::reset | ( | ) | -> void |
Reset congestion controller to initial state.
Definition at line 203 of file congestion_controller.cpp.
References kcenon::network::protocols::quic::slow_start.
| auto kcenon::network::protocols::quic::congestion_controller::set_max_datagram_size | ( | size_t | size | ) | -> void |
Set max datagram size.
| size | New maximum datagram size |
Definition at line 193 of file congestion_controller.cpp.
Referenced by kcenon::network::protocols::quic::connection::disable_pmtud(), and kcenon::network::protocols::quic::connection::enable_pmtud().

|
inlinenodiscardnoexcept |
Get slow start threshold.
Definition at line 134 of file congestion_controller.h.
References ssthresh_.
|
inlinenodiscardnoexcept |
Get current congestion state.
Definition at line 152 of file congestion_controller.h.
References state_.
|
private |
Bytes currently in flight.
Definition at line 195 of file congestion_controller.h.
Referenced by available_window(), and bytes_in_flight().
|
private |
Start of the current congestion recovery period.
Definition at line 201 of file congestion_controller.h.
|
private |
Congestion window in bytes.
Definition at line 189 of file congestion_controller.h.
Referenced by available_window(), congestion_controller(), and cwnd().
|
private |
Initial window size (for reset)
Definition at line 204 of file congestion_controller.h.
Referenced by congestion_controller().
|
staticconstexprprivate |
Default max datagram size (QUIC minimum guaranteed MTU)
Definition at line 213 of file congestion_controller.h.
|
staticconstexprprivate |
Number of datagrams for initial window.
Definition at line 216 of file congestion_controller.h.
Referenced by congestion_controller().
|
staticconstexprprivate |
Loss reduction factor (RFC 9002 Section 7.3.2)
Definition at line 210 of file congestion_controller.h.
|
staticconstexprprivate |
Minimum window in packets.
Definition at line 219 of file congestion_controller.h.
Referenced by congestion_controller().
|
private |
Maximum datagram size.
Definition at line 198 of file congestion_controller.h.
Referenced by congestion_controller(), and max_datagram_size().
|
private |
Minimum window size.
Definition at line 207 of file congestion_controller.h.
Referenced by congestion_controller().
|
private |
Slow start threshold.
Definition at line 192 of file congestion_controller.h.
Referenced by ssthresh().
|
private |
Current congestion state.
Definition at line 186 of file congestion_controller.h.
Referenced by state().