I'm trying to connect to a multicast group to receive some UDP packets. The code I'm using is working good, I'm receiving the packets and I haven't had a problem with this before. But just now there is a new requirement that needs the packets to pass through a switch which needs to see the Multicast join message. Before it has just been dumb switches and this hasn't been a problem.
To join the multicast group, I use this code:
var LocalAddress = "228.12.12.27";
var LocalPort = 46715;
var LocalEndPoint = new IPEndPoint(IPAddress.Parse(LocalAddress), LocalPort);
var RxSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
RxSocket.Blocking = false;
RxSocket.ReceiveBufferSize = UInt16.MaxValue;
RxSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
RxSocket.Bind(new IPEndPoint(IPAddress.Any, LocalEndPoint.Port));
RxSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(LocalEndPoint.Address));
RxSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 50);
RxSocket.Close();
The line that generates the IGMP Join message is
RxSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(LocalEndPoint.Address));
And the IGMP Join message is sent out.
However, as I snoop the network with Wireshark, I see that the IGMP message has a bad checksum;
Is this a problem with my code, or the input? Or is there something else?