WebRTC — Using STUN SERVER

Navid Mostafiz
2 min readDec 26, 2020

Let's have a top level discussion the flow when we can establish direct bidirectional connection between two Peers using WebRTC on STUN Server

I am planning to write very detailed articles on the entire WebRTC protocol. This is just a small portion where we discuss in simple words on STUN servers being used for WebRTC connections.

All peers connect to a SIGNALLING SERVER. Say PEER1 and PEER2. PEER1 sends an OFFER to PEER2 using SDP message via SIGNALLING SERVER PEER2 sends back ACCEPTANCE back to PEER1 using SDP message

PEER1 calls an ICE SERVER (STUN SERVER) over UDP/TCP to get its PUBLIC IP and PORT (also called SERVER REFLEXIVE TRANSPORT ADDRESS, e.i outside NAT) and PRIVATE IP AND PORT (also called HOST TRANSPORT ADDRESS i.e inside NAT). Using this info it creates an ICE message. Similarly, PEER2 does the same.

Both the PEERS exchange this ICE message with each other via the SIGNALLING SERVER and expresses its intention as ICE candidates.

Both PEERS now try to connect with each other using WebRTC protocol using the ICE information. Thus the PEERS can share a direct Bidirectional Audio/Video/Data over the internet

I made a diagram for this :)

WebRTC Using STUN ICE SERVER — Navid Mostafiz

My next article will be on WebRTC — Using TURN SERVER and will discuss its contrast to using only STUN Server. After a very top level conception of the WebRTC is laid down, I will start writing more technical details on how the WebRTC works at granular level. Thanks!

--

--