I’m working on an application which transfers encrypted files over UDP (yes; I know UDP isn’t usually used for file transfer, but this is an edge case), and was wondering if its worth the additional overhead to add an extra checksum to the packet. I know it’s not ‘likely’ that UDP packets will come in corrupted, but would it be worth it to add an additional checksum?
I’m working on an application which transfers encrypted files over UDP (yes; I know
Share
UDP already has a checksum 16 bits, very unlikely that there is a collision, possible in theory.
You definitely want partial checksums. If you have a 1TB file that takes a day to transfer and then you get a hash fail, that would make you very sad.
Lazy solution: Hash every megabyte or so? Maybe more or less, eyeball it.
Right solution: Write an application that sends random data and hashes with your UDP transfer spec. See what percentage fails, (bonus: find tonnes of bugs in your app and fix them in advance) estimate what data sizes you should hash.
Probably not a big deal to go lazy on this one. Just think, how much time are you okay wit losing? How much data will 99% of your use cases transfer in that time? That is how much data you should be hashing intermediately.