Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is WebRTC really peer-to-peer protocol?

Tags:

WebRTC is a peer-peer communication protocol. I wonder, is it really peer-peer if it does require a web server? For example, to create a "room" one has to create it at apprtc.appspot.com or https://hello.firefox.com/something.

like image 383
Incerteza Avatar asked Apr 02 '15 15:04

Incerteza


People also ask

Is WebRTC always peer-to-peer?

WebRTC being P2P is just as P2P as SIP is. Or H. 323. The only difference is that you get to choose your own signaling and your own client.

How does WebRTC P2P work?

Audio and video in WebRTC works by using codecs. These are known algorithms that are used to compress and decompress audio and video data. There are different codecs you can use in WebRTC and I won't get into it now. Audio and video also gets interesting because it is sent with low latency in mind.

Which protocol does WebRTC use?

WebRTC uses Session Description Protocol (SDP) to describe the parameters of the peer-to-peer connection.

Does WebRTC work over HTTP?

WebRTC video streaming doesn't work through http.


2 Answers

It is a true P2P protocol in that it can establish direct server-less communication between two arbitrary parties on the internet. Once the communication is established, no 3rd party is needed.

This comes with a few caveats though:

  1. The two peers first need to find one another. This signalling step is purposefully omitted from the WebRTC specification, since the WebRTC protocol is not specific to browsers and can be used by any number of different devices in different circumstances. Each group of peers will have their own context and will require different discovery methods. You will probably also want a middleman which controls the flow of information according to some business rule.

    You could use some other P2P protocol to establish this initial signalling phase; for instance you could just broadcast UDP packets on your local subnet if the other peer is on the same subnet. You could also use carrier pigeons for your signalling; though this is likely impractical. The most practical way for this over the general internet within a browser is to use a central message broker of some kind or another.

  2. It is not always possible to establish direct connections between two arbitrary peers. Sometimes this is hindered by network topology realities, e.g. non-permissive firewalls or NAT routers. In this case it is physically impossible for the two peers to communicate in a P2P manner and a third party relay is required; this is included in the WebRTC specification in the form of a TURN server.

So, WebRTC is a full P2P protocol at heart, but it needs to work with simple networking realities which sometimes, or maybe often, requires a server's helping hand.

like image 59
deceze Avatar answered Sep 20 '22 00:09

deceze


According to your tags (Chrome & FF), this question is focused on browsers.

If you want to initiate a call with WebRTC :

  • you will need to download your web page (the WebRTC application) from a server (it can be optional if you have already downloaded on your computer).
  • both browsers have to exchange some informations (Codecs, ICE candidates...), also known as SDP. This step is mandatory and you should use a server. But you can involve any other technology (Xaqron's comment).
  • If the browsers are behind a NAT, they need a STUN server for retrieving their public IP addresses.
  • If one of the two browsers is behind a restrictive NAT or a Firewall, you have to use a media relay also known as TURN server.

To conclude, if you want to exchange media or data with WebRTC in P2P, you should use some servers. Usually the media will be exchange in P2P, however sometimes the media will be relayed by a TURN server if one or both browsers are behind a restrictive NAT, a firewall....

like image 44
Antonin M. Avatar answered Sep 21 '22 00:09

Antonin M.