5
votes

I am trying to send UDP datagrams from a UdpClient on Windows XP to a device, but it is not responding. When I look at that traffic in Wireshark, I see that my outbound packets are bad, because all of their IP header checksums are 0x0000.

The machine has two network cards, so I started using the other network card and started experiencing the same issue.

I can ping my device with both network cards just fine, so I assume there must be something that my C# code is doing wrong, but I am not sure what. Is there something you can do wrong in .NET 4 on Windows XP with a UdpClient to cause this?

2

2 Answers

8
votes

You're seeing an empty checksum because Windows is performing hardware offloading of the checksum calculation. It will be performed by the network interface card's (NIC) processor. Capturing a packet using a packet sniffer will show the packet before it has been processed by your NIC. You can turn off offloading from the device's properties page under Device Manager:

enter image description hereenter image description here

In any case, the UDP protocol defines the checksum as optional, and zero is a valid value for the checksum. This is to allow devices with low processing power to skip the checksum calculation. The checksum will usually be filled-in by the first network node that processes the packet (e.g. router). Even if it remains zero, your device should still accept the packet as it's valid.

EDIT: I've just realized that you're talking about the IP header, not the UPD header. This applies to both, except that the IP header checksum is not optional (and will be calculated by your NIC).

4
votes

Looks like a driver issue. Try turning off checksum offload in the driver properties.

Alternatively, if you are running wireshark on the same machine, it may be that checksum offload is working correctly and Wireshark is not reporting the checksum because it is being calculated after Wireshark sees the packet.

To confirm run wireshark on a separate box to confirm the checksum is zero or is not zero.

If the checksums are OK after all, then it is likely a firewall issue. Make sure you have a firewall rule on the local machine permitting the return traffic.