Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whereamicloud-1.2.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whereamicloud-1.2.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file whereamicloud-1.2.1.tar.gz.

File metadata

  • Download URL: whereamicloud-1.2.1.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

Hashes for whereamicloud-1.2.1.tar.gz
Algorithm Hash digest
SHA256 0e0ca1ec8b18785a0f55499da02084280a1ccdc155cb17d2037a3e9c4da97f26
MD5 dc606c303d183ac7d2a59a731a865cb9
BLAKE2b-256 0e969fef6d76bb0e0c4e6fc0c2f988da5c62d8c74b89ec67b55be475448c6132

See more details on using hashes here.

File details

Details for the file whereamicloud-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: whereamicloud-1.2.1-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

Hashes for whereamicloud-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68fae71cf90939e1bb6dac9e88ef15fc7a187da29073e7a6db8ac2d28fbbce87
MD5 e25b7b1247df2e46b676e4777b0c8804
BLAKE2b-256 ee6c230e8248e133f447f44a552cfef792db70fd8ab86d1db74b4c3611dce8f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page