[Vortex] Question regarding sequence number calculations
pblack at tresys.com
Wed Nov 28 19:24:37 CET 2012
I'm trying to understand something in the vortex code, namely how sequence numbers are calculated when they overflow.
>From the BEEP RFC, the max seq number is 4294967295 (2^32 - 1), and that arithmetic needs to be done modulo 4294967296 (2^32).
I see in the vortex code that there are defines for both of these (MAX_SEQ_NO & MAX_SEQ_MOD) in vortex_types.h, but MAX_SEQ_MOD is never used.
In the code, there are a number of places where MAX_SEQ_NO is used and a few places where it's used to perform modulus arithmetic.
Of particular concern (though admittedly, I'm no BEEP expect and I've only traced a little of the vortex code) is around line 2230 of vortex_channel.c, from the 1.1.12 release:
channel->last_seq_no = ((channel->last_seq_no + frame_size) % (MAX_SEQ_NO));
I think this incorrectly calculate the next seq number. i.e. if the last_seq_no was 4294967295, and the frame size was 10, then (according to the RFC) last_seq_no should end up as 9, while this code would assign it to 10.
Similarly at line 2299 of the same file:
channel->last_seq_no_expected = ((channel->last_seq_no_expected + frame_size) % (MAX_SEQ_NO)
Like I said, I don't really know the codebase or protocol all too well, so I'm a bit wary of making any modifications to the code base.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vortex