Difference between TCP window size & MTU
I was reading up on TCP recently when I came across the term “Window size”, which also reminded me of another term I came across earlier, “MTU”.
I briefly understood that these 2 terms dictate how quickly data can be transferred between 2 machines, but what exactly are the differences?
Here is a very brief explanation on it.
What is window size?
Window size is a TCP header value which controls the flow of data. The header space for this value is 2 bytes long, which translates to a maximum value of 65535 bytes. This value is OS/TCP stack dependent.
What does it do?
Imagine you own a brewery and is currently tasked with transferring a huge tank of beer to your customer’s own beer tank.
Instead of being able to pump the beer directly into the other tank, your customer can only receive it with a pail before transferring it to the main tank.
The size of this pail is the
I used pail as an example but you can imagine it being a cup if the window size is even smaller.
Now think about the amount of round trips required to completely transfer the beer over. Throw in the latency between each transfer and we can easily see how this can become a bottleneck.
Window scaling (optional)
For modern client-server communications, 65535 bytes wouldn’t cut it.
Thankfully, there’s the
window scale option and is only sent with
This serves as a multiplier for the
window size, which means a much larger buffer to hold the data.
Using the beer transfer analogy again, it’s like upgrading the pail to a cement truck.
Caveat: both server and client have to support this option, else it wouldn’t be available for use.
How does this differ from MTU?
MTU stands for Maximum Transmission Unit.
We can view the entire data transfer process as a combination of a few entities: server, client and the pipe connecting them.
The MTU determines the size of the pipe whereas
window size determines the size of buffer at both ends.
Assuming MTU is 1500 bytes and the entire payload is 15000 bytes, there will be a total of 10 exchanges needed for entire transfer to complete.
Using Wireshark, we can see how MTU (1500 bytes) limits the
TCP segment len, and also how these segments are finally assembled.
When performing analysis using Wireshark, do note that because
window scale option is only sent with
SYN packet, failing to capture this packet will result in Wireshark being unable to determine the “actual”
window size and thus affect the analysis.