Skip to main content
WebRTC

WebRTC

Active

Web Real-Time Communication (WebRTC) is a collection of IETF and W3C standards that enables peer-to-peer audio, video, and arbitrary data exchange directly between browsers and devices, without plugins or intermediate servers for the media path. WebRTC is used by Google Meet, Discord, Zoom (web), WhatsApp Web, and every major video calling product.

WebRTCP2PRFC 8825ICESTUNTURNDTLS2011
ICE Candidates

In one line

WebRTC (RFC 8825 suite, 2021) enables peer-to-peer audio, video, and data exchange directly in the browser via the RTCPeerConnection API. Connections use ICE (RFC 8445) to discover and negotiate network paths through NAT – STUN (RFC 5389) discovers public IP, TURN (RFC 8656) relays media when direct path fails. Media is encrypted with DTLS-SRTP (RFC 5764). SDP offer/answer (RFC 3264) negotiates codecs and media parameters. Data channels use SCTP over DTLS (RFC 8831).

Quick Reference

FieldSizeDescription
ICERFC 8445Interactive Connectivity Establishment. Gathers local network candidates, discovers public address via STUN, uses TURN relay as fallback. Connectivity checks select the best path.
STUNRFC 5389/8489Session Traversal Utilities for NAT. A server that echoes your public IP:port back to you. Used by ICE to discover server-reflexive (srflx) candidates.
TURNRFC 8656Traversal Using Relays around NAT. A relay server that forwards media when direct P2P fails. Required for symmetric NAT (~20–30% of connections). Adds latency and bandwidth cost.
DTLSRFC 6347Datagram TLS. Encrypts all WebRTC media and data. DTLS handshake establishes keys for SRTP (media) and SCTP (data channels). Mandatory – WebRTC never sends unencrypted media.
SRTPRFC 3711Secure Real-time Transport Protocol. Encrypts audio/video streams. Keys derived from DTLS handshake (DTLS-SRTP, RFC 5764). AES-CM-128 or AES-GCM.
SDP Offer/AnswerRFC 3264Session Description Protocol negotiation. Offerer sends SDP describing capabilities; answerer responds with accepted subset. Defines codecs, ICE credentials, DTLS fingerprint.
SCTPRFC 8831Stream Control Transmission Protocol over DTLS. Powers RTCDataChannel. Supports ordered/unordered, reliable/unreliable, and partially reliable delivery modes.
BUNDLERFC 8843Multiplexes all media streams (audio, video, data) on a single ICE component and port. Reduces TURN relay cost and NAT state. Enabled by default in modern browsers.
SignalingNot specifiedWebRTC does not define a signaling protocol. SDP offer/answer must be exchanged out-of-band via WebSocket, HTTP, or any other channel.

Key Characteristics

Peer-to-peer media

When ICE succeeds with a direct path, media flows P2P without any intermediate server. Sub-100 ms latency for real-time video calls on good networks.

Mandatory encryption

All WebRTC media and data is encrypted. DTLS-SRTP for media streams, DTLS for data channels. There is no opt-out. The spec explicitly forbids cleartext media.

NAT traversal complexity

ICE handles most NAT types automatically, but symmetric NAT requires TURN relay. Deploy TURN servers for production. Coturn is the most common open-source TURN server.

Low-latency media

VP8, VP9, H.264 video codecs. Opus audio codec (48 kHz, 2.5–120 ms frame size). Adaptive bitrate, jitter buffer, packet loss concealment built in.

Message Format

Request
http
// WebRTC connection flow (simplified)
// 1. Get local media
const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });

// 2. Create RTCPeerConnection with ICE servers
const pc = new RTCPeerConnection({
  iceServers: [
    { urls: "stun:stun.example.com:3478" },
    { urls: "turn:turn.example.com:3478",
      username: "user", credential: "pass" }
  ]
});
stream.getTracks().forEach(t => pc.addTrack(t, stream));

// 3. Create SDP offer
const offer = await pc.createOffer();
await pc.setLocalDescription(offer);

// 4. Exchange SDP via signaling channel (your WebSocket/HTTP)
signalingChannel.send(JSON.stringify({ sdp: offer }));
Response
http
// SDP offer (abbreviated)
v=0
o=- 123456 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111
a=rtpmap:111 opus/48000/2
a=ice-ufrag:abc123
a=ice-pwd:xxxxxxxxxxxxxxxxxxxx
a=fingerprint:sha-256 AA:BB:CC:...
a=setup:actpass

// ICE candidate (server-reflexive)
candidate:1 1 UDP 1686052607 203.0.113.1 54321 typ srflx
  raddr 192.168.1.5 rport 12345 generation 0

// Data channel creation
const dc = pc.createDataChannel("chat", {
  ordered: true,     // TCP-like delivery
  maxRetransmits: 3  // or use maxPacketLifeTime
});
dc.onmessage = (e) => console.log(e.data);

Implementations

linuxsince Chrome 28+, Firefox 22+, native in all modern browsers. libwebrtc (C++) for native apps. Pion (Go), aiortc (Python) for servers.built-in
macossince Safari 11+ (full WebRTC 1.0). Same browsers as Linux. CoreRTC framework for native macOS apps.built-in
windowssince Edge 79+ (Chromium). Chrome, Firefox. libwebrtc for C++ apps. Microsoft Teams uses WebRTC.built-in
iossince Safari iOS 11+ WebRTC 1.0. WebRTC native via Google WebRTC framework (FaceTime uses similar stack).built-in
androidsince Chrome Android 28+. Google Meet, WhatsApp use libwebrtc natively.built-in