2013-03-18 51 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.