Skip to content

Protocol Link Setup

finthetechguy edited this page Nov 23, 2026 · 1 revision

Link Setup

After Discovery, two consoles agree that one of them hosts a link. The host's MAC becomes the BSSID. Both sides derive a CCMP key from the two tokens and MACs, and data frames start (see 802.11 Frames and CCMP).

Implemented in: streetpass::ie, streetpass::linkkey, link.

Roles

ctrpass can take either side. It names them by what ctrpass does:

ctrpass role ctrpass does The console does
Lead Sends broadcast probes, accepts the console's offer, polls with directed probes, opens each object in the exchange. Answers with an offer, hosts the link, answers each object.
Wait Answers the console's probe with an offer, hosts the link, answers each object. Probes, accepts, polls, opens each object.

The host is the side that sends the offer and the link-up. In Lead, the console hosts. In Wait, ctrpass hosts.

Handshake

sequenceDiagram
    participant C as Client (probes)
    participant H as Host (offers)
    C->>H: Probe request, broadcast, SSID, token, services
    H->>C: Offer: probe response to C, SSID, channel, token, services
    C->>H: Accept: action frame, sent twice
    loop until link-up or 3 s
        C->>H: Directed probes, a burst every 300 ms
    end
    H->>C: Link-up: probe response, empty SSID, privacy bit
    Note over C,H: key = derive(host token, client token, host MAC, client MAC)
    C->>H: First CCMP data frame
Loading

Offer

A probe response (management subtype 5) from the host to the client.

Field Value
Duration 0
Address 1 Client MAC
Address 2 Host MAC
Address 3 (BSSID) Host MAC

Fixed fields:

Offset in body Size Field Value
0 8 Timestamp TSF timestamp; ctrpass sends microseconds since its pass started
8 2 Beacon interval 100
10 2 Capability 0x0002 (IBSS)

Elements:

ID Element Contents
0 SSID Nintendo_3DS_continuous_scan_000
1 Rates 82 84 8b 0c 12 96 18 24
3 DS parameter Channel number
6 IBSS parameter 00 00
50 Extended rates 30 48 60 6c
221 Vendor Nintendo element with the host's token and services

When ctrpass hosts, the channel in the DS element is the one from the console's probe if it had one, else the current channel. The services are the ones ctrpass chose for this console, not the full broadcast list.

Accept

An action frame (management subtype 13).

Field Value
Duration 0x00d5
Address 1 Host MAC
Address 2 Client MAC
Address 3 Host MAC
Body 7f 00 1f 32 00 00

The body is category 7f (vendor specific), the Nintendo OUI, and two zero bytes. ctrpass sends the accept twice at 11 Mbit/s.

Directed probe

A probe request to one address.

Field Value
Duration 0x013a
Address 1 Host MAC
Address 2 Client MAC
Address 3 Host MAC
Elements Empty SSID, rates, extended rates

Link-up

A probe response from the host. It has the same fixed fields as the offer, with capability 0x0012 (IBSS and privacy).

ID Element Contents
0 SSID Empty
1 Rates As in the offer
3 DS parameter Channel
6 IBSS parameter 00 00
50 Extended rates As in the offer
221 WMM information 00 50 f2 02 00 01 00
221 Vendor 00 03 7f 01 01 02 01 00 00 0a 00

The two closing vendor elements are sent as fixed bytes. The meaning of the second one (OUI 00 03 7f) is not known; ctrpass copies it unchanged.

Link key

Both sides compute the same 16-byte CCMP key. The host's values always go first.

digest = HMAC-SHA1(key  = streetpassHmacKey followed by one 0x00 byte  (17 bytes),
                   data = host token ‖ client token ‖ host MAC ‖ client MAC)   (8 + 8 + 6 + 6 bytes)
link key = AES-128-ECB-encrypt(key = slot 0x2E normal key, block = digest[0..16])
flowchart LR
    ht["Host token, 8 bytes"] --> h
    ct["Client token, 8 bytes"] --> h
    hm["Host MAC, 6 bytes"] --> h
    cm["Client MAC, 6 bytes"] --> h
    hk["streetpassHmacKey plus NUL"] --> h["HMAC-SHA1"]
    h --> d["First 16 bytes of the digest"]
    d --> aes["AES-128 encrypt one block"]
    sk["slot 0x2E normal key"] --> aes
    aes --> key["CCMP link key"]
Loading

Swapping host and client gives a different key, so both sides must agree on who hosts. The keys are described on Keys.

Each side learns the other's token from its probe or offer. A frame without a token cannot start a link.

ctrpass timing

Lead

Step Behaviour
Idle A broadcast probe every 250 ms on the current channel.
Console probe heard while idle A directed probe to that console and one broadcast probe, at most once every 500 ms.
Offer received Ask the host what to trade (see Library Data Flow). If nothing, mark the console declined for this pass. Otherwise derive the key and send two accepts.
Polling 144 ms after the accept, a burst of 6 directed probes. Then a burst of 2 every 300 ms.
Give up No link-up 3 s after the first burst.
Link-up received Start the YY session and open the first object.

Wait

Step Behaviour
Console probe heard Ask the host what to trade. If something, derive the key and answer with an offer.
Repeated probes Up to 4 offers to the same console while waiting for its accept.
Accept received Mark the attempt accepted.
Give up No accept 2 s after engaging.
Directed probe received Answer with a link-up, at most once every 50 ms. The first one starts the YY session.

Both roles

Rule Value
Channel hopping While idle and before any StreetPass frame is heard, move to the next configured channel every 6 s.
Channel lock The first probe or offer heard locks the channel to the one it arrived on.
Attempt timeout 6 s with no progress before the session starts; 12 s once the session is running.
Declined consoles A console the host declined is ignored for the rest of the pass.
Own frames Frames whose address 2 is the local MAC are dropped.

Link state

stateDiagram-v2
    [*] --> Idle
    Idle --> Engaged: offer heard (Lead) or probe heard (Wait), host chose a plan
    Engaged --> Accepted: accepts sent (Lead) or accept received (Wait)
    Engaged --> Linked: directed probe received (Wait)
    Accepted --> Linked: link-up received (Lead) or directed probe received (Wait)
    Engaged --> Abandoned: no accept in 2 s (Wait)
    Accepted --> Abandoned: no link-up in 3 s (Lead)
    Linked --> Done: session ended and the console sent its message list
    Linked --> Abandoned: session ended without the console's message list, or timeout
    Done --> [*]
    Abandoned --> Idle
Loading

After an abandoned attempt the pass goes on and may engage another console. After Done the pass is over.

Clone this wiki locally