What is Peer-to-Peer Networking for Multiplayer Games?
What is Peer-to-Peer Networking for Multiplayer games?
Peer-to-peer (P2P) networking takes a decentralized approach, allowing participants (peers) to communicate directly with each other. In a P2P network, there is no central authority governing the interactions. Participants collaborate and share information instantly, without relying on a central server for decision-making.
Specifically for games, it means that one player becomes the “host”, namely the person who distributes the game’s logic to the other players.
What are the Advantages of Peer-to-Peer Networking for Multiplayer games?
For game developers, it is widely communicated in the industry that peer-to-peer is both the “simplest” networking infrastructure to implement, and the cheapest as it is considered “free” since it is the players themselves who have to send the data amongst themselves.
P2P networks are inherently scalable, distributing the workload across all connected players, which reduces strain on any one system.
Is Peer-To-Peer Networking for Multiplayer Games Truly Simple?
Peer-to-peer (P2P) networking in multiplayer games is often described as a simple and efficient solution for connecting players. In theory, a game creates a "listen server," and with the use of a public IP address, players are easily connected.
However, in reality, it's far more complicated. The reason lies in the way internet service providers (ISPs) handle public IP addresses.
Due to a process known as Network Address Translation (NAT), a single public IP is often shared among multiple users. This setup is akin to living in an apartment block where each flat shares a building address, and individual units (flats) are temporarily identified by a changing number.
To address this, games rely on mechanisms like STUN servers, which help determine and share temporary IP addresses or "flat numbers" with other players.
Is Peer-to-Peer Networking for Multiplayer Game Safe?
STUN servers comes with a major security risk: exposing players' IP addresses to the broader internet. Just like how anyone could learn your flat number and send you unsolicited mail, malicious actors could exploit this information to send harmful traffic to players.
This vulnerability has led many internet service providers to block such connections, forcing developers to adopt more secure solutions like relay servers. These relay servers act as intermediaries, ensuring that private IP addresses remain hidden while still facilitating player connections.
In conclusion, while peer-to-peer networking might appear to be a simple solution, the reality is that it introduces significant security and stability challenges.
As a result, most modern multiplayer games rely on relay servers or authoritative servers (running on public cloud) to provide a safer and more reliable gaming experience.
So, is P2P networking for multiplayer games truly simple and safe? Unfortunately, it's not—and that's why the industry is moving away from it in favor of more secure alternatives for commercial releases of multiplayer games.
---
For more information on the comparison between Peer-to-Peer Networking, Relays and Authoritative Severs (often called Dedicated Servers), check out our dedicated breakdown on our blog.
---
Parts of the above information comes from a presentation done by Michal Buras, Senior Developer at Highwire Games, at the Live Service Game Summit conference.
A full version of this conference can be found here: Peer-to-Peer, Relays & Container Instances: And In-Depth Analysis of Development Resources, Performance, Security Issues for Multiplayer Games