Group: comp.os.linux.networking
From: ibuprofin@painkiller.example.tld (Moe Trin)
Date: Friday, April 11, 2008 2:54 PM
Subject: Re: Calculating subnet distance.

On Thu, 10 Apr 2008, in the Usenet newsgroup comp.os.linux.networking, in
article ,
pramodsharma08@gmail.com wrote:

NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen. Find a real news server.

>I have a requirement to do in my application as below.
>1. I have a list of Sites from where I can download.
>2. Calcualte the nearest site from the host , which can be used to
>download.
>3. Nearest site can be calcualted on the basis of geogriphical
>distance and bandwidth.

The nearest site is RARELY based on geographical distance. It depends
on who your upstream connects to, and who the upstream of the remote
connects to. A few seconds playing with the 'ping' command (yes,
many sites block ping) and looking at the TTL of the responses will
provide such a clue. Try a ping to Mission College, verses one to
yahoo, google, DeAnza or Bezerkeley.

>Problems:
>- I cannot use ICMP protocol as may be some sites have disabled ping.
>- I cannot use raw socket over UDP as came to know that raw sockets on
>windows will be over soon.

windoze is not our problem. I wouldn't recommend UDP as that may also
be blocked, or routed with lower priority.

>- I have to write multiplatform common code (windows , UNIX type).

Look at the TTL of the returning packets. Generally speaking, most O/S
use one of five initial TTLs on a TCP packets: 32 (rare, but some
versions of windoze), 60 (some old IRIX and True64 boxes), 64, 128, or
255. Few places on the Internet are more than 30 hops away. Thus, if
you receive a packet with a TTL of 46, it _PROBABLY_ came from a box
18 hops away with an initial TTL of 64.

>Can anyone suggest me simple and effective method to determine the
>nearest site ?

You _are_ posting from a search engine - and it's not as if this idea
is brand new. While TTL is universal, it's not the only thing in the
packet headers that can be used. Looking at RFC1323 _might_ be worth
the effort.

Old guy

Safety Articles | Usenet Groups | Usenet News | Bluegrass