主要演示了tcpdump捕捉icmp報文以及用ping命令指定icmp長度後ip分組的查看。php
C:\Users\yaxia>ping 10.70.30.60 正在 Ping 10.70.30.60 具備 32 字節的數據: 來自 10.70.30.60 的回覆: 字節=32 時間<1ms TTL=64 來自 10.70.30.60 的回覆: 字節=32 時間<1ms TTL=64 來自 10.70.30.60 的回覆: 字節=32 時間<1ms TTL=64 來自 10.70.30.60 的回覆: 字節=32 時間<1ms TTL=64 10.70.30.60 的 Ping 統計信息: 數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失), 往返行程的估計時間(以毫秒爲單位): 最短 = 0ms,最長 = 0ms,平均 = 0ms
root@php56:/home/tb# tcpdump -ntv -i enp0s3 icmp tcpdump: listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes IP (tos 0x0, ttl 128, id 27746, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4795, length 40 IP (tos 0x0, ttl 64, id 30075, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4795, length 40 IP (tos 0x0, ttl 128, id 27748, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4796, length 40 IP (tos 0x0, ttl 64, id 30127, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4796, length 40 IP (tos 0x0, ttl 128, id 27750, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4797, length 40 IP (tos 0x0, ttl 64, id 30365, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4797, length 40 IP (tos 0x0, ttl 128, id 27752, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4798, length 40 IP (tos 0x0, ttl 64, id 30534, offset 0, flags [none], proto ICMP (1), length 60) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4798, length 40
C:\Users\yaxia>ping 10.70.30.60 -l 1473 正在 Ping 10.70.30.60 具備 1473 字節的數據: 來自 10.70.30.60 的回覆: 字節=1473 時間<1ms TTL=64 來自 10.70.30.60 的回覆: 字節=1473 時間<1ms TTL=64 來自 10.70.30.60 的回覆: 字節=1473 時間<1ms TTL=64 來自 10.70.30.60 的回覆: 字節=1473 時間<1ms TTL=64 10.70.30.60 的 Ping 統計信息: 數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失), 往返行程的估計時間(以毫秒爲單位): 最短 = 0ms,最長 = 0ms,平均 = 0ms
P (tos 0x0, ttl 128, id 27801, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4799, length 1480 IP (tos 0x0, ttl 128, id 27801, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.47 > 10.70.30.60: ip-proto-1 IP (tos 0x0, ttl 64, id 10022, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4799, length 1480 IP (tos 0x0, ttl 64, id 10022, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.60 > 10.70.30.47: ip-proto-1 IP (tos 0x0, ttl 128, id 27803, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4800, length 1480 IP (tos 0x0, ttl 128, id 27803, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.47 > 10.70.30.60: ip-proto-1 IP (tos 0x0, ttl 64, id 10189, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4800, length 1480 IP (tos 0x0, ttl 64, id 10189, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.60 > 10.70.30.47: ip-proto-1 IP (tos 0x0, ttl 128, id 27805, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4801, length 1480 IP (tos 0x0, ttl 128, id 27805, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.47 > 10.70.30.60: ip-proto-1 IP (tos 0x0, ttl 64, id 10418, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4801, length 1480 IP (tos 0x0, ttl 64, id 10418, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.60 > 10.70.30.47: ip-proto-1 IP (tos 0x0, ttl 128, id 27807, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4802, length 1480 IP (tos 0x0, ttl 128, id 27807, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.47 > 10.70.30.60: ip-proto-1 IP (tos 0x0, ttl 64, id 10429, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.60 > 10.70.30.47: ICMP echo reply, id 1, seq 4802, length 1480 IP (tos 0x0, ttl 64, id 10429, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.60 > 10.70.30.47: ip-proto-1
IP (tos 0x0, ttl 128, id 27801, offset 0, flags [+], proto ICMP (1), length 1500) 10.70.30.47 > 10.70.30.60: ICMP echo request, id 1, seq 4799, length 1480 IP (tos 0x0, ttl 128, id 27801, offset 1480, flags [none], proto ICMP (1), length 21) 10.70.30.47 > 10.70.30.60: ip-proto-1
win下查看A端mtu算法
C:\Users\yaxia>netsh interface ipv4 show subinterfaces MTU MediaSenseState 傳入字節 傳出字節 接口 ------ --------------- --------- --------- ------------- 4294967295 1 31577369 21149 Loopback Pseudo-Interface 1 1500 1 10271737813 4348038074 以太網 1500 1 4944 9536968 VirtualBox Host-Only Network
B端mtu ifconfig數組
enp0s3 Link encap:Ethernet HWaddr 08:00:27:ce:14:39 inet addr:10.70.30.60 Bcast:10.70.31.255 Mask:255.255.254.0 inet6 addr: fe80::a00:27ff:fece:1439/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3130176 errors:0 dropped:0 overruns:0 frame:0 TX packets:171929 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:361713379 (361.7 MB) TX bytes:124807829 (124.8 MB)