Check out Optimize, our new AI-powered product!

Basics of WebRTC data channel
By: ,
28 October 2015

Basics of WebRTC data channel

Think of any communication product and you’ll notice that the generated traffic can be divided into three different categories: audio, video and other data. While you may prefer to communicate over audio and video, most of the communication still happens as written text or perhaps share an image or a GIF file. This is was one of the core reason for WebRTC to develop the data channel to send for any type of data, i.e., in addition to being able to transport audio and video over MediaStreamTracks. Another decision that makes using data channels super easy is that the API mirrors the websocket API, making it fairly easy to port code from client/server to peer-to-peer paradigm. Just like audio and video, the data channel for WebRTC is encrypted with Datagram Transport Layer Security (DTLS), which is a derivative of TSL for UDP.

The RTCDataChannel in its current incarnation uses the Stream Control Transmission Protocol (SCTP), which can be configured for ordered or unordered delivery. Essentially, the developer can choose the delivery method depending on the use-case. Due to its versatile nature the data channel is already used for many different applications. It could be used, for example, to send gaming data directly (for example, position and speed) to other players making the gaming experience as close to real-time as possible.

The flexibility of the API and the architecture allows IETF to replace the data channels with a pure RTP based data flow or adapt QUIC (Google’s new UDP transport for HTTP/2) for the peer-to-peer use-case.

The different protocols and technologies related to WebRTC

The different protocols and technologies related to WebRTC

As sending data over the WebRTC datachannel currently does not require consent from the user, using it is one step easier from the user’s standpoint than getting audio from the microphone and video from a camera, which require the user to click “Allow” in a pop-up window. However, building an application this way is risky, in recent months we have seen this being exploited to harvest local IP addresses by NY Times. And the community has responded with disabling access via a plugin and in future versions of Chrome and Firefox.

One of the compelling applications of the data channel is its use with large scale video streaming. Specifically, the video streaming applications offloads the traffic from the central servers to participants, i.e., multiple participants to share bits of video they are currently watching. For example, Streamroot uses the data channel for video streaming. Check out their live demo, ask a friend or a colleague to join the demo and open chrome://webrtc-internals in your Chrome to see the metrics of the video.

Similar to webrtc-stats, callstats.js gathers metrics from the various peer connections via which the browser is receiving media data. Additionally, callstats.js (via the video tag passed by the associateMstWithUserid) uses the video playback stats to measure the playback quality.

All in all, the WebRTC data channel can power many different use cases where a point-to-point connection between users’ end-points is needed. It might just be that as a user you will never know an application uses WebRTC’s datachannel to send and receive data in real-time because in the end it is just a technology that disappears into the background.

To get our blog posts into your email, sign up for our monthly newsletter using the form below.



comments powered by Disqus