Repository navigation
Protocol YY Transport
Inside the CCMP data frames, consoles use a small transport named here after its magic bytes, YY (0x5959). It looks like a cut-down TCP: each object travels in its own connection, opened with SYN, carried in numbered segments, and acknowledged by byte offset. The objects it carries are described on Exchange Objects.
Implemented in: yy::frame, yy::session.
The decrypted body of a data frame holds one segment:
| Offset | Size | Field | Value |
|---|---|---|---|
| 0 | 8 | LLC/SNAP header |
aa aa 03 00 00 00 08 00 (EtherType IPv4) |
| 8 | 2 | Padding | 00 00 |
| 10 | 24 | YY header | Below |
| 34 | n | Payload | Up to 0x5ac (1452) bytes |
YY header, offsets relative to its start, little-endian:
| Offset | Size | Field | Value |
|---|---|---|---|
0x00 |
2 | Magic | 0x5959 |
0x02 |
2 | Length |
0x30 + payload length |
0x04 |
2 | Check A | 0xdead |
0x06 |
2 | Check B | 0xbeaf |
0x08 |
4 | Sequence | Byte offset of this payload in the object |
0x0c |
4 | Acknowledgement | Bytes of the peer's object received in order |
0x10 |
1 | Data offset | In 4-byte words; ctrpass sends 0x0c (48 bytes) |
0x11 |
1 | Flags | Below |
0x12 |
2 | Window |
0x38b8 (14520) |
0x14 |
4 | Reserved | 0 |
The length field and the data offset count 48 bytes of header: the 24-byte YY header plus 24 bytes before it. ctrpass writes only 10 bytes before the header (LLC/SNAP and padding). What the other 14 counted bytes correspond to is not known.
When parsing, ctrpass looks for the magic and the two check words at offsets 10, 0x18, 0 and 8 of the plaintext, in that order. If at least 24 bytes precede the header, the payload starts at header offset - 0x18 + data offset × 4. Otherwise it starts right after the 24-byte header. A segment whose payload length would exceed 1452 bytes is ignored.
| Bit | Name | Use |
|---|---|---|
0x01 |
FIN | Peer is finished. ctrpass notes it but never sends it. |
0x02 |
SYN | Opens a connection |
0x04 |
RST | Defined; not used by ctrpass |
0x08 |
PSH | Set together with END |
0x10 |
ACK | Acknowledgement field is valid |
0x20 |
END | Last segment of an object, or of a window |
Each object is sent in its own connection. Sequence numbers restart at 0 for every object.
sequenceDiagram
participant S as Sender
participant R as Receiver
S->>R: SYN seq 0 ack 0
R->>S: SYN|ACK seq 0 ack 0, window
S->>R: ACK seq 0 ack 0
S->>R: ACK seq 0, 1452 bytes
S->>R: ACK seq 1452, 1452 bytes
S->>R: ACK|PSH|END seq 2904, last bytes
R->>S: ACK ack = total length
Note over S,R: Object delivered. The receiver now takes its turn.
An object is cut into chunks of 1452 bytes. Each chunk has the ACK flag. A chunk also gets PSH|END when it is the last chunk of the object, or when it ends exactly on a multiple of the window (14520 bytes, which is 10 full chunks). An empty object is one segment with ACK|PSH|END and no payload.
- The sender may send up to
acked + windowbytes, wherewindowis the smaller of the peer's advertised window and 14520. - The peer's window is taken from its SYN|ACK and from each later ACK that does not go backwards.
- When the window cuts a chunk, the part that fits is sent with only the ACK flag and the rest waits.
- The sender stops a burst after an END segment or when it reaches the window limit.
- The object is delivered when the peer acknowledges the whole length, or when every segment was sent and the acknowledgement reaches the highest offset sent.
- In-order data is appended. Once the first 16 bytes are in, the receiver reads the declared length from the object or envelope header.
- Data past the expected offset is a gap. The receiver answers with an ACK for what it has.
- Repeated data without END means an ACK was lost. The receiver answers with its current offset.
- On every END segment the receiver sends an ACK with the bytes it has.
- An object is complete when the declared length is reached. For data with no known header, it is complete at an END when no gap was seen and the length is not a multiple of the window.
| Event | Action |
|---|---|
| No SYN|ACK in 750 ms | Send SYN again, up to 16 times, then give up. |
| Two repeated ACKs at the same offset, everything sent | Resend from the acknowledged offset. No further fast resend until the offset moves. |
| No progress for 750 ms with data unacknowledged | Resend from the acknowledged offset. |
| No progress for 750 ms with the window closed | Send a window probe: ACK with seq set to the next offset and no data. |
| 16 resends or 16 window probes without progress | Give up on the peer. The session ends as failed. |
| Peer sends SYN while its last object's final ACK never arrived | Treat the object as delivered. A peer only takes its turn after it has received a whole object. |
| Data from the peer without a fresh SYN, after an object was completed | The peer missed the final ACK. Answer END segments with an ACK for the last object's length. |
The two sides take turns. A side opens its next object:
- right after it receives a whole object from the peer, or
- after 400 ms with nothing arriving once its own last object was delivered.
ctrpass adds two adjustments:
-
Verdict hold. In the Lead role, when the object just received is the console's verdict reply (
0x34), ctrpass waits 60 ms before opening its next object, so the console's next poll sees the verdict delivered before the message list arrives. -
Repeat after the message list. In the Lead role, if the console answers ctrpass's message list with nothing and the idle timeout fires, ctrpass inserts one
0xf2object (4 zero bytes) and sends it. This is done once per session.
The session is over when nothing is left to send and either the peer sent FIN or nothing arrived for the linger time. ctrpass uses a linger of 6 s until the console has sent its message list, then 2 s.
| Limit | Value |
|---|---|
| Largest payload per segment | 1452 bytes |
| Window | 14520 bytes |
| Largest object | 1 MiB |
| Objects received per session | 64 |
| Bytes received per session | 8 MiB |
An object or envelope whose header declares a length outside 16 bytes to 1 MiB is refused, as is any object that would pass one of these limits. The rest of a refused object is ignored.
How to set up
- Overview and requirements
- Choosing a Wi-Fi adapter
- Building and installing
- Making the key file
- Desktop app
- Command line
- Messages and emulators
- Troubleshooting
Plugins
Protocol
- Overview
- Discovery
- Link setup
- Frames and CCMP
- YY transport
- Exchange flow
- Exchange objects
- CEC messages
- CEC message boxes
- Mii records
- Mii Plaza
- Keys
ctrpass library
Linux