dotpcap / packetnet

Official repository - High performance .Net assembly for dissecting and constructing network packets such as ethernet, ip, tcp, udp etc.
Mozilla Public License 2.0
469 stars 105 forks source link

EtherCAT Frame and Datagrams support #212

Open fisherman6v6 opened 1 week ago

fisherman6v6 commented 1 week ago

Hello,

I really appreciate your work on Packet.NET and Sharppcap. I wanted to ask for some help implementing EtherCAT packet dissections natively in Packet.NET. What'd be the best way of doing that in order to achieve the best possible performances?

I've seen that inside the EthernetType enum EtherCAT entry is already present, so I guess it wouldn't be bad to add it to the list of supported packets.

For those unfamiliar with EtherCAT protocol, here you can find the packet structure.

Thank you in advance for your help.

PhyxionNL commented 1 week ago

I recommend taking a look at the other packets and see how it's done there. One easy example is ArpPacket: https://github.com/dotpcap/packetnet/blob/master/PacketDotNet/ArpPacket.cs You should look at the ByteArraySegment ctor first first to parse EtherCAT. Basically what can be should read/write directly from/to the underlying array segment and you'll get the best performance.

Some tests are also needed to verify the read/written data (through pcap files).