UDP checksums?

According to Java Network Programming, UDP’s data checksum feature is “optional and not used in or accessible from application layer programs”. Since it’s optional and I can’t tell whether it was used, isn’t an invisibly optional checksum no better than no checksum at all, from my program’s point of view? What’s your experience: do you include your own application-level checksums in UDP packets? Are you seeing any corrupted packets?

Thanks,
David

Wouldn’t UDP packets with incorrect checksums be dropped at the transport layer, and hence we’d never see them?

e.g. if you recieve a packet from the far side in UDP you can guarantee that the data is intact. This would mean you wouldn’t need to include checksums at the application layer.

I could be wrong, but I thought this was how it worked.

Kev

That’s what I thought too, but if checksums are optional, then maybe the sender’s transport layer didn’t use them and hence you can’t be sure your data’s not corrupted. To be able to rely on corrupted packets being dropped, you’d need to be sure that the sender’s transport layer uses the optional checksums. This could be especially tricky if the sender is a MIDP 2.0-enabled mobile phone: it’s very hard to find out about their UDP protocol implementations.

I hope I’m missing something here…

I don’t think it’d be a Java issue really, more a platform issue. If their passing data backup to the application layer that could potentially be corrupted the implementation doesn’t match what UDP is meant to do.

I’m not saying this isn’t the case, but that if it is you’d need to take it up with the hardware/platform manufacturer.

On PC type hardware I’ve never recieved any corrupted packets, but I think thats the contract between UDP and the application layer.

Kev

A little Googling turns up that SunOS at least used to have UDP checksums switched off to speed up its NFS implementation. However, RFC 1122 ‘Requirements for Internet Hosts’ says that they must default to being on, so maybe the problem no longer exists. My general impression is that you’re only supposed to switch it off when using highly reliable networks (and typically LANs), but that protocol implementors have been somewhat inconsistent about this in the past. The Wikipedia entry on UDP says that UDP checksums are “almost always used in practice”, and that matches what an hour or so of Google-research turned up.

Oh well, I’ll just assume for now that it’s always used, but keep this in mind if I get puzzling bugs…