Question

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; http://i.imgur.com/6Ct52QG.png

Is this a problem with my code, or the input? Or is there something else?

Was it helpful?

Solution

Is this a problem with my code

No, because your code isn't generating the IP checksum. That's either generated by the OS's networking stack or, as Nikolai Fetissov noted in his answer, by the network adapter.

If your network analyzer is running on the machine that sent the packet, and the checksum is generated by the network adapter rather than by the networking stack, then, because capturing your own packets is done by the networking stack "looping those packets back" to the capture mechanism rather than by the network adapter capturing the packets that it transmits (which few if any adapters will), the captured packets will not have had the IP checksum calculated and will thus almost certainly appear to have a bad IP checksum.

Note the "may be caused by "IP checksum offload"?" in the Wireshark display. That's what Wireshark is talking about.

OTHER TIPS

That's expected with modern network cards that do checksumming in hardware. Don't worry about this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top