简体   繁体   English

在Raspberry上使用python读取原始以太网数据包

[英]Read raw ethernet packet using python on Raspberry

I have a device which is sending packet with its own specific construction (header, data, crc) through its ethernet port. 我有一台设备正在通过其以太网端口发送具有自己特定结构(报头,数据,CRC)的数据包。

What I would like to do is to communicate with this device using a Raspberry and Python 3.x. 我想做的是使用Raspberry和Python 3.x与该设备进行通信。

I am already able to send Raw ethernet packet using the "socket" Library, I've checked with wireshark on my computer and everything seems to be transmitted as expected. 我已经能够使用“套接字”库发送Raw以太网数据包,我已经在计算机上使用Wireshark进行了检查,并且一切似乎都按预期进行了传输。

But now I would like to read incoming raw packet sent by the device and store it somewhere on my RPI to use it later. 但是现在我想读取设备发送的传入原始数据包,并将其存储在我的RPI上的某个地方,以便以后使用。 I don't know how to use the "socket" Library to read raw packet (I mean layer 2 packet), I only find tutorials to read higher level packet like TCP/IP. 我不知道如何使用“套接字”库读取原始数据包(我的意思是第2层数据包),我只找到教程来读取更高级别的数据包(如TCP / IP)。

What I would like to do is Something similar to what wireshark does on my computer, that is to say read all raw packet going through the ethernet port. 我想做的是类似于wireshark在计算机上做的事情,也就是说,读取通过以太网端口的所有原始数据包。

Thanks, Alban 谢谢阿尔班

Did you try using ettercap package (ettercap-graphical)? 您是否尝试过使用ettercap软件包(ettercap-graphical)? It should be available with apt. 它应该与apt一起可用。

Alternatively you can try using TCPDump (Java tool) or even check ip tables 另外,您可以尝试使用TCPDump(Java工具),甚至检查ip表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM