Sign in to follow this  

How to determine the distance between two computers by their IP adress

This topic is 2541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,
I'm a newbie in network. I'd like to know if it's far or near between two computers, by their IP adress or by their ping value( the latency between them)?
Can anyone tell me these in detail?
Thanks in advance!

Share this post


Link to post
Share on other sites
The only effect distance has on ping time is the lower bound - two computers X km apart cannot have ping time less than Y, bounded by speed of light and length of wire connecting them. For example: s = 300000km/s*0.65 * 0.147s = 28665 / 2 ~= 14300km. So ping of 147ms would mean that servers are connected with at most 14300km of fiber. Actual distance will be much shorter.

Other than that, due to latency of network stack processing, different priorities, different routes, different bandwidth, ping isn't closely related to distance. For example, it's not uncommon for intercontinental connections to have lower ping times than intracontinental, especially for high profile sites - they simply sit directly on the backbone, while smaller sites are deep within data centers on oversubscribed and virtualized systems.

Share this post


Link to post
Share on other sites
In addition, if you simply have the IP addresses of two computers (without access to one or the other), you could only determine the ping from your computer to theirs. This would get you an (approximate) upper bound of the sum of the pings for the ping between the two computer, but in reality it could be significantly lower.

However, there are IP-lookup sites which try to give geographic locations to IP addresses. They're not great (eg: mine comes up as the nearest major city, which is over 50 miles away), but if you only need very general locations you can try them and some IPs will come up very precisely. For example, here's one.

Share this post


Link to post
Share on other sites
Simply using ping is not going to work as Antheus mentioned. Ezbez is correct and it's really the only way you can do it. Note that even this isn't 100% accurate because if someone uses a proxy or another trick then it's a lot harder to tell where they're coming from, if at all.

Here is an easy method to get you started though:
1) Get the Geolocation via IP address (This is a cheap way. If you are serious about this then you will need to buy a Geolocation database that has all of this information in it).

2) Calculate the distance based on the latitude and longitude points.


If you are programming smart devices then they will have something in the API for obtaining the locations. For instance, GPS will give you the latitude and longitude points.

Share this post


Link to post
Share on other sites
There are a number of companies that provide exactly this service. Maxmind is one of the cheapest, but also one of the least accurate. Banks that do shopping fraud controls will use some of the higher-end providers.

If you want to get started with a free service for smaller volumes (less than 1k queries per day) you can try geoio.com
To reduce the number of calls, you can cache the look-up based on a class C mask, and store for some time (say, four weeks).

Share this post


Link to post
Share on other sites
Quote:
Original post by skyman_cn
Thank you very much, hplus0603,UltimaX,Ezbez,Antheus.
Ask another question, how to select the nearest node in the P2P network? Which is the criterion? the latency?
Thanks.

It depends on your usage.

You may prefer a higher bandwidth or a lower latency for your particular application. If you are trying to get a small amount of data to a destination rapidly, prefer low latency. If you are trying to get a large amount of data rapidly, prefer high bandwidth.

In a P2P environment, you should also be concerned about connectivity. You may have a nearby node with great bandwidth and low latency, but it may be no good for peers if the node is unable to talk to others. This can be the case for a node living in a network DMZ; You may be able to see a very fast connection to a local network node, but that node is completely useless to the outside world.


It takes a little bit of computer science work, but you can create connectivity graphs that are shared across the P2P network. This can be important for partially connected networks where you need to figure out your own routing.

Share this post


Link to post
Share on other sites

This topic is 2541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this