I'm trying to write a program to accept network UDP signals across the network. However, even just using the example code in Ethernet - Arduino Reference, the packets are not received (packetSize always equals 0) unless the sender device explicitly sends the data to the Arudino's IP address, then it works as expected. Unfortunately I want multiple devices to read these signals so this is not a satisfactory solution for me.
I'm running an Arduino Mega2560 R3 and a regular ethernet shield.
Is this normal? I honestly couldn't figure out why the Broadcast UDP signals weren't being received, or is there another step that I'm missing...?
You must set the ip address in the ethernet shield to the broadcast address of the network it is on. For an example, if the network is 192.168.0.0/24, the broadcast ip is 192.168.0.255. This does not apply to dhcp, since there is no network, so I think it uses 255.255.255.255.
All that depends on the network settings used by the sender. Normally the network netmask is 255.255.255.0. That is what it uses by default if you do not specify a subnet in the begin call. The broadcast ip is the last ip in that network subnet. This would be the broadcast ip for that ip/subnet.