With UDP you can get things out of order, and some might not make it. If you are sending a longer message across multiple packets, you also will likely need to add a sequence number to the message data, and have your client track the sequence numbers, and NAK back any packets that it missed after some reasonable amount of time. This can be used for various purposes, including rejecting corrupted packets (say, someone tried modifying the data and calculated the UDP level checksum correctly, but not your application level checksum). ![]() On the receiver side, you extract the message, checksum it up to where the checksum is saved (), compare to the saved checksum. You'd need to calculate the checksum using whatever mechanism you wish, then append it and send it with your message data. ![]() That being said, applications can add their own checksumming to the data part of the packet (or series of packets), to verify that the data in the packet is what was originally sent. They don't get NACK'd though, they just get dropped. ![]() ![]() Your receiver won't even see 'bad' UDP packets, because the network drivers will reject them. Well most network stacks do the packet level UDP checksumming automatically at a lower level than your application.
0 Comments
Leave a Reply. |