I am working on an Ethercat wizard written by Go. The main library is located at http://github.com/distributed/ecat and contains one link-level driver using UDP and multicast. I'm having trouble getting this link-level driver to work sequentially across multiple platforms (OS X, Windows, Linux) and various network configurations.
For those new to Ethercat, here's how it works. Ethercat is an industrial Ethernet bus system. There is one bus master and potentially many subordinates that are connected to the logical ring. The wizard can be built from finished equipment, that is, with conventional Ethernet interfaces. The master sends the packet to its Ethernet interface, the slave modules change the packet on the fly and, having passed through all the slaves, the master receives the packet on the same network interface that sent it. Depending on the number of slaves, the network interface may begin to receive a packet while it is still transmitting the same packet. There are two possible formats for Ethercat frames. The first is an Ethernet packet with a special type of ethertype. The second is a UDP packet destined for port 0x88a4.
Depending on the instructions contained in the Ethernet packet, the slaves may or may not modify the data of the Ethercat packet. Besides changing the Ethercat data, the only thing that has changed in the packet is that bit 1 of the Ethernet destination address is set to 1. The IP header of the packet is not affected by the EtherCat slaves.
My code works as follows. I join a multicast group, say 239.255.65.10on the interface xyzwhere I connected my Ethercat slaves. To exchange data with the bus, I send a packet, name it pAon this interface 239.255.65.10. The OS fills in the source address, say, the IP address of the 192.168.5.2interface xyz. After the packet has passed through the bus and may have been modified, now the packet pB. The IP header still has the source 192.168.5.2and destination 239.255.65.10. Depending on the host network settings, this package may or may not get into my application. In cases where it does not reach my application, let's say when installed rp_filter, the Linux packagepB rejects because it looks like it came from my machine, but we should not receive our own packets over the network.
What steps can I take to reliably receive a processed package pB? Please note that I am not talking about loopback - loopback is about receiving a packet pA, my question is about receiving pB.
source
share