设置套接字接收缓冲区大小,被截断为 244KB
Setting Socket Receive Buffer Size, gets truncated to 244KB
我正在尝试使用 linux 上的 setsockopt() 来增加我的套接字接收缓冲区大小。我可以成功地将它设置为低于 244KB 的任何值。任何超过 244KB 的值都会被截断为 244KB。
似乎存在某种系统限制,但我不知道它来自哪里,因为它与以下值不对应:
$ cat /proc/sys/net/ipv4/tcp_rmem
4096 87380 4194304
$ cat /proc/sys/net/ipv4/tcp_wmem
4096 16384 4194304
$ cat /proc/sys/net/core/rmem_default
124928
$ cat /proc/sys/net/core/wmem_default
124928
默认值是预期的 87380,但我无法将其增加到 4194304。它被限制为 244KB。有趣的是,该值是 2X rmem_default,我需要更改它吗?
谢谢
来自 TCP 的手册页:
The maximum sizes for socket buffers declared via the SO_SNDBUF and
SO_RCVBUF mechanisms are limited by the global net.core.rmem_max and
net.core.wmem_max sysctls. Note that TCP actually allocates twice the
size of the buffer requested in the setsockopt(2) call, and so a suc-
ceeding getsockopt(2) call will not return the same size of buffer as
requested in the setsockopt(2) call
所以你传递给 SO_SNDBUF/SO_RCVBUF
的东西在分配时会翻倍。因此,您不能在 setsockopt
中传递最大值 (4194304)
我正在尝试使用 linux 上的 setsockopt() 来增加我的套接字接收缓冲区大小。我可以成功地将它设置为低于 244KB 的任何值。任何超过 244KB 的值都会被截断为 244KB。
似乎存在某种系统限制,但我不知道它来自哪里,因为它与以下值不对应:
$ cat /proc/sys/net/ipv4/tcp_rmem
4096 87380 4194304
$ cat /proc/sys/net/ipv4/tcp_wmem
4096 16384 4194304
$ cat /proc/sys/net/core/rmem_default
124928
$ cat /proc/sys/net/core/wmem_default
124928
默认值是预期的 87380,但我无法将其增加到 4194304。它被限制为 244KB。有趣的是,该值是 2X rmem_default,我需要更改它吗?
谢谢
来自 TCP 的手册页:
The maximum sizes for socket buffers declared via the SO_SNDBUF and SO_RCVBUF mechanisms are limited by the global net.core.rmem_max and net.core.wmem_max sysctls. Note that TCP actually allocates twice the size of the buffer requested in the setsockopt(2) call, and so a suc- ceeding getsockopt(2) call will not return the same size of buffer as requested in the setsockopt(2) call
所以你传递给 SO_SNDBUF/SO_RCVBUF
的东西在分配时会翻倍。因此,您不能在 setsockopt