5034 字
25 分钟
网络丢包与传输速度异常排查笔记

网络丢包与传输速度异常排查笔记#

现象#

  • 业务下载速度骤降,服务器负载与服务都正常,大概率是机房网络异常不稳定导致的。反馈机房IDC未排查到问题,遂自行排查。
  • 或者明确知道机房网络丢包,也可使用下方笔记协助排查。

排查#

# 1、使用ping命令测试连通性,并观察时延等信息
ping -c 100 -i 0.1 192.168.10.100

# 2、使用mtr命令测试链路丢包率
mtr -c 100 -i 0.1 -n -r -4 192.168.10.100

# 3、使用ifconfig命令查看网卡错误丢包数是否持续上涨
ifconfig eth0

# 4、使用nc命令测试端口丢包率
for i in {0..99};do nc -z -w 192.168.10.100 80;done |wc -l|awk '{print (100-$1)"%"}'

# 5、使用tcping命令测试端口tcp丢包率并观察时延等信息
tcping -t -i 0.1 192.168.10.100 80
tcping -t -i 0.1 -h "lxz.new1cloud.com/index.html"

# 6、最后还不行的话可以使用Wireshark、Tcpdump抓包排查
tcpdump -i any -nn host 192.168.10.100 and host 192.168.20.200 and tcp port 80 -ttt -w client.pcap

一、MTR#

MTR(My traceroute)是一款强大的网络诊断工具,它集成了 tracerouteping 的功能,并且会收集更多的信息,比如连接状态、可用性等等,在排查网络问题中,非常有用。
mtr几乎是所有Linux发行版本预装的网络测试工具。其将traceroute和ping的功能合并,所以功能更强大。mtr默认发送ICMP数据包进行链路探测。您也可以通过-u参数来指定使用UDP数据包进行探测。相对于traceroute只会做一次链路跟踪测试,mtr会对链路上的相关节点做持续探测并给出相应的统计信息。所以,mtr能避免节点波动对测试结果的影响,所以其测试结果更正确,建议优先使用。

1、MTR的安装#

1)CentOS#

# 直接使用yum安装
yum install mtr -y

# 测试命令
sudo mtr www.baidu.com

2)MacOS#

# 使用brew安装,如果没有brew命令,请先安装brew
brew install mtr

# 查看是否已经安装成功
which mtr

# 测试命令
sudo mtr www.baidu.com

3)Windows#

win系统是没有mtr的,只能通过其他软件来实现类似功能,也就是常见的win路由追踪命令,比如TracertBestTrace

2、使用方法#

mtr命令最基础的使用很简单,直接使用命令:mtr ip或域名即可。

1)用法说明#

# mtr -h
usage: mtr [-hvrwctglspniu46] [--help] [--version] [--report]
                [--report-wide] [--report-cycles=COUNT] [--curses] [--gtk]
                [--raw] [--split] [--no-dns] [--address interface]
                [--psize=bytes/-s bytes]
                [--interval=SECONDS] HOSTNAME [PACKETSIZE]

2)常用参数#

  • mtr -s : 用来指定ping数据包的大小
  • mtr -n : no-dns不对IP地址做域名反解析
  • mtr -a : 来设置发送数据包的IP地址,这个用于主机有多个IP时
  • mtr -i : 使用这个参数来设置ICMP返回之间的要求默认是1秒
  • mtr -c : 指定发送多少个数据包
  • mtr -r : 以报告模式显示
  • mtr -4 : IPv4
  • mtr -6 : IPv6

3、使用示例#

发送100个包,间隔0.1s,指定v4,并以报告形式输出。

# sudo mtr -c 100 -i 0.1 -n -r -4 www.baidu.com
Start: 2025-07-13T14:11:35+0800
HOST: IMXIZHEN           Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 192.168.10.1      0.0%   100    0.6   0.6   0.3   0.8   0.1
  2.|-- 192.168.1.1      83.0%   100    1.2   1.3   1.2   1.5   0.1

    ...

 13.|-- ???              100.0   100    0.0   0.0   0.0   0.0   0.0
 14.|-- 111.111.111.11    0.0%   100    9.4   9.6   8.2  36.2   2.7
NOTE

输出参数的解释:
Loss% — 丢包率,单位是”%“
Snt — sent包的数量
Last — 最后一个包的延时
Avg — 所有包的平均延时
Best — 延时最小的包
Wrst — 延时最大的包
StDev — 标准偏差

二、PING#

PING (Packet Internet Groper),因特网包探索器,用于测试网络连接量的程序。Ping发送一个ICMP;回声请求消息给目的地并报告是否收到所希望的ICMP echo (ICMP回声应答)。它是用来检查网络是否通畅或者网络连接速度的命令。
ping命令通常用来作为网络可用性的检查。ping命令可以对一个网络地址发送测试数据包,看该网络地址是否有响应并统计响应时间,以此测试网络。
几乎所有系统都自带了ping命令,我们一般用它来测试网络连通性。除了是否连通,我们还可以用它来获取是否丢包、时延、TTL等关键信息。

1、常用参数#

  • ping -a : 尝试将IP地址解析为主机名
  • ping -c : count 设置要发送的数据包数量
  • ping -i : interval 设置发送数据包之间的时间间隔
  • ping -s : packetsize 设置数据包的大小
  • ping -t : ttl 设置数据包的TTL值
  • ping -w : deadline 设置等待响应的时间
  • ping -W : timeout 设置等待响应的超时时间
  • ping -f : 向目标发送一个“强制”数据包
  • ping -v : 显示详细的ping命令输出

2、使用示例#

  • 发送5个ping数据包到目标主机并显示响应时间:
ping -c 5 www.google.com
  • 每隔1秒发送一个ping数据包到目标主机并显示响应时间:
ping -i 1 192.168.1.1
  • 使用UDP数据包发送10个ping数据包到目标主机并显示响应时间:
ping -U -c 10 www.baidu.com
  • 发送一个大小为1400字节的ping数据包到目标主机并显示响应时间:
ping -s 1400 192.168.1.1
  • 发送一个大小为1400字节的ping数据包到目标主机,并设置发送缓冲区大小为8000字节:
ping -s 1400 -S 8000 www.qq.com
  • 向目标主机发送一个“强制”数据包:
ping -f 192.168.1.1
  • 不停地向目标主机发送ping数据包,直到手动终止:
ping -t www.taobao.com

3、网络排查#

  • 快速ping 100个包
ping -c 100 -i 0.1 192.168.11.1

PING 192.168.11.1 (192.168.11.1): 56 data bytes
64 bytes from 192.168.11.1: icmp_seq=0 ttl=63 time=10.362 ms
64 bytes from 192.168.11.1: icmp_seq=1 ttl=63 time=6.612 ms
...
64 bytes from 192.168.11.1: icmp_seq=99 ttl=63 time=47.933 ms

--- 192.168.11.1 ping statistics ---
100 packets transmitted, 100 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 5.966/19.695/76.790/16.079 ms
NOTE

Ping命令的返回结果及含义

正常结果

  • Reply from 表示目标主机成功响应。
  • bytes=64 表示发送的数据包大小为64字节。
  • time=30ms 表示往返时间为30毫秒,反映网络延迟。
  • TTL=63 表示数据包在网络中的生存时间。 此结果表明本机与目标主机之间的网络连接正常。
    Liunx的默认ttl是64,windows的默认ttl是128,不同系统的不一样,可以通过这个判断对方是什么系统。

异常结果

  • Request timed out. 表示目标主机未响应,可能是网络不通或网络状态差。
  • Destination host unreachable. 表示目标主机无法到达,可能是路由未配置或网络设备故障。
  • PING: transmit failed, error code XXXXX 表示传输失败,通常与网卡驱动或TCP/IP协议配置相关。
  • Unknown host 表示无法解析目标主机名,可能是DNS配置错误或域名不存在。

三、NC#

NC(netcat)命令在Linux中被广泛称为网络界的瑞士军刀,它是一个功能强大的网络工具,可以用于多种网络任务。nc命令的基本用途包括TCP/UDP端口的侦听、端口扫描、文件传输、网络测速等。

1、基本用法#

1)基本语法#

nc [选项] [主机名] [端口号]

2)常用参数#

  • nc -l : 监听模式,用于入站连接。
  • nc -p : 指定本地主机使用的通信端口。
  • nc -s : 设置本地主机发送数据包的IP地址。
  • nc -u : 使用UDP传输协议。
  • nc -v : 显示命令执行过程。
  • nc -w : 设置超时秒数。
  • nc -z : 扫描模式,不发送任何数据。

2、使用示例#

  • 端口扫描:使用-z选项可以扫描一系列端口,例如:扫描192.168.0.1主机的1到100号端口。
nc -v -z -w2 192.168.0.1 1-100
  • 监听端口:使用-l选项可以监听本地端口,例如:在本地1234端口上监听入站连接。
nc -l -p 1234
  • 文件传输:nc可以在两台机器之间传输文件。
# 在接收端,使用以下命令监听端口并接收文件: 
nc -l -p 1234 > received_file.txt
# 在发送端,使用以下命令发送文件: 
nc 192.168.0.2 1234 < file_to_send.txt
  • 创建后门:nc可以用来在系统中创建后门,允许远程访问。例如:在10000端口上创建一个后门,允许通过bash访问系统。
nc -l -p 10000 -e /bin/bash
  • 端口转发:nc还可以用于端口转发。例如:将所有发往本地80端口的流量转发到192.168.1.200上的80端口。
nc -l -p 80 | nc 192.168.1.200 80

3、网络排查#

  • 测试80端口连通性
nc -zw 192.168.10.100 80
  • 测试80端口丢包率
for i in {0..99};do nc -z -w 192.168.10.100 80;done |wc -l|awk '{print (100-$1)"%"}'

四、IFCONFIG#

IFCONFIG是Linux系统中用于配置和显示网络接口信息的命令。通过ifconfig,用户可以查看网络接口的当前状态,包括IP地址、子网掩码、广播地址和MAC地址等信息,也可以对网络接口进行配置,如设置IP地址、启用或禁用接口等。

1、基本用法#

1)基本语法#

ifconfig [网络设备] [选项] [参数]

2)常用参数#

  • add<地址> : 为网络设备添加IPv6地址。
  • del<地址> : 删除网络设备的IPv6地址。
  • up : 启动指定的网络设备。
  • down : 关闭指定的网络设备。
  • netmask<子网掩码> : 设置网络设备的子网掩码。
  • mtu<字节> : 设置网络设备的最大传输单元(MTU)。

2、使用示例#

  • 显示所有网络设备信息:
ifconfig -a
  • 启动或关闭指定网卡:
ifconfig eth0 up
ifconfig eth0 down
  • 为网卡配置IPv6地址:
ifconfig eth0 add 33ffe:3240:800:1005::2/64
ifconfig eth0 del 33ffe:3240:800:1005::2/64
  • 修改网卡的MAC地址:
ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE
  • 配置网卡的IP地址:
ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255
  • 启用或关闭ARP协议:
ifconfig eth0 arp ifconfig eth0 -arp
  • 设置网卡的最大传输单元:
ifconfig eth0 mtu 1500

3、网络排查#

# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.42  netmask 255.255.240.0  broadcast 172.17.15.255
        inet6 fe80::5054:ff:fecf:dc5a  prefixlen 64  scopeid 0x20<link>
        inet6 fd76:3600:170c:5e00:0:9e81:a5ec:878a  prefixlen 128  scopeid 0x0<global>
        ether 52:54:00:cf:dc:5a  txqueuelen 1000  (Ethernet)
        RX packets 2496376961471  bytes 2496542476942730 (2.2 PiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3129176987106  bytes 4405099000077941 (3.9 PiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
NOTE

RX packets,TX packets分别为收包及发包数,errors:错误包数 dropped:丢包数,该值为累加值,所以排查时可以多次执行查看变化值,既错误或丢包数是否持续上涨。

五、TCPING#

TCPING 是一个基于 TCP 协议的网络测试工具,用于检查目标主机的连通性及端口状态,特别适用于禁用 ICMP Ping 的场景。

1、安装Tcping#

1)Linux#

1. CentOS#
yum update -y
yum install -y tcptraceroute bc
cd /usr/bin
wget -O tcping https://soft.mengclaw.com/Bash/TCP-PING
chmod +x tcping
2. Debian/Ubuntu#
apt-get update -y
apt-get install -y tcptraceroute bc
cd /usr/bin
wget -O tcping https://soft.mengclaw.com/Bash/TCP-PING
chmod +x tcping

2)Windows#

直接到Tcping官网下载安装包。软件很小,只有252K,最新版本发布时间为2017年12月30日。
将下载好的tcping.exe程序复制到C:\Windows\System32

2、常用参数#

1)Linux#

  • -d:在每个响应时间前打印时间戳。
  • -w sec:设置等待时间(默认 3 秒)。
  • -x count:限定测试次数(默认无限)。
  • -r sec:每隔 N 秒重试一次(默认 1 秒)。

2)Windows#

--------------------------------------------------------------
tcping.exe by Eli Fulkerson
Please see http://www.elifulkerson.com/projects/ for updates.
--------------------------------------------------------------

Usage: C:\Users\liuxizhen\AppData\Local\Microsoft\WindowsApps\tcping.exe [-flags] server-address [server-port]

Usage (full): C:\Users\liuxizhen\AppData\Local\Microsoft\WindowsApps\tcping.exe [-t] [-d] [-i interval] [-n times] [-w ms] [-b n] [-r times] [-s] [-v] [-j] [-js size] [-4] [-6] [-c] [-g count] [-S source_address] [--file] [--tee filename] [-h] [-u] [--post] [--head] [--proxy-port port] [--proxy-server server] [--proxy-credentials username:password] [-f] server-address [server-port]

 -t     : ping continuously until stopped via control-c
 -n 5   : for instance, send 5 pings
 -i 5   : for instance, ping every 5 seconds
 -w 0.5 : for instance, wait 0.5 seconds for a response
 -d     : include date and time on each line
 -b 1   : enable beeps (1 for on-down, 2 for on-up,
                        3 for on-change, 4 for always)
 -r 5   : for instance, relookup the hostname every 5 pings
 -s     : automatically exit on a successful ping
 -v     : print version and exit
 -j     : include jitter, using default rolling average
 -js 5  : include jitter, with a rolling average size of (for instance) 5.
 --tee  : mirror output to a filename specified after '--tee'
 --append : Append to the --tee filename rather than overwriting it
 -4     : prefer ipv4
 -6     : prefer ipv6
 -c     : only show an output line on changed state
 --file : treat the "server-address" as a filename instead, loop through file line by line
          Note: --file is incompatible with options such as -j and -c as it is looping through different targets
          Optionally accepts server-port.  For example, "example.org 443" is valid.
          Alternately, use -p to force a port at command line for everything in the file.
 -g 5   : for instance, give up if we fail 5 times in a row
 -S _X_ : Specify source address _X_.  Source must be a valid IP for the client computer.
 -p _X_ : Alternate method to specify port
 --fqdn : Print domain name on each line if available
 --ansi : Use ANSI color sequences (cygwin)
 --color: Use Windows color sequences

HTTP Options:
 -h     : HTTP mode (use url without http:// for server-address)
 -u     : include target URL on each line
 --post : use POST rather than GET (may avoid caching)
 --head : use HEAD rather than GET
 --proxy-server : specify a proxy server
 --proxy-port   : specify a proxy port
 --proxy-credentials : specify 'Proxy-Authorization: Basic' header in format username:password

Debug Options:
 -f     : force tcping to send at least one byte
 --header : include a header with original args and date.  Implied if using --tee.
 --block  : use a 'blocking' socket to connect.  This prevents -w from working and uses the
            default timeout (as long as 20 seconds in my case).  However it can detect an actively
            refused connection vs a timeout.

        If you don't pass server-port, it defaults to 80.
TIP

这里推荐使用win系统版本,参数功能更完善。

3、使用示例#

1)Linux#

# tcping -d -x 4 61.160.216.115 80 
Sun Jul 13 18:49:03 CST 2025
traceroute to 61.160.216.115 (61.160.216.115), 255 hops max, 60 byte packets
seq 0: tcp response from 61.160.216.115 (61.160.216.115) <syn,ack>  6.704 ms
Sun Jul 13 18:49:04 CST 2025
traceroute to 61.160.216.115 (61.160.216.115), 255 hops max, 60 byte packets
seq 1: tcp response from 61.160.216.115 (61.160.216.115) <syn,ack>  8.703 ms
Sun Jul 13 18:49:05 CST 2025
traceroute to 61.160.216.115 (61.160.216.115), 255 hops max, 60 byte packets
seq 2: tcp response from 61.160.216.115 (61.160.216.115) <syn,ack>  6.921 ms
Sun Jul 13 18:49:06 CST 2025
traceroute to 61.160.216.115 (61.160.216.115), 255 hops max, 60 byte packets
seq 3: tcp response from 61.160.216.115 (61.160.216.115) <syn,ack>  7.204 ms

2)Windows#

# tcping -n 5 -i 1 -d 192.168.11.100 80

2025:07:13 18:57:00 Probing 192.168.11.100:80/tcp - Port is open - time=5.630ms
2025:07:13 18:57:02 Probing 192.168.11.100:80/tcp - Port is open - time=6.823ms
2025:07:13 18:57:03 Probing 192.168.11.100:80/tcp - Port is open - time=4.293ms
2025:07:13 18:57:05 Probing 192.168.11.100:80/tcp - Port is open - time=4.406ms
2025:07:13 18:57:07 Probing 192.168.11.100:80/tcp - Port is open - time=9.908ms

Ping statistics for 192.168.11.100:80
     5 probes sent.
     5 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 4.293ms, Maximum = 9.908ms, Average = 6.212ms

# tcping -n 5 -i 1 -d -h "www.baidu.com"

** Requesting  from www.baidu.com:
(for various reasons, kbit/s is an approximation)

2025:07:13 18:53:23 Probing 180.101.51.73:80/tcp - HTTP is open - time=13.404ms rcv_time=21.086 status=200 bytes=8102 kbit/s=~3073.917
2025:07:13 18:53:24 Probing 180.101.51.73:80/tcp - HTTP is open - time=9.161ms rcv_time=10.869 status=200 bytes=8102 kbit/s=~5963.602
2025:07:13 18:53:26 Probing 180.101.51.73:80/tcp - HTTP is open - time=8.761ms rcv_time=12.867 status=200 bytes=8102 kbit/s=~5037.226
2025:07:13 18:53:27 Probing 180.101.51.73:80/tcp - HTTP is open - time=9.328ms rcv_time=12.724 status=200 bytes=8102 kbit/s=~5093.835
2025:07:13 18:53:29 Probing 180.101.51.73:80/tcp - HTTP is open - time=7.904ms rcv_time=16.081 status=200 bytes=8102 kbit/s=~4030.545

Ping statistics for 180.101.51.73:80
     5 probes sent.
     5 successful, 0 failed.  (0.00% fail)
Approximate trip times in milli-seconds:
     Minimum = 7.904ms, Maximum = 13.404ms, Average = 9.712ms
Approximate download times in milli-seconds:
     Minimum = 10.869ms, Maximum = 21.086ms, Average = 14.725ms

六、Tcpdump与Wireshark#

1、Tcpdump#

Tcpdump 是一个强大的命令行工具,用于捕获和分析网络数据包。它可以截获网络中传送的数据包的头部,并提供详细的分析信息。

1)基本用法#

  • 截获所有数据包: tcpdump 该命令会截获并显示所有流经第一个网络接口的数据包。
  • 指定抓包数量: tcpdump -c 2 该命令会截获2个数据包后停止。
  • 将抓包信息写入文件: tcpdump -c 10 -w tcpdump_test.log 该命令会将截获的10个数据包保存到文件 tcpdump_test.log 中。
  • 读取记录文件: tcpdump -r tcpdump_test.log 该命令会读取并显示 tcpdump_test.log 文件中的数据包。

2)常用参数#

  • -n 显示IP地址和端口号
  • -v 显示更多信息,ttl,长度,其他选项等,tcpdump的详细信息有3个级别,因此-vvv显示最多信息
  • -D 列出可以抓包的网络接口
  • -i + 网络接口抓包
  • -c + 数字 一次抓取多少数据包后停止抓取
  • -w + 文件名 抓包结果保存到文件
  • -r + 文件名 读取抓包文件
  • -s + 数字 抓包的大小

3)过滤选项#

  • 协议名,如icmp,过滤出icmp的制定报文
  • host + ip 特定主机,抓取目标地址和源地址为特定ip的数据包
  • port + 数字 特定端口抓包
  • src + [host] ip 源地址
  • dst + [host] ip 目标地址
  • -X 以十六进制打印出数据报文
  • -A 打印数据报文的ASCII值
NOTE
  • 多条件选择使用and,or和小括号,在shell中需要用引号包含多个条件的过滤规则如, tcpdump -nvvv -i any -c 20 ‘port 80 or port 443’
  • 过滤指定协议的数据包: tcpdump tcp tcpdump udp tcpdump icmp
  • 过滤指定端口的数据包: tcpdump tcp port 80 tcpdump tcp portrange 1-1024
  • 过滤指定主机的数据包: tcpdump host 192.168.1.113
  • 过滤指定数据包大小: tcpdump greater 1000 tcpdump less 10

4)逻辑表达式#

  • 逻辑与: tcpdump tcp and host 192.168.1.112
  • 逻辑或: tcpdump host 192.168.1.112 or 192.168.1.113
  • 逻辑非: tcpdump not tcp port 22

5)显示详细信息#

  • 显示详细的数据包信息: tcpdump -v tcpdump -vv
  • 不使用域名反解: tcpdump -n
  • 增加抓包时间戳: tcpdump -tttt

6)使用实例#

  • 抓取HTTP包: tcpdump -XvvennSs 0 -i eth0 tcp[20:2]=0x4745 or tcp[20:2]=0x4854
  • 抓取指定主机的HTTP GET请求: tcpdump -s 0 -A -vv 'tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'

2、Wireshark#

Wireshark(前身 Ethereal)是一个网络包分析工具。该工具主要是用来捕获网络数据包,并自动解析数据包,为用户显示数据包的详细信息,供用户对数据包进行分析。
它可以运行在 Windows 和 Linux 操作系统上。可以使用该工具捕获并分析各类协议数据包。

1)安装Wireshark#

Kali Linux 系统自带 Wireshark 工具,而 Windows 系统中默认没有安装该工具。因此,win需要自行安装。
安装方法:
打开Wireshark官网网址,进入 Wireshark 官网,下载安装即可。

2)Wireshark过滤规则#

1. IP地址过滤#
ip.src == 192.168.1.1  #过滤源IP为192.168.1.1的数据包
ip.dst == 192.168.1.1  #过滤目标IP为192.168.1.1的数据包
ip.addr == 192.168.1.1 #同时显示源和目标IP为192.168.1.1的数据包
2. 协议过滤#
tcp  #显示TCP协议数据包
udp  #显示UDP协议数据包
http #显示HTTP协议数据包
3. 端口过滤#
tcp.port == 80      #显示TCP端口为80的数据包
udp.port >= 1000    #显示UDP端口大于等于1000的数据包
tcp.srcport == 443  #显示源端口为443的TCP数据包
tcp.dstport == 8080 #显示目标端口为8080的TCP数据包
4. 数据内容过滤#
http.request.method == "GET" #筛选HTTP GET请求
http contains "User-Agent"   #包含“User-Agent”的HTTP数据包
tcp contains "password"      #TCP数据中包含“password”的数据包
5. MAC地址过滤#
eth.src == A0:00:00:04:C5:84 #源MAC地址为A0:00:00:04:C5:84的数据包
eth.dst == A0:00:00:04:C5:84 #目标MAC地址为A0:00:00:04:C5:84的数据包
TIP

注意事项

  • 语法检查:在Wireshark的过滤框中输入规则时,正确的语法会显示绿色,错误则显示红色。
  • 区分大小写:某些字段(如协议名)需要小写输入。
  • 逻辑操作符:支持 andornot 等逻辑操作符,例如 ip.addr == 192.168.1.1 and tcp.port == 80

3)Wireshark过滤TCP错误包#

在Wireshark中同时过滤TCP重复ACK(Dup ACK)和重传包(Retransmission),使用以下显示过滤器语法:

1. 基础组合过滤#
tcp.analysis.duplicate_ack or tcp.analysis.retransmission

这会显示所有重复ACK和TCP重传包(包括快速重传/超时重传)

2. 进阶过滤技巧#

a. 特定TCP流的丢包分析

(tcp.analysis.duplicate_ack or tcp.analysis.retransmission) and tcp.stream eq <流编>

示例: (tcp.analysis.duplicate_ack or tcp.analysis.retransmission) and tcp.stream eq 3

b. 源/目的IP限定

(tcp.analysis.duplicate_ack or tcp.analysis.retransmission) and (ip.src == 192.168.1.100 or ip.dst == 192.168.1.100)

c. 仅过滤快速重传(Fast Retransmit)

tcp.analysis.duplicate_ack or tcp.analysis.fast_retransmission
3. 关键诊断场景说明#
事件类型过滤器字段典型触发原因
重复ACKtcp.analysis.duplicate_ack接收方检测到报文乱序/丢失
普通重传tcp.analysis.retransmission超时未收到ACK(RTO超时)
快速重传tcp.analysis.fast_retransmission收到3个重复ACK触发立即重传
虚假重传tcp.analysis.spurious_retransmission不必要的重传(如网络抖动)
4. 过滤TCP所有异常标志包#

a. 关联事件分析

  • 重复ACK后紧跟重传 → 快速重传机制触发(网络丢包)
  • 只有重传无重复ACK → 超时重传(严重丢包或ACK丢失)

b. 关键统计命令

tcp.analysis.flags && !tcp.analysis.window_update

显示所有异常标志包(排除窗口更新干扰)

c. 典型问题定位
持续出现Dup ACK#X → 重传#X模式表明 网络路径存在持续丢包,需结合:

  • 往返时间(tcp.time_delta
  • 接收窗口大小(tcp.window_size
  • 报文乱序(tcp.analysis.out_of_order)综合判断
网络丢包与传输速度异常排查笔记
https://blog.imxizhen.asia/posts/笔记/网络丢包与传输速度异常排查笔记/
作者
imxizhen
发布于
2025-07-13
许可协议
CC BY-NC-SA 4.0