When whitelynx posted his initial ideas
about the RUDP protocols, he posted the following questions (which have since been removed, so that we can discuss them without turning the wiki into a forum... :o)
- If Sequence # is 0, then this packet is unordered.
- Do we need all those flag bits?
- Is there any way we can shorten up the unreliable and unordered packets?
- Use a flag for sequenced/non-sequenced packets so we can save the sequence # byte?
- Do we really need header length?
After reading through the first part of the RUDP spec, I think I can answer a few of these (and pose a few questions of my own):
Do we really need header length?
If we look further down the spec, we can see that every segment
except EAK has a fixed length in bytes (which is the unit of the value in header length). About half of the segments (ACK, RST, NUL) have header lengths of 6. SYN has the longest length at 28, and TCS has 12. Only EAK has a variable-length header, since the header contains the list of segments received out of sequence. "Its minimum value is seven and its maximum value depends on the maximum receive queue length." Thus, we need the header length to know how long the segment header is.
I suppose we can make an argument that if we know the type of segment (based on the flags at the start) that we know the size of the segment, meaning that the size is not needed. However, I'd still think the size would be necessary for determining whether additional data was included in the segment (which is expressly forbidden for certain segment types - SYN, RST, NUL - meaning that an error would be thrown), and for determining whether the whole packet made it (especially important for EAK, since we can't know the full header length).
It is worth noting that the spec refers to the data as "segments," not "packets." I think this is due to RUDP being implemented on top of the UDP protocol - the whole thing, UDP header + RUDP header + data (if any) is the whole packet. However, to UDP's standpoint, the RUDP header is simply regular data in binary form, to be interpreted in any way so chosen by the recipient. Thus, I think the spec is thinking of the RUDP headers as simply "segments" in the packet as a whole. Just an observation I thought I'd share.
Do we need all those flag bits?
As described above, the flag bits are necessary to know what kind of packet we're dealing with, so I'll take this question as "Do we have to send all of the types of packets described in the spec?" Initially, I'd say yes - they're in the spec, so we should probably use them. The only one we may not end up using is the NUL packet, which is basically the equivalent of a "ping," which the
Gamdev.net forum post says can easily be accomplished (in games) by just watching the traffic going back and forth. However, I would still rather include it for completeness's sake, rather than leaving it out to save a bit and a minor bit of logic to handle it.
Is there any way we can shorten up the unreliable and unordered packets?
I want to start a separate thread on this, so we can define what we mean by reliable / unreliable and ordered / unordered, which I'm still not entirely clear on.
Two questions of my own:
- Where does channel number fit in here?
- These headers are both for sending ordered data packets? Is that why we have the 7th bit 0 for reliable and 1 for unreliable (which I would reverse, personally)?