WebRTC

What is it and Why should you care?

PyWeb-IL #90
By: Benny Daon

About Me

  • Been to PyWeb-IL #1
  • 30 years of coding in the shell
  • Inspected a lot of packets
  • Last year working on a WebRTC based terminal

The Itch:

Touching the terminal

and nothing happens

The Solution

Why WebRTC

  • Real time
  • Secure
  • Rate Controlled
  • Supported by all browsers
  • Open source projects to start from:
    • aiortc
    • janus
    • pion/webrtc
    • ...
       

WebRTC History

  • 2010 - Google buys GIPS
     
  • 2011 - W3C publishes first draft
     
  • 2014 - Google hangouts uses WebRTC
     
  • 2017 - WebRTC 1.0 becomes a candidate recommendation
     
  • 2021 - WebRTC 1.0 becomes a recommendation

WebRTC is an incomplete API

A bulky API covering a mesh

of network protocols while

leaving signaling to magic

The Browser Parts

The browser part

By: Princiya

The Protocol Monster

By: Sean Dubois

Batteries Included

  • PeerConnection
    • addTrack/onTrack
    • createDataChannel/onDataChannel
    • getStats
    • ...

Interactive Connectivity Establishments

By: Andrew Prokov

Initiator Code

pc = new RTCPeerConnection({ 
       iceServers: [ { urls: iceServers }],
       certificates: myCert
})
pc.addTrack(track, stream...)
pc.createDataChannel('label')
pc.createOffer(offerOptions)
.then(desc => pc.setLocalDescription(desc))
pc.onicecandidate = signalMagic

Tracking State

pc.onconnectionstatechanged(e => {
  switch(pc.connectionState) {
    case "connected":
      // The connection has become fully
      // connected
    case "disconnected":
    case "failed":
      // One or more transports has terminated
      // unexpectedly or in an error
    case "closed":
      // The connection has been closed
})

Accepting Offers

onOffer(offer) {
    let sd = new RTCSessionDescription(offer)
    pc.setRemoteDescription(sd)
}

The story of RTOMax

 RFC 4960: Stream Control Transmission Protocol

The computation and management of RTO in SCTP follow closely how TCP manages its retransmission timer.

 RFC 4960: Stream Control Transmission Protocol

  C7)  A maximum value may be placed on RTO provided it is at least RTO.max seconds.

Further Reading

WebRTC

By Benny Daon

WebRTC

What is it and why should you care?

  • 1,160