Skip to content

feat(sctp): time-based loss detection (RACK-TLP) - #302

Open
volchanskyi wants to merge 2 commits into
webrtc-rs:masterfrom
volchanskyi:sctp-rack-tlp
Open

volchanskyi wants to merge 2 commits into
webrtc-rs:masterfrom
volchanskyi:sctp-rack-tlp

Conversation

@volchanskyi

@volchanskyi volchanskyi commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #301, which makes the receiver report duplicate TSNs. This PR relies on those reports.

When a path reorders packets, the sender cuts its window for losses that never happened. A chunk is declared lost once three later chunks are acknowledged (miss_indicator >= 3), and every recovery halves cwnd. Nothing ever gives a cut back when the "lost" chunk turns up. On a 100 Mbit/s, 40 ms path that sends 1% of packets 20 ms early, today's code is left with standing cuts and recovers them at one MTU per round trip.

TransportConfig::with_rack_tlp(true) turns on RFC 8985 for the sender, and so does SettingEngineBuilder::with_sctp_rack_tlp(true). Both are off by default, and with the setting off the sender behaves as it does today.

  • A chunk is lost once a chunk sent more than the reordering window after it has been acknowledged. A reorder timer covers chunks that haven't reached their deadline yet.
  • The window starts at a quarter of the minimum RTT. Each round trip whose SACK lists a duplicate adds a quarter of SRTT, up to SRTT. It stays grown for 16 recoveries (section 6.2). SCTP's duplicate TSN list plays the role of TCP's DSACK. Section 6.2 grows the window by a quarter of the minimum RTT per step; a packet reordered on both legs can read as a 0.2 ms minimum RTT on a 40 ms path, and the window then never reaches SRTT.
  • SRTT and the minimum RTT sample only chunks the cumulative TSN reached. A chunk acknowledged by a gap block may have overtaken the queue, and its RTT reads short. TCP gets the same effect from its timestamps: the echo for an out-of-order segment carries the time of the last in-order one. The deadlines still use the RTT of the latest delivered chunk, as section 6.2 says.
  • The three-report rule only starts recovery while no reordering has been seen.
  • A tail loss probe goes out at 2·SRTT, plus the delayed-ack allowance when one chunk is in flight. It sends new data if the peer's window allows, otherwise it resends the highest outstanding chunk, and then re-arms T3-rtx (section 7).
  • Undo: once the peer reports every resend since a cut as a duplicate, cwnd and ssthresh go back to their values before the cut, following Linux's DSACK undo. Cuts that overlap are undone together or not at all. The duplicate TSNs of a SACK older than the ack point are still read, since the SACK that overtook it may carry none. If a resent chunk is acknowledged and no duplicate shows up within one RTO, the cut stands. The RFC 3708 safeguards apply: a chunk resent twice blocks the undo, and a duplicate for a chunk that was never resent turns undo off for the rest of the association.
  • since is now reassigned on every retransmission, as its doc comment already said. Karn's rule still takes RTT samples only from chunks sent once.

New counters in AssociationStats: window cuts, cuts undone, loss probes.

Tests:

  • Unit tests for the window, its growth and persistence, which deliveries give an RTT sample, the probe timeout, and the undo rules (association/rack.rs).
  • Eight runs over a simulated 100 Mbit/s link with a 20 ms delay each way and deterministic reordering and loss (association/rack_tlp_test.rs):
    • 1% reordering leaves no cut standing, and stops cutting once the window has grown
    • the same path with the setting off keeps its cuts
    • real loss keeps its cuts, with no T3 timeout
    • a dropped tail chunk is recovered by the probe well under the 1 s RTO
    • an RTT moving 40 → 20 → 40 ms leaves no cut standing
    • delayed SACKs draw no probe
    • reordering and loss together undo only the needless cuts
    • 1% of packets each way sent ahead of the whole queue, as tc netem reorder does, still leaves 80% of the line in use (92 Mbit/s; 7 before the second commit, 57 with all of it but the in-order sampling)
  • A SACK naming a repeat, overtaken by a newer SACK, still undoes the cut.
  • Plumbing tests for the rtc setting.

The second commit adds the in-order sampling, the window's SRTT steps, the stale-SACK repeats and the RTO horizon, found with a WebRTC download from Chrome over a netem router.

cargo fmt --check, cargo clippy, cargo test --workspace, the doc tests and both scripts/check-*.py checks pass locally on rustc 1.99.1, as do the semver check, the standalone crate checks, the crypto provider matrices, packaging and the nightly coverage run.

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.65051% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.61%. Comparing base (0fbcaa7) to head (83e4f6a).

Files with missing lines Patch % Lines
rtc-sctp/src/association/rack.rs 95.00% 10 Missing ⚠️
rtc-sctp/src/association/rack_tlp_test.rs 98.63% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #302      +/-   ##
==========================================
+ Coverage   88.47%   88.61%   +0.13%     
==========================================
  Files         512      514       +2     
  Lines       75483    76162     +679     
==========================================
+ Hits        66787    67490     +703     
+ Misses       8696     8672      -24     
Flag Coverage Δ
aws-lc-rs 88.32% <97.65%> (+0.08%) ⬆️
ring 88.61% <97.65%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rainliu rainliu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rebase to fix conflict first. thanks.

TransportConfig::with_rack_tlp (off by default) and
SettingEngineBuilder::with_sctp_rack_tlp turn on RFC 8985 loss detection
for the sender: a chunk counts as lost once a chunk sent more than the
reordering window after it is acknowledged, the window grows on duplicate
TSN reports and lasts 16 recoveries, the three-report rule applies only
until reordering is seen, and a tail loss probe goes out at the end of a
burst. A cut whose every resend the peer reports as a duplicate is undone,
with the RFC 3708 safeguards.
A path that sends some packets ahead of its whole queue, on both legs, as
`tc netem reorder` does, left RACK-TLP cutting the window for losses that never
happened. On a simulated 100 Mbit/s, 40 ms path with 1% of packets doing that
each way, the sender kept 7 Mbit/s; with these four changes it keeps 92.

- The smoothed and least round trips sample only chunks the cumulative TSN
  reached. A chunk acknowledged by a gap block may have overtaken the queue, and
  read 0.1-20 ms on the 40 ms path. That shrank the reordering window, and the
  needless resends it set off fed more short samples.
- The reordering window starts at a quarter of the least round trip, and each
  later step adds a quarter of SRTT, up to SRTT. A short least round trip no
  longer keeps the window from reaching SRTT.
- A SACK older than the ack point still has its duplicate TSNs read. The newer
  SACK that overtook it moved the ack point past it, but its repeats still prove
  resends needless.
- A resend acknowledged with no repeat counts as needed after one RTO, not two
  SRTTs. A repeat queued behind a burst of resends arrives later than two round
  trips.
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