tezvyn:

WebRTC signaling: SDP, ICE, and the signaling server

AI-drafted, machine-checkedSource: interviewadvanced
WHAT IT TESTS

WebRTC connection setup.

OUTLINE

Peers exchange SDP offer and answer describing media via an out-of-band signaling server, then trade ICE candidates to find a network path using STUN and TURN.

WHAT THIS TESTS Whether you understand that WebRTC handles media transport but deliberately leaves signaling to you, and that SDP and ICE solve two different problems: what to send and how to reach the peer.

A GOOD ANSWER COVERS WebRTC does not define how peers find each other, so you provide a signaling server over any transport you like, commonly WebSockets. The flow: the initiating peer calls createOffer, which produces a Session Description Protocol blob describing its media capabilities, codecs, and parameters, sets it as its local description, and sends it through the signaling server. The remote peer sets it as the remote description, calls createAnswer, returns its own SDP, and both sides now agree on media. Separately, ICE, Interactive Connectivity Establishment, gathers candidate transport addresses. STUN servers help a peer discover its public IP and port behind NAT, and when direct connectivity fails, a TURN server relays the media. Peers trade these ICE candidates via the same signaling channel and converge on the best working path. Once connected, audio, video, and data flow directly between peers; the signaling server is no longer involved.

COMMON WRONG ANSWERS Saying WebRTC includes a built-in signaling protocol. Believing media is relayed through the signaling server. Confusing STUN and TURN; STUN only discovers addresses, TURN relays. Thinking SDP carries the media itself rather than describing it.

LIKELY FOLLOW-UPS Why is TURN sometimes unavoidable and why is it costly? What is trickle ICE? How does the offer/answer relate to setLocalDescription and setRemoteDescription? How do data channels differ from media tracks?

ONE CONCRETE EXAMPLE Two browsers join a call. Browser A createOffer, sends SDP over a WebSocket relay to Browser B. B sets it remote, createAnswer, sends SDP back. Both gather ICE candidates: STUN reveals their public addresses, and they exchange candidates over the same socket. They find a direct UDP path, so video flows browser to browser. If both sit behind strict symmetric NATs, ICE falls back to a TURN relay, and the signaling server still only brokered setup, never the video.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.