Windows 如何决定将哪个 setting/template(Internet 与数据中心)应用于 TCP 连接?

How does Windows decide which setting/template (Internet vs Datacenter) is applied to TCP connections?

为了全局配置Minimum RTO;延迟确认超时; Windows 7 及以上的拥塞算法等应该使用网络 TCP 模板。 要查看这些,您可以使用 Get-NetTCPSetting powershell cmdlet:

PS C:\Users\Administrator> Get-NetTCPSetting

(...)

SettingName                   : Datacenter
MinRto(ms)                    : 20
InitialCongestionWindow(MSS)  : 4
CongestionProvider            : DCTCP
CwndRestart                   : True
DelayedAckTimeout(ms)         : 10
MemoryPressureProtection      : Enabled
AutoTuningLevelLocal          : Normal
AutoTuningLevelGroupPolicy    : NotConfigured
AutoTuningLevelEffective      : Local
EcnCapability                 : Enabled
Timestamps                    : Disabled
InitialRto(ms)                : 3000
ScalingHeuristics             : Disabled
DynamicPortRangeStartPort     : 49152
DynamicPortRangeNumberOfPorts : 16384

SettingName                   : Internet
MinRto(ms)                    : 300
InitialCongestionWindow(MSS)  : 4
CongestionProvider            : CTCP
CwndRestart                   : False
DelayedAckTimeout(ms)         : 50
MemoryPressureProtection      : Enabled
AutoTuningLevelLocal          : Normal
AutoTuningLevelGroupPolicy    : NotConfigured
AutoTuningLevelEffective      : Local
EcnCapability                 : Enabled
Timestamps                    : Disabled
InitialRto(ms)                : 3000
ScalingHeuristics             : Disabled
DynamicPortRangeStartPort     : 49152
DynamicPortRangeNumberOfPorts : 16384

为了获得单独的连接和应用到它们的设置,可以使用 Get-NetTCPConnection cmdlet:

PS C:\Users\Administrator> Get-NetTCPConnection

LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
------------                        --------- -------------                       ---------- -----       --------------
(...)
192.168.75.69                       63220     192.168.75.66                       1433       Established Datacenter
192.168.75.69                       63208     192.168.75.61                       445        Established Internet
192.168.101.13                      63061     185.97.X.X                          20467      Established Datacenter
192.168.101.13                      63059     209.191.X.X                         18083      Established Internet
(...)

我如何影响(或至少是如何影响)Internet 与数据中心 TCP 设置的选择? 我们有几个低延迟连接,我们想用数据中心设置来处理它们(以加快从通信故障中恢复的速度),但我仍然不想盲目地将它应用于所有连接。

应用于给定连接的设置配置文件基于匹配的传输过滤器。默认情况下,有一个过滤器将 Automatic 设置配置文件应用于所有连接,这就是为什么你的看起来是随机的。

PS C:\> Get-NetTransportFilter

SettingName       : Automatic
Protocol          : TCP
LocalPortStart    : 0
LocalPortEnd      : 65535
RemotePortStart   : 0
RemotePortEnd     : 65535
DestinationPrefix : *

New-NetTransportFilter cmdlet 允许您根据端口号或 IP 地址将连接映射到特定的配置文件。

你可以使用像

这样的东西
New-NetTransportFilter -SettingName Datacenter -DestinationPrefix 192.168.75.0/24

New-NetTransportFilter -SettingName DataCenter -LocalPortStart 0 -LocalPortEnd 65536 -RemotePortStart 1433 -RemotePortEnd 1433