我试图在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,我需要更改吗?
由于
答案 0 :(得分:2)
来自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