Wireshark & CAN

自己在几年前曾经写过一个232转CAN的协议转换器,界面用的是VB。能实时显示数据,但是不能把数据都抓下来。上位机编写是个非常困难的事情,对我来说。需要花太多的时间。现在感觉花这么大的时间做这个界面不值得。目前对我来讲我需要学习的是通用的东西。比如wireshark,这个软件很难过时。尽管大家都在用,但是用的好的人并不多。国内网站资料也很少。

目前想法是写个CAN转以太网的协议转换器,然后在wireshark上显示CAN的数据。那么这时候如何能直观的显示,至少在wireshak的info栏目里面能直接显示CAN的数据。

有两个方法,一个是用lua开发。另一个是用C或C++生成dll。前者更简单。

偶然发现wireshark竟然里面含有CAN协议,界面如下:

Wireshark & CAN_第1张图片

 

 

 

------------------

找了个老外的网页https://wiki.wireshark.org/CANopen,里面下载个CANopen.pcap,然后用wireshark打开,

Wireshark & CAN_第2张图片

然后把协议设置成canopen,

 

Wireshark & CAN_第3张图片

不过根据https://libbits.wordpress.com/2012/05/07/capturing-and-analyzing-can-frames-with-wireshark/

推测出很可能wireshark自带的插件仅仅支持linux,很有可能是USB转CAN,就是说和以太网没啥关系,只是借用了wireshark以太网之外的部分,就是用于显示数据的那部分。

这样的话对我来说难度就太大了。只是推测。

---------------------------------------------------------------------------

另外还有个哥们玩的更牛的!把wireshark的界面都改了。http://skpang.co.uk/blog/archives/1141,如下:

**********************************************************************************************************************

**************************************

()************************

 

CAN-Bus Data Capture with Wireshark on Raspberry Pi

20/11/2014

This project shows you how to setup Wireshark for use with the PiCAN board to capture data on the Raspberry Pi.

 

Install the CAN drivers according to this:

http://skpang.co.uk/blog/archives/1165

Make sure the command line candump works first.

Install Wireshark

sudo apt-get install wireshark

Bring up the CAN interface and start the GUI.

sudo su
ip link set can0 up type can bitrate 500000
startx

Start Wireshark, the icon is under “Other”.

Wireshark & CAN_第4张图片

 

Select the 1. “can0″ interface then click the 2. “Start a new live capture” icon.

Wireshark & CAN_第5张图片uploading.4e448015.gif转存失败重新上传取消Wireshark & CAN_第6张图片

Ensure the PiCAN is connected to an active CAN line you should see data like this:

Wireshark & CAN_第7张图片The above capture shows a CAN ID of 7DF. Data 02 01 05 – coolant temperature request. A reply of 03 41 05 86

Wireshark & CAN_第8张图片uploading.4e448015.gif转存失败重新上传取消Wireshark & CAN_第9张图片

 

TODO:

It would be nice if Wireshark can decode a list of PIDs.

Parts List

  • Raspberry Pi Model B+
  • 5″ HDMI monitor
  • PiCAN board
  • Laser cut acrylic base

 

*********************************************************************************************************

 

                          ********************************************************

                                               *********************************************************************************

 

搞来搞去,很有可能还是lua适合我!嗨!!!

 

搞着看吧。O(∩_∩)O哈哈~

 

贴几个常用的wireshark实现http://plcscan.org/blog/2015/https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-canopen.c11/using-the-wireshark-analysis-ics-protocol/

 

 

序号协议类型源码下载简介
1 Siemens S7 https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-s7comm.c西门子PLC支持的通讯协议
2 MMS(IEC61850)https://github.com/wireshark/wireshark/tree/master/asn1/mms输配电通讯协议
3 GOOSE(IEC61850)https://github.com/wireshark/wireshark/tree/master/asn1/goose输配电通讯协议
4 SV(IEC61850)https://github.com/wireshark/wireshark/tree/master/asn1/sv输配电通讯协议
5 Modbus https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-mbtcp.c工控标准协议
6 OPC DA https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-dcom.c工控标准协议
7 FF HSE https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-ff.c基金会现场总线以太网通信协定
8 IEC 104 https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-iec104.c输配电通讯协议
9 Ethernet POWERLINKhttps://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-epl.c开放式实时以太网通信
10 OPC UA https://github.com/wireshark/wireshark/tree/master/plugins/opcua/opcua.cOPC新一代标准
11 HART-IP https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-hartip.c高速可寻址远程传感器协议
12 CoAP https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-coap.c轻量应用层协议
13 Omron FINS https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-omron-fins.c欧姆龙PLC支持的通讯协定
14 openSAFETY https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-opensafety.c开源安全应用协议
15 EGD(Ethernet Global Data)https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-egd.cGE Fanuc为PLC开发的通讯协定
16 DNP3 https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-dnp.c分布式网络协议,主要用于电力行业
17 Sinec H1 https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-h1.c西门子PLC支持的通讯协议
18 Profinet https://github.com/wireshark/wireshark/tree/master/plugins/profinet/开放式的工业以太网通讯协定
19 EtherCAT https://github.com/wireshark/wireshark/tree/master/plugins/ethercat/德国Beckhoff公司推动的开放式实时以太网通讯协定
20 SERCOS III https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-sercosiii.c实时以太网通讯协定
21 RTPS https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-rtps.c实时流传输协议
22 TTEthernet https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-tte.c实时以太网通讯协定
23 CDT https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-cdt.c远动规约
24 EtherNet/IPhttps://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-etherip.c工业通讯协定(Industrial Protocol),是一种CIP的实现方式,由罗克韦尔自动化公司所设计
25 CIP https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-cip.c通用工业协定
26 CIP Safety https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-cipsafety.c安全通用工业协定
27 DeviceNet https://github.com/wireshark/wireshark/tree/master/epan/dissectors/ packet-devicenet.c一种CIP的实现方式,由Allen-Bradley公司所设计
28 BACnet https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-bacnet.c楼宇自动控制网络数据通讯协议
29 KNXnet/IP https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-knxnetip.c住宅和楼宇控制标准
30 Lontalk https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-lon.c埃施朗公司的LonWorks技术所使用的通讯协议
31 CANopen https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-canopen.c控制局域网通讯协定
32 SAE J1939 https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-j1939.c一种CAN的变种,适用在农业车辆及商用车辆
33 USITT DMX512-Ahttps://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-dmx.c灯光控制数据传输协议
34 BSSAP/BSAP https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-bssap.c由Bristol Babcock Inc发展的通讯协定
35 Gryphon https://github.com/wireshark/wireshark/tree/master/plugins/gryphon车用通讯协定
36 ZigBee https://github.com/wireshark/wireshark/tree/master/epan/dissectors/packet-zbee.h开放式的无线通讯协定

 

--------------------------------------------

 

socketcan.C   https://fossies.org/linux/wireshark/epan/dissectors/packet-socketcan.c

***************************

==========================

 

 

 

2017.05.11  折腾一上午,基本的套路弄清楚了,弄个简单界面如下:

Wireshark & CAN_第10张图片

以后可以在info里面添加CAN的信息,包括采集帧的时间,DLC,data,标准/扩展,远程与否,还有CAN的错误状态信息(错误状态高亮显示)。

 

总结几个知识点

(1)EDIT->perference->user interface  里面的各个项需要熟悉。

(2)关于lua, 查遍了所有的例子,以及目前看来只能编辑cols.info和protocol。其余的选项,只能隐藏。

(3)另外,比如对于数据类型

pkt.cols.info:set(buf(0,1):string())

和pkt.cols.info:set(string(buf(0,1)))

似乎是等价的。

至于语法之类的,花一定的时间,照葫芦画瓢,就会搞个大概差不多。

 

 

你可能感兴趣的:(can/canopen,ETH基础)