0

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?

Jake
  • 1,172
  • 6
  • 28
  • 48

2 Answers2

2

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.

Khaled
  • 36,533
  • 8
  • 72
  • 99
1

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.

Aaron
  • 2,968
  • 1
  • 23
  • 36
  • 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 02 '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 02 '11 at 20:10