简体   繁体   中英

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.

What I would like to do is to communicate with this device using a Raspberry and 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.

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. 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.

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.

Thanks, Alban

Did you try using ettercap package (ettercap-graphical)? It should be available with apt.

Alternatively you can try using TCPDump (Java tool) or even check ip tables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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