-
Notifications
You must be signed in to change notification settings - Fork 68
Pia Overview
Pia is Nintendo's networking library that provides a framework to set up and maintain peer-to-peer connections.
Pia supports three different network types.
NEX | Matchmaking is done by game servers. This mode often requires NAT traversal. |
LDN | This is the default mode for local multiplayer on the Nintendo Switch. Pia creates a hidden wireless network to communicate with nearby consoles. |
LAN | This is an alternative mode for local multiplayer. In this mode, Pia uses UDP broadcast packets to find other consoles. |
With Pia version 6, a new game server technology was introduced:
NPLN | Matchmaking is done by game servers. This mode often requires NAT traversal. |
All peer-to-peer packets are sent through UDP. The packet format is described here. Once a connection between consoles has been established they talk to each other through a bunch of protocols. Most of these are only used internally by Pia to set up and manage the connections. The following protocols may be used to exchange game-specific data:
- Unreliable Protocol
- Reliable Protocol
- Broadcast Reliable Protocol
- Stream Broadcast Reliable Protocol
- Clone Protocol
- Sync Protocol
A group of connected consoles is called a mesh. Every mesh has a single "host" that controls the mesh. Initially, the console that created the mesh is the host. Once the host leaves the mesh, a new host is selected through "host migration". The host performs important tasks such as processing join requests by newcomers.
The following steps are performed to join a mesh:
- Your console finds a mesh through matchmaking.
- Your console establishes a connection to the host of the mesh.
- Your console sends a join request to the host.
- The host decides if it wants to accept the join request. For example, if the mesh already has the maximum number of participants it may reject the join request.
- The host sends a join response to your console to inform it about its decision. If the join request was accepted, the join response also information about the other consoles in the mesh.
- If the join request was accepted, the host sends an update message to all consoles in the mesh. The other consoles now try to establish a connection with your console.
- Your console is now part of the mesh and can start exchanging game-specific packets.
After acquiring the StationLocation of another console elsewhere (e.g. from matchmaking or a mesh update), the following steps are performed to establish a connection with the console:
- If necessary, NAT traversal is performed.
- Your console sends a connection request to the other console.
- If the other console does not want to accept the request, it sends a denying connection response to your console. Otherwise, it acknowledges the request and sends an inverse connection request to your console.
- If your console does not want to accept the inverse connection request for some reason, it sends a denying connection response to the other console. Otherwise, it acknowledges the request and sends a connection response to the other console.
- The other console sends a connection response to your console.
In Pia version 5.27 and later, this process is simplified by removing the inverse connection request.
If NEX is used for matchmaking it is often necessary to perform NAT traversal. This is not necessary in LDN and LAN mode, because the consoles are already on the same network in these modes.
The following steps are performed for NAT traversal:
- Your console calls the RequestProbeInitiation or RequestProbeInitiationExt method on the on the game server.
- The server sends an InitiateProbe request to the other console.
- The other console sends a probe request directly to your console. At the same time, it calls RequestProbeInitiation or RequestProbeInitiationExt on the game server.
- When your console receives the probe requests, it sends a probe reply directly to the other console. When the server receives the probe initation request, it sends an InitiateProbe request to your console.
- When your console receives the InitiateProbe request from the server it sends a probe request directly to the other console.
- The other console answers your probe request with a probe reply.
- NAT traversal has been completed and the consoles can now establish a connection using the station protocol.
- Home
-
NEX
- PRUDP Protocol
- RMC Protocol
-
NEX Services
- Common
- Nintendo
- Kerberos Authentication
- Hpp Server
- NPLN
- Pia
- Switch Servers
- Other Pages