Search code examples
network-programmingvideotheory

Idea to handle lost packets (theory)


Context

  • We have got un unsteady transmission channel. Some packets may be lost.
  • Sending a single network packet in any direction (from A to B or from B to A) takes 3 seconds.
  • We allow a signal delay of 5 seconds, no more. So we have a 5-second buffer. We can use those 5 seconds however we want.
  • Currently we use only 80% of the transmission channel, so we have 1/4 more room to utilize.
  • The quality of the video cannot be worsened.
  • We need to use UDP.

Problem

We need to make the quality better. How to handle lost packets? We need to use UDP and handle those errors ourselves. How to do it then? How to make sure that not so many packets will be lost as currently (we can't guarantee 100%, so we only want it better), without retransmitting them? We can do everything, this is theory.


Solution

  • There are different logic's to handle these things.It depends on what application you are using. Are you doing real time video streaming? stringent requirements?

    1. As you said you have a buffer, you can actually maintain a buffer for the packets and then send an acknowledgement for the lost packets (if you feel you can wait).

    2. As this is video application, send acknowledgements only to the key frames. make sure that you have a key or I frame and then do interpolation at the rx side.

    3. Look into something called forward error correction, fountain codes, luby codes. Here, you will encode the packets 1 and 2 and produce packet 3. If packet1 is lost, use packet3 and packet2 to get the packet1 back at the rx side. Basically you send redundant packets. Its little harsh on network but you get most of the data.