Design Solutions Research & Design Hub

Applying WebRTC to the IoT

Written by Allie Mellen

Peer-to-Peer Comms

An open-source project created by Google, Web Real-time Communications (WebRTC) facilitates peer-to-peer communication directly in the web browser and through mobile applications using APIs. In this article, Allie shows how IoT device communication can be made easy by using WebRTC.

  • How WebRTC makes IoT device communications easier

  • What is WebRTC?

  • What are the components of WebRTC?

  • How to use WebRTC with the IoT

  • What are some example devices with WebRTC?

  • What online information is available about WebRTC?

  • Web Real-time Communications (WebRTC) 

  • IoT

  • Content Delivery Networks (CDN)

By 2025, the value for global Internet of Things (IoT) technology is expected to reach up to $6.2 trillion. It’s becoming a huge industry on its own, with applications in one-way conversational devices, medical devices, wearables and many others (Figure 1).

FIGURE 1
IoT is becoming a huge industry on its own, with applications in one-way conversational devices, medical devices, wearables and many others.

The IoT has consistently shared a single goal: data—collecting data, sharing data and analyzing data. The importance of data has reached critical mass over the past ten years, and big data on its own is a burgeoning field. Data is a goldmine for providers. It gives them insights into their customer base. Depending on the device, data can reveal their customers sleeping habits, weight, heartbeat, location and more.

This makes communicating data from the device back to the provider of significant importance. Collecting this data is useless without the ability to receive and analyze it. In similar time to the importance of data, the importance of connecting devices has become vital over the past ten years to consumers and businesses alike. Now, it’s crucial that communication between devices be effective, easy, and reliable. This creates the perfect opportunity for crossover between WebRTC and the IoT. With WebRTC, developers can easily enable devices to communicate securely and reliably through video, audio or data transfer.

WHAT IS WebRTC?

Web Real-time Communications (WebRTC) is an open-source project created by Google that was released in 2011 (Figure 2). It facilitates peer-to-peer communication directly in the web browser and through mobile applications using application programming interfaces. By communicating directly in the web browser, it eliminates the need for plugins and native app installations to make real-time communication as user-friendly as possible. Not only is WebRTC available on most every computing device, it is also used by close to half a billion monthly active users.

FIGURE 2
The WebRTC logo. WebRTC is an open-source project created by Google that was released in 2011.

WebRTC enables developers to create high-quality, real-time communication applications in Chrome, Firefox, Opera, Android and natively on iOS and Android. Facebook, Google, Amazon and many other companies use WebRTC to make audio, video and data transfer applications that are fast, reliable and secure. It is completely free and capable of being adapted to your own needs. It is also constantly evolving and improving, so changes happen quite often.

WebRTC is most commonly used for real-time audio and video conferencing, messaging and direct data transfers. For example, Slack uses WebRTC for Screenhero, which allows users to make real-time audio calls from within Slack. Facebook uses WebRTC in their Messenger application, which allows for real-time messaging between peers. Other applications of WebRTC include Discord, Google Hangouts, GoToMeeting, and Amazon Mayday. Some emerging use cases of WebRTC include onion-routed communication, the internet of things, online education and self-driving cars.

— ADVERTISMENT—

Advertise Here

The Web Real-time Communications Working Group and the Internet Engineering Task Force are creating standards for WebRTC use. Version 1.0 of WebRTC has gone to candidate recommendation as of June 2018.

IMPORTANT COMPONENTS

WebRTC has a few important elements to help make building peer-to-peer applications easier:

● getUserMedia() gives access to the local device audio and video.
● MediaRecorder records local audio and video.
● RTCPeerConnection allows peer-to-peer audio and video communication, including the initial connection, monitoring of the connection, and closing the connection.
● RTCDataChannel allows bidirectional transfers of data between peers.
● getStats is a real-time statistics API for WebRTC to help developers make sure WebRTC calls are the best quality.

Figure 3 shows the structure and flow of the WebRTC data and statistics API. WebRTC has a JavaScript API layer so you can use it inside the browser, making it easier to develop anywhere. In addition, it can be embedded directly into an application with no need for the browser. Internally, WebRTC is mostly C/C++, but the majority of developers that use WebRTC do not need to work directly with those layers. WebRTC gives access to devices including the microphone, video camera and the screen, if applicable.

FIGURE 3
Structure and flow of the WebRTC data and statistics API

WebRTC is great for implementing real-time communication because it is open source, is supported by the majority of browsers and is very powerful for development. WebRTC is open source and 100% free for commercial and private use. It has an active and knowledgeable community dedicated to teaching people about the value of WebRTC. WebRTC is available in the majority of browsers, including Chrome, Firefox, Opera and Android. In addition, it is available for mobile applications in iOS and Android, as well as embedded environments. This enables developers to run WebRTC anywhere, anytime. Among the reasons WebRTC is so powerful is that it isn’t limited to just video calls or audio calls. It can be used for data transfer, group calling, recording or even screen sharing. It is a capable and adaptable tool that can aid development and simplify implementing real-time communication.

USING WebRTC WITH THE IoT

WebRTC has features that can greatly boost the rich machine-to-machine connections that are intrinsic to the internet of things, including real-time and high frequency connections, security, accessibility and direct peer-to-peer connections. In particular, WebRTC makes it easier for developers to build peer-to-peer communications than ever before.

Real-time and high frequency connections are at the core of WebRTC. With IoT devices, the frequency of the connection depends on the needs of the application. For example, a smart refrigerator may only need status updates once per minute, while a video surveillance system may need much more granular control, at least 24 frames per second. WebRTC makes it easy to develop for these variances and any frequency of communication necessary. As for security, WebRTC offers true end-to-end encryption, which makes it possible to provide extremely secure and private communication. All WebRTC components have mandatory encryption, and all JavaScript APIs require secure origins via HTTPS or localhost.

However, WebRTC does not specify signaling protocols. Signaling protocols are the methods used to exchange metadata (Figure 4). This is ideal for developers that want flexibility, as the developer can create their app in the way that best fits their use case. The important thing to remember is that the developer is responsible for taking the appropriate choice to provide truly secure communication.

FIGURE 4
Signaling in WebRTC

WebRTC does not require end users to install any new software or plugins. This makes IoT device communication even easier, as devices can leverage WebRTC’s data channel in the same way they use WebSockets or HTTP.

— ADVERTISMENT—

Advertise Here

WebRTC provides direct peer-to-peer connections. These connections allow mission-critical devices to connect without revealing data to outsiders. Furthermore, the system is able to scale effectively, as every end user contributes to the device network and provides the service to other end users. This allows the device network to naturally grow as the number of end users grows.

EXAMPLE DEVICES WITH WebRTC

The IoT and WebRTC are just starting to work together to build better products in a lot of areas. Some key areas of interest that have already been implemented are video streaming, surveillance, healthcare and content delivery networks. Here’s several example applications:

Video Streaming: Delivering video content simultaneously to thousands of users requires a lot of bandwidth, and can be extremely expensive if individual streams deliver the media to each user. Using WebRTC, some of the video delivery can be done by leveraging other peers that are consuming the same content. Streamroot has developed a product that turns the audience into a broadcasting network to save streamers bandwidth and money.

Surveillance: Amaryllo creates several products that use sensors to detect when someone is at the door. For example, Amaryllo’s iSensor HD bring WebRTC and the internet of things together to offer surveillance via video streaming. It lets the homeowner see exactly what is going on at their house, no matter their location. Other products build on this idea even further, and allow the homeowner to communicate directly with the visitor or individual trying to get in.

Healthcare: TeleMedCo, a company that is working with IBM Watson to improve emergency care, uses WebRTC in conjunction with a real-time communications platform called Kandy to support workflows. Specifically, they use it to quickly triage patients that come into the ER, and start an immediate call with their personal doctor—no matter the doctor’s location. Similarly, another company, MedZed, is able to integrate video chat to live exams through a camera and audio feed using WebRTC.

Content Delivery Networks: Peer5, The Serverless CDN, is a peer-to-peer content delivery network (CDN) built to offload traffic from video content servers to end users. WebRTC enables it to create a truly seamless and robust peer-to-peer content delivery network that can be massively distributed, infinitely scalable and geographically ubiquitous (Figure 5).

FIGURE 5
This shows a traditional CDN versus one with WebRTC.

There is the possibility for the IoT and WebRTC to team up in many more areas, and some research has been done to that effect. For example, the team behind the Banana Bread Demo implemented WebRTC to bring a more agile first-person shooter gaming experience. There is also potential for internet of things and WebRTC crossover with automobiles. Creating a real-time connection between a mobile phone and a networked vehicle could allow for remote driving, fetching telemetry data and tracking.

GETTING STARTED WITH WebRTC

Getting started with WebRTC can be difficult. Just Googling “WebRTC” leads to Github repos and API documentation. There are so many resources available that it can be overwhelming to identify the best one or the right one for you. Different people learn different ways, and it is important to take that into account when learning about WebRTC. With that said, the four most effective ways are to dive in, go straight for the source, follow some effective tutorials or check out a few expert blogs.

These resources may be helpful to expand existing knowledge of WebRTC or help people new to WebRTC get up to speed and learn about resources that exist already. Please bear in mind, this list is by no means exhaustive. It is meant to highlight interesting and helpful WebRTC resources, instead of creating an ocean of WebRTC assets. Links to all these resources are provided here and collected together in RESOURCES at the end of this article.

Dive in: For some, trial and error is the best way to learn. The creators of WebRTC maintain a Github account with multiple repositories and WebRTC code samples at github.com/webrtc. If you like to learn on the job, this is the route for you.

Go straight for the source: Webrtc.org was built by the creators and maintainers of WebRTC. It gives the most up-to-date information on where WebRTC is at and where it is headed. This includes their favorite tutorials, native code, APIs, and an overview and FAQ. The site is actively maintained by the Google Chrome team.

Effective tutorials: There are many helpful tutorials out there, and this is just scratching the surface. It’s important to choose a tutorial based on your own learning style, so you can get the best approach possible.

1. Google Developer CodeLabs: Google Developer CodeLabs provides an insightful, easy-to-follow tutorial for WebRTC. The code and concepts are explained in-depth enough that a web developer should be able to follow them effectively.

2. HTML5Rocks: Getting Started with WebRTC: Sam Dutton gives a conversational tutorial on WebRTC with useful resources, history and developer tools.

3. BlogGeek.Me Advanced WebRTC Architecture Course: This paid course by Tsahi Levent-Levi covers all aspects of WebRTC with dedicated office hours.

— ADVERTISMENT—

Advertise Here

Expert Blogs: The WebRTC community is tight-knit, with a knowledgeable and diverse base. The experts involved are strongly committed to teaching people about WebRTC and expanding its impact.

1. WebRTC Hacks: WebRTC hacks is a blog built by a real-time communications market expert on how WebRTC works, WebRTC tools on the market, and different WebRTC applications.

2. BlogGeek.Me: BlogGeek.Me attempts to unravel the complexities of the latest announcements in tech. This includes conversation on WebRTC, VoIP, communication, disruption and other topics.

3. WebRTC by Dr Alex: Dr. Alex’s blog explains the decision process of WebRTC as a standard and covers the implementation of WebRTC to let individuals implement it easier without a vendor.

MOVING FORWARD

WebRTC and the IoT have huge potential to work together to build better products. Given WebRTC’s inherent focus on real-time communication, and the internet of things need to build machine-to-machine communications, they are a great fit. Building products with WebRTC has never been easier. Take a look at some of the resources mentioned in this article and start tinkering! 

RESOURCES

WebRTC’s Github https://github.com/webrtc

WebRTC | webrtc.org

Tutorials
Google Developer CodeLabs
HTML5Rocks: Getting Started with WebRTC
BlogGeek.Me Advanced WebRTC Architecture Course

Expert Blogs
WebRTC Hacks
BlogGeek.Me
WebRTC by Dr Alex

callstats.io | www.callstats.io (Callstats.io was acquired by 8×8)
WebRTC | www.webrtc.org

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • DECEMBER 2018 #341 – Get a PDF of the issue

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article
+ posts

Allie Mellen is a Forrester analyst covering security operations.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2023 KCK Media Corp.

Applying WebRTC to the IoT

by Allie Mellen time to read: 9 min