[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] Question on comparations of sequence numbers
From: |
narke |
Subject: |
[lwip-devel] Question on comparations of sequence numbers |
Date: |
Thu, 22 Dec 2011 20:52:09 +0800 |
Hi,
To check if a sequence number a within a window [b, c], a macro was used:
#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c))
And, because, TCP_SEQ_LEQ and TCP_SEQ_GEQ are defined as,
#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
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.
How to understand that?
Thanks in advance.
--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer
narke
public key at http://subkeys.pgp.net:11371 (address@hidden)
- [lwip-devel] Question on comparations of sequence numbers,
narke <=