macOSで56バイトを超えるpingを実行する

macOSで56バイトを超えるpingを実行する

私は macOS を使っていて、ターミナルを使って ping しています。56 バイトを超える ping を実行するにはどうすればよいでしょうか? 検索してみましたが、答えは見つかりませんでした。

答え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

関連情報