用 Linux 嗅探器定位网络延迟的实操指南
一、诊断思路与分层定位
二、快速快测与路由定位
hping3 -c 5 -S -p 80 1.1.1.1
traceroute --tcp -p 80 -n 1.1.1.1
三、用 tcpdump 在服务器侧抓包
# ICMP 往返时延
tcpdump -i eth0 -nn -tttt icmp or host 1.1.1.1 -w ping.pcap
# HTTP/TCP 交互
tcpdump -i eth0 -nn -tttt 'tcp port 80 and host 1.1.1.1' -w http.pcap
# 仅三次握手(便于测线路 RTT)
tcpdump -i eth0 -nn -tttt 'tcp[tcpflags] & (tcp-syn|tcp-ack) != 0' -w handshake.pcap
四、用 Wireshark 精确度量与定位瓶颈
tshark -r http.pcap -T fields -e frame.time_epoch -e ip.src -e ip.dst -e http.request.uri
五、常见现象与处置建议