Peer to Peer
Exploring the Versatility and Innovation Behind Web Real-Time Communication
In the modern digital era, face-to-face encounters may not always be feasible, whether due to distance or various circumstances. These challenges have given rise to a transformative concept: connecting with others digitally. This revolutionary idea has not only addressed numerous issues but has also provided an alternative for remote interactions and instant productivity. In this blog, we will delve into the technology that seamlessly facilitates these digital connections, exploring how it elegantly enables the accomplishment of tasks and fosters effective communication in the virtual realm.
webRTC?
webRTC is a free, open-source project that provides web browsers and mobile applications with real-time communication via simple application programming interfaces (APIs). This API enables enables audio and video communication, as well as data sharing between peers.
how it works?
Before getting into this there are some standard terms that we need to understand.
Signaling Server
SDP
ICE
NAT
Peer
STUN
TURN
Peer
A peer is nothing but the computer/system that is participating a webRTC connection.
Networking Address Translation (NAT)
A NAT is a technique used in computer networking to map the private IP addresses within a local network to a single public IP address. within a local network to a single public IP address.
Session Description Protocol (SDP)
SDP stands for . It is a standard protocol for describing and negotiating the parameters of a multimedia communication session. SDP is used to convey information such as audio and video codecs, network addresses, and other session-related details between devices or applications that are setting up a communication session.
This part includes the most important information called ICE properties for a successful connection.
Interactive Connectivity Establishment (ICE)
is particularly important in situations where Network Address Translation (NAT) and firewalls might complicate the process of initiating peer-to-peer connections.
It basically involves gathering information of the peer for communication termed as ICE candidate which has the public IP address and ports combination. As we explored in a previous discussion, when a system needs to communicate externally, it must be aware of the other system's IP address and port to establish effective communication.
Types of Candidates
Host candidates (local IP addresses).
server reflexive candidates (obtained by a STUN server).
relay candidates (obtained through a TURN server).
Session Traversal Utilities for NAT (STUN)
It is used to assist devices in discovering their public IP address and the presence of Network Address Translation (NAT) devices or firewalls between them and the public internet. It serves a crucial role in overcoming some of the challenges posed by NAT when establishing peer-to-peer communication.
Why STUN is need?
If the host candidate fails to make a connection because of the direct connection attempt fails, it may be due to certain levels of NAT restrictions, firewalls, or other network conditions. then the STUN comes into play which has bypassed certain level of NAT to find the IP address and the port for communication termed as server reflexive candidates.
Traversal Using Relays around NAT (TURN)
It is a protocol and a network server that helps facilitate communication in scenarios where direct peer-to-peer communication is challenging due to the presence of restrictive Network Address Translation (NAT) configurations or firewalls. TURN is often used in conjunction with STUN (Session Traversal Utilities for NAT) to overcome these challenges in real-time communication systems like WebRTC.
Why TURN is need?
Even due to some extreme restriction of the firewall the server reflexive candidates fails provided by the STUN gets failed in communication there comes the TURN server which is used to find the relay candidates.
NOTE: The peer-to-peer communication is only completely possible if the communication is made with host and server reflexive candidates. If the communication is made with relay candidates, then the media stream (video/audio) travels through the TURN server for successful communication.
STUN is primarily used to find the IP address and necessary details for initiating communication, while TURN not only helps in finding the IP address but also handles the relay of media streams for successful communication.
Signaling server:
Each WebRTC peer generates its own SDP, which includes information about its media capabilities, network details, and ICE candidates as discussed earlier now its time to make this peers to communicate that is where the Signaling server comes into play.
All peers connect to the signaling server, which is responsible for mapping the appropriate peers with each other. Once this mapping is established, the SDP exchange and subsequent steps for successful communication occur directly between the peers. The signaling server's role is solely to facilitate the initial connection and mapping process, with the actual communication taking place peer-to-peer afterward.
Conclusion:
WebRTC (Web Real-Time Communication) is a powerful and standardized technology that enables real-time communication directly between web browsers. It facilitates peer-to-peer communication for various applications, including video and voice calls, file sharing, and collaborative browsing. WebRTC has become a cornerstone in building seamless and interactive real-time communication experiences on the web, fostering innovation in diverse fields, from online collaboration to customer support and beyond.