20

Here's the ping output from Singapore:

64 bytes from 8.8.8.8: icmp_seq=1 ttl=50 time=1.96 ms

Singapore to 8.8.8.8 = ~2ms

Another ping output:

64 bytes from 23.59.8.146: icmp_seq=81 ttl=44 time=66.1 ms

Singapore to 23.59.8.146 = ~66ms

Now my question is, even if both servers reside in the USA (found from https://ipinfo.io/), how come the first server's latency/RTT is surprisingly lower?

6
  • 20
    It is called anycast.
    – Ron Maupin
    Apr 23, 2020 at 12:42
  • 16
    First, Ron is correct, anycast allows 8.8.8.8 to exist in multiple physical locations. So, chances are the 8.8.8.8 you pinged, is physically in Singapore, or close by. It's also worth noting, that the physical address associated with an IP address is simply where it is REGISTERED, not necessarily physically located. Apr 23, 2020 at 12:45
  • 13
    A signal in fiber propagates a maximum of 200 km per millisecond, so that's the absolut maximum distance of your destination physically. In reality, active components in the data path eat away from that, so it's actually less. Accordingly, it's literally impossible to ping from Singapore to the US in that time frame.
    – Zac67
    Apr 23, 2020 at 14:51
  • 3
    Given that a light-millisecond is about 186 miles / 300 km, then either A) someone has dramatically sped up light, B) someone else has dramatically compressed distance, or C) the 8.8.8.8 which answered your ping isn't in the US. Apr 25, 2020 at 14:51
  • 2
    Sanity check on results, light takes 5.6ms to travel 1000 miles :) Apr 25, 2020 at 23:28

2 Answers 2

35

As others have pointed out, Google DNS uses IP anycast, which allows multiple servers in multiple locations to effectively share an IP address. Google (like many others) has many servers around the world that will respond to 8.8.8.8.

So when you ping that address, the server that responds is the one closest to you, perhaps one in your country.

Note that geo-location services, like ipinfo, use a variety of techniques, including registration information. All of it is an estimation.

5
  • I'd like to particularly point out that ALL websites (HTTP / DNS) on Cloudflare also benefit from the Anycast technology - their points of presence (PoP) are all around the world.
    – iBug
    Apr 24, 2020 at 6:40
  • 3
    @iBug Anycast technology generally can't be used for connection-based protocols like HTTP, only datagram protocols like DNS and Ping. CDNs like Akamai and Cloudflare use other technologies to redirect you to the closest PoP.
    – Barmar
    Apr 24, 2020 at 16:28
  • 5
    @Barmar blog.cloudflare.com/… - At CloudFlare, we've done a significant amount of engineering to allow TCP to run across Anycast without flapping Apr 24, 2020 at 16:45
  • 6
    @Barmar I'm sure Anycast doesn't by itself break connection-based protocols. If routing is configured properly, then for a given source host, in a given time period, all packets are routed to a certain PoP, which surely goes along with connection-based upper-level protocols. For Cloudflare (and I would suspect it's actually the majority of Anycast players), the magic is BGP, which is pretty good at providing consistent routes.
    – iBug
    Apr 24, 2020 at 18:16
  • 1
    @Barmar: It's fine for short-lived connections. DNS is frequently connection-based as well – the same 1.1.1.1 or 8.8.8.8 have always supported regular TCP which is required for compliant DNS services, and the same addresses now also serve DoT (TLS) and DoH (HTTPS) both of which are also TCP-based. (And there's an actual website at https://1.1.1.1/ as well?)
    – user1686
    Apr 25, 2020 at 18:02
9

IP geolocation databases essentially represent a geolocation company's guess as to where an IP is located. Often they are based on the addresses in whois registrations, sometimes supplemented with the geolocation company's own research. For end-user IPs they are usually accurate to country level but for infrastructure IPs even that is frequently off.

When it comes to infrastructure there is often little relationship between IP addresses and physical location. Consider for example a point to point link between Europe and America. The interfaces at the two ends of the link will likely have adjacent IP addresses despite being on separate continents, no geolocation database provider is going to want to include that level of detail in their database.

And some addresses actually exist in more than one location at the same time. The routing infrastructure doesn't actually know or care if all the routes for a given address block actually end up delivering the data to the same place or not. Some service operators deliberately exploit this in a technique called "anycast", They deploy servers at multiple locations which all respond to requests on the same service IP* and then advertise the IP block from all the locations. This is why you see low pings to 8.8.8.8 from all over the world.

* In addition to the shared service IP the servers will likely have at least one non-shared IP that is used for management and for outgoing requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.