Nov 4, 2015

TCP Windowing 101: Speeding Up the Long Distance Internet

There’s no disputing that the Internet has had massive effects on international trade, beyond what anyone could have predicted. There was a time when buying a new shovel meant a trip to the local hardware store a few minutes away, but that’s started to change in recent years. These days, people are (arguably) more likely to make such a purchase online, and this is true of many other services as well.

Long Distance Relationships on the Internet Pose “Communication Issues”

The problem is that sometimes the services one wants to consume can be in a geographically distant region from the end user. There’s nothing inherently wrong with that, but when one lives in (for example) Nigeria and is trying to download a video or a large file from (again, for example) Japan, we start to run into technical limitations.

If one were to pop the hood on the Internet (just don’t let the magic leak out!), one would see that the way traffic flows is not a one-way stream (like turning on a faucet). The transfer is more like a conversation between two people, one of whom is doing the bulk of the talking. They’ll tell a chunk of their story, pause, and wait for the listener to nod their head. When they see that nod, they go on with their story. Rinse and repeat until the story is told.

Why is this done? Societal and cultural factors aside, it’s partly so they don’t tell a long, winding story about the time they got their keys stuck in the toaster only to have the listener say, “Hmm? Sorry, I missed that.”

Long Distance Conversations Can Create Confusion and Missed Messages

Internet transfers work in the same manner. The host that will ultimately become the listener in the previous analogy will send “Hey, send me cutepuppies.mp4!’ to the host that will ultimately become the speaker. The speaker receives the request and sends the first chunk. The listener responds with an acknowledgement and the speaker sends the second chunk.

The problem here is that over long distances with default configurations, only a relatively small amount of data is in each of these chunks. Latency may only be measured in milliseconds, but it adds up quickly as the ‘conversation’ between the two hosts continues. What is normally a high-speed connection slows to a crawl. Many applications for things like FTP uploads have fairly low default values, which may not be what is needed for ‘long range’ transfers of data.

Fix the Flow of Information: Tweaking TCP Settings

Fortunately, this experience can be improved in many cases. By making tweaks to something called TCP windowing settings, we can increase the size of these chunks, which results in less back and forth. With larger chunks, we have more data ‘in flight’ at any given time; that is manifested to the end user as an increase in speed.

It should be noted that these TCP windowing settings are not the same things as the TCP MTU, which is the largest a packet can be before it is broken up into fragments. The specifics of changing these settings vary by operating system and are beyond the scope of this document; however, they are very easy to find online.

Communicating in the Real World in Real Time

Let’s see a real-world example. Say that I have a 100Mbps pipe, and I want to make full use of that to a destination that’s 80ms away. By calculating the BDP (bandwidth delay product; there are plenty of free calculators out there), I can see I’d need to tweak my settings so that about 1MB of data was on the wire at any given time to get 100Mbps of throughput. If, however, that destination is now 200ms away, that number jumps to about 2.4MB.

Remember: TCP windowing changes will not result in a faster ping time to a remote host; ping uses either UDP or ICMP, which are unaffected by these settings. The test for success will be a TCP-based transfer, such as a download of a larger file.

In situations where someone is experiencing slower-than-expected throughput with no evidence of resource contention (e.g. maxing out the capacity of the server or circuit), TCP window settings are a great place to start looking. It should be noted that changing these settings is something that should only be done by qualified personnel.

If you have questions about latency or TCP windowing, please contact us. We appreciate your business and are always here at your service!

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedIn