最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to detect nearest server to test latencyping speed using Javascript? - Stack Overflow

programmeradmin3浏览0评论

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


How does SpeedTest detect these servers ?

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

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


How does SpeedTest detect these servers ?

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

Share Improve this question edited Jun 10, 2013 at 15:43 Ashraf Bashir asked Jun 10, 2013 at 15:15 Ashraf BashirAshraf Bashir 9,80415 gold badges60 silver badges83 bronze badges 3
  • I found some geoip libraries that have some useful functionalities, like detecting your geographical place based on your ip, for example maxmind./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 Commented Jun 10, 2013 at 15:31
  • 1 That information is quite possibly preputed, and certainly is probably not puted live on the client. If that is puted at run-time it almost definitely would be done on the server, not in client-side js – Ben McCormick Commented Jun 10, 2013 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 Commented Jun 10, 2013 at 15:39
Add a ment  | 

1 Answer 1

Reset to default 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.

发布评论

评论列表(0)

  1. 暂无评论