If I am receiving data through UDP, with a checksum that checks out to show no data loss, is there a possibility that the checksum missed some errors. My data transmitted is split into 24-bits chunks by the protocol that uses the checksum. Similarly, if errors are detected through the checksum, does that fully guarantee that the error actually occured?

1 Answer 1


If you mean the optional (for IPv4, but required for IPv6) UDP checksum, then that creates a 16-bit checksum that conceptually matches multiple combinations of datagrams that are larger than 16-bits. There is no guarantee that a UDP datagram that matches the checksum is error-free, but the odds of an error are very small. Many errors that would match the checksum would prevent the datagram from reaching its destination.

If the checksum indicates an error, then something is wrong somewhere, and it is almost always corruption in the datagram. Other possibilities include an incorrect or buggy checksum algorithm on the part of the sender or receiver.

If you mean a checksum in the application data, that further protects the data, but that is off-topic here.

There are also the possibilities that bits get flipped in RAM or on a disk drive. It does happen, but not very often.

See RFC 768, User Datagram Protocol:

Checksum is the 16-bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets.

The pseudo header conceptually prefixed to the UDP header contains the source address, the destination address, the protocol, and the UDP length. This information gives protection against misrouted datagrams. This checksum procedure is the same as is used in TCP.

              0      7 8     15 16    23 24    31 
             |          source address           |
             |        destination address        |
             |  zero  |protocol|   UDP length    |

If the computed checksum is zero, it is transmitted as all ones (the equivalent in one's complement arithmetic). An all zero transmitted checksum value means that the transmitter generated no checksum (for debugging or for higher level protocols that don't care).

  • With large transfers over bad networks the TCP/UDP checksums are nowhere near strong enough to reliably prevent corruption. Feb 16, 2017 at 21:49
  • This is correct. The algorithms in use are a trade-off between performance and acceptable performance in the context of the original specs of these protocols. In practice it's proven to be good enough in the majority of cases but there's no question that app-level sanity checking is never a bad idea. There's also the interesting phenomenon that encryption can serve as an excellent error-detection mechanism.
    – rnxrx
    Feb 17, 2017 at 3:08
  • Also, I think it will be pretty evident that there is a problem when there are a lot of checksum errors. It is very unlikely that all UDP datagrams will pass the checksum when a lot of the datagrams are damaged. I wouldn't trust any data if there is even one percent of datagrams not passing the checksum.
    – Ron Maupin
    Feb 17, 2017 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.