Skip to content

Simplify OutstandingData state machine#100

Merged
boivie merged 1 commit intowebrtc:mainfrom
boivie:feature-simplify-outstanding-data
Mar 3, 2026
Merged

Simplify OutstandingData state machine#100
boivie merged 1 commit intowebrtc:mainfrom
boivie:feature-simplify-outstanding-data

Conversation

@boivie
Copy link
Collaborator

@boivie boivie commented Feb 26, 2026

This change replaces the separate Lifecycle and AckState enums with a single ItemState enum. Previously, the use of two independent state machines allowed for invalid combinations and required storing variables like time_sent and nack_count on all items, even when they were not applicable. The new design makes use of Rust's algebraic data types to scope these variables strictly to the states that need them.

This also fixes a bug where measure_rtt could return an incorrect and too large duration for fragments that were previously gap-acked. By removing the time_sent field from the new Acked state, the code now explicitly prevents RTT calculations on chunks that have already been acknowledged, avoiding false measurements when a gap-acked chunk is later cumulatively acked.

The new states closely follow the chunk lifecycle: in flight, reported missing, queued for retransmission, acked, and abandoned. The only exception to a strict progression is the Acked state, which includes a "was_abandoned" boolean flag. This field is necessary because an item can be logically abandoned by the sender, for example due to a message timeout or reaching the maximum number of retransmissions, while still being successfully delivered to and acknowledged by the receiver.

Preserving the abandoned status within the Acked state ensures that when the cumulative acknowledgment eventually covers the chunk and it is removed from the queue, its lifecycle ID is correctly added to the abandoned lifecycle IDs list rather than being falsely reported as successfully delivered.

@boivie boivie force-pushed the feature-simplify-outstanding-data branch from 2bf4897 to 7958d9f Compare March 1, 2026 21:26
DanilChapovalov
DanilChapovalov previously approved these changes Mar 2, 2026
@boivie boivie force-pushed the feature-simplify-outstanding-data branch from 7958d9f to 4c7e7aa Compare March 3, 2026 09:42
@boivie boivie requested a review from DanilChapovalov March 3, 2026 09:42
DanilChapovalov
DanilChapovalov previously approved these changes Mar 3, 2026
This change replaces the separate Lifecycle and AckState enums with a 
single ItemState enum. Previously, the use of two independent state 
machines allowed for invalid combinations and required storing variables 
like time_sent and nack_count on all items, even when they were not 
applicable. The new design makes use of Rust's algebraic data types to 
scope these variables strictly to the states that need them.

This also fixes a bug where measure_rtt could return an incorrect and 
too large duration for fragments that were previously gap-acked. By 
removing the time_sent field from the new Acked state, the code now 
explicitly prevents RTT calculations on chunks that have already been 
acknowledged, avoiding false measurements when a gap-acked chunk is 
later cumulatively acked.

The new states closely follow the chunk lifecycle: in flight, reported 
missing, queued for retransmission, and three terminal variants:
Acked, Abandoned, and AbandonedAndAcked. This separation ensures that 
the "abandoned" status is preserved even if a SACK eventually arrives 
for that chunk. When the cumulative acknowledgment point advances and 
the chunk is removed, its lifecycle ID is correctly reported as 
abandoned rather than falsely reported as a successful delivery.
@boivie boivie force-pushed the feature-simplify-outstanding-data branch from 4c7e7aa to 0add31a Compare March 3, 2026 09:58
@boivie boivie requested a review from DanilChapovalov March 3, 2026 09:58
@boivie boivie merged commit d0c2ee9 into webrtc:main Mar 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants