【问题标题】:Ping timeout issues [closed]Ping超时问题[关闭]
【发布时间】:2023-10-13 01:53:01
【问题描述】:

下午好,

我正在使用三台计算机(在 Linux Mint 14 下)局域网。它们连接到交换机,并且没有任何防火墙。 问题是他们每个人都很难检测到他们的同行之一的失败。

例如,我继续进行该测试: 我从 192.168.0.2 ping 到 192.168.0.3。 10 秒后,我从交换机上拔下 192.168.0.3 ......问题是 192.168.0.2 需要 48 秒才能检测到! 在这里您可以找到该测试的日志

oneadmin@192.168.0.2 ~ $ ping -v -i 1 192.168.0.3
PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
64 bytes from 192.168.0.3: icmp_req=1 ttl=64 time=0.233 ms
64 bytes from 192.168.0.3: icmp_req=2 ttl=64 time=0.236 ms
64 bytes from 192.168.0.3: icmp_req=3 ttl=64 time=0.220 ms
64 bytes from 192.168.0.3: icmp_req=4 ttl=64 time=0.229 ms
64 bytes from 192.168.0.3: icmp_req=5 ttl=64 time=0.233 ms
64 bytes from 192.168.0.3: icmp_req=6 ttl=64 time=0.210 ms
64 bytes from 192.168.0.3: icmp_req=7 ttl=64 time=0.271 ms
64 bytes from 192.168.0.3: icmp_req=8 ttl=64 time=0.273 ms
64 bytes from 192.168.0.3: icmp_req=9 ttl=64 time=0.291 ms
64 bytes from 192.168.0.3: icmp_req=10 ttl=64 time=0.201 ms
From 192.168.0.2 icmp_seq=58 Destination Host Unreachable
From 192.168.0.2 icmp_seq=59 Destination Host Unreachable
From 192.168.0.2 icmp_seq=60 Destination Host Unreachable
From 192.168.0.2 icmp_seq=61 Destination Host Unreachable
From 192.168.0.2 icmp_seq=62 Destination Host Unreachable
From 192.168.0.2 icmp_seq=63 Destination Host Unreachable
From 192.168.0.2 icmp_seq=64 Destination Host Unreachable
From 192.168.0.2 icmp_seq=65 Destination Host Unreachable
From 192.168.0.2 icmp_seq=66 Destination Host Unreachable
From 192.168.0.2 icmp_seq=67 Destination Host Unreachable
From 192.168.0.2 icmp_seq=68 Destination Host Unreachable
From 192.168.0.2 icmp_seq=69 Destination Host Unreachable

我应该怎么做才能减少这个时间?

最好的问候, 索索莱斯

【问题讨论】:

  • 注意:ping 中的“-W”选项仍然存在问题。

标签: linux networking ubuntu timeout ping


【解决方案1】:

你可以使用 -w 来指定超时时间

ping -c1  -w1 192.168.0.3

选项详情:

-c count

                  Stop  after  sending  count  ECHO_REQUEST packets. With deadline option, ping
                  waits for count ECHO_REPLY packets, until the timeout expires.


-w deadline
                      Specify a timeout, in seconds, before ping exits regardless of how many pack‐
                      ets  have  been sent or received. In this case ping does not stop after count
                      packet are sent, it waits either for deadline expire or  until  count  probes
                      are answered or for some error notification from network.

【讨论】:

    【解决方案2】:

    我猜你可以-O

    ping -O host.com
    

    claudionei@TI-03 ~ $ ping -O 10.251.15.251
    PING 10.251.15.251 (10.251.15.251) 56(84) 字节数据。
    来自 10.251.15.251 的 64 个字节:icmp_seq=1 ttl=62 time=4.50 ms
    icmp_seq=2 尚无答案
    来自 10.251.15.251 的 64 个字节:icmp_seq=2 ttl=62 time=1950 ms
    icmp_seq=3 尚无答案
    来自 10.251.15.251 的 64 个字节:icmp_seq=3 ttl=62 time=1409 ms
    来自 10.251.15.251 的 64 个字节:icmp_seq=4 ttl=62 time=576 ms
    来自 10.251.15.251 的 64 个字节:icmp_seq=5 ttl=62 time=654 ms
    来自 10.251.15.251 的 64 个字节:icmp_seq=6 ttl=62 time=4.41 ms

    --- 10.251.15.251 ping 统计 ---
    发送 6 个数据包,接收 6 个数据包,0% 数据包丢失,时间 5001 毫秒
    rtt min/avg/max/mdev = 4.416/766.491/1950.291/710.053 ms,管道 2

    【讨论】: