Search code examples
javaudpbandwidthdatagram

Effect of Bandwidth on DatagramChannel Packets


I have a limited Bandwidth 512 Kbps Download 368 Kbps Upload

I am sending 40 byte UDP packets at regular Intervals of 10ms in loop

with Thread.sleep(10) statement.

While receiving packets (UDP) can be of size 0-1500 bytes and can come at any time in any quantity which i receive with

channel.receive(); in a while(true){} loop .Channel is in Blocking mode.

I think i am missing packets with this code.

How can i prevent packet loss due to low download speed.


Solution

  • How can i prevent packet loss due to low download speed.

    You can't prevent it. Some level of packet loss is inevitable, even if you have lots of bandwidth.

    If you are going to use UDP as your transport, you are going to have to design your application protocol to be resilient in the face of packet loss ... AND to avoid swamping your network link with too much traffic. These are non-trivial problems.

    A simpler alternative is to use TCP, and let it deal with retrying in the face of packet loss and flow control issues.