While WebRTC has been around for awhile now but its still feels like a young technology and there are few resources to learn about it. These are the basics of how a connection is made between peers which is important for understanding how WebRTC differs from traditional networking.
Creating a Connection
Fetch ICE (Interactive Connectivity Establishment) Candidates from STUN server.
- Contains details of how the data is going to be exchanged (ip, port, protocol).
If STUN reports we are unreachable (behind a symetric NAT?) then we must use a TURN relay.
- Need to use
TURNrelay since peer wont be able to directly connect to us.
Make an offer SDP which contains meta-data about the data the peers will be sending.
- SDL = session description protocol
SDL is shared with peer via Signal Channel.
- Signal channel can be anything from a websocket to word of mouth but WebRTC doesn’t do this part.
Remote party answers with their own SDP via Signal Channel.
Peers connect with information recieved SDP.
I learned about WebRTC in the context of WebTorrent which is an amazing project, you should check it out.