quic_flow (quic v1.3.1)
View SourceQUIC connection-level flow control implementation.
This module manages flow control at the connection level: - Tracking bytes sent against peer's MAX_DATA limit - Tracking bytes received against our MAX_DATA limit - Generating MAX_DATA frames when needed - Detecting when we're blocked by flow control
Flow Control Concepts
- MAX_DATA: Maximum total bytes the peer can send - DATA_BLOCKED: Indicates sender is blocked by receiver's limit - Window: The difference between max_data and bytes received
Summary
Functions
Get total bytes we've received.
Get total bytes we've sent.
Check if we can send the specified number of bytes.
Generate a new MAX_DATA value to send. Returns {NewMaxData, UpdatedState}.
Create a new flow control state.
Create a new flow control state with options.
Record that we received data.
Record that we sent data. Returns {ok, NewState} or {blocked, NewState} if we hit the limit.
Process a MAX_DATA frame from peer. Updates our send limit.
Get our current receive limit (our MAX_DATA).
Get available receive window.
Check if we're currently blocked on send flow control.
Get our current send limit (peer's MAX_DATA).
Get available send window.
Check if we should send a MAX_DATA update. Returns true if we've consumed more than the threshold.
Types
Functions
-spec bytes_received(flow_state()) -> non_neg_integer().
Get total bytes we've received.
-spec bytes_sent(flow_state()) -> non_neg_integer().
Get total bytes we've sent.
-spec can_send(flow_state(), non_neg_integer()) -> boolean().
Check if we can send the specified number of bytes.
-spec generate_max_data(flow_state()) -> {non_neg_integer(), flow_state()}.
Generate a new MAX_DATA value to send. Returns {NewMaxData, UpdatedState}.
-spec new() -> flow_state().
Create a new flow control state.
-spec new(map()) -> flow_state().
Create a new flow control state with options.
-spec on_data_received(flow_state(), non_neg_integer()) -> {ok, flow_state()} | {error, flow_control_error}.
Record that we received data.
-spec on_data_sent(flow_state(), non_neg_integer()) -> {ok | blocked, flow_state()}.
Record that we sent data. Returns {ok, NewState} or {blocked, NewState} if we hit the limit.
-spec on_max_data_received(flow_state(), non_neg_integer()) -> flow_state().
Process a MAX_DATA frame from peer. Updates our send limit.
-spec recv_limit(flow_state()) -> non_neg_integer().
Get our current receive limit (our MAX_DATA).
-spec recv_window(flow_state()) -> non_neg_integer().
Get available receive window.
-spec send_blocked(flow_state()) -> boolean().
Check if we're currently blocked on send flow control.
-spec send_limit(flow_state()) -> non_neg_integer().
Get our current send limit (peer's MAX_DATA).
-spec send_window(flow_state()) -> non_neg_integer().
Get available send window.
-spec should_send_max_data(flow_state()) -> boolean().
Check if we should send a MAX_DATA update. Returns true if we've consumed more than the threshold.