Advanced TCP/IP Connection Tweaking by injx

This guide will help you tweak your TCP/IP parameters in order to optimize your connection. This is a long, advanced article however there are many benefits to be gained from using it. This guide is based on Windows 2000/XP.

TCP/IP – What is it?

TCP/IP stands for Transmission Control Protocol/Internet Protocol. These are 2 protocols working together to transfer data from one place to another successfully. It is the main protocol used for data transmission across the internet.

TCP/IP – What does it do?

Data is divided up into “packets”. These packets have 2 main parts to them: the data part and the header part. The data part contains the actual requested data that you are downloading/uploading. The header part contains all the information about that particular packet (e.g. packet number, size, origin, destination, etc.).

The difference between Ping and Latency

Your Ping is the time taken for data to travel from your computer to a server and back again. Generally, the further away the server, the higher the ping time as the data has further to travel, and more routers to pass through.

Latency is the ping PLUS the time it takes for your connection to actually send the outgoing packets and receive the incoming packets. This means latency is greater than ping. This also means that if you have a faster connection, your latency will be closer to your ping as the send/receive time will be less.

For example, on a 1Mb connection, based on Quake 3, the latency will be around 3ms greater than the ping. However on a slow connection such as my dial-up, the latency is over 100ms greater.


Before I start, I will define the main terms that are used…

Line Speed – The physical rate at which data can be transferred down your connection from your ISP.

Throughput – The actual amount of requested data that can be transferred along your connection per second. This is usually between 75% and 90% of your line speed. Tweaking TCP/IP aims to maximize this.

MTU (Maximum Transmission Unit) – The largest packet of data that can be transmitted down your connection. This maximum is determined by your ISP and is usually 1500 Bytes in most cases (but not all).

MSS (Maximum Segment Size) – The largest data part size of a packet. It is calculated by taking the size of the IP and TCP headers away from the MTU. (MSS = MTU – Header). The header is 40 Bytes usually: 20 for the IP header and 20 for the TCP header.

RWIN (Receive Window) – The amount of requested data that you will be sent before the server will stop and wait for an acknowledgement from you. A server will not continue to transmit data until it has received an acknowledgement.

TTL (Time To Live) – The lifetime of a packet of data. Every time a packet travels through a router its lifetime decreases by 1. When a pakcet’s TTL is 0 it is destroyed. The TTL should be large enough to give the packets enough time to travel to their destination.

Also, to avoid confusion…

b – bit
B – Byte (8 bits)
K – Kilo (1024) [binary]
k – kilo (1000) [decimal]

All data amounts are measured in Bytes unless otherwise stated.

The Tweaking

First you will need to do a couple of tests and a couple of calculations in order to determine your connection’s properties. Don’t worry, these are very simple and I will give step-by-step instructions. Secondly, I will state some other settings that have been found to be universally beneficial to all and that everyone should use. Then I will explain how you can set these values.

1. MTU

The very first thing you must do is to find out what the MTU is for your connection. To do this follow these simple steps:

a) Open a Command Prompt or MS-DOS window. (Start > Run > “cmd.exe”)

b) Choose a server to ping. For example, you could use, however it is best to use your ISP. Then use the following command to ping that server:

ping -f -l 1472

If you get a message that says “Packet needs to be fragmented but DF set” then reduce the number on the end (1472) by 1 and try again until you do not get the fragmented message.

If however you did not receive the fragmented message then increase the value by 1 and try again until you get the fragmented message.

Look for the largest value that does NOT give you a fragmented error message.

Once you have this value, add 28 to it and that is your MTU value.

e.g. 1472 + 28 = 1500

2. MSS

Your MSS value is the following:

MSS = MTU – 40

so if you found that your MTU is 1500 then your MSS would be:

MSS = 1500 – 40
MSS = 1460

3a. RWIN

This is the difficult one. If you have trouble with this, just use the calculator.

Your RWIN should be a multiple of your MSS.

RWIN = MSS * multiplier

The multplier should always be an even number.

The maximum RWIN value you can use is 65535. If you wish to use a value higher than that you can scale up your answer by a power of 2:

RWIN = MSS * multiplier * 2^n (where n is a whole number)

For example,

RWIN = 1460 * 22 = 32120

RWIN = 1460 * 22 * 2^4 = 513920

That is the format for RWIN.

The optimal value for RWIN can be described like this… RWIN should equal the number of Bytes that can be downloaded in your maximum latency time, plus 10% as a buffer. This value then needs to be rounded up so it is a multiple of your MSS, following the format above.

The latency time is roughly equal to your ping to a server. However, you should always use your maximum ping time – ie the largest ping you have out of all the servers around the world. For most of you this will be around 250 ms.

You can find out your maximum ping by using the ping command on a server far away.

If you enter your maximum ping into the calculator, it will convert this into latency automatically.

3b. SWIN

This is exactly the same as the RWIN above but it is for your UPSTREAM.

Calculate it using exactly the same numbers but use your upstream data rate in place of the downstream rate.

The optimal value for SWIN can be described like this… SWIN should equal the number of bytes that can be UPLOADED in your maximum latency time, plus 10% as a buffer. This value then needs to be rounded up so it is a multiple of your MSS, following the syntax above.

You can use the calculator to get this value, just put your upstream rate in the “Line Speed” box. The RWIN output can be then be taken as your SWIN.

4. TTL

You can set this to 64 if you do not wish to experiment with it. 64 will be sufficient in all cases.

However, you should be able to set it to 48, or as low as 32 if you can.

For example, from myself to a server in India is only 14 hops, however from myself to Alf’s server is 25 hops. Since I have not found a server which is greater than 25 hops away from me, I can set my TTL to 32.

If you set this too low, your packets may be destroyed before they reach a server.
If you set this high (like the default value) then it’s not really a big deal, however it is possible that longer delays may result from packetloss.

You can find out how many hops it is to a server by running a traceroute.

To run a traceroute, at the command prompt type:

tracert address



OK that’s all the calculations and information you need to find out. Now I will state some universal optimals and the settings you can derive from the calculations above:

DisableAddressSharing = 1

PriorityBoost = 0

TransmitWorker = 32

EnableFastRouteLookup = 1

EnablePMTUDiscovery = 1

MaxFreeTCBs = 8000

MaxHashTableSize = 16384

MaxNormLookupMemory = 5000000

SackOpts = 1

SynAttackProtect = 1

TCPLogLevel = 1

TCPTimedWaitDelay = 30

MaxConnectionsPer1_0Server = 20

MaxConnectionsPerServer = 10

DisableUserTOSSetting = 0

TCPMaxDataRetransmissions = 6

DefaultTOSValue = 240

You also have these optimal values obtained from the calculations above:

DefaultReceiveWindow = [Your RWIN]

DefaultSendWindow = [Your SWIN]

TCP1323Opts = [If your RWIN is >65535 set this to 1. If your RWIN is <=65535 set this to 0]

TCPRecvSegmentSize = [Your MSS]

TCPSendSegmentSize = [Your MSS]

TCPWindowSize = [Your RWIN]

DefaultTTL = [Your TTL]

Now to implement these settings, you could spend ages creating registry entries manually… or you can download the excellent “Cablenut” which will create them for you.

Download Cablenut here (823KB):

Simply open Cablenut, enter the values stated above into the appropriate boxes and click “Save to Registry”. You then need to restart for the changes to take effect. Leave all settings not mentioned above blank in CableNut – they will use the default values. Once you have Cablenut open infront of you, it will all make sense.

If you wish to restore the default value for any of the settings, simply load CableNut, clear the box of the setting you wish to default and click “Save to Registry”. This will delete that specific registry entry and the default value will be used.