Pia (Library)
Pia is a library developed by Nintendo to make implementing network features in games easier. It operates using a peer-to-peer network, and supports connections over the Internet, local wireless, and LAN. This page is current as of pia version 5.9.1.
Packet
Pia uses AES-128-GCM to encrypt messages and verify them on receipt.
Offset | Size | Description | Value |
---|---|---|---|
0x0 | 4 | Magic number | 0x32ab9864
|
0x4 | 1 | Encryption type | 0 = not encrypted, 1 = encrypted |
0x5 | 1 | Target console | |
0x6 | 2 | Sequence number | |
0x8 | 2 | Transmission time(?) | |
0xA | 2 | Arrival time(?) | |
0xC | 8 | Unique data for IV | |
0x14 | 16 | HMAC | |
0x24 | variable | Messages (encrypted) |
Message
Offset | Size | Description | Value |
---|---|---|---|
0x0 | 1 | Flag(?) | |
0x1 | 2 | Data size | |
0x3 | 8 | Unknown | |
0xB | 4 | Source IP | |
0xF | 4 | Source port | |
0x13 | 2 | Protocol ID | |
0x15 | 3 | Unknown | |
0x18 | variable | Payload |
Clone
A clone is something that pia will attempt to synchronize across all consoles connected to the session. For example, creating a clone object on an int will cause all subscribing consoles to be notified about any changes to that int. Splatoon 2's netcode works entirely off clones and does not use any other message format to transmit game data. The protocol ID for clone messages is 0x0074
. There are three types of clones known so far:
- Unreliable (type
0x0001
) - synchronization may fail - Reliable (type
0x0002
) - synchronization is guaranteed to succeed - Event (type
0x0003
) - synchronization is guaranteed to succeed and the order of data sent is preserved
The format for clone messages is not yet well understood. Some clone messages appear to have synchronization information (like the "clone clock") instead of actual data for one of the clone types. Messages that do contain actual data have a zlib header starting at 0xD or 0xE. The size field set in the decompressed data header may be larger than the payload actually contained within. It is currently unknown why this is occasionally the case.