|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Connection-level flow control for QUIC (RFC 9000 Section 4) More...
#include <flow_control.h>

Public Member Functions | |
| flow_controller (uint64_t initial_window=1048576) | |
| Construct a flow controller. | |
| ~flow_controller ()=default | |
| flow_controller (const flow_controller &)=default | |
| auto | operator= (const flow_controller &) -> flow_controller &=default |
| flow_controller (flow_controller &&) noexcept=default | |
| auto | operator= (flow_controller &&) noexcept -> flow_controller &=default |
| auto | available_send_window () const noexcept -> uint64_t |
| Get available send window. | |
| auto | consume_send_window (uint64_t bytes) -> VoidResult |
| Try to consume send window for outgoing data. | |
| void | update_send_limit (uint64_t max_data) |
| Update the send limit (from peer's MAX_DATA) | |
| auto | is_send_blocked () const noexcept -> bool |
| Check if send is blocked. | |
| auto | send_limit () const noexcept -> uint64_t |
| Get the current send limit (peer's MAX_DATA) | |
| auto | bytes_sent () const noexcept -> uint64_t |
| Get total bytes sent. | |
| auto | record_received (uint64_t bytes) -> VoidResult |
| Record received data. | |
| void | record_consumed (uint64_t bytes) |
| Record data consumed by application. | |
| auto | receive_limit () const noexcept -> uint64_t |
| Get our receive limit (advertised as MAX_DATA) | |
| auto | bytes_received () const noexcept -> uint64_t |
| Get total bytes received. | |
| auto | bytes_consumed () const noexcept -> uint64_t |
| Get bytes consumed by application. | |
| auto | should_send_max_data () const noexcept -> bool |
| Check if MAX_DATA frame should be sent. | |
| auto | generate_max_data () -> std::optional< uint64_t > |
| Generate MAX_DATA value if update needed. | |
| auto | should_send_data_blocked () const noexcept -> bool |
| Check if DATA_BLOCKED frame should be sent. | |
| void | mark_data_blocked_sent () |
| Mark DATA_BLOCKED as sent (to avoid repeated sending) | |
| void | set_window_size (uint64_t window) |
| Set the window size for auto-tuning. | |
| auto | window_size () const noexcept -> uint64_t |
| Get the current window size. | |
| void | set_update_threshold (double threshold) |
| Set the threshold for sending MAX_DATA updates (0.0 - 1.0) | |
| void | reset (uint64_t initial_window) |
| Reset flow controller state. | |
Private Attributes | |
| uint64_t | send_limit_ {0} |
| uint64_t | bytes_sent_ {0} |
| bool | data_blocked_sent_ {false} |
| uint64_t | receive_limit_ {0} |
| uint64_t | bytes_received_ {0} |
| uint64_t | bytes_consumed_ {0} |
| uint64_t | window_size_ |
| double | update_threshold_ {0.5} |
| uint64_t | last_sent_max_data_ {0} |
Connection-level flow control for QUIC (RFC 9000 Section 4)
QUIC provides connection-level and stream-level flow control. This class handles connection-level flow control, tracking the total amount of data that can be sent/received across all streams.
Definition at line 33 of file flow_control.h.
|
explicit |
Construct a flow controller.
| initial_window | Initial window size (from transport parameters) |
Definition at line 12 of file flow_control.cpp.
|
default |
|
default |
|
defaultnoexcept |
|
nodiscardnoexcept |
Get available send window.
Definition at line 24 of file flow_control.cpp.
References bytes_sent_, and send_limit_.
|
inlinenodiscardnoexcept |
Get bytes consumed by application.
Definition at line 120 of file flow_control.h.
References bytes_consumed_.
|
inlinenodiscardnoexcept |
Get total bytes received.
Definition at line 115 of file flow_control.h.
References bytes_received_.
|
inlinenodiscardnoexcept |
|
nodiscard |
Try to consume send window for outgoing data.
| bytes | Number of bytes to consume |
Definition at line 32 of file flow_control.cpp.
References kcenon::network::error_void(), kcenon::network::ok(), and kcenon::network::protocols::quic::flow_control_error::send_blocked.

|
nodiscard |
Generate MAX_DATA value if update needed.
Definition at line 109 of file flow_control.cpp.
|
nodiscardnoexcept |
Check if send is blocked.
Definition at line 59 of file flow_control.cpp.
References bytes_sent_, and send_limit_.
Referenced by should_send_data_blocked().

| void kcenon::network::protocols::quic::flow_controller::mark_data_blocked_sent | ( | ) |
Mark DATA_BLOCKED as sent (to avoid repeated sending)
Definition at line 133 of file flow_control.cpp.
References data_blocked_sent_.
|
default |
|
defaultnoexcept |
|
inlinenodiscardnoexcept |
Get our receive limit (advertised as MAX_DATA)
Definition at line 110 of file flow_control.h.
References receive_limit_.
| void kcenon::network::protocols::quic::flow_controller::record_consumed | ( | uint64_t | bytes | ) |
Record data consumed by application.
| bytes | Number of bytes consumed |
Definition at line 85 of file flow_control.cpp.
References bytes_consumed_, and bytes_received_.
|
nodiscard |
Record received data.
| bytes | Number of bytes received |
Definition at line 68 of file flow_control.cpp.
References kcenon::network::error_void(), kcenon::network::ok(), and kcenon::network::protocols::quic::flow_control_error::receive_overflow.

| void kcenon::network::protocols::quic::flow_controller::reset | ( | uint64_t | initial_window | ) |
Reset flow controller state.
| initial_window | New initial window size |
Definition at line 156 of file flow_control.cpp.
References bytes_consumed_, bytes_received_, bytes_sent_, data_blocked_sent_, last_sent_max_data_, receive_limit_, send_limit_, and window_size_.
|
inlinenodiscardnoexcept |
Get the current send limit (peer's MAX_DATA)
Definition at line 83 of file flow_control.h.
References send_limit_.
| void kcenon::network::protocols::quic::flow_controller::set_update_threshold | ( | double | threshold | ) |
Set the threshold for sending MAX_DATA updates (0.0 - 1.0)
| threshold | Fraction of window that triggers update |
Definition at line 147 of file flow_control.cpp.
References update_threshold_.
| void kcenon::network::protocols::quic::flow_controller::set_window_size | ( | uint64_t | window | ) |
Set the window size for auto-tuning.
| window | New window size |
Definition at line 142 of file flow_control.cpp.
References window_size_.
|
nodiscardnoexcept |
Check if DATA_BLOCKED frame should be sent.
Definition at line 128 of file flow_control.cpp.
References data_blocked_sent_, and is_send_blocked().

|
nodiscardnoexcept |
Check if MAX_DATA frame should be sent.
Definition at line 98 of file flow_control.cpp.
References bytes_consumed_, last_sent_max_data_, update_threshold_, and window_size_.
| void kcenon::network::protocols::quic::flow_controller::update_send_limit | ( | uint64_t | max_data | ) |
Update the send limit (from peer's MAX_DATA)
| max_data | New maximum data limit |
Definition at line 50 of file flow_control.cpp.
References data_blocked_sent_, kcenon::network::protocols::quic::max_data, and send_limit_.
Referenced by kcenon::network::protocols::quic::connection::apply_remote_params().

|
inlinenodiscardnoexcept |
Get the current window size.
Definition at line 160 of file flow_control.h.
References window_size_.
|
private |
Definition at line 187 of file flow_control.h.
Referenced by bytes_consumed(), record_consumed(), reset(), and should_send_max_data().
|
private |
Definition at line 186 of file flow_control.h.
Referenced by bytes_received(), record_consumed(), and reset().
|
private |
Definition at line 181 of file flow_control.h.
Referenced by available_send_window(), bytes_sent(), is_send_blocked(), and reset().
|
private |
Definition at line 182 of file flow_control.h.
Referenced by mark_data_blocked_sent(), reset(), should_send_data_blocked(), and update_send_limit().
|
private |
Definition at line 194 of file flow_control.h.
Referenced by reset(), and should_send_max_data().
|
private |
Definition at line 185 of file flow_control.h.
Referenced by receive_limit(), and reset().
|
private |
Definition at line 180 of file flow_control.h.
Referenced by available_send_window(), is_send_blocked(), reset(), send_limit(), and update_send_limit().
|
private |
Definition at line 191 of file flow_control.h.
Referenced by set_update_threshold(), and should_send_max_data().
|
private |
Definition at line 190 of file flow_control.h.
Referenced by reset(), set_window_size(), should_send_max_data(), and window_size().