What Is Webrtc ?

Let's take a quick look at how webRTC operates.

When one IP address wants to establish a real time connection to exchange audio, video and data with an another IP address over the internet. This is where WEBRTC comes into the picture.

examples
G meet(audio/video communication), zoom(video conferencing), Whatsapp Web(audio/video/text msg) etc.

so now lets divide this into two parts to understand the structure :

  1. Tools or interface provided by WebRTC ( lets call this Frontend) :
    These are called WebRTC APIs so developers can use this to establish real time connection . There are mainly three apis -
    - MediaStream
    - RTCPeerConnection
    - RTCDataChannel

  2. Protocols and Techniques ( Backend ) : This part insure that connection works between two devices or IP address. It works behind the scene as you guessed it by the name Backend .

    - Signaling

    - SDP
    - STUN
    - NAT
    - ICE
    - TURN

Now, Lets Discuss the first part in short .

  • MediaStream : This represents the stream of audio and video. Think this as audio and video capturing. we can obtain media stream with

    navigator.getUserMedia()
    but through this we can't transmit data into another computer. This is where RTCPeerConnection comes in.

  • RTCPeerConnection : This is a code APIs for handling the Peer-to-Peer Connection between Browsers or two devices .

  • RTCDataChannel : This is all about establishing a Bi-Directional communication of arbitrary data between the devices or browsers.So it is useful for sending the audio , video , text message or any other type of data between two browsers or two IP address in a real-time communication.

Now, Lets Discuss the second part in short .

  • Signaling : Before any process start, signaling comes into the picture and helps two browsers to share the details of communication or SDP offers. Similar to a messenger preceding war: Either yield under my name, or witness the inevitable onset of conflict. Means it insure that u want to connect or not simple as that .

  • SDP (Session Description Protocols ) : Sharing the manual of how connection happens or exchanging the information about their capabilities. so now war will happen this sdp is like lets discuss the war protocols .

  • NAT (Network Address Translation ) : lets say u have a router on home so that router shares a single IP address to communicate with the outside world. so NAT allows devices inside the network to talk with the internet.
    so how it works when A send request to B:
    req - A sending the request to router and router send the request to B
    res - B send the response to router and router send the response to A

  • STUN (Session Traversal Utilities for NAT) : So It basically used to find their public IP address. It helps to build the connection in direct communication.

  • TURN ( Traversal using Relays around NAT) : When STUN don't work due to strict firewalls or NAT configurations for communication, TURN comes into the picture and it build the connection .Think this as backup functionality. Helping the devices to exchange data indirectly when direct communication don't work.

  • ICE : It helps to find the best possible or most efficient path to establish the connection.