0

I am reading some UDP data from a socket, processing the results and then reading from the UDP again. It appears that if I take "too long" processing the results, then I miss some UDP packets on the socket. I have set the sysctl buffers to 262144, so why would I miss UDP packets if the buffers are bigger than the default 4096.

I have found a solution to buffer my results before processing so that I continue to read from the socket, but was just confused why I had an issue in the first place.

Thanks.

cabanaboy
  • 71
  • 4
  • 2
    Well yes, that is normal with UDP. No rate control, so as long as you take longer consuming and processing packets, you will run out of buffer, inevitably. A larger buffer slightly delays this, but cannot avoid it. Imagine a leaking bucket with a small hole. It's raining, and while one drop per second leaves the bucket through the hole, two drops come in. No matter how big it is, after some time the bucket will be full. When that happens with UDP, UDP just discards any further datagrams. – Damon May 09 '14 at 22:11
  • 1
    I had similar situation, use another thread to process the data. The thread receiving UDP data can have higher priority. Still, UDP is not reliable. – m. c. May 09 '14 at 23:40
  • I typically use two threads when reading from sockets - one to service the socket and one to process the data. If the traffic is load is significant, this is a must. – Matt Davis May 10 '14 at 01:27

0 Answers0