We have ipinfo at home or how to geolocate IPs in your CLI using latency
84 points
5 hours ago
| 10 comments
| blog.globalping.io
| HN
VladVladikoff
28 minutes ago
[-]
If I understood the post the author just takes the location of smallest ping as the winner. This seems like a very rudimentary approach. Why not do triangulation? If you take each ping time as a measurement of distance between two points, you should be able to ping from a random selection of IPs and from there calculate the location.
reply
jimaek
22 minutes ago
[-]
I talk a little about it in the article, but the main goal was to build something simple that works as proof of concept.

This brute force approach works much better than I expected as long as you have enough probes and a bit of luck.

But of course there are much better and smarter approaches to this, no doubt!

reply
tomtomtom777
4 minutes ago
[-]
How did you know how well these results work?

You mention the quality several times in the article but it's not clear how this is verified. Do you have a set of known-location-ip-addresses around the world (apart from your home)? Or are we just assuming that latency is a good indicator?

reply
direwolf20
23 minutes ago
[-]
Packets don't travel in straight lines.
reply
coffeeri
6 minutes ago
[-]
This is/was also my take. I’m skeptical that a probe-based network can be granular enough to reliably pinpoint a city, especially when some paths are much better connected than others (fewer hops, uncongested fiber, no throttling).

However, ipinfo still appears to rely on active probing to triangulate geolocation data, which suggests they believe these routing asymmetries can be modeled or averaged out in practice.

https://ipinfo.io/blog/ipinfos-probe-network

reply
jimaek
4 hours ago
[-]
This is a little project exploring the feasibility of using a service such as Globalping for geo location needs.

I had fun making it but please note that the current implementation is just a demo and far from a proper production tool.

If you really want to use it then for best possible results you need at least 500 probes per phase.

It could be optimized fairly easily but not without going over the anon user limit which I tried to avoid

reply
kortex
36 minutes ago
[-]
I wonder if you could optimize for reducing the total probe count (at the expense of possibly longer total time, though it may be faster in some cases) by using some sort of "gradient descent".

Start by doing the multi-continent probe, say 3x each. Drop the longest time probes, add probes near the shortest time, and probe once. Repeat this pattern of probe, assess, drop and add closer to the target.

You accumulate all data in your orchestrator, so in theory you don't need to deliberately issue multiple probes each round (except for the first) to get statistical power. I would expect this to "chase" the real location continuously instead of 5 discrete phases.

I just watched the Veritasium video on potentials and vector fields - the latency is a scalar potential field of sorts, and you could use it to derive a latency gradient.

reply
jimaek
28 minutes ago
[-]
Yes, most likely there are multiple algorithms that could be used to get better results with fewer probes, but I'm not smart enough to do the math and implement them.
reply
kortex
10 minutes ago
[-]
The simplest is drop the longest latency probe, and add a new one in the proximity of the fastest.
reply
navigate8310
45 minutes ago
[-]
> Globalping is an open-source, community-powered project that allows users to self-host container-based probes. These probes then become part of our public network, which allows anyone to use them to run network testing tools such as ping and traceroute.

How's this different from RIPE ATLAS?

reply
jimaek
30 minutes ago
[-]
Atlas is great but it is focused more on academic research and professional use.

Globalping offers real-time result streaming and a simpler user experience with focus on integrations https://globalping.io/integrations

For example you can use the CLI as if you were running a traceroute locally, without even having to register.

And if you need more credits you can simply donate via GitHub Sponsors starting from $1

They are similar with an overlapping audience yet have different goals

reply
navigate8310
40 minutes ago
[-]
> Group and sort the results; the country with the lowest latency should be the correct one

Sometimes residential ISPs (that hosts the probe) may have a bad routing due to many factors, how does the algorithm take that into account?

reply
direwolf20
22 minutes ago
[-]
You have a lot of probes so you also have one with good routing
reply
Havoc
3 hours ago
[-]
Bit surprised this works. Latency variability is huge and sometimes quite disconnected from geo location. I recall talking to someone in NL and realised I've got better latency to NL content from the UK than he did. Presumably better peering etc.
reply
matt-p
1 hour ago
[-]
Could just be local loop latency, in VDSL or DOCSIS you can get 5-15ms of latency just in your first 1KM. London (e.g Telehouse) > Amsterdam is only about 7ms.
reply
vasco
1 hour ago
[-]
Wouldn't you just be closer to the closest PoP and requesting mostly cached content? With how connected amsterdam is they couldn't be around there. Also depending on when it was up until like 7-8 years ago even in major city centers there was no fiber in most places in NL. Now it's mostly covered.
reply
greyface-
3 hours ago
[-]
How feasible would it be for the host under measurement to introduce additional artificial latency to ping responses, varying based on source IP, in order to spoof its measured location?
reply
Retr0id
2 hours ago
[-]
Not-impossible, but it would be a whole lot simpler to just not respond to pings in the first place.
reply
Retr0id
44 minutes ago
[-]
But also, as mentioned in https://news.ycombinator.com/item?id=46836803 , someone can still probe the second-last hop and get pretty close.
reply
altairprime
2 hours ago
[-]
Courtesy of Xfinity and Charter overprovisioning most neighborhood’s circuits, we already have that today for a significant subset of U.S. Internet users due to the resulting Bufferbloat (up to 2500ms on a 1000/30 connection!)
reply
p1mrx
20 minutes ago
[-]
Have you seen excessive bufferbloat on a DOCSIS 3.1 modem?
reply
walletdrainer
2 hours ago
[-]
Totally feasible.

You could do even cooler tricks, like https://github.com/blechschmidt/fakeroute

Pointless? Almost certainly.

reply
maccard
2 hours ago
[-]
Totally feasible but a bit like all these situations - it’s not happening in practice.
reply
danuel
14 minutes ago
[-]
Hacks
reply
lpapez
2 hours ago
[-]
Amazing idea and execution, the sort of stuff I wish there was more of on HN.
reply
westurner
54 minutes ago
[-]
Wi-FI RTT is more accurate than trilateration with RSSI but requires hw support.

IEEE 802.11mc > Wi-Fi Round Trip Time (RTT) https://en.wikipedia.org/wiki/IEEE_802.11mc#Wi-Fi_Round_Trip...

/? fine time measurement FTM: https://www.google.com/search?q=fine+time+measurement+FTM

reply
xyst
57 minutes ago
[-]
Tried with an IP allocated to a major wireless network operator. It was far off but also ran out of credits when trying with higher limits on subsequent attempts.

Seems tool is relying on ICMP results from various probes. So wouldn't this project become useless if target device disables ICMP?

I wonder if you can "fake" results by having your gateway/device respond with fake ICMP requests.

reply
jimaek
54 minutes ago
[-]
I talk about it a bit in the article. The easiest solution is to use the last available hop. In most cases its close enough to properly detect the country even if the target blocks ICMP.

Email me if you would like to get some additional credits to test it out, dakulovgr gmail.

reply
DenisDolya
2 hours ago
[-]
Wow, it works !
reply