WebRTC Architecture

We will be looking at:

  • Networking
  • Protocol stack
  • Codec Negotiation
  • Case: Video Conferencing

TCP versus UDP

TCP

  • Connection oriented
  • with ordering
  • and retransmissions
  • and congestion control

UDP

  • Connection-less
  • without ordering
  • without retransmissions
  • no congestion control


⇒ Fire-and-forget

Networking

Internet Communications

A client connects

Internet Communications

Second clients connects

Internet Communications

In the home network

Home Networking

Client connects to server

Home Networking

The gateway performs NAT

Home Networking

And does housekeeping

Home Networking

Peer-to-peer TCP won’t work

Internet Communications

STUN to the rescue

STUN - Session Traversal Utilities for NAT


Have an external server answer the questions:

  • “What is my external IP?”
  • “What is my external port?”


var ice = {"iceServers": [
    {"url": "stun:23.21.150.121"},
    {"url": "stun:stun.l.google.com:19302"},
]};

Bad Luck

Sometimes a connection fails:

  • (company) firewall
  • WiFi without client interconnect
  • network topologies


Then use TURN - Traversal Using Relays around NAT

⇒ Traffic is relayed, no longer P2P!

var ice = {"iceServers": [
    {"url": "stun:23.21.150.121"},
    {"url": "stun:stun.l.google.com:19302"},
    {"url": "turn:user@turnserver.com", "account": "********"}
]};

WebRTC simplifies with ICE

ICE - Interactive Connectivity Establishment


Finds a PeerConnection for you

  • on the local network
  • using STUN
  • using TURN

Security

W3C WebRTC working group requires all transmissions to be encrypted

  • Media
  • Data
  • Control

For UDP media traffic solutions are available, e.g. SRTP. For connection-oriented traffic, DTLS was invented.

WebRTC protocol stack

WebRTC Protocol Stack

Source: HPBN, Ilya Grigorik, ISBN 9781449344764

SDP

Session description
    v=  (protocol version number, currently only 0)
    o=  (originator and session identifier : username, id, version number, network address)
    s=  (session name : mandatory with at least one UTF-8-encoded character)
    i=* (session title or short information)
    u=* (URI of description)
    e=* (zero or more email address with optional name of contacts)
    p=* (zero or more phone number with optional name of contacts)
    c=* (connection information—not required if included in all media)
    b=* (zero or more bandwidth information lines)
    One or more Time descriptions ("t=" and "r=" lines; see below)
    z=* (time zone adjustments)
    k=* (encryption key)
    a=* (zero or more session attribute lines)
    Zero or more Media descriptions (each one starting by an "m=" line; see below)

SDP (cont)

Time description (mandatory)
    t=  (time the session is active)
    r=* (zero or more repeat times)

Media description (if present)
    m=  (media name and transport address)
    i=* (media title or information field)
    c=* (connection information — optional if included at session level)
    b=* (zero or more bandwidth information lines)
    k=* (encryption key)
    a=* (zero or more media attribute lines — overriding the Session attribute lines)

Case: Video Conferencing

Video Conferencing P2P

Using a media gateway

Video conferencing through Media Gateway