3

Just as the tittle suggests: Does WebRTC handle packet loss and packet received confirmations etc. for you or are you required to write your own solution for that?

I'm writing a multiplayer peer-to-peer game and I'm wondering how webrtc will handle packet loss. Will it continue to broadcast a packet till a confirmation of receival is returned? Will it send a packet 4 times and only send again if no confirmation comes after a set interval? Or is that left to me to code?

Cookie
  • 73
  • 1
  • 5

2 Answers2

2

It is responsibility of the transport layer. TCP handles packet losses, whereas UDP doesn't. By default WebRTC uses UDP, but it can use both protocols.

DataChannel uses another protocol called SCTP which is implemented on top of UDP. Though it is supposed that you can specify the reliable parameter in settings, it doesn't work yet in Chrome.

You can find a more detailed answer here: Does WebRTC use TCP or UDP?

Also you can find some information here: WebRTC. Real-Time Network Transports

Community
  • 1
  • 1
vortexwolf
  • 13,967
  • 2
  • 54
  • 72
  • "It is responsibility of the transport layer" is plain wrong, when you're sending a realtime media. There are: FEC (http://en.wikipedia.org/wiki/Forward_error_correction), PLC (http://en.wikipedia.org/wiki/Packet_loss_concealment), FIR packets in RTCP, and other smart algorithms to compensate the loss without confirming every packet in the stream like TCP does. – Victor Sergienko Dec 25 '14 at 17:58
  • "Though it is supposed that you can specify the reliable parameter in settings, it doesn't work yet in Chrome." is this still the case in 2022? Or have things improved in the meantime? @vortexwolf – XDS Jan 27 '22 at 09:38
0

For voice, it does handle packet loss.

https://bloggeek.me/single-voice-codec-webrtc/ : "Opus has built in FEC and flow control mechanisms"

Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91