1

Sending 16 byte packets across a Unix datagram domain socket with SNDBUF left at the default on my box of 124928 (verified with getsockopt()). Have also bumped the max_dgram_qlen up to 512. For testing purposes my receiver is currently sleeping after binding to the Unix datagram domain socket.

When I fire up the sender I start receiving EAGAIN errors after sending 423 packets (I am sending with the MSG_DONTWAIT). At that point I have only sent about 7k (not including any headers), seems a bit early to have filled the SNDBUF given it's current settings.

To verify that it is indeed the SNDBUF that is limiting the sends I gradually bumped up the SNDBUF until it was able to hit the max_dgram_qlen (actually it hit 513). The SNDBUF value I had to set for this was 75177 (151554 as returned by getsockopt()).

Any ideas would be greatly appreciated as it feels as though I'm missing something obvious here.

mr19
  • 187
  • 1
  • 15
  • A 16-byte packet has an 8-byte UDP header overhead, and when it leaves the IP layer it also has a 20-byte IP header overhead. So you need to modify '7k not including any headers' to 10.5k including the UDP headers. `max_dgram_qlen` appears to be for receiving, not sending. – user207421 May 13 '15 at 01:35
  • Even with that overhead I would still expect it to fit in the original buffer. The `max_dgram_qlen` still comes into play in that if the number of packets queued from your `sendto()` call hits this value before the total size of packets queued reaches SNDBUF you will still get the EAGAIN errors. – mr19 May 13 '15 at 03:08
  • Citation please. I can't find anything reputable that says it is for anything other than receive. There's a suggestion somewhere that if you exceed max_dgram_qlen at the receiver the sender will block, but that's as far as it goes. All referring only to Unix domain sockets of course. – user207421 May 13 '15 at 11:58
  • Not disagreeing with your statement that it only applies to receive -- found that online as well. My sender opens a datagram Unix domain socket, does not bind, but performs `sendto()` operations with the destination being the socket bound to by my receiver. In this scenario, my sender will block (or return `EAGAIN` if using `MSG_DONTWAIT`) if it hits either the total bytes sent (plus overhead) hits SNDBUF OR the number of datagrams waiting to be processed on that socket (the one bound by my receiver) hits the `max_dgram_qlen` value. – mr19 May 13 '15 at 14:19

0 Answers0