接続が失われた場合、「ping -W」フラグがタイムアウトしないのはなぜですか?

接続が失われた場合、「ping -W」フラグがタイムアウトしないのはなぜですか?

-WDebian Busterでは、フラグの説明で判断すると、ping次のようなものを使用できるようになります。

ping -i 10 -W 5 8.8.8.8

インターネット接続を継続的に監視します。接続が切断されると、各ping(10秒間隔)後5秒間はping応答が報告されないことが予想されます。代わりに、接続が復元されるまで出力が一時停止し(最小60秒、無期限に可能になります)、その一時停止中に送信されたすべてのpingが完了し、長いフォン時間のみが表示されます。したがって、出力は次のようになります。

64 bytes from 8.8.8.8: icmp_seq=36 ttl=117 time=11.705 ms
64 bytes from 8.8.8.8: icmp_seq=37 ttl=117 time=11.963 ms
64 bytes from 8.8.8.8: icmp_seq=38 ttl=117 time=11.900 ms
64 bytes from 8.8.8.8: icmp_seq=39 ttl=117 time=11.288 ms   <-- connection interrupted after this line
64 bytes from 8.8.8.8: icmp_seq=40 ttl=117 time=65697 ms    <-- this line takes ~65s to appear   
64 bytes from 8.8.8.8: icmp_seq=41 ttl=117 time=55880 ms
64 bytes from 8.8.8.8: icmp_seq=42 ttl=117 time=45116 ms
64 bytes from 8.8.8.8: icmp_seq=43 ttl=117 time=35949 ms
64 bytes from 8.8.8.8: icmp_seq=44 ttl=117 time=25266 ms
64 bytes from 8.8.8.8: icmp_seq=45 ttl=117 time=15943 ms
64 bytes from 8.8.8.8: icmp_seq=46 ttl=117 time=5818 ms
64 bytes from 8.8.8.8: icmp_seq=47 ttl=117 time=11.578 ms    <--- connection restored before this ping
64 bytes from 8.8.8.8: icmp_seq=48 ttl=117 time=11.382 ms
64 bytes from 8.8.8.8: icmp_seq=49 ttl=117 time=11.624 ms
64 bytes from 8.8.8.8: icmp_seq=50 ttl=117 time=11.407 ms
64 bytes from 8.8.8.8: icmp_seq=51 ttl=117 time=11.864 ms
64 bytes from 8.8.8.8: icmp_seq=52 ttl=117 time=11.716 ms

私が期待したように:

64 bytes from 8.8.8.8: icmp_seq=36 ttl=117 time=11.705 ms
64 bytes from 8.8.8.8: icmp_seq=37 ttl=117 time=11.963 ms
64 bytes from 8.8.8.8: icmp_seq=38 ttl=117 time=11.900 ms
64 bytes from 8.8.8.8: icmp_seq=39 ttl=117 time=11.288 ms   <-- connection interrupted after this line
ping is down: no route to host
ping is down: no route to host
ping is down: no route to host
ping is down: no route to host
ping is down: no route to host
ping is down: no route to host
ping is down: no route to host
64 bytes from 8.8.8.8: icmp_seq=47 ttl=117 time=11.578 ms    <--- connection restored before this ping
64 bytes from 8.8.8.8: icmp_seq=48 ttl=117 time=11.382 ms
64 bytes from 8.8.8.8: icmp_seq=49 ttl=117 time=11.624 ms
64 bytes from 8.8.8.8: icmp_seq=50 ttl=117 time=11.407 ms
64 bytes from 8.8.8.8: icmp_seq=51 ttl=117 time=11.864 ms
64 bytes from 8.8.8.8: icmp_seq=52 ttl=117 time=11.716 ms

これらの質問に基づいて明確な答えがない一般的な質問は次のとおりです。

したがって、2つの質問を要約すると、次のようになります。

  1. タイムアウト後にpingに接続障害を報告させる方法はありますか?
  2. -W(1)を解決できない場合、デザインの目的は何ですか?

ベストアンサー1

答え:

  1. ping私が知る限り、組み込まれたものは何もありません。 2つの解決策があります。
    • 出力をgrepするか、戻りフラグをチェックし、便利な出力をエコーするループに単一のping(たとえばping -c1 -W 5 8.8.8.8)をラップします。bash良い例は次のとおりです。https://superuser.com/a/668124
    • この-Oフラグは直ちに失敗メッセージを表示します。それとは何の関係もなく、-W関連するタイムアウトもないため、まったく同じではありませんが、少なくとも接続の問題は明らかでなければなりません。
  2. -W特に指定しない限り、-cパケット数を制限する目的はないようです。-c指定されている場合、タイムアウトが全体ではなくpingあたりであることを除いて、-W同様です。-w

おすすめ記事