[ENet-discuss] Newby Question

Lee Salzman lsalzman1 at cox.net
Fri Aug 17 07:19:24 PDT 2007

I do some trickery to compress a 32 bit sequence number into 16 bits. 
This saves a huge amount of bandwidth on little packets.

If the sequence number received so far on a channel are all at the high
end of the 16 bit range, but you received a sequence number at the low 
end, that, without much loss, you can assume that it was just a sequence 
number that wrapped around back to the low end again, hence, it should 
be really treated as a number 2^16 greater than it actually is. That's
what that first test does. In this case, ">= 0xF000" being the high end,
and "< 0x1000" being the low end.

The second test just checks if the sequence number is old, i.e. if even
after adjustment the sequence number is less than the ones already received.

It is almost impossible that you will have anywhere near to 2^16 packets 
in flight at any given tme, so that's what makes this sort of 
compression possible.


Giuseppe Greco wrote:
> HI guys,
> I'm trying to learn ENet so I'm looking at the source code...
> Nice stuff, you did really a great job!!! I've just a question:
> In file peer.c, function enet_peer_queue_incoming_command, what
> is the purpose of lines 563-567?
> if (channel -> incomingReliableSequenceNumber >= 0xF000 &&
>         reliableSequenceNumber < 0x1000)
>     reliableSequenceNumber += 0x10000;
> if (reliableSequenceNumber < channel -> incomingReliableSequenceNumber
>         || (channel -> incomingReliableSequenceNumber < 0x1000
>         && (reliableSequenceNumber & 0xFFFF) >= 0xF000
>     goto freePacket;
> For instance, could you explain me what are you testing here?
> Tx a lot,
> j3d.

More information about the ENet-discuss mailing list