My Blog Posts

What is WebRTC ?

What is WebRTC ?

WebRTC is an open source project currently under development to provide real-time, peer-to-peer communication between web applications.

WebRTC provides simple JavaScript APIs that help developers easily build web applications with real-time audio, video, and data transfer capabilities. Recent developments in WebRTC have also ensured its inclusion in local applications. Because there is so much under the API heading, it is important to understand the concept and operation of WebRTC to take full advantage of the technology.

To establish a WebRTC connection, we must perform the following two steps:

  1. Locate a peer.

Step 1: Find a peer

Think of it as making a phone call, when you need to talk to someone on the phone, you dial the other person's phone number and connect with that person. The same thing happens when someone wants to call you. In the case of mobile communication, we use mobile phone/phone numbers as a user's ID. This description is also used by telecommunications systems to locate a user.

However, web applications cannot 'search and search' for each other. There is no unique ID (such as a phone number) assigned to each of the millions of browsers around the world. However, the system with these applications is assigned a unique IP address that can be used to locate a wife.

However, this process is not as easy as it seems. Because most of these systems are Network Address Translation (NAT) device. sitting behind him Nat devices are required for security and IPv4 restrictions on available public IP addresses. A NAT device throws ip addresses specific to systems within a local network. These private IP addresses are valid and visible only within the local network, and systems outside the network cannot be used to accept communications from the outside world because they are not aware of the public IP of devices within the network.

Because of the participation of NAT devices, a peer does not know their public IP address because they are masked by a private IP address assigned by NAT. And therefore, it cannot share the public IP address with another peer to accept connections. More clearly, if you want someone to phone you, you need to give your phone number to the other person. In the presence of NAT, however, incoming calls to the hotel are handled at reception and also directed to your room upon request, such as staying in a hotel where your room's phone number is hidden from the outside world. This type of indirect connection format is not intended in an end-to-end connection technology.

To get over it Interactive Connection Organization (ICE) we use a protocol called ICE's job is to find the best possible way to connect the two peers. ICE can perform direct connections, i.e. in the absence of NAT and also indirect connections, i.e. in the presence of a NAT. The ICE framework provides us with 'ICE candidates'. 'ICE candidates' are nothing more than objects that contain our own public IP address, port number, and other connection-related information.

In the absence of NAT, ICE is fairly simple as the wife's public IP address is ready. However, in the presence of NAT, ICE Session Migration Utilities for (STUN) and/ or Using Relays Around NAT (TURN) Transition are based on so-called entities.

An STUN server basically allows a wife to find their own public IP address. Spouses who need to know their public IP address send a request to the STUN server. The STUN server responds with that wife's public IP address. This public address can now be shared with other colleagues so they can find you. However, if the peer is behind a complex NAT and/or firewall, even STUN cannot find the requesting peer and provide the IP address. In such cases, ICE trusts TURN to establish the connection. TURN, as its name suggests, is a transfer server and works as an intermediary for data, audio, and video transfer when a direct connection between two spouses is not possible.

The STUN server is only involved in the overall IP discovery process. After the WebRTC connection is established, all other communication occurs through WebRTC. However, in the case of TURN, webrtc is required throughout the TURN server even after the connection is established.

A TURN server is not intended, but we have to rely on it because of STUN limitations. An STUN server succeeds only about 86% of the time.

"ICE is complicated because we live in a complex world."

Step 2: Notify a wife to establish a WebRTC connection

Now that we've got ice candidates, the next step is to send them to a peer we want to connect with. Session Comments such as session information, time description, media description are sent with the candidates. ICE candidates and session descriptions are collected within an object and Session Disclosure Protocol (SDP) transmitted using In some cases, ICE candidates are not collected and sent separately on the same object as the Session Description, which is called Trickle ICE (this is an entirely new concept, let's not go deep for now!).

I wrote that we should 'send' the information to the other peer. However, how to transfer candidates and session description only when we know the sender's IP address and we don't know the recipient wife's IP address? Since the WebRTC connection has not yet been established, in what media is this information rated?

The answer to all these questions is, Signal Mechanism lies in a concept called Before a WebRTC connection is established, we need an medium to transfer the above information between spouses and let them know how to find and connect to each other for a WebRTC connection. That's where the signaling mechanism comes in. As the name suggests, a signaling mechanism signals the connection between two spouses aiming to connect (ICE candidates, Session description, etc.) Changes.

WebRTC does not define any standards for implementing such a signaling mechanism and leaves it to the developer to create a mechanism of its choice. The signaling mechanism for exchange information, either by copying and pasting the information to the relevant spouses, or by websockets,, Server Side Events, etc. It can be performed using a communication channel, such as. In short, a signaling mechanism is just a mode. the exchange of information about the connection between spouses occurs so that the spouses can identify each other and start communicating more using WebRTC.

Share this article

Comments (0)