Windows 中的默认 TCP 连接超时时间是多少?

Ren*_*one 31 windows tcpip tcp

Windows 中的默认 TCP 连接超时时间是多少?有一个注册表项来配置它还是动态设置?

sys*_*138 26

在 Windows 中,已建立连接的值是动态的,但初始连接的默认值为 72 秒。注册表设置在本文中定义:

http://technet.microsoft.com/en-us/library/cc739819(WS.10).aspx

HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services: \Tcpip \Parameters

TcpInitialRTT:定义新连接的初始超时设置。每次在连接超时之前重新传输时,这个以秒为单位的数字都会加倍。默认为 3。

TcpMaxConnectRetransmissions:定义连接超时之前的重传次数。默认为 5。

  • 实际上,它在我重新启动后起作用了!Windows 中没有任何变化!似乎您必须重新启动,如果您只是在不重新启动的情况下编辑注册表,则该设置对旧连接或新连接都没有影响! (3认同)
  • 在较新的操作系统中,您现在可以通过在 powershell 中运行来设置 TcpInitialRTT:“Set-NetTCPSetting -SettingName Internet -InitialRtoMs 1000”...默认值为 1000ms。此外,还有为每个连接自动分配的设置名称,例如“Internet”和“DataCenter”。您可以通过运行“Get-NetTCPConnection”并查看“AppliedSetting”列来找到每个连接使用的设置。 (2认同)

小智 11

通常“连接超时”是指创建与主机的初始连接的超时时间。在许多系统(包括 Windows 7)中,此值是使用与建立连接后正在进行的通信的超时不同的设置来配置的。此答案解决了与 XP 不同的 Windows 7 的“初始连接”方案。

对于 Windows 7,需要两个修补程序来支持调整连接超时设置。可以使用“netsh”命令配置新设置。

来自 2786464 修补程序文章:

注意在 Windows 7 和 Windows Server 2008 R2 中,TCP 最大 SYN 重传 (JH: MaxSynRetransmissions) 值设置为 2,并且不可配置。由于初始超时值(JH:InitialRTO)有3秒的限制,TCP三次握手被限制在21秒的时间范围内(3秒+2*3秒+4*3秒=21秒) )。

第一个修补程序添加了一个“MaxSynRetransmissions”设置,它允许从默认值 2 更改重试设置。第二个修补程序添加“InitialRto”设置,它允许将初始 RTO 值从默认值 3000 毫秒(是的,毫秒)更改,但仅限于短于 3000 毫秒的东西;它不能增加。根据您的情况,您可能只需要“MaxSynRetransmissions”修补程序。

安装这两个修补程序,重新启动,然后以管理员身份打开命令窗口。后续的 netsh 命令调用不需要进一步重新启动。

C:\Windows\system32>NET SESSION >nul 2>&1

C:\Windows\system32>IF %ERRORLEVEL% EQU 0 (ECHO Administrator PRIVILEGES Detected!) ELSE ( ECHO NOT AN ADMIN! )
Administrator PRIVILEGES Detected!

C:\Windows\system32>netsh interface tcp show global
Querying active state...

TCP Global Parameters
----------------------------------------------
Receive-Side Scaling State          : enabled
Chimney Offload State               : automatic
NetDMA State                        : enabled
Direct Cache Acess (DCA)            : disabled
Receive Window Auto-Tuning Level    : normal
Add-On Congestion Control Provider  : none
ECN Capability                      : disabled
RFC 1323 Timestamps                 : disabled
Initial RTO                         : 3000
Non Sack Rtt Resiliency             : disabled
Max SYN Retransmissions             : 2
** The above autotuninglevel setting is the result of Windows Scaling heuristics

overriding any local/policy configuration on at least one profile.

C:\Windows\system32>cmd /v:on /c "echo !TIME! & telnet 192.168.1.254 & echo !TIME!"
14:10:30.53
Connecting To 192.168.1.254...Could not open connection to the host, on port 23: Connect failed
14:10:51.60


C:\Windows\system32>netsh interface tcp set global MaxSynRetransmissions=3
Ok.


C:\Windows\system32>netsh interface tcp show global
Querying active state...

TCP Global Parameters
----------------------------------------------
Receive-Side Scaling State          : enabled
Chimney Offload State               : automatic
NetDMA State                        : enabled
Direct Cache Acess (DCA)            : disabled
Receive Window Auto-Tuning Level    : normal
Add-On Congestion Control Provider  : none
ECN Capability                      : disabled
RFC 1323 Timestamps                 : disabled
Initial RTO                         : 3000
Non Sack Rtt Resiliency             : disabled
Max SYN Retransmissions             : 3
** The above autotuninglevel setting is the result of Windows Scaling heuristics

overriding any local/policy configuration on at least one profile.

C:\Windows\system32>cmd /v:on /c "echo !TIME! & telnet 192.168.1.254 & echo !TIME!"
14:27:02.33
Connecting To 192.168.1.254...Could not open connection to the host, on port 23:
 Connect failed
14:27:47.41

C:\Windows\system32>netsh interface tcp set global MaxSynRetransmissions=2
Ok.


C:\Windows\system32>netsh interface tcp set global InitialRto=1000
Ok.


C:\Windows\system32>netsh interface tcp show global
Querying active state...

TCP Global Parameters
----------------------------------------------
Receive-Side Scaling State          : enabled
Chimney Offload State               : automatic
NetDMA State                        : enabled
Direct Cache Acess (DCA)            : disabled
Receive Window Auto-Tuning Level    : normal
Add-On Congestion Control Provider  : none
ECN Capability                      : disabled
RFC 1323 Timestamps                 : disabled
Initial RTO                         : 1000
Non Sack Rtt Resiliency             : disabled
Max SYN Retransmissions             : 2
** The above autotuninglevel setting is the result of Windows Scaling heuristics

overriding any local/policy configuration on at least one profile.


C:\Windows\system32>cmd /v:on /c "echo !TIME! & telnet 192.168.1.254 & echo !TIME!"
14:29:06.13
Connecting To 192.168.1.254...Could not open connection to the host, on port 23:
 Connect failed
14:29:13.20
Run Code Online (Sandbox Code Playgroud)

注:实际连接超时以 Windows telnet 为参考。它需要单独安装,但很容易做到。

其他链接/荣誉: