What Is WebRTC, and What Can You Use It For?

James Jor
9 min readSep 3, 2021

WebRTC enables you to use your browser and the power of modern web technologies to build peer-to-peer applications that work over any type of network, including mobile.

It’s not just for video chat; it also provides a powerful way to create rich media experiences like voice calling, audio/video conferencing, and even collaborative editing in the cloud.

What does WebRTC do?

The most obvious thing you can do using WebRTC is actually _calling_ someone else via their webcam. You’ll need some kind of communications channel between the caller and recipient before you can talk to them.

But what if you want to call someone right now, without having to get on Skype first? What if you don’t know how much bandwidth you have available?

Or maybe you’re traveling somewhere and wouldn’t mind being charged more per minute than usual because you won’t be able to use your data plan. With WebRTC, these are things you can easily do as long as both users support it.

In fact, you might think of WebRTC simply as enabling communication between peers, but it goes beyond simple calls. For example, you can share files directly with each other, collaborate remotely by sharing documents online, or even communicate securely through e2e encryption.

How does it work?

There are three main parts to WebRTC: signaling, codecs, and transport. Signaling refers to methods of communicating information between devices such as “I’m here” messages sent from the sender device telling the receiver its location. Codecs refer to types of compression algorithms used during real-time conversations.

Transport describes protocols that allow devices to connect together, exchange data, and manage resources. In addition, WebRTC uses PeerConnection objects to handle everything related to connection establishment, negotiation, and management.

Signaling -

First, let’s look at signaling. The core part of WebRTC is called ICE and consists of several pieces of information exchanged between participants. These include SDP, STUN, TURN, and RTSP.

All of those terms may sound foreign to many developers, but the important thing to understand is that they represent different ways of sending information back and forth between endpoints, allowing them to find each other and establish a reliable session.

This process works something like this: One endpoint sends out a request asking for another endpoint to identify itself. If that endpoint responds correctly then the original requester will send a response indicating whether it wants to continue talking to that endpoint.

That’s pretty straightforward, but note that the requests and responses are done over TCP/IP connections. So once again, we need to explain what happens between a client and a server. A typical HTTP GET request looks something like as mentioned below:

GET /index.html HTTP/1.0Host: www.example.comAccept: */*User-Agent: Mozilla/5.0 Gecko/2008092417 Ubuntu/8.04 Firefox/3.6

If there was no Host header in the previous line, then the browser would try to load index.html directly rather than going through any sort of proxy cache. This means that every user who accesses our site gets served with exactly the same HTML file regardless of where they come from.

We could change that behavior by setting up a reverse proxy that caches all content based on IP address so that when anyone comes from anywhere within our network, they see the same page. This is why proxies exist — they help keep websites safe while still making sure everyone sees the exact same source code.

Web browsers typically make multiple requests to download pages because they assume each one will take longer to complete than the last; however, if you’ve ever tried downloading a large document, you probably noticed that only two or three were made before the whole thing started to finish.

The reason for this has nothing to do with the size of the document. Instead, it’s due to caching. When Web servers receive the initial GET request, they respond immediately with whatever content they already have stored locally.

Because the web browser usually makes subsequent requests after receiving a 200 OK response, the cached copy remains unchanged until it finally expires. Caching improves performance by reducing the number of times the entire web page needs to be downloaded. It also reduces traffic since fewer people are accessing the same website simultaneously.

A similar concept applies when you browse a webpage on your computer. Most programs use a local web cache known as a “browser object” which stores copies of frequently accessed files such as images, stylesheets, and JavaScript scripts. Each time you visit an URL, the program first checks its own internal cache to determine if it contains a version of the requested resource.

If not, it retrieves the data from the remote host via standard networking protocols. In general, most sites don’t mind having their resources cached because it helps speed things up. However, some sites actively discourage caching.

For example, search engines often want clients to rerun queries whenever possible so that fresh results can be returned faster. Also, certain dynamic features such as AJAX require new versions of assets to be loaded regularly.

There are also privacy concerns associated with caching. Some users might prefer to limit exposure to tracking cookies which allow advertisers to track their browsing habits across the internet. Sites should therefore always specify Cache-Control headers to indicate how long visitors are allowed to store copies of documents.

Caches aren’t just used by computers anymore. Almost all mobile devices today support some form of offline storage. They’re even starting to appear in desktop operating systems, including Windows 7.

Offline applications work by storing persistent data on removable media such as SD cards or USB drives. Data stored here isn’t backed up automatically. Users must explicitly tell these devices to save their changes to disk using special commands.

Codecs -

The video calls and voice call codecs are the most important ones for a VoIP phone system, which is basically an internet-based telephony service that uses the Internet Protocol as its transmission medium instead of landlines or mobile networks. The codecs work at different speeds, thus enabling you to choose one according to your bandwidth. There are many other kinds of codecs out there but they aren’t crucial in this context.

For our example we will use G711A-uLaw because it’s usually easy to implement, has good quality and low bitrate, and supports up to 64 kbps data rate. We also recommend using AMR-WB, if possible, since it offers better audio quality than G.722 with lower bitrates.

Now let’s see how to configure the Sip phones to support those two codecs!

Configuring Sip Phones

First thing first — configuring the sip phones before connecting them to the PBX server is essential. Configure each sip phone individually, so that when you connect the phones together via the voipmanager.conf file you don’t end up having problems like “unable to register” error messages. In order to do that:

1) Open the configuration files of all the Sip phones. Then add the following lines after the existing CallerID tag:

and

2) Save the changes by pressing Ctrl+S and close any open editors. If you have multiple sip phones, repeat step 1 until all sip phones are configured correctly. It may take some time depending on the size of your sip phone list. You can check whether all sip phones were properly configured by running asterisk –rxvvv command from console. This should print something similar to below while asterisk is starting up:

NOTICE : chan_sip.c: Starting SIP dialog ‘dialog@domain.com’

NOTICE : chan_siptree.c: Dialing peer0x1234 with address. Reason SIP /Cancel /No Response

NOTICE : chanserver.c: Got ACK for INVITE [ACK id285464

Note: From 192.168.10.4;tag18391947492699

To user@domain.com;tag29797548175984

Transport -

In the mobile world, a transport protocol is what gets your application from point A to B. For example, if you are building an Android app for sending messages between two users over SMS or MMS then it will use TCP/IP as its underlying network layer. If you want your app to send emails through Gmail’s SMTP server, that would be using POP3 on top of TCP/IP; and so forth.

However, even though we talk about “transports” in this book, only one transport protocol actually exists: UDP. The others — TCP, SCTP, FTP, HTTP, etc. — are all built upon UDP. So really they should just be referred to as “UDP-based transports.” We’ll call them simply “transports,” but keep in mind that there’s more than one!

Note — All these transport protocols can also work across various networks, including Internet Protocol, Serial Line IP, serial lines without network interfaces, Bluetooth, ZigBee, WiFi Direct, NFC, WiMax, 3GPP2 GSM, CDMA2000 EVDO Rev 0+, UMTS HSPA+ Rev 10+, LTE, and many others. Even when talking about things like USB or Ethernet networking, remember that those two could be considered transports because their layers may be based on UDP.

What Can You Use It For?

WebRTC technology is used for audio/video streaming. It is also a popular platform to build web applications with the help of JavaScript, HTML, and CSS3. The application may be developed using any one or more programming languages such as Java, PHP,.Net, etc., which are supported by WebRTC.

In an example shown in FIG. 1A, there is provision to have two user equipment 101a-1 & UE101b-2 connected to both parties A 102a and B 103b respectively through their respective access points AP 104a and AP104b via different wireless communication networks 105a and 105b.

Each party has a device 106a and a device 107b and each of these devices can communicate directly with another device on the same network without involving the third party i.e. Access point. In this case, if we want to exchange data between the users having different UEs from different networks then we need to establish a direct connection between them.

This kind of scenario will not work well when they belong to different operator’s networks e.g. it won’t allow us to share video streams across operators’ networks because of security issues.

On the contrary, if they belong to the same operator’s network then it should be possible that how can we transfer data between them? One way could be to use RTP over UDP protocol but still, you would face some challenges like packet loss on long-distance transmission due to high latency issues.

So, what about VoIP calls where voice quality becomes a very important factor? Can we achieve a reliable call setup even if there exists a huge difference between latencies involved here?

If yes, how? These questions lead us towards designing new solutions for the interworking of heterogeneous radio technologies within a single domain. To address above mentioned problems, we propose an architecture called “Mobile Domain Interconnect” in which all the participants belonging to the same mobile service area get interconnected to form Mobile Network Domains and those MNDs get interconnected to form larger domains based on the geographical location of various parts of the city.

Now the question arises; How does MDI help achieving a highly efficient call setup procedure? We answer this query below: What happens if multiple connections are established simultaneously between two endpoints located far apart geographically?

Answers — In normal scenarios, when multiple simultaneous connections are initiated between two remote peers, only one link gets selected for a successful handshake while the rest links remain idle until either node fails to complete its handshaking phase. However, in our proposed approach, every peer always initiates a separate channel establishment attempt whenever it wishes to connect to another endpoint.

As soon as the first peer completes its own session establishment process successfully, the second peer starts establishing sessions with remaining unconnected nodes.

Few More Words -

Hope you find this article useful in understanding the WebRTC technology. Do share your thoughts in the comment section.

Meanwhile if you are looking for any custom WebRTC development company, then reach out to RTCWeb.in as they are one of the best company of this time.

Here are the thing they can help you with -

  • Experienced WebRTC developers offering high quality and cost-effective services.
  • End-to-end services, right from planning, installation to WebRTC implementation, and delivery.
  • A solid track record of keeping up with evolving telecom needs.
    Seamless connectivity/communication solutions for your thriving business.
  • The jargon-free approach to prevent any confusion.
  • We enable you to focus on running the business and reaping the rewards of WebRTC technology.
  • Excellent after-sales support and account management services.

--

--

James Jor

Hi, I am passionate technical researcher & writer, skilled in writing about web, app, UX/UI development, technologies,e-learning,webrtc & more.