IGH EtherCAT Master 1.6.4 + Ubuntu

Wireshark 只抓 EtherCAT 报文配置说明(纯中文)


一、基础认知(非常重要)

1. EtherCAT 的本质

  • EtherCAT 不是 TCP/IP,也不是 UDP
  • EtherCAT 是 裸以太网帧
  • EtherType 固定为:0x88A4

结论:

  • 用 IP 层过滤一定抓不到 EtherCAT
  • 必须在二层(以太网层)抓包

二、确认 IGH 使用的网卡

1. 查看所有网卡

ip link

常见物理网卡名称:

  • eth0
  • eno1
  • enp3s0

不要使用:

  • lo
  • docker0
  • virbr0
  • br-*

2. 确认 IGH Master 绑定的网卡

ethercat master

示例输出:

Master0
  Phase: OP
  Active: yes
  Link: UP
  Device: enp3s0

结论:
Wireshark 必须抓 Device 指定的网卡


三、Wireshark 抓包权限配置(Ubuntu)

推荐方式(普通用户抓包)

sudo dpkg-reconfigure wireshark-common

选择:Yes

sudo usermod -aG wireshark $USER

注销并重新登录

临时方式(不推荐)

sudo wireshark

四、Wireshark 抓 EtherCAT 的正确配置

1. 选择接口

  • 选择 IGH 使用的物理网卡(如 enp3s0

2. 抓包过滤器(Capture Filter,推荐)

ether proto 0x88a4

作用:

  • 只抓 EtherCAT 报文
  • 降低 CPU 占用

3. 显示过滤器(Display Filter)

ethercat

eth.type == 0x88a4

五、标准抓包流程(一步不漏)

  1. 可选:停止 EtherCAT Master
sudo systemctl stop ethercat
  1. 打开 Wireshark,选择正确网卡

  2. 点击 开始抓包

  3. 启动 EtherCAT Master

sudo systemctl start ethercat
  1. 设置显示过滤器:
ethercat

应看到:

  • LRW
  • LRD
  • LWR
  • BRD / BWR
  • FPRD / FPWR

六、只看过程数据(PDO)的过滤方法

1. 只看 LRW 周期帧

ethercat.cmd == 0x0C

2. 只看某个从站地址(ADP)

ethercat.adp == 0x0001

3. 只看寄存器 / SDO 访问

ethercat.cmd == 0x05 || ethercat.cmd == 0x06

七、常见问题与排错表

现象 原因 解决
完全抓不到包 抓错网卡 ethercat master
只有 ARP / IP 过滤条件错误 ether proto 0x88a4
不解析 EtherCAT Wireshark 版本低 升级 ≥ 2.6
数据异常 网卡 offload 关闭 offload

八、强烈建议:关闭网卡 Offload

sudo ethtool -K enp3s0 rx off tx off tso off gso off gro off lro off

说明:

  • 防止硬件合并帧
  • 避免 EtherCAT 解析错误

九、tcpdump 快速验证(推荐)

sudo tcpdump -i enp3s0 -e ether proto 0x88a4

如果 tcpdump 能看到 EtherCAT:

  • IGH 正常
  • Wireshark 问题在权限或过滤

文档结束

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐