cenko.tech

latency-atlas: how far the internet detours from the speed of light

A live map of round trips between Kraków and about a thousand machines worldwide, set beside the time light in fibre would need for the same trip.

When you ping a server on another continent, the number you get back is hard to judge. Is 180 ms to Sydney slow? Is 30 ms to London good? Without something to compare against, a millisecond figure doesn’t tell you much.

latency-atlas gives you that comparison. It’s a live map of round-trip times between Kraków and cities around the world, and it sets each one beside the fastest possible round trip: light travelling through glass fibre in a straight line. The difference between the two is how far the real network detours from physics.

It’s live at 0xgitpushpray.github.io/latency-atlas. The hosting is free, and there’s no server, API key or build step.

Where the numbers come from#

I didn’t want to run probes myself, and I didn’t have to. RIPE Atlas runs anchors, which are dedicated measurement machines hosted by networks around the world, and the anchors ping each other all the time. This is called the anchoring mesh.

One of those anchors is in Kraków. Measurement 84162223 is the IPv4 mesh that targets it: about 1,000 anchors each send it 3 ICMP packets every 4 minutes. The results and the anchor metadata (city, country, coordinates, network) are public, and the RIPE Atlas API sends CORS headers, so a web page can read them directly.

The anchors are pinging Kraków, not the other way round. For a round trip that doesn’t matter, because the packet covers the same loop in either direction, so the page says “round trip between Kraków and X”.

A few rules decide what each city shows:

  • A city’s value is its fastest anchor’s best packet. Several anchors can share a city, and the slowest packet of three mostly measures queueing, so the minimum RTT is the closest thing to the route’s real cost.
  • Different spellings count as one city. Anchor operators write “Frankfurt am Main”, “Milano” and “New York City”, so a short alias table merges them with “Frankfurt”, “Milan” and “New York”.
  • Silent anchors stay on the map. An anchor that didn’t reply in the latest collection is stamped Return to sender. Dropping it would make the coverage look better than it is.

The physics floor#

Light in a vacuum covers about 300 km per millisecond. Glass has a refractive index of about 1.468, which slows light to about 204 km per millisecond. A round trip is twice the distance, so:

floor (ms) = 2 × great-circle distance (km) ÷ 204.19

Every 1,000 km between two machines costs at least 9.8 ms of round trip, so a city 10,000 km away can never answer in less than 98 ms. Halfway round the planet, at 20,015 km, the floor is 196 ms. On the map this is light’s limit, the slowest possible straight-line fibre trip on Earth.

Real routes are slower than the floor, because cables don’t follow great circles, packets pass through routers, and traffic between two networks often goes through an exchange in a third city. When you select a city, the page divides its round trip by its floor and explains the result:

  • Under 150 km away, almost all the time is spent in routers and switches, so the ratio doesn’t mean much.
  • Below 1×, the result is faster than light could manage, so the anchor’s registered location is probably wrong.
  • Under 1.3×, the route is about as direct as the internet gets.
  • Up to 2.2×, it’s the usual overhead of bent cable paths, routers and queues.
  • Above that, the packets are probably taking a long way round.

The “faster than light” case isn’t hypothetical. Anchor coordinates are entered by the people who host them, and a wrong coordinate shows up straight away when the measured time beats physics. The page reports it instead of hiding it.

Two ways to draw the world#

The map is one round disc centred on Kraków. It uses an azimuthal equidistant projection, which keeps every direction from Kraków true. Distance is drawn on a square-root scale so that Europe, where most anchors are, gets room while the whole globe still fits in the disc.

A switch moves between two views:

Distance places each city at its real direction and distance from Kraków.

Delay moves every city outwards to where its round trip puts it, using the same square-root scale but in milliseconds. At the same time the land shrinks to where light in fibre would place each point. The land’s scale factor is the square root of the light limit divided by the scale’s maximum (196 ms out of 400 ms), so a coastline in the shrunken land sits exactly at its light-time radius. Each city gets a line from where light would have put it to where the network actually did, and the length of that line is the detour.

A replay strikes each city’s stamp in order of its real round trip, slowed down seven times, while a blue ring for light in fibre expands outwards from Kraków. The cities that stamp well after the ring has gone past them are the ones with the biggest detours.

The visual design follows one idea: every ping is a letter posted in Kraków. The disc is drawn as a postmark with the collection date on its rim, cities are cancellation stamps in six zone inks (under 20 ms up to 250 ms and over), and the page uses airmail colours, with red reserved for things that didn’t come back. Each zone also has its own mark shape, so zones can be told apart without relying on colour, and every value is also listed in a searchable, sortable register that works from the keyboard.

Hosting with no server#

The page needs to load quickly and also show live data, and those two goals pull in opposite directions. The anchor list alone takes a few pages of API calls, so I split the work in two:

GitHub Actions (hourly)                     Browser
  scripts/collect.mjs                         index.html + app.js
    ├─ anchors + latest results ─┐              ├─ paints data/latest.json at once
    └─ extends data/history.json │              └─ then polls RIPE Atlas every 4 min
                                 ▼                 while the tab is visible
                  deployed to GitHub Pages

Every hour, a workflow fetches all anchors and the latest results, then writes a snapshot and an hourly history. The page paints that snapshot at once and then switches to live data. It asks RIPE Atlas for the latest results about 30 seconds after the next 4-minute collection is due. Polling stops when the tab is hidden, and when you come back the page fetches again straight away if the data is stale.

The logic that joins results to anchors, groups cities and computes the physics is in one dependency-free module, lib/atlas.js. The Node collector and the browser both import it, so the snapshot and the live view can’t disagree about how a city is calculated. If the snapshot is missing, the page builds everything from the API on its own.

History without data commits#

Each city’s slip has a 7-day hourly chart with the fibre floor drawn as a dashed line. The obvious way to keep a rolling history on GitHub Pages is to commit JSON to the repo every hour, which floods the history with data commits.

latency-atlas doesn’t commit any data. The data/ folder is in .gitignore. Each workflow run downloads the history.json that’s already deployed on the live site, adds the new hour, trims anything older than 7 days and deploys the result. The live site stores its own history. If the download fails, for example on the very first run, the history starts again from empty.

One 504 failed the first deploy#

The first deploy failed: the RIPE Atlas anchors API returned a single 504 during the collection, and the workflow stopped. The second commit wraps every collector request in a retry that waits 5, 20 and then 60 seconds after network errors, 5xx responses and 429s. Other 4xx responses still fail straight away, because retrying them won’t help.

Point it at your own city#

The project is meant to be forked. Each anchor has its own mesh measurement, so moving the map to another city means changing three IDs and the city name:

  1. Find an anchor in your city with https://atlas.ripe.net/api/v2/anchors/?search=<city>.
  2. Find its mesh ping measurement: the one whose description starts with “Anchoring Mesh Measurement”.
  3. Update MEASUREMENT_ID, ORIGIN_ANCHOR_ID and ORIGIN_PROBE_ID in lib/atlas.js, and the city name in the collector, the page and app.js.

The map recentres on the new anchor’s coordinates automatically. To deploy, set GitHub Pages to deploy from GitHub Actions and run the workflow once.

The limits#

  • Coverage is uneven. Anchors cluster in Europe and North America, while Africa, South America and Central Asia have few. The map shows those gaps instead of filling them in.
  • Locations come from the anchor hosts. A wrong coordinate distorts that city’s physics comparison. The faster-than-light check catches the bad cases, but not the merely inaccurate ones.
  • It’s IPv4 only. An IPv6 mesh for the same anchor exists, and adding it is an open option.
  • Scheduled workflows pause after 60 days with no repository activity. The page keeps working from live polling, but the snapshot and the history stop updating until the workflow is re-enabled.
  • The fibre floor is a straight line. No real cable follows the great circle, so even a perfect network can’t reach 1×. The floor is a lower limit, not a target.

What I wanted was for someone to open the map, flip to Delay, and see the gap between the network and physics without reading a single number. For a finer look, every city’s slip shows the anchor, its network and the time of the measurement.

cd ~/blog