TCP Templates for Windows Server 2019 ‚Äď How to tune your Windows Server Transports (Advanced users only ūüėČ)

Don’t forget to #LEDBAT¬†and @Win10Transports

Windows TCP parameters can be ¬†configured using templates. However, Windows TCP template tuning is one of the deepest darkest mysteries throughout the land. There is only one solution to this problem. Simplicitas ad redigendum (according to Bing) this is Latin for ‚ÄúReduce to simplicity‚ÄĚ. Good thing that TCP templates are simpler than Latin!

Ready? Set! Let’s get started! First, we need to understand the Powershell cmdlets  that we will use. There are two of them: Get-NetTCPSetting and Set-NetTCPsetting. Let’s start with Get-NetTCPSetting. Go ahead. Open a powershell window, type the cmdlet and pipe it through the Select command as shown in the example. You should see something like this:

PS C:\WINDOWS\system32> Get-NetTCPSetting | Select SettingName
SettingName
-----------
Automatic
InternetCustom
DatacenterCustom
Compat
Datacenter
Internet

Why are those two templates in strikethrough font? Because those are two templates that you don‚Äôt have to worry about! The Automatic template is used for (automatically) switching between Internet and Datacenter templates. The Compat template is only for legacy applications and is not recommended for use with modern apps. Now we are down to four templates and this is getting closer to simplicity ūüėČ!

Figure 1 — TCP Template SettingNames

Referring to Figure 1 we see that there are really only 2 templates that can be customizable or not. The Internet template is used for connections with an RTT of more than 10 ms and the Datacenter template is used for connections with an RTT of 10 ms or less. Remember that Automatic template that I said you don’t need to worry about? Well you still don’t need to worry about it. But, just for information sake the Automatic template is taking the initial RTT as measured by the TCP connection handshake and applying the appropriate template to the TCP connection.

What’s the difference between the two? The Datacenter template is designed for low-latency LAN environments and the Internet template is designed for higher latency WAN environments. Now let’s have a look at all the settings that you can tune!

PS C:\Users\dahavey> Get-NetTCPSetting -SettingName InternetCustom

SettingName                     : InternetCustom
MinRto(ms)                     : 300
InitialCongestionWindow(MSS)   : 10
CongestionProvider             : CUBIC
CwndRestart                     : False
DelayedAckTimeout(ms)           : 40
DelayedAckFrequency             : 2
MemoryPressureProtection       : Disabled
AutoTuningLevelLocal           : Normal
AutoTuningLevelGroupPolicy     : NotConfigured
AutoTuningLevelEffective       : Local
EcnCapability                   : Disabled
Timestamps                     : Disabled
InitialRto(ms)                 : 3000
ScalingHeuristics               : Disabled
DynamicPortRangeStartPort       : 49152
DynamicPortRangeNumberOfPorts   : 16384
AutomaticUseCustom             : Disabled
NonSackRttResiliency           : Disabled
ForceWS                         : Enabled
MaxSynRetransmissions           : 2
AutoReusePortRangeStartPort     : 0
AutoReusePortRangeNumberOfPorts : 0

WoW! Look at all those settings you can tune! That is enough to make an uber geek giggle with joy! Use Set-NetTCPSetting to change things. Like this:

### Change the congestion provider to LEDBAT
PS C:\Users\dahavey> Set-NetTCPSetting -SettingName InternetCustom -CongestionProvider LEDBAT
PS C:\Users\dahavey> Get-NetTCPSetting -SettingName InternetCustom

SettingName                     : InternetCustom
MinRto(ms)                     : 300
InitialCongestionWindow(MSS)   : 10
CongestionProvider              : LEDBAT   ### <------- Changed
CwndRestart                     : False
DelayedAckTimeout(ms)           : 40
DelayedAckFrequency             : 2
MemoryPressureProtection       : Enabled
AutoTuningLevelLocal           : Normal
AutoTuningLevelGroupPolicy     : NotConfigured
AutoTuningLevelEffective       : Local
EcnCapability                   : Enabled
Timestamps                     : Disabled
InitialRto(ms)                 : 3000
ScalingHeuristics               : Disabled
DynamicPortRangeStartPort       : 49152
DynamicPortRangeNumberOfPorts   : 16384
AutomaticUseCustom             : Disabled
NonSackRttResiliency           : Disabled
ForceWS                         : Enabled
MaxSynRetransmissions           : 2
AutoReusePortRangeStartPort     : 0
AutoReusePortRangeNumberOfPorts : 0

Fair warning! If you do not know what a setting means you it’s probably best to leave it alone.  If you get into trouble and want to reset to default:

### Reset tcp parameters to default
PS C:\Users\dahavey> netsh int tcp reset
Reset of all TCP parameters OK!
Ok.

PS C:\Users\dahavey> Get-NetTCPSetting -SettingName InternetCustom

SettingName                     : InternetCustom
MinRto(ms)                    : 300
InitialCongestionWindow(MSS)   : 10
CongestionProvider             : CUBIC   ### <------- Reset to default
CwndRestart                     : False
DelayedAckTimeout(ms)           : 40
DelayedAckFrequency             : 2
MemoryPressureProtection       : Enabled
AutoTuningLevelLocal           : Normal
AutoTuningLevelGroupPolicy     : NotConfigured
AutoTuningLevelEffective       : Local
EcnCapability                   : Enabled
Timestamps                     : Disabled
InitialRto(ms)                : 3000
ScalingHeuristics               : Disabled
DynamicPortRangeStartPort       : 49152
DynamicPortRangeNumberOfPorts   : 16384
AutomaticUseCustom             : Disabled
NonSackRttResiliency           : Disabled
ForceWS                         : Enabled
MaxSynRetransmissions           : 2
AutoReusePortRangeStartPort     : 0
AutoReusePortRangeNumberOfPorts : 0

Please see the links to Set/Get-NetTCPSettings for descriptions of the individual settings and what they do. Have fun and happy TCP tuning!