丢包确认与缓解
丢包确认与缓解
tcpdump -nn -i eth0 -B 32768 -w /tmp/big.pcap 'host 10.0.0.5' # 32MB 缓冲
# 退出时会打印:
# 12345 packets captured
# 67 packets dropped by kernel
tcpdump -nn -i eth0 -q -s 128 -c 100000 'tcp port 443'
# 内核侧丢包统计(抓包外的视角):
ip -s link show eth0 | grep -A2 RX
nstat -az | grep -iE 'UdpInErrors|TcpExtTCPBacklogDrop'| 判据 | 「packets dropped by kernel」非 0 = 抓包丢了,不是网络丢了 |
|---|---|
| 缓解 | -B 加大缓冲、-s 减小 snaplen、过滤条件尽量靠前、-q 减少格式化开销 |
| 对照 | 用 ip -s link / nstat 判断丢包是否也发生在内核统计层 |
把抓包丢包当成网络丢包是经典误判:两者要分别取证,前者只能说明抓包能力不足。