• Advertisement
Sign in to follow this  

UDP, reliable *un*ordered?

This topic is 3313 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Its well known how to implement reliable, ordered UDP using basic sequence numbering, but i'm trying to get my head around how one might implement a reliable unordered method. I'll keep on thinking, and post up if I come up with any ideas, I get the feeling I'm missing something really simple here :|

Share this post


Link to post
Share on other sites
Advertisement
It's not that different. Each packet is marked with a sequence number, and each sequence number is acknowledged, potentially out of order. The sender keeps a list of acked messages, and re-sends every once in a while. Note that you'll need to ack the acks to make sure that there's no problem with lost return packets (but you don't need to ack the acks of the acks :-)

Share this post


Link to post
Share on other sites
Thanks, thats sounds perfectly reasonable :)

I think my problem was I was trying to be too clever, e.g trying to avoid ack'ing every packet, with sequenced its possible just to ack the last in sequence packet.

Share this post


Link to post
Share on other sites
For implementation details, what you want to do is send many messages in a single UDP packet. Some of those are reliable ordered, some are reliable unordered, some are unreliable ordered, and some are unreliable unordered.

The trick is to only put a sequence number on the UDP packet, not each individual message. This sequence number is of course monotonously increasing. The recipient then acks only entire packets, not individual messages. It can do this with a "last received" and a small bitmask of messages recevied before the last received. For simplicitly, your window size can be the number of bits in your bit mask (typically 8 or 16 packets).

The sender then maps message numbers to UDP packet numbers, and keep that table in RAM while the outstanding packets are still desired/live. As long as the recipient discards packets that are out of window (and, technically, the window has to have a "slop" of at least one to allow for it to grow), you'll be fine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement