2013-03-18 54 views
6

我正在通过非常慢的接口编程linux设备驱动程序,其ping回合时间可能长达几分钟。当我尝试使用TCP建立两个节点之间的连接时,连接总是超时。更改linux网络设备的TCP超时

是否有一种方法可以在驱动程序中设置TCP重新传输或握手超时时间更长,还是有任何命令将其设置为?谢谢

回答

4

你试过寻找这个问题的答案吗?一个快速的谷歌搜索给了我this,似乎直接解决了这个问题。总结是net.ipv4.tcp_syn_retries的设置决定了TCP连接可用的最大超时时间。

如果那个文件不是回答你的问题,你应该说明你尝试了什么以及行为与你的期望有什么不同。

+0

+1 - 只是简单的整洁:) – linski 2013-03-18 19:30:44

+0

谢谢。你的答案确实有帮助。但我可以为不同的接口设置不同的超时时间吗 – 2013-03-18 20:05:35

0
/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.