更改 linux 网络设备的 TCP 超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15484906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change the TCP timeout for a linux network device
提问by Yifan Sun
I am programming linux device driver over a very slow interface, whose ping round time can be as long as several minutes. When I try to use TCP to establish connection between two nodes the connection always times out.
我正在通过一个非常慢的接口编写 linux 设备驱动程序,其 ping 轮时间可能长达几分钟。当我尝试使用 TCP 在两个节点之间建立连接时,连接总是超时。
Is there a method to set the TCP retransmission or handshaking timeout longer in the driver, or are there any commands to set it with? Thanks
有没有一种方法可以在驱动程序中设置更长的 TCP 重传或握手超时,或者是否有任何命令可以设置它?谢谢
回答by larsks
Have you tried searching for an answer to this question? A quick Google search gave me this, which appears to directly address this issue. The summary is that the setting of the net.ipv4.tcp_syn_retries
determines that maximum timeout available to TCP connections.
你有没有试过寻找这个问题的答案?一个快速的谷歌搜索给了我这个,它似乎直接解决了这个问题。总结是 的设置net.ipv4.tcp_syn_retries
决定了 TCP 连接可用的最大超时。
If that document doesn'tanswer your question, you should indicate what you tried and how the behavior differed from what you expected.
如果该文档 没有回答您的问题,您应该指出您尝试了什么以及行为与您预期的有何不同。
回答by Satish
/proc/sys/net/ipv4/tcp_retries1
/proc/sys/net/ipv4/tcp_retries2
.
.
tcp_retries1 - INTEGER
This value influences the time, after which TCP decides, that
something is wrong due to unacknowledged RTO retransmissions,
and reports this suspicion to the network layer.
See tcp_retries2 for more details.
RFC 1122 recommends at least 3 retransmissions, which is the
default.
tcp_retries2 - INTEGER
This value influences the timeout of an alive TCP connection,
when RTO retransmissions remain unacknowledged.
Given a value of N, a hypothetical TCP connection following
exponential backoff with an initial RTO of TCP_RTO_MIN would
retransmit N times before killing the connection at the (N+1)th RTO.
The default value of 15 yields a hypothetical timeout of 924.6
seconds and is a lower bound for the effective timeout.
TCP will effectively time out at the first RTO which exceeds the
hypothetical timeout.
RFC 1122 recommends at least 100 seconds for the timeout,
which corresponds to a value of at least 8.