Using STUN and TURN
As you know from Chapter 1, Developing a WebRTC Application, WebRTC uses the ICE technology and utilizes STUN/TURN servers when establishing a peer-to-peer connection process to break through firewalls and NAT. The difference between using STUN and TURN is schematically visualized in the following diagrams (we also used these diagrams in Chapter 1, Developing a WebRTC Application):
The following diagrams show a peer-to-peer connection using the STUN server:
The following diagram represents a general simple case of when the TURN server is used. Here, we have a situation where both peers use the same TURN server. We can see that peers use the STUN server to discover their network parameters and use the TURN server exchanging with media data. Technically, every TURN server can also serve as a STUN server. So, in the diagram, the STUN and TURN servers are represented as separate entities, but in the real world, they are usually one physical TURN/STUN server.
On the other hand...