Published on

Tinkering with the WebTRC API

What is WebRTC?

WebRTC is a framework that enables real time communication for the web. It supports video, voice, and generic data to be sent between peers. [^1]

The WebRTC standard covers two different technolgies:

  • Media capture devices (e.g cameras, microphones)
  • Peer to peer connectivity

Introduction to WebRTC protocols

ICE

Interactive Connectivity Establishment (ICE) is a framework to allow your web browser to connect with peers. ICE uses STUN and (or) TURN servers to do so.

STUN

Session Traversal Utilities for NAT (STUN) is a protocol to discover your public address and determine any restrictions in your router that would prevent a direct connection with a peer.

STUN illustration

Credit : MDN

NAT

Network Address Translation (NAT) is used to give your device a public IP address. A router will have a public IP address and every device connected to the router will have a private IP address.

TURN

Some routers using NAT employ a restriction called ‘Symmetric NAT’. This means the router will only accept connections from peers you’ve previously connected to.

Traversal Using Relays around NAT (TURN) is meant to bypass the Symmetric NAT restriction by opening a connection with a TURN server and relaying all information through that server. You would create a connection with a TURN server and tell all peers to send packets to the server which will then be forwarded to you.

TURN Illustration

Credit : MDN

SDP

Session Description Protocol (SDP) is a standard for describing the multimedia content of the connection such as resolution, formats, codecs, encryption, etc. so that both peers can understand each other once the data is transferring. This is, in essence, the metadata describing the content and not the media content itself. [^2]

Technically, then, SDP is not truly a protocol, but a data format used to describe connection that shares media between devices.

References

[^1] - https://webrtc.org/getting-started/overview [^2] - https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols