nquic_protocol_send_queues (nquic v1.2.0)

View Source

Per-encryption-level pending-frame queues and their flush drains.

Pure functions over #conn_state{} that buffer outbound frames into three per-space queues (Initial / Handshake / 1-RTT), coalesce them, and drain each queue into one or more encrypted packets via the packet builders in nquic_protocol_send. The dependency is one-way: this module calls down into nquic_protocol_send (builders, MTU batching, send context) module-qualified, and into nquic_protocol_ack to piggyback a pending ACK before an application flush. nquic_protocol drives the flush; the queue functions are called from across the protocol family whenever a control or stream frame is produced.

Summary

Functions

Let the next flush send one packet over the congestion window when the window of the loss state Before is larger than the current one. This is the packet on entry to recovery (RFC 9002 §7.3.2).

Flush the pending ACK and the pending 1-RTT control frames while the pacer holds back data. STREAM and DATAGRAM frames, and the stream data not yet drained, stay queued for the next paced flush. ACK frames are not congestion controlled (RFC 9002 §7) and leave within max_ack_delay (RFC 9000 §13.2.1). A PTO probe is not blocked by the congestion controller (RFC 9002 §7.5).

Queue a frame for a Handshake-space packet. Drained by flush/1 into a Handshake-coalesced packet at the next flush. Used for retransmits of Handshake CRYPTO and PTO probes between Initial and Established.

Queue a frame for an Initial-space packet. Drained by flush/1 into an Initial-coalesced packet at the next flush. Used for retransmits of client/server Initial CRYPTO and PTO probes during the handshake.

Let the next flush send one ack-eliciting packet over the congestion window: a PTO probe (RFC 9002 §6.2.4) or the packet on entry to recovery (RFC 9002 §7.3.2).

Functions

build_app_or_zero_rtt(PreEncoded, Time, State)

-spec build_app_or_zero_rtt([nquic_protocol_send:pre_encoded()], integer(), nquic_protocol:state()) ->
                               {ok, iodata(), nquic_protocol:state()} |
                               {error, term(), nquic_protocol:state()}.

enter_recovery/2

Let the next flush send one packet over the congestion window when the window of the loss state Before is larger than the current one. This is the packet on entry to recovery (RFC 9002 §7.3.2).

flush_app(State0)

-spec flush_app(nquic_protocol:state()) ->
                   {ok, [iodata()], nquic_protocol:state()} | {ok, nquic_protocol:state()}.

flush_app_control/1

-spec flush_app_control(nquic_protocol:state()) ->
                           {ok, [iodata()], nquic_protocol:state()} | {ok, nquic_protocol:state()}.

Flush the pending ACK and the pending 1-RTT control frames while the pacer holds back data. STREAM and DATAGRAM frames, and the stream data not yet drained, stay queued for the next paced flush. ACK frames are not congestion controlled (RFC 9002 §7) and leave within max_ack_delay (RFC 9000 §13.2.1). A PTO probe is not blocked by the congestion controller (RFC 9002 §7.5).

flush_handshake/1

-spec flush_handshake(nquic_protocol:state()) -> {[iodata()], nquic_protocol:state()}.

flush_initial/1

-spec flush_initial(nquic_protocol:state()) -> {[iodata()], nquic_protocol:state()}.

queue_app_frame(Frame, State)

-spec queue_app_frame(nquic_frame:t(), nquic_protocol:state()) -> {ok, nquic_protocol:state()}.

queue_app_frame(Frame, Bytes, State)

-spec queue_app_frame(nquic_frame:t(), non_neg_integer(), nquic_protocol:state()) ->
                         {ok, nquic_protocol:state()}.

queue_app_frames/3

-spec queue_app_frames([nquic_frame:t()], non_neg_integer(), nquic_protocol:state()) ->
                          {ok, nquic_protocol:state()}.

queue_app_pre_encoded/3

queue_handshake_frame(Frame, State)

-spec queue_handshake_frame(nquic_frame:t(), nquic_protocol:state()) -> {ok, nquic_protocol:state()}.

Queue a frame for a Handshake-space packet. Drained by flush/1 into a Handshake-coalesced packet at the next flush. Used for retransmits of Handshake CRYPTO and PTO probes between Initial and Established.

queue_initial_frame(Frame, State)

-spec queue_initial_frame(nquic_frame:t(), nquic_protocol:state()) -> {ok, nquic_protocol:state()}.

Queue a frame for an Initial-space packet. Drained by flush/1 into an Initial-coalesced packet at the next flush. Used for retransmits of client/server Initial CRYPTO and PTO probes during the handshake.

set_cwnd_exempt/1

-spec set_cwnd_exempt(nquic_protocol:state()) -> nquic_protocol:state().

Let the next flush send one ack-eliciting packet over the congestion window: a PTO probe (RFC 9002 §6.2.4) or the packet on entry to recovery (RFC 9002 §7.3.2).

sort_frames(Frames)

-spec sort_frames([nquic_frame:t()]) -> [nquic_frame:t()].