I have setup an independent network (that is not connected to any other devices) with four devices each of which are on a slightly different subnet. There is just a hub with the four devices connected to it.
- Raspberry Pi: 10.10.0.1/24
- Embedded Old: 10.11.0.1/24
- Embedded New: 10.12.0.1/24
- Mac: 10.13.0.1/24
We are sending a UDP broadcast using the following code:
import socket
UDP_IP_ADDRESS = "255.255.255.255"
UDP_PORT_NO = 5007
MESSAGE = "Hello, world!"
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
udp_socket.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP_ADDRESS, UDP_PORT_NO))
udp_socket.close()
And we have the following code on each device listening for the broadcast.
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) # UDP
client.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
client.bind(("", 5007))
while True:
data, addr = client.recvfrom(1024)
print("received message: %s" % data)
The Mac, Raspberry Pi and the Embedded PC (old image) all receive the UDP broadcasts.
The Embedded PC (new image) will not receive the UDP broadcast. Interestingly the new image will receive the broadcast if the sender is on the same subnet.
The Embedded PC (old image) is running:
- Kernel: 5.3
- OE: Warrior
The Embedded PC (new image) is running:
- Kernel: 6.1
- OE: Kirkstone
Has anything changed between these versions that might prevent it from receiving UDP broadcasts? Is there a networkd setting that we need to make?
Update:
Nothing was received on a 255.255.255.255 broadcast:
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 64 0 0 0 25 0 0 0 BMRU
lo 65536 0 0 0 0 0 0 0 0 LRU
----------> SEND BROADCAST PACKET
root@VIA-511723:~# netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 64 0 0 0 25 0 0 0 BMRU
lo 65536 0 0 0 0 0 0 0 0 LRU
but on a regular message it was:
root@VIA-511723:~# netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 64 0 0 0 25 0 0 0 BMRU
lo 65536 0 0 0 0 0 0 0 0 LRU
-----> SEND PACKET 192.168.10.255
root@VIA-511723:~# netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 65 0 0 0 25 0 0 0 BMRU
lo 65536 0 0 0 0 0 0 0 0 LRU
Update 2
Going back to Kernel 5.3 (with Kirkstone) had the same problem.
sysctl -w net.ipv4.conf.all.rp_filter=0; sysctl -w net.ipv4.conf.eth0.rp_filter=0