Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC Overhead

Tags:

webrtc

I want to know, how much overhead WebRTC produces when sending data over datachannels. I know that Websockets have 2 - 14 Bytes overhead for each frame. Does WebRTC use more Overhead? I cannot find some useful information on the web. Its clear for me, that Datachannels can not be used for now. How much overhead is used with Mediastreams?

Thanks

like image 402
chaosbohne Avatar asked Aug 13 '12 12:08

chaosbohne


3 Answers

At the application layer, you can think of DataChannel as sending and receiving over SCTP. In the PPID (Payload Protocol Identifier) field of the SCTP header, Datachannel sets value 0x51 for indicating that it's sending UTF-8 data and 0x52 for binary data.

Yes, you are right. RTCDataChannel uses SCTP over DTLS and UDP. DTLS is used for security. However, SCTP has problems traversing most NAT/Firewall setups. Hence, to overcome that, SCTP is tunneled through UDP. So the overall overhead to send data would be overhead of:

SCTP + DTLS + UDP + IP

and that is:

28 bytes + 20-40 bytes + 8 bytes + 20 - 40 bytes

So, the overhead would be rougly about 120 bytes. The maximum size of the SCTP packet that a WebRTC client can send is 1280 bytes. So at max, you can send roughly 1160 bytes of data per SCTP packet.

like image 77
Afaque H Avatar answered Oct 21 '22 02:10

Afaque H


WebRTC uses RTP to send its media. RTP runs over UDP.

Besides the usual IP and UDP headers, there are two additional headers:

  1. The RTP header itself starts from 12 bytes and can grow from there, depending on what gets used.
  2. The payload header - the header that is used for each data packet of the specific codec being used. This one depends on the codec itself.

RTP is designed to have as little overhead as possible over its payload due to the basic reasoning that you want to achieve better media quality, which means dedicating as many bits as possible to the media itself.

like image 22
Tsahi Levent-Levi Avatar answered Oct 21 '22 02:10

Tsahi Levent-Levi


enter image description here

Here's a screenshot of 2 peer.js instances (babylon.js front end) sending exactly 3 bytes every 16ms (~60 per second).

The profiler shows 30,000 bits / second:

30,000 bits / 8 bits per byte / 60 per second = 62.5 bytes, so after the 3 bytes I'm sending it's ~59.5 bytes according to the profiler.

I'm not sure if something is not counted on the incoming, because it is only profiling half that, 15k bits / second

like image 21
hydrix Avatar answered Oct 21 '22 02:10

hydrix