28 KiB
Advanced Peer Distribution
- Research date: 2026-08-21
- Scope: at most eight trusted viewers, sub-second interactive media, endpoint downstream fanout at most two, and minimal central-server media egress
- Status: bounded C+B local reparenting and admission rescue are deployed;
one-root healthy SFU reselection is deployed but browser/media/production-route
evidence is unverified; relay-capacity
0 -> 1, multi-root reselection, and advanced encoded-media routes remain unimplemented candidates
Terms
- Multiple trees: split one media representation into two stripes and send each stripe through a different peer tree. A viewer receives both trees; an internal relay forwards only its assigned stripe. This balances endpoint upload but requires two parents, assembly, loss recovery, and churn handling.
- SVC: one encoder produces a base layer plus dependent temporal or spatial enhancement layers. It lets a forwarder drop enhancement data, but it does not create a distribution topology or move layers between transports.
- Network coding: send repair symbols formed from several source symbols so a receiver can recover loss after collecting enough independent symbols. It adds bytes and CPU; it can reduce retransmission delay but cannot compress the video or replace route migration after a complete path failure.
Complexity alone is not a rejection reason. A route is retained only when a bounded experiment shows lower endpoint compute or bandwidth, keeps the user experience automatic, and meets the latency and queue limits below.
Cost Accounting
Let B be one complete stream bitrate, N the viewer count, and r repair
overhead. Protocol headers, retransmission, and TURN overhead are additional.
| Route | Host upload | Central media traffic | Encode work |
|---|---|---|---|
| Current full-stream browser chains | at most 2B |
zero except TURN edges | host up to two encoders; every relay encodes again |
| Native full-stream RTP relay | at most 2B |
zero except TURN edges | relay zero encode; native host can share one encode |
| Two encoded-object stripe trees | about (1+r)B |
zero except TURN edges | host one encode; relay zero encode |
| SFU virtual parent to bounded roots | measured B_pub |
root-only; see low-server model | one publication may carry at most two active representations; physical encoder count remains measured evidence |
| Full central SFU/MoQ fanout | about B |
ingress B, egress N*B |
comparison class, not the accepted fallback shape |
Useful last-hop traffic remains approximately N*B; these routes only decide
which nodes emit the copies. Exact B_pub/B_i, root, TURN-hop, and billing
accounting is owned by Low-Server-Cost Media Routes.
TURN is edge transport; it is not a peer/SFU topology.
Candidate 1: Native RTP Relay
This is the nearest-term high-confidence optimization. A native helper can read encoded RTP from one WebRTC receiver and write the payload to at most two independent downstream browser PeerConnections without decoding and encoding the video again. Each downstream edge keeps its own SSRC, pacing, RTCP, DTLS-SRTP, ICE, and TURN behavior.
Draft PR #16 passes an earlier
in-process transport oracle: one Pion v4.2.18 TrackLocalStaticRTP.WriteRTP
call reaches two independent PeerConnections with preserved semantic payload,
sequence number, and timestamp plus binding-specific SSRCs. It contains no
encoder or browsers, so it is not evidence for one physical encode, end-to-end
compatibility, feedback arbitration, congestion control, or latency.
The next Go/Pion spike is video-only VP8 at 720p30 with one browser upstream and two unchanged browser children. It must prove:
- zero relay video-encoder calls and at least 40% lower relay CPU than browser remote-track forwarding;
- no more than 25 ms added p95 relay latency;
- per-child bytes no more than 110% of input payload bitrate;
- bounded queue age below 100 ms;
- PLI, NACK/RTX, 1% loss, one direct edge, and one TURN edge; and
- reparented first picture within one second after failure detection.
This lowers relay compute and generational quality loss. It does not lower host or total upload until combined with a native shared sender or striped media. Relay-capable participants need the helper; ordinary desktop/mobile browsers remain valid leaves.
Candidate 2: Two Stripe Trees With SVC
The target shape assigns every relay-capable endpoint at most two downstream
edges. The host sends stripe A to one seed and stripe B to another. An internal
node forwards its assigned roughly B/2 stripe to at most two children, so its
total upload stays near B. Every viewer receives both stripes from two parents.
The host encodes once and sends about B, central egress stays near zero, and
relay nodes do not encode.
SVC may make one stripe a base temporal layer and the other enhancement data, or duplicate selected base data for resilience. SVC alone cannot implement this shape: the WebRTC SVC API keeps layers in one encoded RTP stream, and WebRTC Encoded Transform does not permit moving encoded frames across streams. The data plane therefore requires either native RTP/object nodes or WebCodecs plus DataChannel.
Start with single-layer 50/50 frame/object striping, then test L1T2 temporal
SVC only after transport works. Use two deterministic, interior-node-disjoint
trees; do not add a continuous optimizer.
Go gates:
- host and relay upload no more than
1.1Bwithout repair; - unique host encode calls equal input frames and relay encode calls stay zero;
- whole-room useful bytes no more than
1.1*N*Bwithout repair; - no more than 20 ms p95 overhead per hop and depth-four p95 no more than 350 ms;
- a path failure returns a decodable picture within one second after detection;
- protection still saves at least 30% host upload relative to
2B; and - the controlled Web relay cohort passes runtime codec capability probes; mobile browsers remain compatibility observations, not a capacity class.
Reject that spike if endpoint upload remains near 2B, relay encoding returns,
queues cannot be bounded, or supported clients require two unrelated decoders
and application-side picture composition.
Candidate 3: Browser Encoded Objects
WebCodecs can encode once and expose EncodedVideoChunk values. WebRTC
DataChannel can carry framed chunks over peer ICE/TURN paths. This is the
credible pure-browser route to encoded forwarding and later two-tree striping,
but it replaces the browser's RTP media receiver with application framing,
pacing, a jitter buffer, keyframe requests, a WebCodecs renderer, and eventually
A/V synchronization.
The first spike is only host -> relay -> leaf, 720p30 video, reliable control,
and unordered media with bounded retransmission. Use chunks no larger than
16 KiB and a hard bufferedAmount ceiling.
Go gates:
- one host encode and zero relay encode;
- at least 30% lower host encode CPU than two browser send pipelines and at least 40% lower relay CPU than remote-track forwarding;
- framing bytes no more than 110% of the RTP baseline;
- two-hop glass-to-glass p95 no more than 250 ms;
- bounded queues and first picture below one second after reroute; and
- required mobile decoders pass, with later A/V drift no more than 50 ms.
Candidate 4: FEC And Network Coding
FEC is useful only when repair bytes avoid slower RTX or visible freezes. It does not reduce clean-path bandwidth or survive permanent loss of a full tree unless redundancy approaches another complete stream.
Before media integration, replay captured RTP/object traces through a simulator:
- random loss at 0%, 1%, 3%, and 5%;
- 20, 50, and 100 ms bursts at 20, 40, and 80 ms RTT;
- baseline NACK/RTX versus XOR or Reed-Solomon
k=4/8with one/two repair symbols, then sliding-window RLC only if those results justify it.
Go gates:
- at least 50% lower residual loss/freeze at 1-3% loss or 20-50 ms bursts;
- repair p95 below 100 ms and at least 25% faster than RTX;
- total media plus repair and residual RTX bytes no more than 110% of baseline media plus RTX bytes;
- no more than 16 ms generation buffering and 15% active repair overhead; and
- coding CPU below roughly 5% of one reference core.
Clean paths should keep repair disabled or below 3-5%. Whole-path failure still belongs to the route controller.
Candidate 5: MoQ
Browser WebTransport connects a browser to a server; it does not make a normal browser an Internet-listening peer relay. A central MoQ deployment therefore has the same server-egress class as an SFU. Benchmark it only as an optional central fallback and keep it only if, at equal quality and egress, latency or server CPU improves at least 20% over the SFU reference and draft-version churn is isolated behind a small adapter.
Candidate 6: Bounded Capability-Aware Local Reparenting
This remains a bounded topology candidate outside ADR-0004. Narada and Overcast demonstrate measurement-driven overlay improvement, but neither supplies a maintained WebRTC RTP/RTCP routing library. BitTorrent/WebTorrent and P2P Media Loader use chunk-pull swarms and playout buffers, while SplitStream requires striped multi-tree media. Their exploration and hysteresis ideas are useful, but none is a drop-in route controller for sub-second screen sharing. A mature SFU is the directly reusable low-latency alternative, with central egress rather than audience forwarding.
The first quality-driven slice reuses the authenticated Viewer C window and
existing route intent, plus one strict parent-to-server B message. Signaling
binds C to room, Viewer session, connection ID, active revision, parent
peer/session, sequence, two-second rate and 2 KiB size, then forwards the same
sanitized object. The current parent answers that exact sequence within five
seconds only when its current outbound sample has a positive packetsSent
delta. The existing discriminated proof is sending for diagnostic liveness,
sender-limited only for an exact qualityLimitationReason of cpu or
bandwidth, or remote-loss when that interval has at least 100 sent packets
and RTCP-reported remote loss divided by sent packets is at least 30%; it never
carries a null placeholder. One current connection cannot reuse the same
sampleTimestampMs for multiple C sequences; fractional stats windows are
rounded before applying the protocol bounds. The
server accepts one B from the bound parent session and generation. The router
may retain C while awaiting B, but advances only when B is hard and C is either
severe or relatively degraded. The relative case exists only below a Viewer
relay: the relay's own latest correlated C must still match its session, active
route and connection and be at most five seconds old; the child must receive
less than two-thirds of that actual inbound FPS. The configured FPS ceiling is
not evidence. sending, either report alone, and healthy or ambiguous pairs
reset or do not advance the streak.
It holds at most one pending/streak state per connected Viewer and one room
cooldown, with no timer or weighted score. One confirmed child event stays
edge-local. The two-distinct-child corroboration logic is retained only for a
future accepted Viewer-capacity tier; current ordinary Browser Viewer capacity
one makes that state unreachable in release routing.
The conservative Viewer C hard predicates are: freeze duration at least half
of the one-to-five-second window; positive received-packet delta with zero
decoded frames; or at least 100 received-plus-lost packets with loss at least
30%. Parent B must independently report the exact cpu/bandwidth sender
limitation or at least 100 sent packets with remote loss divided by sent packets
at least 30%. Three consecutive windows of the same severe or relative kind are
required. A healthy or incomplete correlated window, any Viewer/parent session,
connection, route revision or parent change, or a gap over five seconds clears
the streak. Severe and relative-FPS quality evidence each tries one Viewer whose
active upstream is peer or SFU through make-before-break; Host is excluded, and
session/share/revision plus one strict effective-capacity slot are required
before breadth-first selection continues. No candidate, probe failure, or timeout keeps
the old edge without SFU, TURN, or an error. A started attempt spends a
30-second room migration
budget, so a new public Viewer identity cannot bypass it. Per-edge state clears
on authentication/generation change, disconnect/removal and route replacement;
room stop/delete also clears the cooldown.
The candidate is bound to the exact Viewer/parent sessions, active and pending route revisions, share lifecycle and a separate connection ID. Its parent owns one provisional child PC outside the active child map and never auto-retries it with another connection ID. Signaling keeps the old connection ID authoritative until the Viewer proves positive RTP, positive decoded-frame progress and a live video track on the candidate; commit then promotes that same PC and changes topology, route and active connection identity together. Failure after ready retains the exact provisional identity across repeated matching active updates; the candidate parent stays fail-closed and the target Viewer probe owns recovery. Rollback or another edge's authoritative failure clears or aborts the soft probe before using the ordinary ladder. A successful relative move holds the old parent for 30 seconds or until its session changes. A real active-route failure remains a separate hard recovery trigger and can reuse an otherwise playable old parent.
W3C defines outbound packetsSent as the local cumulative RTP packet count.
remote-inbound-rtp.packetsLost is remote receiver data delivered by RTCP and
the corresponding stats object does not exist until that RTCP first arrives;
absence is therefore not zero. W3C's video-only qualityLimitationReason stays
an exact local sender predicate rather than an encoder score. Parent B and
Viewer C are gathered by stock browsers at separate endpoints, but RTCP remote
loss is receiver-originated and neither report is cryptographically independent
or resistant to colluding authenticated participants. W3C also defines
Viewer-side
packetsReceived, packetsLost, framesDecoded, freezeCount and
totalFreezesDuration; its WebRTC 1.0 diagnostic example treats loss over 30%
as a likely culprit. It does not define route-migration thresholds. The 50%
freeze share, two-thirds FPS ratio, 100-packet floor, three windows,
five-second gap and 30-second
cooldown are falsifiable candidate constants for production calibration, not
standards-derived or claimed optimum values.
One correlated pair still attributes a problem only to its current
parent-to-child edge generation: remote loss comes from that child and
qualityLimitationReason belongs to one outbound stream. Screener therefore
keeps a single event edge-local. In a future accepted capacity-two tier, two independently confirmed current children
within five seconds are instead treated as bounded corroboration to pause that
Viewer parent's relay eligibility for 30 seconds, not as proof of device-wide
quality or a numeric score. The client-advertised capacity remains intact; new
capacity messages cannot override the server-owned pause. Existing children
try deterministic peer reassignment and keep their old edge when none exists;
the parent keeps its upstream and the pause itself never starts SFU or TURN.
Host parents are excluded, while expiry, a new parent session or a new share
restores eligibility. Alternate-parent selection remains breadth-first;
preferring recent healthy candidates remains later. The triggering child now
uses bounded make-before-break; converting the quarantined parent's remaining
children from their existing immediate reassignment is a separate slice.
With current Host degree two and Browser Viewer degree one, deterministic
assignment forms at most two bounded chains. A tree for N viewers
still has N media edges, approximately N*B useful upload in aggregate, and
approximately 2B host upload once both roots are used. Local reparenting does
not reduce either bandwidth quantity. Reordering an already balanced healthy
tree also cannot reduce depth; a move needs a discrete admission, path, TURN,
relay-resource, recovery, or future native-capacity benefit.
The source admission-rescue slice is limited to its discrete capacity case. If a relay-capable viewer is unassigned because two zero-capacity roots occupy both host slots, it inserts that viewer above one deterministic childless root:
host -> new relay -> existing leaf
host -> other root
This admits the waiting viewer while keeping Host fanout at two and Browser Viewer fanout at one. The router permits it only on an active peer-only route with no SFU publication or pending prepare, when the connected candidate currently has no upstream or children, offers relay capacity, and has no failed-parent history. The host must have exactly two children and the chosen child must be a connected, childless, zero-capacity leaf. Existing server join order chooses the oldest eligible leaf. One synchronous topology snapshot changes the host, candidate, and leaf; one route revision replaces both upstream generations and clears their old connection IDs. The Host reconciler closes every stale child edge before starting replacement children, so its physical fanout does not temporarily exceed two.
Eligibility remains discrete: an active authenticated session, explicit relay capacity, compatible representation, a free downstream slot, acyclicity, and depth/edge budgets. The implemented rescue never moves a candidate that already has an upstream, never handles a failed-path intent, and never selects a root by quality. An authenticated viewer can still lie about its relay capacity, so the exact-room canary and ordinary route-failure recovery remain required; the lie can cause at most this one local move before the candidate is no longer unassigned. Broader experiments may react to a hard media failure, a reviewed threshold-crossing event from correlated path evidence, or a proven native capacity change, but never a continuous optimizer. Do not use a weighted score, UA/device model, IP geography, or one party's unverified report. Keep healthy assignments sticky, move only one affected subtree, use separate enter and recovery thresholds plus a cooldown, and disable proactive moves for the share after repeated rollback.
Use make-before-break only when the new parent has a free downstream media slot
and every affected endpoint remains within its current release limit: Host at
most two, ordinary Browser Viewer at most one. A future native role requires its
own accepted limit. Admission rescue
starts with both host slots occupied, so it is break-before-make: retire the
chosen host-to-leaf media edge before activating host-to-new-relay media. A
control-only RTCPeerConnection may prewarm ICE but cannot prove media uplink:
WebRTC exposes availableOutgoingBitrate only after congestion-controlled RTP
has used that candidate pair. Zero interruption, active standby media, and a
hard endpoint edge limit cannot all be guaranteed at once.
Proceed only after the current evidence-alignment and peer canary gates pass. Every sampled instant must retain host/relay fanout limits; unaffected branches must not freeze; make-before-break must decode at every affected receiver on the new path before retiring the old edge, while break-before-make must do so within one second p95 after the break and before declaring the move successful. Stable reference runs must not migrate; each move must record one discrete benefit, avoid reversal during cooldown, and restore the prior deterministic route on rollback. Reject this candidate if it needs all-pairs probing, a continuous optimizer, temporary fanout above budget, self-reported geography or device quality, or cannot beat the unchanged route. The earlier admission-rescue case remains valid. The implemented quality slice moves only the affected Viewer-rooted subtree, keeps its old edge until the candidate decodes, and does not enter SFU or selected-edge TURN. Those transports remain available only to the separate real-failure route owner.
Staged Connection Recovery Evidence
Recovery should spend attempts on different layers, not repeat one opaque action
three times. The current WebRTC Recommendation advises an ICE restart when
iceConnectionState reaches failed; for disconnected, it recommends first
checking whether sent/received bytes progress over the next couple of seconds.
Pinned LiveKit client 2.22.0 uses reconnect delays of 0, 300, 1,200, 2,700,
4,800 and then 7,000 ms (with later jitter), a 15-second peer/WebSocket timeout,
and a four-second state reconciliation that requires three consecutive
mismatches before a full reconnect. Jitsi Videobridge similarly defaults to a
15-second first-transfer timeout and an eight-second inactivity limit. These are
reference boundaries, not universal prescriptions. Screener's separately owned
15-second initial deadline remains a candidate pending mobile-network evidence.
The accepted Screener order is therefore: soft visible wait while initial ICE is still making progress; one ICE restart on hard failure; one same-parent PC rebuild; one different eligible peer parent; then SFU only after peer exhaustion. Each success cancels the remaining stages. Every completion is guarded by the current session, route revision, assignment/connection generation, and cooldown. Connected-but-bad media is a separate correlated-quality trigger and must not be treated as a connection retry.
The first room-1 production trace on 2026-08-20 observed two short Host participants while two roots remained for roughly 4.6 seconds; all ended with client-requested leave, no track publication survived, and neither service restarted. This proves LiveKit participant entry. The timing is consistent with the current one-shot grant refresh and Peer-failback state machine, but logs do not prove those transitions and cannot distinguish connect, source, video publish, sender configuration, optional audio publish, or transport failure. The next bounded diagnostic exposes only that local enum to the Host and deliberately keeps raw errors, URLs, tokens, candidates, and addresses out of wire and logs.
Automatic Route Controller Boundary
The accepted product order is:
direct/peer UDP -> SFU roots -> optional exceptional-edge TURN -> wait/fail
Native full-stream relay and striped-object routes remain the bounded candidates above; passing their own gates may change capability, but does not insert them into the current product ladder.
The enabled SFU is normally a virtual parent for at most R=2 roots, which
retain bounded peer descendants. A viewer that cannot attach behind any healthy
root may be separately admitted only under the explicit E/central-egress cap;
this is an exceptional compatibility budget, not unbounded whole-room fanout.
The SFU/UDP and optional selected-edge TURN transport accounting lives in
Low-Server-Cost Media Routes. ADR-0005's deployed
controller handles failure and bounded admission; the current source also has
the one-root healthy-reselection slice described below. None changes the sticky
local reparenting candidate above.
The controller must be automatic and invisible. It uses explicit capability bits, route revisions, media generations, edge budgets, and discrete failures; it does not expose topology choices to host or viewers. Initial hard triggers are capacity, maximum depth, ICE/media failure, unsupported codec, and bounded send-queue overflow. Measurements may later justify additional triggers.
For healthy SFU-to-peer reselection, W3C inbound RTP counters expose the needed
bounded observations: packetsReceived counts received RTP packets and
framesDecoded counts successfully decoded video frames. Neither ICE state nor
a track object alone proves decodable progress. Pinned LiveKit client 2.22.0
already exposes reconnecting/reconnected room events, so recovery is a discrete
trigger; no network-type poll or new timer is required. The current source arms
the same two-window gate when a refreshed signaling session receives an
authoritative sticky SFU assignment. This avoids immediately reversing an
ordinary peer-to-SFU fallback, whose initial authenticated assignment was peer.
The overlap edge is physical: an active Host SFU publication consumes one of the Host's two downstream media edges while the provisional peer offer consumes the other. A browser parent remains limited to one downstream edge during this probe even if its normal advertised relay capacity is two. Failed or stale probes restore the prior controller revision without writing ordinary failed-parent state.
Use make-before-break when a downstream slot is free. With all two slots in use, strict fanout means break-before-make; zero interruption, no standby, and a hard two-edge limit cannot all be guaranteed simultaneously. Sub-second recovery also requires a media/data heartbeat near 100-200 ms rather than the current 30-second control heartbeat.
Sources And License Boundary
Sources checked on 2026-08-20 and 2026-08-21:
- WebRTC SVC, Encoded Transform, WebCodecs, and WebTransport - W3C specifications.
- WebRTC Data Channels, RFC 8831 and Sliding-window RLC, RFC 8681.
- Pion WebRTC and klauspost/reedsolomon - MIT; no source copied.
- WebRTC Recommendation -
failedICE restart anddisconnectedbytes/stats guidance. - LiveKit client 2.22 reconnect policy,
room defaults,
and state reconciliation
- pinned implementation behavior, not a universal timeout prescription.
- LiveKit server 1.13.5 participant quality aggregation
and connection scorer
- Apache-2.0; studied only, with no source copied.
- Jitsi Videobridge endpoint status defaults
- first-transfer and inactivity reference values.
- SplitStream
and Network Coding for Large Scale Content Distribution
- research evidence, not reusable source licenses.
- Narada, Overcast, NICE, and CoolStreaming/DONet - original application-layer multicast and live-streaming research.
- BitTorrent BEP 3, WebTorrent, and P2P Media Loader - mature chunk/segment swarms, not an RTP route implementation.
- WebRTC statistics, ICE, RFC 8445, and LiveKit SFU - observable path boundaries and the centralized low-latency alternative.
- LiveKit client 2.22 room events
- pinned reconnect/reconnected behavior; no implementation source was copied.
- TURN, RFC 8656 - per-edge relay transport rather than a room topology.
- MOQT draft and moq-dev/moq - core MIT/Apache-2.0; its OBS plugin is separately GPL-2.0-or-later and remains study-only.
No GPL/AGPL implementation code was copied.