What is the right approach to checksumming UDP packets

Posted by mr.b on Stack Overflow See other posts from Stack Overflow or by mr.b
Published on 2010-03-09T01:00:28Z Indexed on 2010/03/09 1:06 UTC
Read the original article Hit count: 374

I'm building UDP server application in C#. I've come across a packet checksum problem.

As you probably know, each packet should carry some simple way of telling receiver if packet data is intact.

Now, UDP already has 2-byte checksum as part of header, which is optional, at least in IPv4 world. Alternative method is to have custom checksum as part of data section in each packet, and to verify it on receiver.

My question boils down to: is it better to rely on (optional) checksum in UDP packet header, or to make a custom checksum implementation as part of packet data section?

Perhaps the right answer depends on circumstances (as usual), so one circumstance here is that, even though code is written and developed in .NET on Windows, it might have to run under platform-independent Mono.NET, so eventual solution should be compatible with other platforms. I believe that custom checksum algorithm would be easily portable, but I'm not so sure about the first one.

Any thoughts?

Also, shouts about packet checksumming in general are welcome.

© Stack Overflow or respective owner

Related posts about network-programming

Related posts about udp