Skip to content

Instantly share code, notes, and snippets.

@nemumu
Created June 22, 2014 04:54
Show Gist options
  • Save nemumu/8040adea38a6632ccbca to your computer and use it in GitHub Desktop.
Save nemumu/8040adea38a6632ccbca to your computer and use it in GitHub Desktop.
セキュリティキャンプ2014 で提出した応募用紙の一部です
4. Maximum Transmission Unit (MTU) の最大値はいくつでしょうか?
(複数回答がある場合は、わかる範囲で全部書いてください)
pingコマンドを用いてMTUを取得しました。
pingコマンドは以下のオプションを指定して測定しました。
[ -s ]:送信するパケットのサイズ
[ -c ]:送信する回数
[ -M do ]:Path MTU DiscoveryでのDFビットを1に設定
今回はDFビットを1にしてDestination Unreachable Fragmentation Needed and Don't Fragment was Set (Type 3 Code 4)が返った場合は返ってきたICMPパケット内に含まれるNext-Hop MTUの値をMTUとして再送します。
終着点まで到達した場合はその時のMTUの値がMTUの最大値となります。
今回は上記のPath MTU Discoveryを利用した方法でMTUの最大値を測定しました。Linuxでのpingではオプション無しのIPヘッダは20オクテット、それに加えてICMPヘッダが8オクテットであるため実際に受け取るデータ量はオプション[ -s ]で指定したパケットサイズ + 28 [octet] です。
今回は自宅のlinuxハードウェアからgoogle.co.jpへのMTUの最大値を測定しました。
経路情報自宅のlinuxハードウェアからgoogle.co.jpへの経路情報は以下の通りです。
[root@nemumu ~]# traceroute google.co.jp
traceroute to google.co.jp (173.194.38.24), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 0.190 ms 0.157 ms 0.166 ms
2 118.23.61.180 (118.23.61.180) 2.826 ms 3.185 ms 3.427 ms
3 118.23.59.145 (118.23.59.145) 2.613 ms 2.652 ms 2.681 ms
4 118.23.88.245 (118.23.88.245) 4.026 ms 6.002 ms 7.969 ms
5 61.207.46.45 (61.207.46.45) 2.293 ms 2.301 ms 2.270 ms
6 125.170.96.45 (125.170.96.45) 11.303 ms 11.082 ms 11.064 ms
7 61.207.4.75 (61.207.4.75) 10.626 ms 9.899 ms 9.974 ms
8 180.37.200.26 (180.37.200.26) 9.971 ms 10.444 ms 10.329 ms
9 211.122.28.226 (211.122.28.226) 10.874 ms 10.788 ms 10.740 ms
10 209.85.255.156 (209.85.255.156) 13.277 ms 13.211 ms 13.141 ms
11 216.239.48.65 (216.239.48.65) 13.819 ms 13.934 ms 13.799 ms
12 kix01s03-in-f24.1e100.net (173.194.38.24) 10.477 ms 10.423 ms 10.668 ms
Linuxハードウェアからルーター間のMTU
[root@nemumu ~]# ping -M do -c 1 -s 1472 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 1472(1500) bytes of data.
1480 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.455 ms
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
[root@nemumu ~]# ping -M do -c 1 -s 1473 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 1473(1501) bytes of data.
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 10000ms
よってLinuxハードウェアからルーター間のMTUは
1472 + 28 = 1500 [octet] となります。
自宅から118.23.61.180(プロバイダOCN)間のMTU
[root@nemumu ~]# ping -M do -c 1 -s 1426 118.23.61.180
PING 118.23.61.180 (118.23.61.180) 1426(1454) bytes of data.
1434 bytes from 118.23.61.180: icmp_seq=1 ttl=126 time=4.62 ms
--- 118.23.61.180 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 4ms
rtt min/avg/max/mdev = 4.622/4.622/4.622/0.000 ms
[root@nemumu ~]# ping -M do -c 1 -s 1427 118.23.61.180
PING 118.23.61.180 (118.23.61.180) 1427(1455) bytes of data.
From 192.168.1.1 icmp_seq=1 Frag needed and DF set (mtu = 1454)
--- 118.23.61.180 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
よって自宅から118.23.61.180(プロバイダOCN)間のMTUは
1426 + 28 = 1454 [octet]となります。
なお、ここから先のMTUは1454 [octet]を下回っていました。
[root@nemumu ~]# ping -M do -c 1 -s 1426 google.co.jp
PING google.co.jp (173.194.38.56) 1426(1454) bytes of data.
1434 bytes from kix01s04-in-f24.1e100.net (173.194.38.56): icmp_seq=1 ttl=53 time=11.0 ms
--- google.co.jp ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 19ms
rtt min/avg/max/mdev = 11.034/11.034/11.034/0.000 ms
従って、自宅からgoogle.co.jp間のMTUは
1426 + 28 = 1454 [octet] となります。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment