AccelByte Gaming Services (AGS) provides low-level networking capabilities for games to implement secure peer-to-peer communication, based on the WebRTC protocol.
These are the components that enable AGS P2P functionalities:
- AGS Lobby Service, acting as a Signaling Server
- TURN servers, hosted in AGS Armada
- The Session service, to manage and keep track of player sessions
- The TURN manager service, to manage and track all the TURN servers deployed in multiple regions (consult us for region selection)
- Networking Utilities library (currently supporting Unreal and Unity)
Using the AGS P2P networking library, game clients can establish secure connections to other game clients (as peers). Behind the scenes, AGS handles the handshake negotiation, secure address exchange (STUN), NAT traversals, and fallback to use a Relay Server (TURN) in case direct connection is not possible.
Common usage of the P2P networking library is for games that implement peer-hosted multiplayer sessions without a Dedicated Server. AGS P2P networking library can be used in conjunction with Unreal's Replication system, as well as Unity's GameObjects.
The WebRTC, ICE, STUN and TURN technologies are the basis of the P2P system.
WebRTC is an open protocol standard to facilitate real-time communication between applications over the internet.
WebRTC employs multiple protocols and techniques:
Interactive Connectivity Establishment (ICE) is a technique to get two computers to communicate with each other, and to deal with network address translators (NATs), firewalls, and other network barriers.
ICE uses various techniques such as exchanging network connectivity information via STUN - Session Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs) server - as well as relaying network traffic via TURN (Traversal Using Relays around NAT) servers.
AGS hosts these STUN and TURN servers, which are based on Google's COTURN project.
When a peer is attempting to connect to another peer, a handshake will be performed via a Signaling Server, implemented within the AGS Lobby service. For security purpose, no public IP address will be exposed and exchanged between the peers.
Source for the AGS Networking Utilities:
Sample projects on how to utilize the P2P Networking Library: