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:WINDOWSsystem32> 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 !
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:Usersdahavey> 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:Usersdahavey> Set-NetTCPSetting -SettingName InternetCustom -CongestionProvider LEDBAT PS C:Usersdahavey> 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:Usersdahavey> netsh int tcp reset Reset of all TCP parameters OK! Ok. PS C:Usersdahavey> 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!