quic_ack (quic v1.3.1)
View SourceQUIC ACK frame generation and processing.
This module handles: - Tracking received packet numbers - Generating ACK frames with ranges - Processing incoming ACK frames - ACK delay calculation
ACK Ranges
ACK ranges are stored as a list of {Start, End} tuples where Start =< End. The list is sorted in descending order by Start. Example: [{100, 105}, {90, 95}, {80, 82}] acknowledges packets 100-105, 90-95, and 80-82.
Summary
Functions
Get the number of ACK-eliciting packets in flight.
Convert ACK frame to list of ranges instead of expanded list. Returns a list of {Start, End} tuples where Start is less than or equal to End. Much more efficient than ack_frame_to_pn_list for large ranges. Example: {100, 5, [{2, 3}]} becomes [{95, 100}, {89, 92}]
Get the current ACK ranges.
Generate an ACK frame for the current state. Returns {ok, AckFrame} or {error, no_packets}.
Generate an ACK frame with a specific timestamp.
Get the largest acknowledged packet number.
Get the largest received packet number.
Mark that an ACK was sent.
Check if an ACK needs to be sent.
Create a new ACK tracking state.
Process a received ACK frame. Returns {NewState, AckedPackets} where AckedPackets is a list of newly acknowledged packet numbers.
Process a received ACK frame with sent packet info. SentPackets is a map of PacketNumber => SentPacketInfo
Record that a packet was received.
Record that a packet was received, optionally marking it as ACK-eliciting.
Types
Functions
-spec ack_eliciting_in_flight(ack_state()) -> non_neg_integer().
Get the number of ACK-eliciting packets in flight.
-spec ack_frame_to_ranges(non_neg_integer(), non_neg_integer(), list()) -> [{non_neg_integer(), non_neg_integer()}] | {error, ack_range_too_large}.
Convert ACK frame to list of ranges instead of expanded list. Returns a list of {Start, End} tuples where Start is less than or equal to End. Much more efficient than ack_frame_to_pn_list for large ranges. Example: {100, 5, [{2, 3}]} becomes [{95, 100}, {89, 92}]
-spec ack_ranges(ack_state()) -> [{non_neg_integer(), non_neg_integer()}].
Get the current ACK ranges.
Generate an ACK frame for the current state. Returns {ok, AckFrame} or {error, no_packets}.
-spec generate_ack(ack_state(), non_neg_integer()) -> {ok, term()} | {error, no_packets}.
Generate an ACK frame with a specific timestamp.
-spec largest_acked(ack_state()) -> non_neg_integer() | undefined.
Get the largest acknowledged packet number.
-spec largest_received(ack_state()) -> non_neg_integer() | undefined.
Get the largest received packet number.
Mark that an ACK was sent.
Check if an ACK needs to be sent.
-spec new() -> ack_state().
Create a new ACK tracking state.
-spec process_ack(ack_state(), term()) -> {ack_state(), [non_neg_integer()]}.
Process a received ACK frame. Returns {NewState, AckedPackets} where AckedPackets is a list of newly acknowledged packet numbers.
-spec process_ack(ack_state(), term(), map()) -> {ack_state(), [non_neg_integer()]} | {error, ack_range_too_large}.
Process a received ACK frame with sent packet info. SentPackets is a map of PacketNumber => SentPacketInfo
-spec record_received(ack_state(), non_neg_integer()) -> ack_state().
Record that a packet was received.
-spec record_received(ack_state(), non_neg_integer(), boolean()) -> ack_state().
Record that a packet was received, optionally marking it as ACK-eliciting.