Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a program that allows users to supply a list of hostsname or IPs which I will then find out which host connectivity is faster and connect to it.

And right as I am typing the question in the title, I thought that pinging might be a possibiity, but what other methods can I use since not all hosts respond to pings?

There are a bunch of website that calculate distance between 2 IPs, how does that work?

share|improve this question
up vote 2 down vote accepted

The network distance is measured in number of hops. A tool like traceroute sends ICMP packets with varying TTL values. TTL values gets decremented whenever it is forwarded by another hop (router). When TTL reaches zero, the sender is notified by another ICMP packet (Time exceeded error). Have a look at this page.

The other option is to measure the delay between two nodes. This highly depends on the protocol used and does not give the same result for all protocols for several reasons. For example, different protocols are not given the same priority. Also, different protocols have different connection natures (connection-less vs connection oriented) and so on.

share|improve this answer

I think that you're going the long way around to fix a problem. If you are taking a list of user supplied IPs and then finding out which has the lowest latency, you have to decide what services on these hosts you will be using. Ping would be my guess, but as you point out, they might not respond to that. So what are they responding to? HTTP? Then time that.

share|improve this answer
Will be connecting on TCP consuming the services of a custom database provider. How to time a TCP connection? Send a request and then start a timer? – Jake Dec 2 '11 at 19:10
If you definition of "faster" is the time it takes to reply to a custom database request, then time that. That's how you'll know which one is faster. (If you have cooperation with the other end, ask them how to tell. Perhaps they'll even offer you a specific query for that purpose.) – David Schwartz Dec 2 '11 at 20:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.