2. WebRTC
WebRTC is FOSS that provides browsers and mobile applications with Real Time Communication
capabilities via simple API’s
It is supported by almost all modern browsers
Mobile applications & desktop applications can also embed WebRTC without much hassle
It leverages multiple protocols and standards like
TURN/STUN(Traversal Using Relay NAT/Session Traversal Utilities for NAT)
ICE(Interactive Connectivity Establishment)
SIP(Session Initiation Protocol)
SDP(Session Description Protocol)
It is a project supported by Google, Mozilla & Opera
3. WebRTC
It can be used for low cost, high quality audio, video & data communication
WebRTC itself is written in C++
Available for android and iOS integration without any hassle
RTCPeerConnection is the heart of WebRTC, handles lots of things including
4. Connection Process
Caller creates an offer SDP using some constraints
Send this SDP to the callee via some signaling mechanism
Callee accepts the offer and generate an answer SDP
Answer SDP is sent to caller using some signaling mechanism
Meanwhile both caller and callee discovers ICE candidates and exchange them with each others
using signaling mechanism
Both machines have 2 SDP’s, i.e. local and remote
Both machines have ICE candidates from each other
WeRTC connects both machines using ICE Candidates
Connection is Peer-Peer.
5. Signaling Mechanism
Signaling is required to transmit following from caller to callee and vice versa
Session Description
ICE Candidates
It can use any protocol & messaging mechanism
XMPP has an XEP for this called Jingle
You can use WebSockets for this as well.
WebRTC doesn’t restrict any protocol
Signaling is lightweight, it doesn’t transmit voice, video or data, instead it only transmits SDP’s
and Candiates
8. NAT
Network Address Translation is a process in which a device(usually firewall) assigns a public IP to a
computer or group of computers inside a private network.
Main purpose of NAT is to limit the number of public IP addresses a network or organization
must use.
Symmetric NAT also map a specific port network’s public IP, every time a new connection is made
a new port will be mapped.
9. NAT continued
If systems are behind NAT then simply sending candidates doesn’t work
If candidates are local IP addresses and ports and both machines resides on different private
networks then they won’t be able to connect.
We somehow need to know the public IP of the caller and a port mapped to that public IP.
Similarly we need to know the same information on second public
11. STUN
STUN(Session Traversal Utilities for NAT) provides a set of tools for NAT traversal.
It actually probes your public IP, bind a port on NAT machine to your local machine
It requires a server for NAT traversal
13. TURN
Sometimes peer-peer connection fails because of some of the following reasons
Firewalls blocking peer-peer connections because of custom ports
NAT device not allowing ports binding
State restrictions based on type of traffic
TURN(Traversal Using Relay Network) provide a fallback mechanism if peer-peer connection fails
It requires a Relay Server to act as a relay data among different machines
Ensures that calling works in almost all of the environments
15. ICE(Interactive Connectivity Establishment)
ICE is basically a mechanism to find multiple paths to communicate
It also provides costs of different paths so that all parties use optimal paths to communicate and
user experience is improved
Intention is to find best route between caller and callee.
It leverages STUN to find routes