Receiving a late packet every 254 packets

Hi all,
I’m trying to pipe an audio stream from Mediasoup to a third-party RTP server. For some reason, the receiving server reports a late packet every time after it receives 253-254 packets(i.e. it will receive the packet with the sequence number = 254 before it receives the packet with sequence number = 253, the same for the 508th, 762th… ). The RTP server needs to decode the packet right away hence it leads to periodical audio distortion. Lastly, it seems the issue only happens if the codec is opus.
Any advice will be appreciated!

mediasoup relays packets as they are received, it doesn’t put them in order. So check your stream source.

hmmm the stream source is just the media stream I get from Chrome. Could it be a bug in libwebrtc?

Some updates on the Wireshark result. Probably a bug in the browser side encoder?

No issue here. UDP packets can be lost or arrive out of order. This is completely normal in RTP protocol and your endpoint should be ready for it. The client (Chrome) and the SFU (mediasoup) cannot guarantee that all packets are received and all them in order. Don’t look for bugs anywhere. Your RTP receiving endpoint should be ready for lost packets and packets out of order, that’s why RTP endpoints typically have a jitter buffer.

1 Like

Yeah I’m working on implementing a buffer on the receiving side. My initial thought is late packet/packet lost shouldn’t be too frequent for servers that communicate over the loopback interface. Thanks for the advise!

Re-ice the user if it’s overly noticeable and make them use TCP.