quic_flow (quic v0.11.0)

View Source

QUIC 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

flow_state/0

-opaque flow_state()

Functions

bytes_received(Flow_state)

-spec bytes_received(flow_state()) -> non_neg_integer().

Get total bytes we've received.

bytes_sent(Flow_state)

-spec bytes_sent(flow_state()) -> non_neg_integer().

Get total bytes we've sent.

can_send(Flow_state, Size)

-spec can_send(flow_state(), non_neg_integer()) -> boolean().

Check if we can send the specified number of bytes.

generate_max_data(Flow_state)

-spec generate_max_data(flow_state()) -> {non_neg_integer(), flow_state()}.

Generate a new MAX_DATA value to send. Returns {NewMaxData, UpdatedState}.

new()

-spec new() -> flow_state().

Create a new flow control state.

new(Opts)

-spec new(map()) -> flow_state().

Create a new flow control state with options.

on_data_received(Flow_state, Size)

-spec on_data_received(flow_state(), non_neg_integer()) ->
                          {ok, flow_state()} | {error, flow_control_error}.

Record that we received data.

on_data_sent(Flow_state, Size)

-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.

on_max_data_received(Flow_state, NewMax)

-spec on_max_data_received(flow_state(), non_neg_integer()) -> flow_state().

Process a MAX_DATA frame from peer. Updates our send limit.

recv_limit(Flow_state)

-spec recv_limit(flow_state()) -> non_neg_integer().

Get our current receive limit (our MAX_DATA).

recv_window(Flow_state)

-spec recv_window(flow_state()) -> non_neg_integer().

Get available receive window.

send_blocked(Flow_state)

-spec send_blocked(flow_state()) -> boolean().

Check if we're currently blocked on send flow control.

send_limit(Flow_state)

-spec send_limit(flow_state()) -> non_neg_integer().

Get our current send limit (peer's MAX_DATA).

send_window(Flow_state)

-spec send_window(flow_state()) -> non_neg_integer().

Get available send window.

should_send_max_data(Flow_state)

-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.