在 macOS 上 Ping 超過 56 位元組

在 macOS 上 Ping 超過 56 位元組

我在 macOS 上並使用終端機進行 ping。我如何能夠 ping 超過 56 個位元組?我嘗試搜索但未能找到答案。

答案1

ping -s 尺寸 主持人

ping -s 1472 target.example.com

我以 1472 作為範例,因為對於典型的標頭長度,它會建立一個沒有分段的全尺寸資料包。

有關該命令選項的更多信息,請在終端中ping(1)使用該命令查看其手冊頁。man ping

答案2

這也取決於您 ping 的主機

mbp ~ % ping -s 1400 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 1400 data bytes
76 bytes from 8.8.8.8: icmp_seq=0 ttl=117 time=12.969 ms
wrong total length 96 instead of 1428
76 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=12.342 ms
wrong total length 96 instead of 1428
^C

mbp ~ % ping -s 1400 bbc.co.uk
PING bbc.co.uk (151.101.64.81): 1400 data bytes
1408 bytes from 151.101.64.81: icmp_seq=0 ttl=59 time=10.415 ms
1408 bytes from 151.101.64.81: icmp_seq=1 ttl=59 time=12.601 ms

在上面的例子中,8.8.8.8 沒有回覆完整的資料包,而是回覆 bbc.co.uk。做

在 Linux 中你會得到類似的行為,只是

wrong total length 96 instead of 1428

你得到

truncated 

Linux 中的相同範例:

E520:~$ ping -s 1400 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 1400(1428) bytes of data.
76 bytes from 8.8.8.8: icmp_seq=1 ttl=117 (truncated)
76 bytes from 8.8.8.8: icmp_seq=2 ttl=117 (truncated)

E520:~$ ping -s 1400 bbc.co.uk
PING bbc.co.uk (151.101.192.81) 1400(1428) bytes of data.
1408 bytes from 151.101.192.81 (151.101.192.81): icmp_seq=1 ttl=59 time=8.27 ms
1408 bytes from 151.101.192.81 (151.101.192.81): icmp_seq=2 ttl=59 time=8.36 ms

相關內容