diff --git a/docs/CLEAN_ROOM.md b/docs/CLEAN_ROOM.md index 4d6e33a..332f640 100644 --- a/docs/CLEAN_ROOM.md +++ b/docs/CLEAN_ROOM.md @@ -96,3 +96,4 @@ All entries by the DomiStream protocol engineer. Pinned commits are the ones rea | S-30 | 2026-12-04 | [Moonshine](https://github.com/hgaiser/moonshine) at `f184d5e3693e09c3a6ab1025bde6cdb67f36a6bc` (same pin as S-9): `src/rtsp.rs` again, read for the host side | BSD-2, facts only. One request per TCP connection, the note that Moonlight opens a connection per request; `CSeq` required (connection closed without it); no method order and no `Session` check; statuses 200/400/500 only; OPTIONS `Public`; SETUP needs `Transport` (400 without), stream from the first `streamid=` query segment, answer `Session: MoonshineSession;timeout = 90` and `Transport: server_port=`; DESCRIBE line order and values (`featureFlags:3`, `encryptionSupported` 5 or 7, `sprop-parameter-sets=AAAAAU`, invalidation, AV1, H.264, surround lines); ANNOUNCE: the ten required attributes (400 when missing), the defaults of the optional ones (`maxNumReferenceFrames` 1, `dynamicRangeMode`/`chromaSamplingType`/`encoderCscMode`/`encryptionEnabled`/`surround.enable` 0, `numChannels` 2, `channelMask` 0x3, `AudioQuality` 1), `maxFPS` 0 refused, bitrate ×1000 must fit a u32, QoS off for `0`. The comments citing Sunshine, moonlight-common-c or GFE are logged as second-hand GPL facts above and not used. | | S-31 | 2026-12-04 | Moonshine at `f184d5e`: `src/session/stream/mod.rs`, `src/session/stream/video/mod.rs`; the repository tree listing (GitHub API) | BSD-2, facts only. `bitStreamFormat` 0 H.264 (default), 1 HEVC, 2 AV1, others invalid; dynamic range 0 SDR (default), 1 HDR; chroma 0 4:2:0 (default), 1 4:4:4; valid video packet size 200..=65471 (one stream packet in an IPv6 UDP datagram), below 200 refused; FEC default 20 %. The bitrate comment citing Sunshine is logged above and not used. | | S-32 | 2026-12-04 | [Wolf: RTSP](https://games-on-whales.github.io/wolf/stable/protocols/rtsp.html) again (as S-3); [RFC 2326](https://www.rfc-editor.org/rfc/rfc2326.txt) | Wolf: nothing new for the host (no per-method answers, no ANNOUNCE list). RFC 2326: reason phrases of 400, 451, 454, 455, 501 (7.1.1); a missing `Content-Length` means zero (4.4); OPTIONS may be sent at any time (10.1); session ids at least 8 random octets (3.4); `Public` as a comma-separated list (10.1 example). | +| S-34 | 2026-12-04 | [Stock ENet](https://github.com/lsalzman/enet) v1.3.18 (`2662c0d`, same pin as S-17), read again for the host side: `protocol.c` (`enet_protocol_handle_connect`, `_verify_connect`, `_disconnect`, `_ping`, `_bandwidth_limit`, `_throttle_configure`, `_acknowledge`, `_send_unsequenced`, `_send_unreliable_fragment`, `_send_reliable`/`_send_fragment` state checks, the acknowledgement rules of `_handle_incoming_commands`, the ping condition of `_send_outgoing_commands`) and `include/enet/enet.h` (peer window constants) | MIT. Facts for PROTOCOL.md 3.1 "The accepting side" and `enet::host`: a CONNECT is answered by a reliable verify on channel 0xFF and is not itself acknowledged; repeated connects from a live peer are refused; session id derivation (offered id or the slot's, plus one mod 4, skipping the slot's previous id) and which verify field carries which; MTU, window and channel clamping, bandwidths are the host's own, throttle echoed, connect data reported with the connect event; connected on the acknowledgement of the verify; acknowledgements only while connected and only with a sent time, a failing command ends the datagram; ping, bandwidth and throttle need the connected state; unsequenced window 1024 groups, 32 free windows; pings when nothing was received for the ping interval and nothing reliable is in flight. Read through an automated summary of the raw files at the pinned commit; no code copied. | diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index 0738bef..1cacee6 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -340,6 +340,38 @@ UNKNOWN U9 (narrowed): anything Sunshine's ENet sends that stock 1.3 does not; t data` a client offers; whether the client sets non-default ping or timeout values. Settle: the lab capture's control port datagrams, decoded with our parser (LAB_CAPTURE.md). Until then our client offers stock defaults. +**The accepting side, as stock ENet 1.3 does it** [E] (S-17, S-34; DomiStream `enet::host`, the Lumen host): +- A datagram addressed to `0xFFF` is looked at only for a CONNECT at its start; anything else in it is ignored. A + CONNECT asking for 0 or more than 255 channels is refused. A CONNECT repeated by a client whose connection already + exists (same address, same connect id) is ignored: no second peer, no acknowledgement. +- The CONNECT is **not acknowledged**; the host answers with a reliable VERIFY CONNECT on channel `0xFF` (the + connection channel's first reliable sequence number, 1), and the verify retires the client's connect. +- Session ids: the host's outgoing id is the client's offered *incoming* id (or, for `0xFF`, the slot's previous + outgoing id) plus one, modulo 4, bumped once more if it equals the slot's previous outgoing id; the host's + incoming id likewise from the client's offered *outgoing* id. A fresh slot has `0xFF` for both, so a client offering + `0xFF`/`0xFF` gets 0/0. The verify carries `incoming session = the host's outgoing` and `outgoing session = the + host's incoming`, i.e. both fields from the client's point of view; a sender puts its outgoing id in the header + (only once the remote peer id is known), a receiver drops datagrams whose id is not its incoming id. +- Verify fields: `outgoing peer id` = the host's own peer id (the client addresses it from then on); MTU = the + client's clamped to 576-4096, then at most the host's; window = the client's, at most 65536 when the host's + bandwidth is unlimited, clamped to 4096-65536; channel count = the client's, at most the host's channel limit; + bandwidths = the host's own (0 = unlimited); throttle interval, acceleration and deceleration echoed; connect id + echoed. The connect's `data` word is what the host's connect event reports. +- The peer is connected when the client **acknowledges the verify**. Before that, data, pings and bandwidth or + throttle commands from the client are not taken and not acknowledged (the client sends them again). +- Acknowledgements: a command with the acknowledge flag is acknowledged only while connected, echoing the datagram's + sent time; in a datagram **without** sent time such a command is handled but not acknowledged and the rest of the + datagram is skipped. A failing command also ends the datagram. +- Disconnect from the client while connected: acknowledged (if flagged), the connection closes with the client's + data word. Ping, bandwidth limit and throttle configure need the connected state. +- Unsequenced duplicates are dropped with a window of 1024 groups; groups up to 32 windows ahead move the window, + older or farther ones are dropped. +- The host pings a connected peer when nothing was **received** from it for the ping interval (500 ms by default) + and no reliable command is in flight. + +Not in DomiStream's host: the checksum and compression (see above), throttling what it sends by bandwidth, and +unreliable fragments (dropped: every control message is small and reliable). + ### 3.2 Encrypted frame Every control message is wrapped [W4] (little-endian): @@ -392,6 +424,17 @@ does not match, **ends the session** when it arrives outside the encrypted frame message is skipped, and so is a frame that fails decryption. Whether Sunshine reads bodies (and which) is what U10 still settles live: the probe sends empty bodies first ([LIVE-INTEROP.md](LIVE-INTEROP.md), table V). +How DomiStream's host side reads the client (`control::host`, for Lumen; ours, on [M] above): frames open with the +client-to-host nonce; a frame that fails, or whose sequence number is not above the last accepted one, is dropped +without moving the replay state (U11: the first number is not checked); a malformed message inside a good frame is +skipped. Bodies of START_B, PERIODIC_PING and the IDR request are ignored, LOSS_STATS and FRAME_STATS are kept raw, +INVALIDATE_REF_FRAMES reads `first`/`last` with missing bytes as 0, INPUT_DATA goes through section 4 (a layout we +cannot read is reported, not fatal), every other type (START_A among them) is skipped. Only control V2 is spoken: a +bare message outside the frame is dropped. Host messages: rumble, trigger rumble, motion event, RGB LED and the +extended termination are sent, reliable on channel 0, numbered from 0; the plain TERMINATION (body U10) and +HDR_MODE (`[M*]`) are refused until measured. Each PERIODIC_PING moves the stop deadline (default 60 s) out; when it +passes, the host reports it once and the caller ends the session. + --- ## 4. Input and gamepad packets