It is difficult to imagine the internet as a complex network of propietary wires and routers. The scale is so massive that we employ metaphors like “the cloud” to ease the psychic burden of understanding this crucial infrastructure. Tools like traceroute help to demystify the network, but still fail to communicate the internet’s sheer size and physicality. How many miles do packets need to travel before they reach their intended destination? When you want to see that cat video your grandmother sent you, how many countries does your signal traverse? I wrote a script that tries to approximate the distance in miles that a get request needs to travel to get to its intended destination.
The script first listens on port 80 for outbound traffic to an inputted destination to determine how many packets were sent. It then performs a basic trace route to get the IP addresses of the network hops along the way. Finally the script will geolocate those IP addresses and measure the distance between them.
Of course geolocation of IP addresses is often painfully incorrect, however my goal with this script is to at least begin to quantify distance.