lwip-devel
[Top][All Lists]

## Re: [lwip-devel] Question on comparations of sequence numbers

 From: narke Subject: Re: [lwip-devel] Question on comparations of sequence numbers Date: Sun, 25 Dec 2011 09:39:15 +0800

```On 23 December 2011 16:34, address@hidden <address@hidden> wrote:
> narke wrote:
>>
>>   #define TCP_SEQ_LEQ(a,b)    ((s32_t)((a)-(b))<= 0)
>>   #define TCP_SEQ_GEQ(a,b)    ((s32_t)((a)-(b))>= 0)
>>
>> so it means, a is within [b, c] iif
>>
>>  b<= a<= c
>
> In window-numbers, your example is correct, but not in integer arithmetic.
>
>> However, because sequence number cycles (module 2**32), so I cannot
>> understand why a - b>=  0 mean  a>= b or a - c<= 0 means a<= c.
>> For example, in a 2 bit window, and a window could be [3, 1] and 0
>> falls in the window.  But here 3<= 0<= 1 does not hold.
>
> I'm not sure I understand your example numbers. Should 3 be the smallest
> sequence number and 1 be the highest sequence number? How can that be if the
> biggest possible window size is 65535? If you meant it the other way round,
> 0 is outside of the window, isn't it?
>

I mean, just for example, if the sequence number space is only 2 bit,
then we have only 0, 1, 2, 3 as valid sequence numbers, right?  And,
if current sequence number is 3, so the next one must be 0 ( 0 = 3 + 1
mod 4), right?.

Well, now assume SND.UNA = 3 and SND.WND = 3, so the send window is 3,
0, 1 or [3, 1].   In this example, 0 is in the window and a = 3, b =
1, but a <= 0 <= b does not hold.

Okay, here the biggest possbile window size is 4.   If that would be
65535, I think it still possible to make another example but make the
explanation complicate.

--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

narke