donglang9880 2012-08-20 09:53
浏览 119
已采纳

来自浏览器的延迟/ Ping测试

I want to check ping from Browser to a Server.

Ping/Latency should not be from Server but from Client's Machine.

I have seen sites like Pingtest.net so it is possible to do from Browser.

Any language will do.

The server ping can also be tested by an UDP packet other than normal shell command ping.

How should i proceed. ?

  • 写回答

2条回答 默认 最新

  • duanjian9148 2012-08-20 10:01
    关注

    Try using XMLHTTPRequest() for javascript. The objective is to make about 10 objects and place them in an array. Then use onreadystatechange in each and every one of them. For the function inside it, use the status 1 to start the timer and status 3 to finish the timer. Use the object Date() to get the times.

    That's the whole idea behind solving that. if you need more just comment my answer and I'll try to make it more complete and "spoily".


    Assuming you know how to program in javascript, this is one idea for a possible solution: You first create an array where you'll insert in each position an instance of XMLHTTPRequest(). Then, you'll create a function that returns a function where:
    The outside function will save some sort of identification towards the "current" request, including a reference to the instance. This function is supposed to be executed right away.
    The inner function is supposed to be used to execute the state and know when to "start" the timer and when to "stop" the timer. Take care of opening the connect and sending the headers to all of 'em, wait to get the answer and finally register the times you got. Do some math and you get the ping.

    That's the whole idea behind this. Good luck!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP