nquic_protocol_send_queues (nquic v1.2.0)
View SourcePer-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
-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()}.
-spec enter_recovery(nquic_loss:loss_state(), nquic_protocol:state()) -> nquic_protocol:state().
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).
-spec flush_app(nquic_protocol:state()) -> {ok, [iodata()], nquic_protocol:state()} | {ok, nquic_protocol:state()}.
-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).
-spec flush_handshake(nquic_protocol:state()) -> {[iodata()], nquic_protocol:state()}.
-spec flush_initial(nquic_protocol:state()) -> {[iodata()], nquic_protocol:state()}.
-spec queue_app_frame(nquic_frame:t(), nquic_protocol:state()) -> {ok, nquic_protocol:state()}.
-spec queue_app_frame(nquic_frame:t(), non_neg_integer(), nquic_protocol:state()) -> {ok, nquic_protocol:state()}.
-spec queue_app_frames([nquic_frame:t()], non_neg_integer(), nquic_protocol:state()) -> {ok, nquic_protocol:state()}.
-spec queue_app_pre_encoded([nquic_protocol_send:pre_encoded()], non_neg_integer(), nquic_protocol:state()) -> {ok, nquic_protocol: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.
-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.
-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).
-spec sort_frames([nquic_frame:t()]) -> [nquic_frame:t()].