3

I'm implementing a browser extension which should connect to the nearest server to test the ping speed.

To have more details, kindly have a look on SpeedTest, it first calculates the ping time.
And to calculate this ping time, it detects the nearest servers and then pings it.

For example, here's the nearest servers detected by SpeedTest. I marked them in red arrows

SpeedTest detected nearest servers


How does SpeedTest detect these servers ?

i.e. How can I detect the nearest servers and their locations in javascript as SpeedTest does ?

Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
  • I found some geoip libraries that have some useful functionalities, like detecting your geographical place based on your ip, for example http://www.maxmind.com/en/web_services, but i didn't find any function in documentation which get list of servers (ip/long/lat), BTW, i'm not sure whether i took the right path in investigation :) – Ashraf Bashir Jun 10 '13 at 15:31
  • 1
    That information is quite possibly precomputed, and certainly is probably not computed live on the client. If that is computed at run-time it almost definitely would be done on the server, not in client-side js – Ben McCormick Jun 10 '13 at 15:35
  • You are totally right. That's why I'm looking for a webservice to do so, so that i may connect to it in JS. But I didn't manage to find one – Ashraf Bashir Jun 10 '13 at 15:39

1 Answers1

2

What speedtest is doing is not a real "ping" in the sense of having the client machine run a ping operation. I have no knowledge of their exact methods (and I believe they use flash rather than pure JS, or at least used to), but I would guess that they try to access a small resource (an empty text/image file?) on each of these machines, and then time the response back. That is certainly one way to implement this anyway.

Ben McCormick
  • 25,260
  • 12
  • 52
  • 71
  • Yes, you are right, they just connect to a simple txt file many times, using this url http://speedtest1.linkdsl.com/speedtest/latency.txt?x=1370874660967, as you may have noticed, they first detected the presence of speedtest1.linkdsl.com server. where linkdsl is an ISP in Egypt (the nearest one to my location). I'm trying to get the nearest server too, I'm also wondering are these servers distributed all over the world as private servers for testspeed !!?? Is there a service which I can connect to to get nearest server back to me ? – Ashraf Bashir Jun 10 '13 at 15:36
  • 1
    It appears they are in fact private servers: https://support.speedtest.net/entries/20860621-Why-does-Speedtest-net-recommend-a-nearby-server- – Ben McCormick Jun 10 '13 at 16:09
  • 1
    Marked as answer for your last comment which contains the solution (i.e. acquiring private servers distributed around the world). – Ashraf Bashir Jun 23 '13 at 15:06
  • I've seen some answers on similar questions in Stack Overflow, stating that the client side sends an HTTP HEAD request to measure ping speed, which makes sense – Sarah Nov 16 '19 at 17:55