Pings various known datacenter locations to triangulate itself
Project description
Where Am I?
whereami is a tool which answers the question of where a system is located on Earth. Or on another planet, or space, as long as the system can reach other systems with ICMP or HTTP.
How does it work?
whereami uses Ping / ICMP Echo Requests and a list of KNOWN systems to approximately infer where it must be located based on the response times of other systems.
Install pipx https://github.com/pypa/pipx
TLDR:
# install poetry using pipx (installs as a standalone system package)
pipx install poetry
# use poetry to install dependencies
poetry install
# run the package as a module
python3 -m whereami
What's the point?
Believe it or not, it can be somewhat difficult - or even impossible - to pinpoint exactly where a system is located - even as you're using it. You usually only ever have an approximation.
There are various classic systems and techniques which can help:
- Traceroute
- Whois
- BGP Looking Glass
- DNS
- GeoIP Databases
Used together, we can get a pretty good indicator of WHERE in the world our system is, and which networks host it, But getting a really close pinpoint is much harder.
Generally the databases are not current and the information about physical location is variable and opaque, by design.
This is because ISP's, DataCenter Providers and Cloud Hosting Providers don't want to give away too much information for security and privacy reasons. They'll tell you a system is inside a region and inside an availability-zone but not which DataCenter and certainly not any information about internal datacenter architecture.
Why would I care?
If you're deploying distributed/connected workloads and resources in various locations, their distance in hops matters from a performance and reliability perspective.
Generally speaking, the less distance a packet needs to travel the less it will cost and the more reliable its journey will be.
Sure, you can put everything in a single DC or region, at the cost of performance for edge customers. You can also garner cost savings by running selected workloads on cheaper hardware.
If you're looking to assess network path performance between two points, this is a useful tool. Often you'll find the results switch between two providers which indicate mostly equal performance... once this factor is taken out we can focus on things like cost or reliability to make decisions.
How does this tool know its own location?
It's a very simple concept, pinging out to known hosts and narrowing down to find the fastest one.
If a host is INSIDE our datacenter, then we will get the lowest possible response-time to our ping.
The real power comes from the data in locations.json. The more accurate and complete data, the better the performance of this tool.
If the dataset of locations and pingable IP's covers every datacenter in the world, this tool can easily determine that it's in the same DC as the fastest responding host.
Contributing
We need to build out the locations.json file to contain as many known hosts inside datacenters as possible.
If you own a system which consistently responds to pings and you know the datacenter within which it's located, you can add it under the appropriate region in locations.json
locations.json File Format
This file should provide as many different providers and DC's as possible under each region for best accuracy.
locations.json
{
"[region]":
{
"[provider_name-dc_code]": "[pingable_address]",
"[...]": "[...]"
},
"[...]": {}
}
Scraped Data
Cloudping https://www.cloudping.info/ Has a list of HTTP pingable IP's which I've scraped into JSON. Credit to Michael Leonhard for putting this list together https://gitlab.com/leonhard-llc/cloudping.info
wget https://www.cloudping.info/ | grep -A 3 "<tr>" | grep "<td" > test.csv
import json
f = open("test.csv")
lines = f.readlines()
output = {}
for line in lines:
if line.find("<td>") > 0:
left = line.split(">")[1]
right = left.split("<")
region_name = right[0]
output[region_name] = {}
# Get the provider
if line.find("<b>") > 0:
provider_name = line.split('/')[2]
# Get the ping URL
if line.find("pingUrl") > 0:
ping_url = line.split("/")[2]
output[region_name][provider_name] = ping_url
print(json.dumps(output))
TODO:
* Distribute as pip module
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whereamicloud-1.2.0.tar.gz.
File metadata
- Download URL: whereamicloud-1.2.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd5a9cc9d0129f13815d885f3a0997dc2e26ed5c0913586ef0ddceacce1520a3
|
|
| MD5 |
7d21b155ef6530af88fdc46400ce7fcc
|
|
| BLAKE2b-256 |
45bd9bb619d137666f7529aa355dec31ae8b10cd027fe4c4337385180b7835bf
|
File details
Details for the file whereamicloud-1.2.0-py3-none-any.whl.
File metadata
- Download URL: whereamicloud-1.2.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b47c045b1495d14438751e6548180bb8c768af4a5d46498f78d4067d2e92a133
|
|
| MD5 |
69feaefd1d7a1d1b7896a0d90b0cc282
|
|
| BLAKE2b-256 |
21c91fff392afa8fe2fb64bd8ae19ff04d6b2576aaa17c1edeeabdcfb3007b66
|