Quick Figuring Optimal TCP Window Size

There generally isn’t a single correct way to figure out the optimal TCP window for an interface since you’re probably connecting to different hosts across different links at different latencies; however, you can roughly guess what the optimal window would be if you’re only primarily worried about your communication with one other host (or, perhaps, one other site).  First, you’ll need to know the latency and the throughput available between you & the remote host.  To get the latency, ping the remote host and take the average response time.  For the throughput, take the slowest link between you & the remote host (ie, you might both be connected to 100Mb/s Ethernet, but there is a 1.5Mb/s WAN link between).  If the slowest link is asymmetrical, use the faster of the two speeds — for example, on an ADSL connection that was rated as 1.5Mb/s down and 384Kb/s up, use the 1.5Mb/s speed.  (If both ends are on DSL, use the lower speed as this will always be the limiting factor.)

Once we’ve got these two numbers, the normal formula used to calculate optimal TCP window is bandwidth * latency = window.  Remember that throughput is measured in bits per second whereas our TCP window is going to be configured in bytes per second.  Divide the throughput by 8 to convert bits per second to bytes per second.

So, if we were using a 1.5Mb/s ADSL link with 70ms of latency, our calculation would look something like this:

(1.5*1024*1024/8)bytes/second  *  .07seconds = ~13763bytes

So, on this link, a 13KB TCP window would work well.  Since the default TCP window for Windows 2000/XP/2003 is 16K (or more), there would be no need to change the window on this client; however, if either the throughput or the latency was higher, we would probably benefit from a change.

Comments (2)

  1. vincentv@microsoft.com says:

    I took your formula Neil and put it into a command line c++ quick app.


    1. Use VS6

    2. New -> Win32 Console App -> Hellow World

    3. Paste the code below in.


    It worked for me. Well except that it might not round up correctly (but that is just 1 byte). :)

    Thanks for your blog.

    // tcpwindow.cpp : Defines the entry point for the console application.


    #include "stdafx.h"

    #include <stdio.h>

    #include <string.h>

    #include <stdlib.h>

    int main(int argc, char* argv[])


    float pingRTT;

    float bandwidth;

    char* pingExample = "c:\>ping slow-msg-51nntReply from bytes=32 time=176ms TTL=56ntReply from bytes=32 time=114ms TTL=56ntReply from bytes=32 time=117ms TTL=56ntReply from bytes=32 time=171ms TTL=56n";

    char* pingExample2 = "ntPing statistics for Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),ntApproximate round trip times in milli-seconds:nt Minimum = 114ms, Maximum = 176ms, Average = 144msnn";


    printf(" The TCPWindow Size Tooln");



    printf("STEP 1: Find the RTT:n");


    printf("Example: n");




    printf("Note —> Approximate round trip times in milli-seconds:nt … Average = 144msnn");



    printf("What is the Approximate round trip times for your issue?n");


    printf(" Action: Type in the seconds value (if rtt was 144 then enter ".144")n and press ENTERnn");

    printf("RTT Value: ");



    printf("STEP 2: State the bandwidth:n");


    printf("Example: nn");


    printf("This is the WAN bandwidth. An example could be 1.44, 5, 10, 45, etc…n");



    printf("What is the the available bandwidth of your WAN link?n");


    printf(" Action: Type in the value (i.e. 1.5) and press ENTERnn");

    printf("Value: ");



    printf("You have specified: %f as the RTT.n",pingRTT);

    printf("You have specified: %f for the bandwidth.n",bandwidth);


    printf("STEP 3: Do the numbers:n");


    printf("Step1: ([BANDWIDTH]*1024*1024/8)bytes/second * [ROUND TRIP] = [TCP WINDOW]nn");

    printf("Step2: (%f*1024*1024/8)bytes/second * (%f) = [TCP WINDOW]nn",pingRTT,bandwidth);

    int step3;

    step3 = (pingRTT * 1024*1024/8);

    printf("Step3: (%f) * (%f) = [TCP WINDOW]nn",step3,bandwidth);

    float step4;

    step4 = step3 * bandwidth;

    printf("Step4: %f = [TCP WINDOW]nn",step4);

    printf("Step4: TCPWindowSize = %dnn",int(step4));

    return 0;


  2. Neilcar says:

    Glad you found it useful! I’d like to start getting more network-oriented stuff out here…