Apologies in advance for the incompleteness/unprofessional terms as I do not have a CS background and Thank you so much for your help!
I am making a Simple Multicast Receiver through Python, the receiver receives singlecast/multicast/broadcast packets through ethernet connection from a Elevator Control Server. And I encountered a strange problem:
When my computer is connected to Wifi, the multicast packets stops being received, while singlecast/broadcast packets are fine. I used wireshark to monitor the ethernet connection and found that the multicast packets are still being transmitted, just not received and printed on my receiver.
I used wireshark to monitor the wifi connection when wifi is turned on and found that there is packets sent from my device to the router, in IGMPv2 protocol, source ip being my device ip and destination ip being the multicast ip address specified in my receiver code.
So I wonder does the transmission between my device and the router when wifi is connected affect my receiver from receiving multicast packets?
For the receiver I just basically used the code from this solution: How do you UDP multicast in Python?
import socket
import struct
MCAST_GRP = '239.64.0.2'
MCAST_PORT = 52000
IS_ALL_GROUPS = True
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if IS_ALL_GROUPS:
# on this port, receives ALL multicast groups
sock.bind(('', MCAST_PORT))
else:
# on this port, listen ONLY to MCAST_GRP
sock.bind((MCAST_GRP, MCAST_PORT))
mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
while True:
# For Python 3, change next line to "print(sock.recv(10240))"
print sock.recv(10240)
I tried using Wireshark to monitor the packets transmission of both the ethernet and wifi connections, I speculate the connection to wifi blocks the binding of port and multicast address. However I am shooting in the dark here and please correct and enlighten me.