為什麼使用 -f 時 ping 速度更快

為什麼使用 -f 時 ping 速度更快

我同時從同一台機器 ping 同一台主機。使用 時-f,結果幾乎是原來的兩倍:

[root@localhost Desktop]# ping 196.1.6.16
PING 196.1.6.16 (196.1.6.16) 56(84) bytes of data.
64 bytes from 196.1.6.16: icmp_seq=1 ttl=62 time=0.744 ms
64 bytes from 196.1.6.16: icmp_seq=2 ttl=62 time=0.166 ms
64 bytes from 196.1.6.16: icmp_seq=3 ttl=62 time=0.164 ms
64 bytes from 196.1.6.16: icmp_seq=4 ttl=62 time=0.164 ms
64 bytes from 196.1.6.16: icmp_seq=5 ttl=62 time=0.167 ms

[root@localhost Desktop]# ping -f 196.1.6.16
PING 196.1.6.16 (196.1.6.16) 56(84) bytes of data.
.^C
--- 196.1.6.16 ping statistics ---
84226 packets transmitted, 84225 received, 0% packet loss, time 9782ms
rtt min/avg/max/mdev = 0.083/0.091/0.191/0.012 ms, ipg/ewma 0.116/0.090 ms

我只是想知道為什麼。據我了解,無論我發送資料包的頻率如何,時間都應該是相同的。

由於我有如此不同的結果,這兩個中哪一個是「公平的」?

更新#1

當它本身很有趣時,我問這個的另一個原因是 - 因為我想要更好的延遲(我執行高頻交易)。因此,如果「洪水」ping 以某種方式改善了延遲,那麼我想知道如何以及為什麼。如果它將某個緩衝區歸零,那麼我應該評估以持久方式將該緩衝區歸零是否有意義等。

更新#2

ping 127.0.0.1 時差異較大

[root@localhost Desktop]# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
....
64 bytes from 127.0.0.1: icmp_seq=17 ttl=64 time=0.067 ms
64 bytes from 127.0.0.1: icmp_seq=18 ttl=64 time=0.058 ms
64 bytes from 127.0.0.1: icmp_seq=19 ttl=64 time=0.064 ms
64 bytes from 127.0.0.1: icmp_seq=20 ttl=64 time=0.067 ms
^C
--- 127.0.0.1 ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 18999ms
rtt min/avg/max/mdev = 0.058/0.065/0.069/0.006 ms


[root@localhost Desktop]# ping -f 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
^C 
--- 127.0.0.1 ping statistics ---
92267 packets transmitted, 92267 received, 0% packet loss, time 1273ms
rtt min/avg/max/mdev = 0.005/0.005/0.065/0.003 ms, ipg/ewma 0.013/0.006 ms

更新#3

我稍微調整了我的系統,特別是我已經使用tuned-adm並切換到了network-latency.現在數字降低了,但我仍然遇到同樣的問題 - 當洪水 ping 值好多了時,為什麼?

[root@localhost]# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.011 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.010 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.009 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.011 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.011 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.011 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.011 ms
^C
--- 127.0.0.1 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 5999ms
rtt min/avg/max/mdev = 0.009/0.010/0.011/0.003 ms

[root@localhost]# ping -f 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.

^C--- 127.0.0.1 ping statistics ---
42294 packets transmitted, 42294 received, 0% packet loss, time 837ms
rtt min/avg/max/mdev = 0.003/0.003/0.025/0.002 ms, ipg/ewma 0.019/0.003 ms

我使用的是 RHEL 7,最新的內核,所有更新。

答案1

回答您的更新:我對高頻交易一無所知,但我幾乎可以保證它不會發生ICMP(用於 ping 的協定)。由於 ICMP 訊息的緩衝和優先順序可能與攜帶實際資料的流量(最有可能使用 TCP 或 UDP)不同,因此 ping 結果與您想要完成的任務沒有直接關係。

答案2

根據ping手冊頁,該f標誌是:

  • -f:洪水平。對於每個發送的 ECHO_REQUEST 都會列印一個句點“.”,而對於收到的 ECHO_REPLY 則列印一個退格鍵。這可以快速顯示有多少資料包被丟棄。如果未給出間隔,它將間隔設為零,並以資料包返回的速度或每秒一百次(以較高者為準)輸出資料包。只有超級使用者可以以零間隔使用此選項。

因此,透過使用該f標誌,我得到:

[support@cloudHA1 exporttool]$ sudo ping -f www.google.com
[sudo] password for support:
PING www.google.com (74.125.228.51) 56(84) bytes of data.
..^C
--- www.google.com ping statistics ---
12502 packets transmitted, 12500 received, 0% packet loss, time 29394ms
rtt min/avg/max/mdev = 1.335/2.194/191.342/6.182 ms, pipe 2, ipg/ewma 2.351/1.524 ms
[support@cloudHA1 exporttool]$

沒有標誌,我得到:

[support@cloudHA1 ~]$ ping www.google.com
PING www.google.com (74.125.228.50) 56(84) bytes of data.
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=1 ttl=49 time=1.53 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=2 ttl=49 time=1.51 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=3 ttl=49 time=1.72 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=4 ttl=49 time=1.62 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=5 ttl=49 time=1.78 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=6 ttl=49 time=1.66 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=7 ttl=49 time=1.59 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=8 ttl=49 time=1.66 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=9 ttl=49 time=1.43 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=10 ttl=49 time=1.72 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=11 ttl=49 time=1.84 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=12 ttl=49 time=1.80 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=13 ttl=49 time=1.69 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=14 ttl=49 time=1.87 ms
64 bytes from iad23s06-in-f18.1e100.net (74.125.228.50): icmp_seq=15 ttl=49 time=1.84 ms

^C
--- www.google.com ping statistics ---
61 packets transmitted, 61 received, 0% packet loss, time 60530ms
rtt min/avg/max/mdev = 1.438/2.026/12.749/1.548 ms

我將i在下一個範例中新增該標誌,根據 ping 手冊頁,該標誌執行以下操作:

  • -i 間隔 發送每個資料包之間的等待間隔秒數。預設情況下,正常情況下每個資料包之間等待一秒,或在泛洪模式下不等待。只有超級使用者可以將間隔設定為小於 0.2 秒的值。

    [support@cloudHA1 ~]$ ping -fi 4 www.google.com PING www.google.com (74.125.29.106) 56(84) bytes of data. ^C --- www.google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 13875ms rtt min/avg/max/mdev = 9.381/9.531/9.749/0.153 ms, ipg/ewma 4625.308/9.495 ms [support@cloudHA1 ~]$

相關內容