What are STUN, TURN & ICE?
The WebRTC standard enables peer-to-peer communication between clients. I.e. computers can talk to one another directly over the internet, rather than through a server.
Before the computers can communicate remotely, however, they must establish an initial connection by discovering each other’s IP address. Often, NAT traversal makes it hard for remote computers to learn of each other’s IPs, since computers are only aware of their private IPs. Thus, the STUN, TURN and ICE protocols are used to establish peer-to-peer communication.
STUN (Session Traversal Utilities for NAT) allows a computer to retrieve its public IP address (the IP address of the router).
TURN (Traversal Using Relay around NAT) provides a fallback option when clients are unable to connect. Since the clients are unable to find each other’s IP addresses, TURN provides another IP address for a server through which the two clients can communicate. When TURN is used to connect clients, the communication is no longer peer-to-peer since the data must pass through a server.
ICE (Interactive Connectivity Establishment) coordinates the connection to make the best connection.