Repository navigation
Protocol Discovery
Consoles find each other with 802.11 probe requests. There is no access point and no beacon. Each console sends broadcast probe requests with a fixed SSID and a Nintendo vendor element. A console that hears one and wants to exchange answers with a probe response, called an offer. The offer starts Link Setup.
Implemented in: streetpass::ie, streetpass::service, scan.
Consoles look for each other on channels 1, 6 and 11 of the 2.4 GHz band. A side that is listening moves between these channels until it hears a StreetPass probe or offer, then stays on the channel it heard it on.
Channel and frequency map as usual for 2.4 GHz: channel n from 1 to 13 is 2407 + 5n MHz, channel 14 is 2484 MHz.
A management frame, type 0, subtype 4 (probe request).
| Field | Value |
|---|---|
| Duration | 0 |
| Address 1 (receiver) | ff:ff:ff:ff:ff:ff |
| Address 2 (transmitter) | The console's MAC |
| Address 3 (BSSID) | ff:ff:ff:ff:ff:ff |
| Sequence | Running 12-bit sequence number |
Information elements, in order:
| ID | Element | Contents |
|---|---|---|
| 0 | SSID |
Nintendo_3DS_continuous_scan_000 (32 bytes) |
| 1 | Supported rates | 82 84 8b 0c 12 96 18 24 |
| 50 | Extended rates | 30 48 60 6c |
| 221 | Vendor specific | Nintendo element, below |
ctrpass sends the probe at 1 Mbit/s.
A frame is recognised as a StreetPass probe when it is a probe request and its SSID element is exactly the string above.
The vendor element (ID 221) starts with the Nintendo OUI and a subtype byte, followed by a list of small TLV records.
| Offset | Size | Field |
|---|---|---|
| 0 | 3 | OUI 00 1f 32
|
| 3 | 1 | Subtype, 01
|
| 4 | ... | TLV records |
Each TLV has a 2-byte little-endian header:
| Bits | Meaning |
|---|---|
| 0-3 | Type A |
| 4-7 | Type B |
| 8-15 | Length of the value in bytes |
Two TLV kinds are known:
| Type A, B | Value |
|---|---|
| 1, 1 | Service records, concatenated |
| 0, 15 | Token, 8 bytes |
Other TLV kinds are skipped. Service records may be split over several 1,1 TLVs. A record is never split across two TLVs, because each TLV value is at most 255 bytes. The token TLV comes after the service TLVs.
The whole element must fit in 255 bytes. After the OUI, subtype, token TLV and one TLV header, 239 bytes are left for service records. ctrpass keeps the records, in order, that fit in that budget and drops the rest from the probe. The full list is sent later inside the link, in the services object (see Exchange Objects).
flowchart LR
ie["Element 221"] --> oui["00 1f 32"]
oui --> sub["01"]
sub --> t1["TLV 1,1: records"]
t1 --> t2["TLV 1,1: more records, if any"]
t2 --> tok["TLV 0,15: token, 8 bytes"]
A service record says that a console offers one title, and how. Records are variable length.
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | Title ID, big-endian |
| 4 | 1 | Flags |
| 5 | 3 × w | Three argument arrays A, B, C, each w bytes |
Flags:
| Bits | Meaning |
|---|---|
| 0-3 | Width w of each argument array |
| 4-5 | Mode, 0 to 3 |
| 6-7 | Not used by ctrpass; kept as received |
So a record is 5 + 3w bytes. A title ID of 0 is invalid.
Two consoles only exchange a title when their records for it pair. ctrpass checks, in this order:
- The title IDs are equal.
- The widths are equal.
- The modes pair:
- mode 0 pairs only with mode 0;
- mode 1 pairs with mode 2;
- mode 3 pairs with any nonzero mode.
- The argument masks agree. With local arrays
lA, lB, lCand peer arrayspA, pB, pC, for every bytei:lA[i] & lC[i] == lA[i] & pB[i]andpA[i] & pC[i] == pA[i] & lB[i].
flowchart TD
start["Local record L, peer record P"] --> t{"Same title?"}
t -- no --> no["No pair"]
t -- yes --> w{"Same width?"}
w -- no --> no
w -- yes --> m{"Modes pair?"}
m -- no --> no
m -- yes --> a{"Argument masks agree on every byte?"}
a -- no --> no
a -- yes --> yes["Pair"]
The meaning of the individual modes is not named in the code beyond these rules. Two facts are used:
- Mode 3 is what ctrpass advertises for a title that only receives, because it pairs with every sending mode.
- When a title's inbox has no room, ctrpass skips a title whose message has mode 0 or 1, and advertises mode 2 for one whose message has mode 2 or 3.
The record a title is advertised with comes from the service extension header of its outbox message (see CEC Messages), with the mode adjusted as above.
From a probe or an offer, a listener reads:
| Item | Source |
|---|---|
| MAC | Address 2 |
| SSID | SSID element |
| Channel | DS parameter element, when present (offers carry it) |
| Token | Token TLV, when it is exactly 8 bytes |
| Services | Service TLVs |
| Problem | Set when the records end in the middle of a record |
ctrpass's scanner reports each console with this information and a signal level. The signal is the median of the last 8 plausible readings (between -100 and -1 dBm) on the channel where the console is strongest. It is given once there are 3 readings. A console is reported again when its token or services change or the median moves by 6 dB or more.
The same element parser also recognises the frames of Link Setup:
| Frame | How it is recognised |
|---|---|
| Probe | Probe request with the StreetPass SSID |
| Directed probe | Probe request with an empty SSID sent to a unicast address |
| Offer | Probe response with the StreetPass SSID and a token |
| Link-up | Probe response with an empty SSID and the privacy capability bit |
| Accept | Action frame, category 7f, OUI 00 1f 32
|
Anything else 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