Skip to content

fix(nvst): use the server's unprotected retransmissions and hold gaps until they arrive - #1455

Open
etgbrown wants to merge 2 commits into
OpenCloudGaming:devfrom
etgbrown:nvst-unprotected-retransmissions
Open

etgbrown wants to merge 2 commits into
OpenCloudGaming:devfrom
etgbrown:nvst-unprotected-retransmissions

Conversation

@etgbrown

Copy link
Copy Markdown

Depends on #1450 (FEC gap waits side by side). This branch includes that commit, so please review the last commit.

Problem

The server answers NACK-v2 requests with copies sent as payload type 106 on the video SSRC, and those copies have no SRTP protection: there is no authentication tag, and the body is the plaintext GameStream payload. OpenNOW runs every video datagram through SRTP unprotect, so every one of these copies fails authentication and is dropped. Until now this only showed up as the gap between inbound and authenticated packets, about 500–1,900 per 10 s window during loss episodes.

Evidence from a live session:

  • They answer NACKs: all 46 sampled authentication failures were sequence numbers this receiver had NACKed 100–218 ms earlier.
  • The tag is missing: originals are type 101 and 1304 bytes (32-byte header + 1264 payload + 8-byte tag). The failures are type 106 and 1296 bytes: the same header and payload with no tag.
  • The payload is plaintext: all 3 rejected first shards began with a GameStream frame header (81 08 01 01 …), the same structure as a decrypted original's.
  • They are re-stamped copies: two copies of one retransmitted sequence were byte-identical except for the RTP timestamp.
  • It is not a counter mismatch: no rollover counter value authenticated any of them.

A tagged 1304-byte type-106 form also exists and already authenticates. This change does not affect it.

Even when accepted, these answers complete their frames 150–200 ms after the gap opens (9 of 9 measured), well after the 52 ms give-up.

Change

  • Accept only what was asked for. A datagram that fails authentication is accepted only as the answer to one of this receiver's own NACKs from the last 500 ms. It must also be on the bound SSRC, is accepted once, and still goes through the replay window (take_retransmission_request, accept_unprotected).
  • Hold the gap while the answer can still arrive. When frame types are known, a gap is now held for 220 ms.
    • The recovery frame is still requested at 52 ms, through a new early invalidation request (anticipate).
    • A complete recovery frame queued behind the gap ends the hold at once (recovery_frame_ready).
    • So holding longer does not delay recovery.
  • Make it visible. The video stats line gains an unprotectedRtx counter.

Security note

These packets are unauthenticated. Acceptance is limited to:

  • indices the receiver itself requested within the last 500 ms;
  • packets from the authenticated peer address, on the bound SSRC;
  • one acceptance per index.

An on-path attacker who can observe those requests could still inject payload for those indices. The server chose to send them this way, and the alternative is NACKs that can never repair anything. Please weigh this.

Results

This is one Starlink session before and one after, with each session's first minute excluded.

Before (15.8 min) After (17.3 min)
Invalidation requests per minute 28.2 17.3
10 s windows with a freeze over 250 ms 14.6% 6.7%
Worst gap per 10 s window, p90 348 ms 228 ms
Retransmissions used per minute 0 228

Freezes of about 1 s are unchanged. In those, frames had lost a third to most of their packets, which no retransmission window covers.

For reference, static analysis of the official Linux client (libBifrost2.so, the source docs/mjolnir-nack-v2.md already uses) shows waiting-queue limits of 52/68 ms, with a maximum frame wait of 68/84 ms. This change waits longer because the answers measured here take 150–200 ms to arrive.

Tests

  • New test: nacked_packets_are_accepted_unprotected_once_within_the_window.
  • Recovery tests re-timed to the 220 ms hold.
  • New tests for the hold, the early request and the recovery-frame release.
  • cargo test --workspace with linux-ffmpeg-bundled,linux-vaapi: 1547 passed, 0 failed, 27 ignored.

🤖 Generated with Claude Code

etgbrown and others added 2 commits November 14, 2026 18:02
The FEC reorder queue started a block's 52 ms retransmission wait, and sent
its first NACK, only when the block reached the head of the queue. A loss
that damaged N blocks therefore held the queue for N x 52 ms, and with it
the reference-invalidation request (queued when the next frame assembles)
and the recovery frame the server sends in reply. The backlog was then
released at once, which overflowed the decoder hand-off and cost another
IDR round trip.

A block's wait now starts when a packet from a later block arrives, and a
hole's when the block behind it arrives. All waits run in parallel:

- every gap is requested as soon as it is evident, with up to eight NACK
  reports per 4 ms tick instead of one;
- a stalled block asks for every missing data run it needs to reconstruct,
  because its wait is no longer extended for a second round;
- giving up on a gap forgets only that gap's NACK requests instead of all;
- the queue reports one discontinuity per pass, so a complete frame between
  two abandoned gaps is delivered instead of discarded.

Evidence, five 2-minute 3840x2160@120 AV1 sessions on a link that loses
packets every 15 s (48 loss episodes): 21 gave up on two or more gaps in
series, 52 ms apart, before the first invalidation left. The six longest
(0.65-1.5 s) gave up on 15 to 66 gaps each, and in five of them a recovery
keyframe was released 4-52 ms before another keyframe that the server had
sent 0.3-0.5 s after it: both had been waiting in the queue.

The plain reorder queue (streams without an FEC layout) is unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… until they arrive

The Mjolnir server answers most NACKs with copies sent as payload type 106 on
the video SSRC without SRTP protection: no authentication tag, and the body is
the plaintext GameStream payload. In a live dump all 3 rejected first shards
began with the GameStream frame header, and two copies of one packet differed
only in the re-stamped RTP timestamp. The receiver ran them through SRTP
unprotect and dropped them as authentication failures; 46 of 46 sampled
failures answered a NACK sent 100-218 ms earlier. NACK repair never filled a gap.

- A datagram that fails authentication is accepted only as the answer to one of
  this receiver's NACKs from the last 500 ms, on the bound SSRC, once, through
  the replay window.
- The answers complete frames 150-200 ms after the gap opens, well after the
  52 ms give-up. While frame types are known, a gap is now held for 220 ms. The
  recovery frame is still requested at 52 ms (an early invalidation request),
  and a complete recovery frame queued behind the gap ends the hold at once, so
  holding does not delay recovery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a92165e2-9e5d-4d46-bf9e-e0d923aa9711

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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.

1 participant