Home > 资源分享 > 使用JS模拟系统ping命令

使用JS模拟系统ping命令

March 15th, 2011 发表评论 阅读评论

JS虽然发送不了真正Ping的ICMP数据包,但ping的本质仍然是请求/回复的时间差,HTTP自然可以实现此功能。当然,在请求时无法统计HTTP头部的长度,所以当请求数据包长度在最大传输单元临界点时,额外的HTTP头可以导致IP分组,因此存在一定的误差。

以下是一个示例:

转载请以超链接注明来自  云在天边看世界
本文永久链接  http://www.tangblog.info/2011/03/15/js-ping.html

分类: 资源分享 标签:

  1. avatar
    菜鸟 2014-12-07 at 21:31 |#10

    @admin 博主你好,我不懂html语言(真的不会),跪求“使用JS模拟系统ping命令”的完整版原版代码,最好是我复制你的代码到“1.html”中可以直接使用,就好像是在你这网页中打开的一样,太感谢了!
  2. avatar
    三七 2012-07-04 at 14:37 |#9

    非常不错啊,
  3. avatar
    sigma 2011-03-25 at 00:22 |#8

    @admin
    谢谢,之前一直搞不定的就是奇偶问题
  4. avatar
    admin 2011-03-22 at 21:25 |#6

    @sigma
    可以这样写:
    <ul style='float:left;width:50%;' class='xoxo blogroll'>{%for link in blogroll%}{% if not forloop.counter|divisibleby:"2" %}
    <li><a href="{{link.href}}" title="{{link.linkcomment}}" {% if link.linktarget %}rel="{{link.linktarget}}"{%endif%} target="_blank">{{link.linktext}}</a></li>{%endif%}{%endfor%}
    </ul>
    <ul style='float:right;width:50%;' class='xoxo blogroll'>{%for link in blogroll%}{% if forloop.counter|divisibleby:"2" %}
    <li><a href="{{link.href}}" title="{{link.linkcomment}}" {% if link.linktarget %}rel="{{link.linktarget}}"{%endif%} target="_blank">{{link.linktext}}</a></li>{%endif%}{%endfor%}
    </ul>
    
  5. avatar
    sigma 2011-03-20 at 00:47 |#5

    杯具,html格式出问题。。。
  6. avatar
    sigma 2011-03-20 at 00:46 |#4

    全是timeout
    btw:请问一下,阁下的友链是怎么分成两栏显示的?
    我的那部分代码是:
    {%for link in blogroll%} <li><a href="{{link.href}}" target="_blank">{{link.linktext}}</a></li> {%endfor%}
    我不知道如何将这些东西放到两个ul上,就是不知道如何把link选成两类,能提示一下或者给我这段代码么,thanks
  7. avatar
    admin 2011-03-17 at 17:23 |#3

    @dengmin
    我这里倒是可以返回时间的。。
  8. avatar
    dengmin 2011-03-16 at 17:11 |#2

    Reply from http://www.tangblog.info time=1516ms
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
  9. avatar
    Mucid 2011-03-16 at 12:44 |#1

    要是用js调用操作系统的ping
  10. avatar
    Gary 2011-03-16 at 08:58 |#1

    Pinging http://gary-blog.com:
     
    Reply from http://gary-blog.com time=3256ms
    Reply from http://gary-blog.com time=845ms
    Reply from http://gary-blog.com time=823ms
    Reply from http://gary-blog.com time=825ms
    Reply from http://gary-blog.com time=846ms
    Reply from http://gary-blog.com time=2025ms
    Reply from http://gary-blog.com time=1113ms
    Reply from http://gary-blog.com time=860ms
    Reply from http://gary-blog.com time=835ms
    Reply from http://gary-blog.com time=1959ms
    Reply from http://gary-blog.com time=1101ms
    Reply from http://gary-blog.com time=845ms
    Reply from http://gary-blog.com time=803ms
    Reply from http://gary-blog.com time=826ms
    Reply from http://gary-blog.com time=864ms
    Reply from http://gary-blog.com time=820ms
    Reply from http://gary-blog.com time=834ms
     
    Ping statistics for http://gary-blog.com:
      Packets: Sent = 17, Received = 17, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
      Minimum = 803ms, Maximum = 3256ms, Average = 1145ms


    貌似比较不稳定
Comment pages
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
/static/smilies/icon_twisted.gif /static/smilies/icon_smile.gif /static/smilies/icon_cry.gif /static/smilies/icon_question.gif /static/smilies/icon_razz.gif /static/smilies/icon_mrgreen.gif /static/smilies/icon_sad.gif /static/smilies/icon_evil.gif /static/smilies/icon_exclaim.gif /static/smilies/icon_redface.gif /static/smilies/icon_biggrin.gif /static/smilies/icon_surprised.gif /static/smilies/icon_eek.gif /static/smilies/icon_confused.gif /static/smilies/icon_cool.gif /static/smilies/icon_lol.gif /static/smilies/icon_mad.gif /static/smilies/icon_rolleyes.gif /static/smilies/icon_wink.gif /static/smilies/icon_idea.gif /static/smilies/icon_arrow.gif /static/smilies/icon_neutral.gif
capacha 请输入验证码(不区分大小写)