当前位置: 技术问答>linux和unix
请教关于TCP窗口大小的问题
来源: 互联网 发布时间:2015-03-05
本文导语: 在Windows 2000中,可以在注册表中更改TCP窗口大小。 在Linux中,怎么修改? 注:该TCP窗口大小将在三次握手期间作为TCP协议一字段传给对方,表明TCP的接收窗口。 另外,对套接字调用 setsockopt和 getsockopt操作的是套...
在Windows 2000中,可以在注册表中更改TCP窗口大小。
在Linux中,怎么修改?
注:该TCP窗口大小将在三次握手期间作为TCP协议一字段传给对方,表明TCP的接收窗口。
另外,对套接字调用 setsockopt和 getsockopt操作的是套接字的缓冲
它和TCP的接收或发送窗口是同一概念吗?
在Linux中,怎么修改?
注:该TCP窗口大小将在三次握手期间作为TCP协议一字段传给对方,表明TCP的接收窗口。
另外,对套接字调用 setsockopt和 getsockopt操作的是套接字的缓冲
它和TCP的接收或发送窗口是同一概念吗?
|
窗口大小不只在三次握手时有,在整个连接过程中都要互相通告,且是动态变化的。其大小可以理解为套接字缓冲中还有多少空闲空间,所以增大socket缓冲,相应的TCP接收窗口(跟发送窗口没关系)也会增大,可以认为是同一概念。
至于socket接收缓冲的默认大小可以用sysctl修改内核参数rmem_default实现,或直接修改/proc/sys/net/ipv4/tcp_rmem文件。
至于socket接收缓冲的默认大小可以用sysctl修改内核参数rmem_default实现,或直接修改/proc/sys/net/ipv4/tcp_rmem文件。
|
# man tcp
...
tcp_rmem
This is a vector of 3 integers: [min, default, max]. These
parameters are used by TCP to regulate receive buffer sizes.
TCP dynamically adjusts the size of the receive buffer from the
defaults listed below, in the range of these sysctl variables,
depending on memory available in the system.
min - minimum size of the receive buffer used by each TCP
socket. The default value is 4K, and is lowered to PAGE_SIZE
bytes in low memory systems. This value is used to ensure that
in memory pressure mode, allocations below this size will still
succeed. This is not used to bound the size of the receive
buffer declared using SO_RCVBUF on a socket.
default - the default size of the receive buffer for a TCP
socket. This value overwrites the initial default buffer size
from the generic global net.core.rmem_default defined for all
protocols. The default value is 87380 bytes, and is lowered to
43689 in low memory systems. If larger receive buffer sizes are
desired, this value should be increased (to affect all sockets).
To employ large TCP windows, the net.ipv4.tcp_window_scaling
must be enabled (default).
max - the maximum size of the receive buffer used by each TCP
socket. This value does not override the global
net.core.rmem_max. This is not used to limit the size of the
receive buffer declared using SO_RCVBUF on a socket. The
default value of 87380*2 bytes is lowered to 87380 in low memory
systems.
...
至于为什么是5840我也不清楚了。
关于最后一个问题,建议读一下《详解》第20章的内容,或者《UNP》中关于SO_RCVBUF选项的阐述。
...
tcp_rmem
This is a vector of 3 integers: [min, default, max]. These
parameters are used by TCP to regulate receive buffer sizes.
TCP dynamically adjusts the size of the receive buffer from the
defaults listed below, in the range of these sysctl variables,
depending on memory available in the system.
min - minimum size of the receive buffer used by each TCP
socket. The default value is 4K, and is lowered to PAGE_SIZE
bytes in low memory systems. This value is used to ensure that
in memory pressure mode, allocations below this size will still
succeed. This is not used to bound the size of the receive
buffer declared using SO_RCVBUF on a socket.
default - the default size of the receive buffer for a TCP
socket. This value overwrites the initial default buffer size
from the generic global net.core.rmem_default defined for all
protocols. The default value is 87380 bytes, and is lowered to
43689 in low memory systems. If larger receive buffer sizes are
desired, this value should be increased (to affect all sockets).
To employ large TCP windows, the net.ipv4.tcp_window_scaling
must be enabled (default).
max - the maximum size of the receive buffer used by each TCP
socket. This value does not override the global
net.core.rmem_max. This is not used to limit the size of the
receive buffer declared using SO_RCVBUF on a socket. The
default value of 87380*2 bytes is lowered to 87380 in low memory
systems.
...
至于为什么是5840我也不清楚了。
关于最后一个问题,建议读一下《详解》第20章的内容,或者《UNP》中关于SO_RCVBUF选项的阐述。
|
收藏