From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
To: dccp@vger.kernel.org
Subject: Re: 48-bit sequence number arithmetic
Date: Fri, 15 Dec 2006 08:59:57 +0000 [thread overview]
Message-ID: <200612150859.58016@strip-the-willow> (raw)
In-Reply-To: <45818142.4090001@cs.ucla.edu>
Hi Eddie,
sorry there is a bit of confusion here. For the record, please let's move the
issue whether RFC 4340 is right or not out of the focus. If you say it is right,
I will not argue with it; but there are useful and valid points that can be
used to make existing algorithms better.
And I think it is time well spent to think these issues through, in particular since
the performance of CCID 3 for instance depends on the accuracy with which loss is
detected - therefore I don't think that it harms to strive for maximum precision in
these matters.
| - Patches to clean up sequence number arithmetic are fine.
| - Your analysis of the 2^47 problem is not correct, however. As RFC 1982
| says, two 48-bit numbers which are 2^47 apart are *unordered*. Think about
| it: You see 0 and 2^47. The distance between 0 and 2^47 is, IN EITHER
| DIRECTION, exactly 2^47. Neither can be declared before the other.
Although RFC 1982 is about serial numbers as they are used in the Domain Name
System, it is a very useful reference here. Your point is valid, and it is solved
by the solution below. My point here is that for 2^(n-1) the result should really be
'undefined': with the current solution of subtraction, the result is not undefined,
but ambiguous.
| - This is exactly the same case as in 32-bit TCP sequence number comparisons.
You are right and therefore RFC 4340 is not `wrong'. It is strange that this way
of comparing sequence numbers has survived for so long: as early as 4.4BSDLite
(the SEQ_LEQ macros in Stevens vol II), until today's Linux IP stack.
| - Therefore I'd recommend staying with the simplest check you can find, which
| may be the 64-bit trick recommended by RFC4340.
I found a solution which is as easy to implement as that _and_ removes the ambiguity.
It is, for two n-bit sequence numbers a and b, as follows:
a `before' b <=> 1 <= b-a <= 2^(n-1) - 1
To contrast: the previous definition was:
a `before' b <=> 2^(n-1) <= a-b <= 2^n-1
and it suffers from the ambiguity problem when a-b = 2^(n-1). With the former solution,
the ambiguity is removed: whenever the difference between a and b is 2^(n-1), the result
is 2^(n-1) and thus neither a `before' b nor b `before' a: this is exactly what RFC 1982
suggests.
And my suggestion is not even new: we say "it is 29 minutes /before/ xxx o'clock", but we
don't say "it is /half/ before xxx o'clock".
To summarise, the revised algorithm is:
* store 48-bit numbers in leftmost fields of 64-bit numbers as per RFC 4340
* a sequence number comparison based on the following pseudo-code:
int before48(u64 a, u64 b) { return ((b << 16) - (a << 16)) > 0; }
* this removes the ambiguity
* same suggestion was made for 32-bit TCP sequence numbers to netdev@vger
Gerrit
next prev parent reply other threads:[~2006-12-15 8:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-14 16:52 48-bit sequence number arithmetic Eddie Kohler
2006-12-14 16:56 ` Eddie Kohler
2006-12-15 8:59 ` Gerrit Renker [this message]
2006-12-17 22:19 ` Eddie Kohler
2006-12-19 10:33 ` Gerrit Renker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200612150859.58016@strip-the-willow \
--to=gerrit@erg.abdn.ac.uk \
--cc=dccp@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.