I am trying to get Python3 on Windows to join a IPv4 Link Local multicast group 239.255.0.3. When I configured my script to join group 224.3.29.71 I got a Windows firewall prompt and I successfully joined the group and received messages. But when I change the group address to 239.255.0.3 (on both transmitter and receiver) the messages no longer get through. In both configurations, I can see (via Wireshark) the packets arriving into Windows. But they do not arrive in my application. I have a single Ethernet cable running directly from my Windows PC (static IP config) to the embedded device which is transmitting the multicast packets (also static IP config).
Details:
- IPv4 Subnet: 192.168.150.0/24
- Transmitter IP: 192.168.150.2
- Receiver IP: 192.168.150.5
- Working multicast address: 224.3.29.71
- Not-working multicast address: 239.255.0.3
Receiver code:
import socket
import struct
import sys
multicast_group = '244.3.29.71' # WORKS
#multicast_group = '239.255.0.3' # DOES NOT WORK. OF COURSE I AM CHANGING THE TX SIDE TO MATCH.
address = ('', 32768)
# Create the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#allow other sockets to bind this port too
sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
# Bind to the server address
sock.bind(address)
# Tell the operating system to add the socket to the multicast group
# on all interfaces.
group = socket.inet_aton(multicast_group)
mreq = struct.pack('4sL', group, socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
# Receive loop
while True:
print('nwaiting to receive message', address[1], file=sys.stderr)
data, address = sock.recvfrom(1024)
print('received %s bytes from %s' % (len(data), address), file=sys.stderr)
print(data.decode(), file=sys.stderr)
Are there some Windows settings I need to configure to allow 239...* multicast groups to work?