I’ve always been fascinated by the relationship between internet speed and latency. I know that for a given a specific latency you can calculate the maximum speed of an internet connection:
TCP-Window-Size-in-bits / Latency-in-seconds = Bits-per-second-throughput
It’s described in more detail here
But will that hold up in real world tests? I decided to measure it. Here are the results:
To do this I did the following:
- Created a script that tested each of the ~3000 speedtest.net servers by wget’ing a large test image from each. Ran this off of a 1 Gbs connection, on Centos 7 server with default window size.
- Summarized the data by country
- Uploaded to openheatmap.com to make it pretty
Here are some interesting things that came out of this little experiment:
- Countries in the same geographic region that have slower throughput are not running at their full potential. Examples include: Guatemala, Brazil, Libya, Latvia, Lithuania, Iceland, Portugal, etc. Take these results with a grain of salt, because some of these suffer from small sample size. For example, I had to remove Japan from the data set because the only server Japan was a unusually slow one.
- Vast majority of the countries do run at their theoretical max throughput. That means that most of the time, as long as you know your TCP window size, you can easily calculate the throughput with confidence.
- You can roughly deduce route paths by looking at the map. Take Iceland for example. Even though it’s closer to Canada than Great Britain, the route clearly traverses through Great Britain, Ireland or Norway before heading to Iceland.
- I got an impossible latency for Pakistan. (47 milliseconds) With that latency there is no way to even get to Europe, much less China. The closest country with that kind of latency is Mexico. I eliminated that from the data set as an anomaly.
- I got impossible latency for Morocco. (64 milliseconds). Again, that’s way too quick. I’m guessing both Morocco and Pakistan have been mis-classified and are actually somewhere in the USA.
- If you noticed, I haven’t said what my Centos 7 default TCP window size was. That’s because I’m not really sure my self. Working back from the real-life results, I’m sure the window size is approx 1,000 KB. However, that doesn’t seem to match these parameters on my system: net.core.wmem_max = 212992 and net.ipv4.tcp_wmem = 4096 16384 3915616 … there must be some multiplication division factor involved. Or maybe I’m looking at the wrong parameter altogether?