13 : send_limit_{initial_window}
14 , receive_limit_{initial_window}
15 , window_size_{initial_window}
16 , last_sent_max_data_{initial_window}
38 const uint64_t available = available_send_window();
39 if (bytes > available) {
41 "Send window exhausted",
42 "quic::flow_controller");
46 data_blocked_sent_ =
false;
74 const uint64_t new_total = bytes_received_ + bytes;
75 if (new_total > receive_limit_) {
77 "Received data exceeds flow control limit",
78 "quic::flow_controller");
81 bytes_received_ = new_total;
106 return consumed_from_last >= threshold;
111 if (!should_send_max_data()) {
116 const uint64_t new_limit = bytes_consumed_ + window_size_;
119 if (new_limit <= last_sent_max_data_) {
123 receive_limit_ = new_limit;
124 last_sent_max_data_ = new_limit;
Connection-level flow control for QUIC (RFC 9000 Section 4)
auto should_send_max_data() const noexcept -> bool
Check if MAX_DATA frame should be sent.
void update_send_limit(uint64_t max_data)
Update the send limit (from peer's MAX_DATA)
auto record_received(uint64_t bytes) -> VoidResult
Record received data.
flow_controller(uint64_t initial_window=1048576)
Construct a flow controller.
auto is_send_blocked() const noexcept -> bool
Check if send is blocked.
void record_consumed(uint64_t bytes)
Record data consumed by application.
auto available_send_window() const noexcept -> uint64_t
Get available send window.
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)
auto consume_send_window(uint64_t bytes) -> VoidResult
Try to consume send window for outgoing data.
uint64_t last_sent_max_data_
void reset(uint64_t initial_window)
Reset flow controller state.
void set_update_threshold(double threshold)
Set the threshold for sending MAX_DATA updates (0.0 - 1.0)
auto generate_max_data() -> std::optional< uint64_t >
Generate MAX_DATA value if update needed.
void set_window_size(uint64_t window)
Set the window size for auto-tuning.
constexpr int receive_overflow
constexpr int send_blocked
auto get_flow_control_stats(const flow_controller &fc) -> flow_control_stats
Get flow control statistics.
VoidResult error_void(int code, const std::string &message, const std::string &source="network_system", const std::string &details="")
Statistics for flow control monitoring.
uint64_t receive_window_available
uint64_t send_window_available