2 EtherCAT ubuntu wireshark

IGH 1.6.4 + Ubuntu Wireshark 抓 EtherCAT 报文配置指南

目标:只抓 EtherCAT 报文(EtherType = 0x88A4)

适用环境:Ubuntu + IGH EtherCAT Master 1.6.4


一、核心结论(先看这个)

  • Wireshark 抓的是 以太网原始帧
  • EtherCAT 的 EtherType 固定为 0x88A4
  • 抓包成功的关键:
    1. IGH 使用的物理网卡
    2. IGH 运行时不要独占网卡
    3. 关闭网卡 Offload
    4. Wireshark 启用 EtherCAT 协议解析
    5. 使用 EtherCAT 显示过滤器

二、确认 IGH 使用的网卡

bash 复制代码
cat /etc/ethercat.conf

示例:

ini 复制代码
MASTER0_DEVICE="eth0"
DEVICE_MODULES="generic"

记住 eth0,Wireshark 只抓这块网卡


三、停止 IGH(抓包前必须)

如果 IGH 正在运行,会独占网卡,Wireshark 抓不到包。

bash 复制代码
sudo systemctl stop ethercat

或:

bash 复制代码
sudo /etc/init.d/ethercat stop

四、关闭网卡 Offload(非常关键)

bash 复制代码
sudo ethtool -K eth0 gro off gso off tso off lro off

验证:

bash 复制代码
ethtool -k eth0

五、安装并配置 Wireshark

1. 安装

bash 复制代码
sudo apt update
sudo apt install wireshark

安装时选择:

复制代码
Allow non-superusers to capture packets? → Yes

2. 加入 wireshark 用户组

bash 复制代码
sudo usermod -aG wireshark $USER

注销并重新登录后生效


六、Wireshark 抓包步骤

  1. 启动 Wireshark:
bash 复制代码
wireshark &
  1. 选择网卡:eth0(或你的实际网卡)

  2. 开始抓包

  3. 另开终端,启动 IGH:

bash 复制代码
sudo systemctl start ethercat

七、只显示 EtherCAT 报文(重点)

Display Filter 中输入:

text 复制代码
ether proto 0x88a4

或:

text 复制代码
ethercat

推荐使用 ethercat(Wireshark 自带解析)


八、确认 EtherCAT 协议解析已启用

路径:

复制代码
Edit → Preferences → Protocols → EtherCAT

确认:

  • ☑ Enable EtherCAT dissection
  • ☑ Show Datagrams
  • ☑ Decode Mailbox(可选)

九、常用 EtherCAT 专用过滤器

1. 所有 EtherCAT 帧

text 复制代码
ethercat

2. Mailbox 帧

text 复制代码
ethercat.mailbox

3. CoE(SDO)

text 复制代码
ethercat.mailbox.protocol == 0x01

4. FoE(固件升级)

text 复制代码
ethercat.mailbox.protocol == 0x02

5. 工作计数器异常

text 复制代码
ethercat.wkc != 0

十、你应该看到的正常结构

text 复制代码
Ethernet II
 └─ EtherType: EtherCAT (0x88A4)
    └─ EtherCAT Frame
       └─ Datagram (LRD / LWR / LRW)
          ├─ Address
          ├─ Length
          ├─ Working Counter

十一、常见问题排查

抓不到任何包

  • IGH 未停止
  • 抓错网卡
  • 网卡被独占

能抓包但无 EtherCAT 解析

  • Offload 未关闭
  • Wireshark 版本过低
  • 过滤器错误

十二、推荐抓包顺序(标准流程)

bash 复制代码
sudo systemctl stop ethercat
sudo ethtool -K eth0 gro off gso off tso off lro off
wireshark &
sudo systemctl start ethercat

十三、一句话总结

EtherCAT 抓包 = 正确网卡 + Offload 关闭 + EtherCAT 过滤器

相关推荐
橙子也要努力变强10 分钟前
Linux信号机制
linux·服务器·网络
程序猿编码26 分钟前
给你的网络流量穿件“隐形衣“:手把手教你用对称加密打造透明安全隧道
linux·开发语言·网络·安全·linux内核
skilllite作者43 分钟前
AI agent 的 Assistant Auto LLM Routing 规划的思考
网络·人工智能·算法·rust·openclaw·agentskills
pengyi8710151 小时前
私网IP映射公网基础原理,搭配代理IP远程访问入门
linux·服务器·网络
AILabNotes1 小时前
014、隐私增强技术:零知识证明与混合网络在网关中的应用
网络·区块链·零知识证明
深圳市九鼎创展科技2 小时前
MT8883 vs RK3588 开发板全面对比:选型与场景落地指南
大数据·linux·人工智能·嵌入式硬件·ubuntu
闫利朋2 小时前
Ubuntu22.04桌面版安装Cubic2024版本并定制ISO完整教程
ubuntu·自动化的安装系统
Y学院5 小时前
网络安全基础核心知识点教程
网络·web安全·php
烛衔溟5 小时前
TypeScript this 参数类型与全局 this
javascript·ubuntu·typescript
风曦Kisaki6 小时前
#企业级网络架构Day01:网络概述,网络参考模型,交换机命令行
网络·架构·智能路由器