Search code examples
csocketsnetwork-programmingudpchecksum

How to enable UDP checksums


I'm working on a project involving UDP socket communication between a VxWorks device and a Linux machine. In this project, I'd like to take advantage of the checksum field of the UDP header.

It appears that in the VxWorks socket interface, the checksum field of outgoing UDP packets is enabled by default.

However, for the usual Unix sockets interface, there doesn't appear to be any flag or other method to open a UDP socket that will check the checksum for incoming packets and populate it for outgoing ones.

For the usual Unix sockets interface, does such a flag exist?

Thanks!


Solution

  • I'm no expert, but the only thing that man 7 udp has to say on the matter suggests that it's enabled by default:

    UDP generates and checks checksums to catch transmission errors.

    It does not mention any way to disable it.

    Edit: I'm too lazy to look up current kernel source, but this page suggests that packets with invalid checksums are simply dropped (the csum_copy_err part).