Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions doc/bin/relay/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ alike. A client that advertises its own name (moq-lite-05+ or any moq-transport
reaches the [auth server](/bin/relay/auth#the-contract) with it as `implementation`,
which is where to count client versions; older clients arrive without one.

`bind` is the relay's one UDP port. Beside QUIC it carries WebRTC media for an
[embedder](/bin/relay/#embed) that takes it; otherwise that traffic is dropped,
as are STUN Binding queries ([`[stun]`](#stun) has its own port) and anything
else. `/metrics` counts the drops in `moq_relay_demux_dropped_total` by `reason`:
`unclaimed` (WebRTC with no embedder), `overflow`, `stun`, and `unknown`. Not
with `runtime.io_uring`, which serves QUIC alone.

`reset.secret` lets a relay restarted on the same address reset its
predecessor's QUIC connections, so clients reconnect at once instead of
waiting out the idle timeout. Keep it secret, and give it to one relay
Expand Down
7 changes: 7 additions & 0 deletions doc/bin/relay/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ relay.with_web(web).run().await?;
send its path in the SETUP.
- To decide admissions yourself, leave `[auth]` empty and answer
`relay.admissions()`; see [Authentication](/bin/relay/auth#in-process).
- To serve WebRTC media (WHIP, WHEP) on the QUIC port, take `relay.webrtc()`:
ICE, DTLS, and RTP arrive on it, and its `send` answers from the same
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
port. On a wildcard bind with several local addresses, set the reply's
`Transmit.src_ip` to the `Datagram.local` it answers; left `None`, the kernel
picks the source address, which the peer may not accept. It fails unless the
tokio runtime serves QUIC: on a stream-only relay, and with `runtime.io_uring`,
whose workers do not split the port yet.
- To serve RTMP on the web ports, take `relay.rtmp()` and pass each accepted
stream to `moq_rtmp::accept_stream`. The HTTP and HTTPS listeners hand it
plaintext RTMP, and RTMPS (TLS with no ALPN) already decrypted; untaken, the
Expand Down
36 changes: 23 additions & 13 deletions quest/m2/one-port/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ Decided 2026-10-05, from moq.pro's audit: `moq-rtc` taking a fed socket
m2 rather than m3, since moq.pro's edge cutover and its uring rollout wait on
them.

Decided 2026-10-15: [UDP demux](/quest/m2/p2p/udp-demux.md) remains
under P2P, now deferred to m2,
because [native pairs](/quest/m2/p2p/native-quic.md) run QUIC and ICE's
STUN on one socket through the same demux. The rest of this line builds on
that shared prerequisite in m2. QUIC shard steering landed in #5638;
reuse its filter rather than recreating that completed work.
The UDP demux has landed: `moq_sock::demux` classifies, and the tokio QUIC
listener's socket diverts the WebRTC media path inline in its receive to a
`moq_tokio::quic::demux::WebRtc` feed, which `moq_relay::Relay::webrtc`
hands an embedder. [Native pairs](/quest/m2/p2p/native-quic.md) reuse the
classifier. QUIC shard steering landed in #5638; reuse its filter rather than
recreating that completed work.

Decided 2026-10-31 by the maintainer, in
[moq-dev/moq#7095](https://github.com/moq-dev/moq/pull/7095): the split runs
inline in the QUIC socket's `poll_recv`, not in a task owning the socket and
fanning out to per-stack virtual sockets, so a QUIC datagram keeps its
zero-copy, same-task path and its GRO batch. The API stays as shipped:
`moq_tokio::quic::demux::Demux` in `server::Config::demux`, `Demux::webrtc()`
returning the `WebRtc` feed, and `moq_relay::Relay::webrtc()`. SRT adds its
class to the same inline split.

### Classifying a datagram

Expand All @@ -63,11 +72,11 @@ unknown tuple is not SRT; it is dropped or given to the WebRTC mux.

### Virtual sockets

One OS socket, or one shard of a reuseport group, is read by the demux and
fanned into virtual sockets, one per stack, each with the `AsyncUdpSocket`
shape. Sends go straight to the shared socket, so every stack answers from
the same address and port. moq-tokio's `quic::driver` accepts the virtual socket through
`new_with_abstract_socket`. `moq-rtc`'s `Mux` already demuxes STUN by ufrag
One OS socket, or one shard of a reuseport group, is read by the QUIC
endpoint's own socket, which keeps QUIC in place and copies every other
class into that stack's bounded feed, shared by every shard. Sends go
straight to the shared socket, so every stack answers from the same address
and port. `moq-rtc`'s `Mux` already demuxes STUN by ufrag
internally and takes a fed socket in
[WebRTC on the shared socket](/quest/m2/one-port/rtc-feed.md). SRT skips `srt-tokio`,
which accepts a `tokio::net::UdpSocket` but no abstraction, and feeds
Expand All @@ -78,7 +87,9 @@ decided.

Decided 2026-10-08: the public STUN responder is left to P2P (m2), its
only consumer. Here, a Binding request carrying USERNAME is an ICE check
and goes to WebRTC; any other is dropped and counted. Decided 2026-10-13:
and goes to WebRTC, as does every Binding response, since the WebRTC agent
runs full ICE and only it sends requests from this port. Any other STUN is
dropped and counted. Decided 2026-10-13:
the responder binds its own port ([relay STUN](/doc/bin/relay/config.md#stun)),
so the shared port never answers public Binding requests.

Expand All @@ -89,6 +100,5 @@ so the shared port never answers public Binding requests.

## Related

- [UDP demux](/quest/m2/p2p/udp-demux.md) - one socket carries QUIC, with a WebRTC hook for embedders; owned by deferred native P2P in m2
- [One port on the io_uring workers](/quest/m2/uring-demux.md) - the io_uring workers host the UDP demux
- [Stream transports](/quest/m2/perf/stream/README.md) - the io_uring workers that would host the TCP acceptor later
14 changes: 10 additions & 4 deletions quest/m2/one-port/rtc-feed.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ demux routes that tuple to WebRTC before any SRT test (see the
released when its session ends or ICE moves to another pair: either an
unpin message or idle expiry in the flow table, as SRT's pins have.

The demux side has landed: `moq_tokio::quic::demux::WebRtc` (from
`Demux::webrtc`, or `moq_relay::Relay::webrtc` for an embedded relay) yields
ICE checks and responses, DTLS, and RTP as `Datagram`s whose `remote` is already in
`moq_ice::canonical` form, sends a `Transmit` from the shared port (mapping an
IPv4 destination for an AF_INET6 socket), and pins a remote with `pin`, which
returns a guard that releases the pin on drop. So the fed `Socket` takes a
`WebRtc` rather than the channels in the sketch, and the mux holds a `Pin` per
selected pair, dropped when its session ends or ICE moves. A feed's `recv`
returns `None` once the listener is gone.

Things to watch: the server config is `Clone` today and a receiver is not, so
the fed socket may belong in the server's constructor rather than the
config. The fed mux has nothing to bind lazily, and a dropped feed should
Expand All @@ -69,7 +79,3 @@ Tests: a fed mux completes ICE and DTLS with a client through an in-memory
`Transmit`, reports the selected tuple on `pinned`, and releases it when the
session closes. A fed dual-stack socket serves an IPv4 peer. The existing
bound tests keep passing.

## Required

- [UDP demux](/quest/m2/p2p/udp-demux.md) - the WebRTC hook and flow table this feeds from and pins into
11 changes: 5 additions & 6 deletions quest/m2/one-port/srt-demux.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ demuxed packets. That is more code, but it removes the dependency on
upstream (now rosalyntg/srt-rs) has not been pushed since 2024-05, and its
maintainer said they do not actively support it.

The demux side is the flow table from [UDP demux](/quest/m2/p2p/udp-demux.md):
a 4-tuple already pinned to WebRTC (ICE succeeded) is never tested for SRT.
The demux side extends `moq_sock::demux`, whose `Flows` table today pins a
remote to WebRTC only, and the tokio listener's `quic::demux::Demux`, which
diverts inline in the QUIC socket's receive: add an SRT class with its own
feed and bounded `Queue`, and an owner per pin. A 4-tuple already pinned to
WebRTC (ICE succeeded) is never tested for SRT.
An unknown 4-tuple whose full SRT handshake header matches (control bit,
type 0, and the SRT magic, not merely `80 00`) pins to SRT provisionally:
the provisional table is small and bounded, per-source rate limited, and an
Expand All @@ -43,7 +46,3 @@ clock, so `tokio::time::pause` cannot drive its idle timeout.
Tests: `moq-srt`'s existing integration test runs against the shared socket
with a QUIC client active on the same port; a QUIC short header from a new
4-tuple during an SRT session still reaches QUIC.

## Required

- [UDP demux](/quest/m2/p2p/udp-demux.md)
1 change: 0 additions & 1 deletion quest/m2/p2p/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ Extractor declaration checks, which analyze only published packages since

- [Peer grants](/quest/m2/p2p/peer-grant.md) - the relay issues a key-bound, asymmetrically signed grant a browser can verify; HS256 keys issue none
- [Signaling and policy](/quest/m2/p2p/signal.md) - opted-in peers find each other under the prefix, the application picks who to dial, and the roster-size gate decides whether STUN is used
- [UDP demux](/quest/m2/p2p/udp-demux.md) - one classifier splits QUIC from STUN and WebRTC on the relay's socket and on a native pair's
- [Native pairs over ICE and QUIC](/quest/m2/p2p/native-quic.md) - two native peers connect through ICE, then `moq-quic` over the nominated path with fingerprints pinned from the offer
- [moq-cli joins](/quest/m2/p2p/cli.md) - `--p2p` publishes a roster entry, dials native peers over ICE and QUIC, and serves browsers as a transit hop
- [Peer route policy](/quest/m2/p2p/cost-scopes.md) - application priorities and total cost choose eligible routes, with epoch-aware handover
Expand Down
6 changes: 4 additions & 2 deletions quest/m2/p2p/native-quic.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ Decided with the maintainer on 2026-10-13:
in SDP. Both sides pin it with the existing `tls.fingerprint` check. MoQ
AUTH with a [peer grant](/quest/m2/p2p/peer-grant.md) still runs on top.
- After nomination the session's socket carries ICE consent checks and
QUIC, split by the [UDP demux](/quest/m2/p2p/udp-demux.md) classifier.
QUIC, split by `moq_sock::demux::classify`: `Ice` and `Stun` go to the
ICE agent and `Quic` to the endpoint. The tokio listener's `quic::demux`
routes for a relay (STUN queries dropped, no ICE agent), so the session
socket needs its own small policy over the same classifier.

Roles are deterministic: the ICE controlling side is the QUIC client, so a
simultaneous dial resolves the same way [signaling](/quest/m2/p2p/signal.md)
Expand Down Expand Up @@ -62,5 +65,4 @@ covers LAN and NAT pairs between two `moq-cli --p2p` nodes.

## Required

- [UDP demux](/quest/m2/p2p/udp-demux.md) - the classifier that splits STUN from QUIC
- [Signaling and policy](/quest/m2/p2p/signal.md) - the offer schema and roster this extends
63 changes: 0 additions & 63 deletions quest/m2/p2p/udp-demux.md

This file was deleted.

1 change: 0 additions & 1 deletion quest/m2/perf/shard-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,5 @@ Update `doc/bin/relay/` for the default change.
## Related

- [kio channel contention](/quest/m2/perf/kio-channel-contention/README.md) - its per-thread spikes run on the workers
- [UDP demux](/quest/m2/p2p/udp-demux.md) - demuxes each shard's socket
- [Performance survey](/quest/m2/performance-survey/README.md) - paired benchmark evidence and memory/settings controls
- [Socket queues](/quest/m2/performance-survey/socket-queues.md) - queue sizing and local drop attribution
4 changes: 0 additions & 4 deletions quest/m2/quic-sansio-driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,3 @@ impl.

- [Waits](/quest/m1/quic-api/waits.md) - moq-quic owns every wait, so the driver keeps no waiter table
- [Poll forms](/quest/m1/quic-api/poll.md) - the drivers' poll shape this one mirrors

## Related

- [UDP demux](/quest/m2/p2p/udp-demux.md) - also feeds datagrams from a socket the endpoint doesn't own
10 changes: 5 additions & 5 deletions quest/m2/uring-demux.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ STUN responder class either. An ICE Binding request is WebRTC traffic and
follows that class.

Each worker's endpoint receives a batch and feeds every segment straight to
the QUIC endpoint. The classifier and flow table from the
[UDP demux](/quest/m2/p2p/udp-demux.md), split there into a
runtime-agnostic piece, run first on each segment; only QUIC continues into
the endpoint. The worker is thread-per-core and `!Send`, while the consumers
the QUIC endpoint. The classifier, pin table, per-source `Queue`, and
`Counters` in `moq_sock::demux` run first on each segment, as the tokio
listener's socket does inline in its receive; only QUIC continues into the
endpoint. Until this lands, `moq_relay::Relay::webrtc` refuses an io_uring
relay. The worker is thread-per-core and `!Send`, while the consumers
of the other classes (`moq-rtc`, `moq-srt`) run on
tokio, so non-QUIC datagrams cross to them on a `Send` channel, and their
replies come back through a remote-send path into the owning worker's ring,
Expand All @@ -49,7 +50,6 @@ off on the ring, from shard steering.

## Required

- [UDP demux](/quest/m2/p2p/udp-demux.md) - the classifier and flow table this runs on the ring
- [WebRTC on the shared socket](/quest/m2/one-port/rtc-feed.md) - the fed RTC socket and transmit contract the ring integrates
- [SRT on the shared socket](/quest/m2/one-port/srt-demux.md) - the SRT state machines fed through the shared demux

Expand Down
Loading