2

I've been working on this project for a while. I found out that there any many free databases which map between IP number (sort of manipulation of the IP adress) to a long and latitude cordinates. Howerver , these database accuracy is realy bad.

I tried to merge between some databases , and to the best frequent answer or the "average" among answers.

That did improve my accuracy , but not as much as i expected .

I have another idea - using Traceroute command to figure out to the path to this target , and according to the hops on the way to determine where my target is.

I'm looking for new ideas , or some kind of protocols that will help to figure out the location. I've been thinking about public cookies , but that might be too invasive . Furthermore , a friend told me that SNMP protocol might help me , but it is highly complicated to implement.

My goal is to deteremine in which city this computer is. This is the accuray i'm aiming it.

thanks and sorry for my english!

RanZilber
  • 1,840
  • 4
  • 31
  • 42
  • Have you looked at MaxMind (commercial) accuracy, and how does your aim compare to it? – CharlesB Nov 03 '11 at 16:15
  • @CharlesB -Yes , I did look on MaxMind. Thier free database is far worse than the commerical one . Thier paid service is realy good , but my goal is to get that information without paying :) . I'm not looking for super-accurate determination. I just want to know in which city the remote computer is . – RanZilber Nov 03 '11 at 16:20

2 Answers2

1

You could use HTML5's new geolocation. Example : http://html5demos.com/geo

(taken from link above)

Code:

<script>
function success(position) {
  var s = document.querySelector('#status');

  if (s.className == 'success') {
    // not sure why we're hitting this twice in FF, I think it's to do with a cached result coming back    
    return;
  }

  s.innerHTML = "found you!";
  s.className = 'success';

  var mapcanvas = document.createElement('div');
  mapcanvas.id = 'mapcanvas';
  mapcanvas.style.height = '400px';
  mapcanvas.style.width = '560px';

  document.querySelector('article').appendChild(mapcanvas);

  var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
  var myOptions = {
    zoom: 15,
    center: latlng,
    mapTypeControl: false,
    navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);

  var marker = new google.maps.Marker({
      position: latlng, 
      map: map, 
      title:"You are here!"
  });
}

function error(msg) {
  var s = document.querySelector('#status');
  s.innerHTML = typeof msg == 'string' ? msg : "failed";
  s.className = 'fail';

  // console.log(arguments);
}

if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(success, error);
} else {
  error('not supported');
}

</script>

As for databases, I've been down that road, there isn't a perfect solution all the databases will only give you around 50 mile accuracy.

With this you could use Ajax to push the location data to your server.

Patrick Lorio
  • 5,520
  • 11
  • 45
  • 74
  • -This is nice example . But notice that it is only accurate for connections throw WIFI. I have lan in my house , and a Wifi. When i was connected by the lan , it spotted me 25 miles away , in other city. But , when i was connected to my Wifi it was super accurate. My explation is that google has been mapping around all the world Wifis and access points and according to your signal strengh it can determine where you are located. If you better explation enlighten me :) – RanZilber Nov 03 '11 at 16:24
  • 1
    It works by the browser. HTML is client side, basically the browser uses methods: "GPS, WLAN AP-based location, IP location". Here is more : http://stackoverflow.com/questions/2641948/how-html5-geolocation-feature-works I don't think you'll get any better accuracy then 25 miles away by using a database. – Patrick Lorio Nov 03 '11 at 16:37
  • I know I wouldn't get that accurate. Thats why im looking for new ideas. The problem with this HTML-5 method is that it aint accurate either. I've been testing it with some examples with LAN and it was poor . And as i said before- using this tool with WLAN is super accurate, but I'm mainly intersted in LAN users. – RanZilber Nov 03 '11 at 16:46
  • 1
    A theoretical idea that will probably render bad accuracy but could work is having several servers that connect to the client determine the latency between each and use that data to triangulate the location of the client. Other than that I don't think it's possible to determine the location without having access to the internet providers information. They're the only people that know location of each of their ips at a given time. – Patrick Lorio Nov 03 '11 at 17:00
  • - and is it possible to infer who is the ISP from an IP? I'm not sure there is correlation ... . Maybe there is a way to find out the IP allocation protocol of an ISP? Theoreticly speaking if I can make ISP believe i'm somewhere in the earth I might be able to get the inverse goal ( From location -> IP) and that might help me get my real goal. But I realy dont have a clue how to do that – RanZilber Nov 03 '11 at 20:23
  • That could be possible but I don't think you can get location -> IP from the ISP through some sort socket, (if you could it would be a unique method foreach ISP). For IP -> ISP : http://stackoverflow.com/questions/855967/how-do-i-retrieve-the-visitors-isp-through-php – Patrick Lorio Nov 03 '11 at 21:03
1

It cannot work reliably. E.g., take the following scenarios:

  • I have a VPN at my company.

    With this, I can get an IP address from my company without being physically present.

    Where am I? At the place of my company? Or at the other side of the world, where I spend my holidays?

  • I have a dialup connection to my provider.

    Where am I? At the point where the dial-in node sits, or where I really am?

These two examples show that the IP address itself does not hold (and cannot hold) any geographical information. It can be related to such by experience - users enter their (dynamical?) IP address into a database, related with their current IP address, but that's all. So to say, it is inherent to the system that it cannot be exact.

If you look for the "average user", which goes online via ADSL and a dynamic IP address, you don't know how big the area is where the provider take the adresses from the same pool. After I kill my connection, the user getting this IP address next might be 50 km, 500 km or even 2000 km away from me (depending on the country you live in).

Even a fixed IP assigned to a business customer might change its location: the business moves, or it ceases to exist and the IP address gets assigned to a completely different customer.

And all this stuff will change again in the next months/years with IPv6 getting more and more popular.

glglgl
  • 89,107
  • 13
  • 149
  • 217
  • I gave you +1 . This is correct. VPN , Proxy and TOR are bummer . But i'm looking for the "average user". I'm looking for the simple case , after I'll solve it - ill go on for the harder stuff. VPN is probably the easyest because all you have to do is figure out where the gateway is. – RanZilber Nov 03 '11 at 16:39
  • 1
    Updated to clarify that VPN, Tor etc. are only examples. – glglgl Nov 04 '11 at 08:38