TCP Window Size Calculator - Bandwidth-Delay Product & Scaling
TCP Window Size Calculator (Bandwidth-Delay Product)
Bandwidth-delay product, required TCP receive window and RFC 7323 window scale factor, window-limited throughput, a Mathis loss estimate, MSS from MTU, and Linux / Windows / iperf3 tuning hints. Bandwidth is in bits per second (1 Mbps = 1,000,000 bit/s); windows and buffers are in bytes (KiB/MiB = 1024-based, KB/MB = 1000-based).
1. Bandwidth-delay product and window scaling
Bottleneck rate of the path. Decimal prefixes: 1 Gbps = 10^9 bit/s.
Measured with ping or from ss -ti (rtt field). Used by every section.
2. Reverse: window size to maximum throughput
65535 bytes is the largest window without window scaling. Uses the RTT from section 1.
3. MSS from MTU
Linux enables timestamps by default; Windows does not.
4. Packet loss estimate (Mathis et al.)
Leave empty to skip. 0.01 % = 1 loss per 10,000 packets.
Values from Table 1 of Mathis, Semke, Mahdavi, Ott (1997).
5. Single-flow ceiling and tuning hints
Linux sysctl (guidance, not magic)
iperf3 test
Windows
What this TCP window size calculator does
A single TCP connection can only have one receive window of unacknowledged data in flight per round trip. On a long or fast path (a "long fat network") the window, not the link, is often what limits throughput. This calculator works out the bandwidth-delay product (BDP) of a path, the receive window and RFC 7323 window scale shift count needed to fill it, the throughput a given window can reach, the MSS for an MTU, a packet-loss estimate with the Mathis formula, and starting values for Linux sysctl, Windows autotuning and an iperf3 test. Every input lives in the URL, so you can share a calculation with a link.
How it works
Bandwidth-delay product
BDP (bits) = bandwidth (bit/s) x RTT (s) and BDP (bytes) = BDP (bits) / 8. Bandwidth uses decimal prefixes (1 Gbps = 1,000,000,000 bit/s); sizes are shown both in binary units (1 KiB = 1024 bytes, 1 MiB = 1,048,576 bytes) and decimal units (1 KB = 1000 bytes). The required receive window is the BDP rounded up to a whole byte.
Window scaling (RFC 7323)
The TCP header window field is 16 bits, so the largest unscaled window is 65,535 bytes. The Window Scale option, sent only in SYN segments, carries a shift count S; the advertised window is multiplied by 2^S. RFC 7323 limits S to 14, so the largest possible window is 65,535 x 2^14 = 1,073,725,440 bytes, just under 1 GiB (2^30). The calculator picks the smallest S with 65535 x 2^S >= required window. If even S = 14 is not enough, one flow cannot fill the path and the tool tells you how many parallel streams are needed at minimum.
Window-limited throughput
max throughput (bit/s) = window (bytes) x 8 / RTT (s). This is an upper bound: it assumes the sender always has data and the congestion window is not smaller than the receive window.
Loss-limited throughput (Mathis et al.)
BW = (MSS / RTT) x C / sqrt(p), where p is the packet loss probability. The constant C depends on the loss pattern and ACK strategy: 1.22 = sqrt(3/2) for periodic loss with an ACK for every segment, 0.87 = sqrt(3/4) with delayed ACKs, and 1.31 / 0.93 for random loss (Table 1 of the paper). The model describes Reno-style congestion avoidance with light to moderate loss and assumes no retransmission timeouts and a large enough receive window. It is an approximation, not a prediction for CUBIC or BBR.
MSS from MTU
RFC 6691: the MSS option is the MTU minus the fixed IP header (20 bytes for IPv4, 40 bytes for IPv6) and the fixed 20-byte TCP header. TCP options such as timestamps (10 bytes, normally padded to 12 with two NOPs per RFC 7323 Appendix A) are not subtracted from the advertised MSS, but they do reduce the data carried in each segment. That reduced payload is used for the Mathis estimate.
Tuning hints
Linux autotunes the receive buffer up to the third value of net.ipv4.tcp_rmem (default 131072 for the initial size; the max depends on RAM), and the kernel counts overhead inside the buffer, so the window you get is smaller than the buffer. The tool therefore suggests a buffer max of 2 x BDP rounded up to a power of two and never below the documented 4 MiB net.core.rmem_max default. A setsockopt SO_RCVBUF/SO_SNDBUF call (iperf3 -w) is doubled by the kernel, capped at rmem_max/wmem_max, and disables autotuning for that socket. On Windows the receive window autotuning level Normal (default) uses a scale factor of 8; Microsoft documents five levels from disabled to experimental (shift count 14). These are starting points to measure against, not guaranteed speedups; the sender's congestion control, CPU, disk and middleboxes also matter.
Sources
- RFC 7323, TCP Extensions for High Performance (sections 2.2, 2.3, Appendix A)
- M. Mathis, J. Semke, J. Mahdavi, T. Ott, The Macroscopic Behavior of the TCP Congestion Avoidance Algorithm, ACM SIGCOMM CCR 27(3), July 1997
- RFC 6691, TCP Options and Maximum Segment Size; RFC 791 (IPv4 minimum MTU 68); RFC 8200 (IPv6 minimum MTU 1280)
- Linux kernel docs: ip-sysctl (tcp_rmem, tcp_wmem, tcp_moderate_rcvbuf, tcp_adv_win_scale), net.core sysctls (rmem_max default 4194304), socket(7) man page (SO_RCVBUF doubling)
- Microsoft Learn: Performance tuning network adapters (TCP receive window autotuning levels)
- iperf3 manual (-w option and binary K/M suffixes); ESnet fasterdata Linux tuning
Worked examples
- 1 Gbps, 50 ms RTT. 1,000,000,000 x 0.05 = 50,000,000 bits = 6,250,000 bytes (5.96 MiB). 6,250,000 / 65,535 = 95.4, so the shift count must be at least 7 (65,535 x 128 = 8,388,480 bytes). Linux buffer max: 2 x 6,250,000 = 12,500,000, rounded up to 16,777,216 (16 MiB). iperf3:
-w 6M. - Classic 64 KB window. Without window scaling, 65,535 bytes per 50 ms round trip gives 65,535 x 8 / 0.05 = 10,485,600 bit/s, about 10.49 Mbps, on any link speed. At 100 ms it drops to 5.24 Mbps. This is why an old or broken host is slow over a WAN even though the line is 1 Gbps.
- 10 Gbps transatlantic, 100 ms RTT. BDP = 125,000,000 bytes (119.2 MiB); shift count 11 (max 134,215,680 bytes). Linux buffer max: 2 x BDP = 250,000,000, so 268,435,456 (256 MiB). Windows level Normal (max 16,776,960 bytes) cannot reach it.
- Loss on a 1 Gbps, 50 ms path. MTU 1500, IPv4 with timestamps gives 1448 bytes per segment. With 0.01 % loss (p = 0.0001) and C = 1.22: (1448 x 8 / 0.05) x 1.2247 / 0.01 = about 28.37 Mbps. A bigger window will not help here; the loss must be fixed.
- MSS values. MTU 1500: IPv4 MSS 1460 (1448 with timestamps), IPv6 MSS 1440 (1428 with timestamps). MTU 9000 IPv4: MSS 8960, 8948 with timestamps.
- 100 Gbps, 100 ms. BDP = 1,250,000,000 bytes (1.164 GiB), more than the 1,073,725,440-byte TCP maximum, so even shift count 14 is not enough. You need at least 2 parallel flows (for example
iperf3 -P 2), and usually more in practice.
Bandwidth-delay product reference table
BDP in binary units and the minimum window scale shift count (ws) for common bandwidths and round-trip times.
| Bandwidth | 1 ms | 10 ms | 50 ms | 100 ms | 300 ms |
|---|---|---|---|---|---|
| 10 Mbps | 1.221 KiB, ws 0 | 12.21 KiB, ws 0 | 61.04 KiB, ws 0 | 122.1 KiB, ws 1 | 366.2 KiB, ws 3 |
| 100 Mbps | 12.21 KiB, ws 0 | 122.1 KiB, ws 1 | 610.4 KiB, ws 4 | 1.192 MiB, ws 5 | 3.576 MiB, ws 6 |
| 1 Gbps | 122.1 KiB, ws 1 | 1.192 MiB, ws 5 | 5.96 MiB, ws 7 | 11.92 MiB, ws 8 | 35.76 MiB, ws 10 |
| 10 Gbps | 1.192 MiB, ws 5 | 11.92 MiB, ws 8 | 59.6 MiB, ws 10 | 119.2 MiB, ws 11 | 357.6 MiB, ws 13 |
| 100 Gbps | 11.92 MiB, ws 8 | 119.2 MiB, ws 11 | 596 MiB, ws 14 | 1.164 GiB, over limit | 3.492 GiB, over limit |
FAQ
What is the bandwidth-delay product?
The bandwidth-delay product (BDP) is the amount of data that must be in flight to keep a path full: bandwidth in bits per second multiplied by the round-trip time in seconds, divided by 8 to get bytes. A 1 Gbps path with 50 ms RTT has a BDP of 6,250,000 bytes, about 5.96 MiB.
How large should the TCP window be?
At least the BDP of the path. A single TCP flow cannot send more than one receive window per round trip, so its throughput is limited to window / RTT. With the classic 65,535-byte window and 50 ms RTT that is only about 10.5 Mbps.
What is the TCP window scale factor?
RFC 7323 lets each side announce a shift count in its SYN. The 16-bit window field is then multiplied by 2 to the power of the shift count. The shift count is limited to 14, so the largest window is 65,535 x 16,384 = 1,073,725,440 bytes, just under 1 GiB.
Why is my iperf3 -w value different from the window I see?
iperf3 -w sets the socket buffer size, not the advertised window directly. On Linux the kernel doubles the requested value for bookkeeping overhead and caps it at net.core.rmem_max or wmem_max, and part of the buffer is overhead rather than window. iperf3 size suffixes are binary: 1M means 1,048,576 bytes.
How does packet loss limit TCP throughput?
For Reno-style congestion avoidance, Mathis et al. (1997) estimate throughput as MSS / RTT x C / sqrt(p), where p is the loss probability and C is about 1.22 for periodic loss with an ACK for every segment. It is an approximation: it ignores retransmission timeouts and does not describe CUBIC or BBR exactly.
Do I need to tune Linux or Windows TCP buffers manually?
Usually not for ordinary paths. Linux autotunes receive buffers up to the tcp_rmem maximum and Windows autotunes the receive window by default (level Normal). Manual tuning matters on long fat networks where the BDP is larger than those maximums; raise the limits, then measure again.
Is the bandwidth in this calculator in bits or bytes?
Bandwidth is entered in bits per second with decimal prefixes, so 1 Mbps is 1,000,000 bit/s. Window and BDP sizes are shown in bytes, with binary units (KiB, MiB, 1024-based) and decimal units (KB, MB, 1000-based) labeled explicitly.
Comments
Post a Comment