0

I have a device that is made up of separate modules running embedded linux. The modules are all the same hardware and software but perform different tasks depending upon their location in the device. All the modules talk to each other over an internal network. The ip addresses of the modules are set statically based on the location in the device. This is done by having the modules read a physically set device that returns a 0-15 number. It plugs into the modules but is physically attached to the location in the device. A device might have 6 racks, so there are 6 of these plugs set 1-6.

I want the device to determine if any module is incorrectly set as this would cause two or more modules to have the same IP address. This could be caused by either an incorrectly set or broken location dongle. The modules communicate with each other using broadcast UDP messages. One of the data members of the message is a unique 48-bit serial number, the MAC address.

My initial plan was to have all the modules compare the messages that are from themselves with their serial number and throw an error if they don't match. The problem is the modules only receive the broadcast packets that are either from themselves or another IP address. They are not seeing packets that are from the same IP address but a different module.

When I check the interface using ifconfig I can see the Rx packets increasing, but when I use netstat -su I see nothing. The UDP Rx packets never increment. Therefore, at some point they're being dropped from the stack.

Is there a way around this? I know I can rely on a third node to tell it is receiving broadcast packets from the same IP address but different MACs, but I was hoping have each module be self aware of this problem.

rawbus
  • 27
  • 6

1 Answers1

1

Upon startup the modules should broadcast an ARP packet annoncing their MAC and IP. This is the 'normal' solution for duplicate IP addresses, you could listen to these broadcasts and send one new one, this way your modules will detect someone else on the network is using the same IP.

Nicolas Defranoux
  • 2,646
  • 1
  • 10
  • 13
  • The problem is, the modules that have the issue won't see each others broadcast, because the packet is dropped. So, they just look offline to each other. I suppose I could just tack on a additional thing to check for if a node is down, but I was hoping for it to be more straight forward. – rawbus Aug 05 '14 at 21:50
  • ARP broadcast is not an UDP broadcast, it's a broadcast at ethernet level but the protocol is different from UDP. You need to create a special socket to receive them (raw socket if I remember properly). By the way, why don't you derive the IP from the MAC address ? – Nicolas Defranoux Aug 05 '14 at 21:53
  • Ah, I will have to explore that. I've never touched raw sockets before. As far as generating unique IPs, every module is suppose to know all the other modules that are suppose to be in the device. Not knowing this until run-time will sort of cause issues. – rawbus Aug 05 '14 at 22:02