0

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.

  • 40 bytes of UDP 100x per second is 4KB of data and about 200 bytes of overhead, and your upload speed is about 46KB/s. You shouldn't run into issues at these rates, unless something else is competing with your program for traffic. Is continuous bursting really the best way to do this, or would you be better off caching data? – Wug Jul 20 '12 at 14:33
  • You can't prevent packet loss with UDP, you can only minimise it. I would design you application so that some packet loss is acceptable. (or use TCP) – Peter Lawrey Jul 20 '12 at 14:40
  • 40 byte packets are exactly same only IP and port changes. My concern is the reply packets which are 1500 bytes in size and different. –  Jul 20 '12 at 14:41

1 Answers1

0

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • I have to use UDP (game networking) . My concern is missing reply packets which are 1500 bytes in size that are missed when Download speed limit is reached. –  Jul 20 '12 at 14:43
  • @Solution - there is no solution. If the packets get dropped, you just have to deal with it ... somehow. – Stephen C Jul 20 '12 at 14:46
  • Game documentation says server supports only UDP/IP packets with byte values. I can increase the sending interval from 10 ms to 1000ms to avoid loss but that takes too long time for list of IPs. Will increasing the bandwidth or Buying a 128MB RAM VPS help ? –  Jul 20 '12 at 14:50
  • @Solution - that *might* help. Another thing that *might* help is reducing other non-game traffic; e.g. by stopping services, browsers, etc. – Stephen C Jul 20 '12 at 23:20