lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: narke
Subject: Re: [lwip-devel] Question on comparations of sequence numbers
Date: Tue, 27 Dec 2011 22:19:44 +0800

On 27 December 2011 05:09, Simon Goldschmidt <address@hidden> wrote:
> narke <address@hidden> wrote:
>
>> 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.
>
> OK, so now I understand. In that case, note that your example doesn't really 
> hold: in real life, the maximum window size is 16 bit (unsigned) while our 
> macros cast to 32 bit (signed!), so your a<=0<=b isn't really correct as it 
> doesn't take care for the data types.
>
> Simon


Thanks Simon.  Now I understand where I was wrong but with different reasoning.

Yes, my example window [3, 1] has a size greater than what it should
be allowed.  For this point, it's impossible in TCP.  But the sequence
number 0 in my question still falls in the window by applying the
mentioned macros, I just did a incorrect signed/unsigned arithmetic:

Unsigned:  0 - 3 = 1, cast to signed, it's 1.  (positive)
Unsigned: 0 - 1 = 3, cast to signed, it's -1 (negative)

So, 0 > 3 and 0 < 1, so 0 is in the window [3, 1].

This is exactly what the macros does.   Am I right?


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

narke
public key at http://subkeys.pgp.net:11371 (address@hidden)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]