0

Firstly, I know that we can use setsockopt() to control SNDBUF (I know it is not recommended but I want to know how it works and how bad it is), and this will fix the buffer size to a value we want (The size I set is rightly between the limitaion of net.ipv4.tcp_wmem so that they work well). I try some different sizes to see the relationship between the SNDBUF and send queue which we can get from netstat.

I expect that if we set a larger SNDBUF size, we may get a larger send queue from netstat. But it doesn't work like I expect : this will cause lots of EAGAIN/EWOULDBLOCK error.

So I wonder if there is any connection between the send queue size and the error EAGAIN/EWOULDBLOCK, if a long queue size cause the error then everything can be explained. I trace the Linux kerenel source code but I haven't find anything useful. Can you gives some useful guide like how it works and which function realise it, thanks for any help.

tyChen
  • 1,404
  • 8
  • 27
  • The `EAGAIN`/`EWOULDBLOCK` errors shouldn't "make[s] connection broken", it's not a fatal error that you must close the connection for. The usual solution to work around such problems is to use e.g. `select` (or other polling mechanisms) to know when socket operations can be performed without blocking. And generally there's rarely any need to modify the send or receive buffer sizes. – Some programmer dude Sep 22 '20 at 09:17
  • @Some programmer dude Thanks for your commet, I edit my question to make it more clear and without those questions. – tyChen Sep 22 '20 at 09:22
  • @Some programmer dude What's more, the thing I fouces is how EAGAIN/EWOULD works with the send queue length. I think it worhs tracing to get a deep understand of TCP source code. – tyChen Sep 22 '20 at 09:27
  • For TCP it's more complicated than full buffers or queues, [congestion control](https://en.wikipedia.org/wiki/TCP_congestion_control) is also an issue that could lead to operations blocking. – Some programmer dude Sep 22 '20 at 09:31
  • @Some programmer dude So you mean that maybe it is beacuse something like cwnd or swnd makes the error? But I check the function tcp_write_xmit() and there is nothing related to EAGAIN/EWOULDBLOCK. – tyChen Sep 22 '20 at 09:46
  • _I know it is not recommended_ - not recommended by who? – Maxim Egorushkin Sep 22 '20 at 12:37
  • @Maxim Egorushkin I see some benchmark test for auto adjust by kernel vs `setsockopt()`, and the result is that the linux kernel can adjust SNDBUF more efficient than fix value. – tyChen Sep 22 '20 at 14:21
  • @tyChen Can you post a link to that benchmark, please? – Maxim Egorushkin Sep 22 '20 at 15:25
  • @Maxim Egorushkin It's written by Chinese, can you read it? – tyChen Sep 22 '20 at 15:52
  • @tyChen I can read any language Google Translate understands. – Maxim Egorushkin Sep 22 '20 at 16:02
  • @Maxim Egorushkin OK, Here it is. But I have to say , google can not translate Chinese well. https://plantegg.github.io/2019/09/28/%E5%B0%B1%E6%98%AF%E8%A6%81%E4%BD%A0%E6%87%82TCP--%E6%80%A7%E8%83%BD%E5%92%8C%E5%8F%91%E9%80%81%E6%8E%A5%E6%94%B6Buffer%E7%9A%84%E5%85%B3%E7%B3%BB/ – tyChen Sep 22 '20 at 16:04
  • I see what you refer to. Increasing the size of send/receive buffers is a useful practice, the default size is often too small. – Maxim Egorushkin Sep 22 '20 at 17:28
  • @Maxim Egorushkin You are right, but the kenel can adjust the default size to larger. – tyChen Sep 23 '20 at 01:34

0 Answers0