RFC 1982
Serial Number Arithmetic
Serial Number Arithmetic π¦
okay bestie, this is RFC 1982 π, and it's called "Serial Number Arithmetic" π. It's from the Network Working Group and dated August 1996 πΈ. The authors are R. Elz (University of Melbourne) and R. Bush (RGnet, Inc.) π«Ά. It's a Standards Track doc, so it's an Internet standards track protocol π. It updates RFC 1034 and RFC 1035 π§. There's no obsoletes line, so it doesn't replace anything π .
Status of This Memo β¨
this doc specifies an Internet standards track protocol for the Internet community, and it's asking for discussion and suggestions for improvements π. For the standardization state and status of this protocol, check the current edition of the "Internet Official Protocol Standards" (STD 1) π. Distribution of this memo is unlimited π.
Abstract π
so this memo defines serial number arithmetic, as used in the Domain Name System π. The DNS has long relied upon serial number arithmetic, a concept which has never really been defined, certainly not in an IETF document, though it's been widely understood. This memo supplies the missing definition π₯. It is intended to update RFC1034 and RFC1035.
1. Introduction π
the serial number field of the SOA resource record is defined in RFC1035 like this π:
SERIAL The unsigned 32 bit version number of the original copy of
the zone. Zone transfers preserve this value. This value
wraps and should be compared using sequence space
arithmetic.
RFC1034 uses the same terminology when defining secondary server zone consistency procedures π¦.
unfortunately, the term "sequence space arithmetic" isn't defined in either RFC1034 or RFC1035, and none of their references give any more info π.
this phrase seems to have been meant to describe the arithmetic used in TCP sequence numbers [RFC793], and defined in [IEN-74] π§ .
unfortunately, the arithmetic defined in [IEN-74] isn't good enough for the DNS, because no general comparison operator is defined π.
to avoid more problems with this simple field, this document defines the field and the operations you can do on it β¨. This definition is meant to clarify the intent of RFC1034 and RFC1035, and it's believed to generally agree with current implementations πΈ. However, older, superseded implementations are known to have treated the serial number as a simple unsigned integer, with no attempt at any kind of "sequence space arithmetic" (however that may have been interpreted). They also ignored the requirement that the value wraps. Nothing can be done with these implementations, beyond extermination π .
2. Serial Number Arithmetic π₯
serial numbers are formed from non-negative integers from a finite subset of the range of all integer values. The lowest integer in every subset used for this purpose is zero, and the maximum is always one less than a power of two π.
when you treat them as serial numbers, no value has any special significance. There's no minimum or maximum serial number, and every value has a successor and a predecessor π¦.
to define a serial number to be used this way, you have to give the size of the serial number space. This value, called "SERIAL_BITS", is the power of two that gives one more than the largest integer corresponding to a serial number value. It also tells you how many bits you need to hold every possible value of a serial number of that type π. The operations allowed on serial numbers are defined in the next section π.
3. Operations upon the serial number β¨
only two operations are defined on serial numbers: adding a positive integer of limited range, and comparing with another serial number π.
3.1. Addition π
serial numbers can be incremented by adding a positive integer n, where n is taken from the range of integers [0 .. (2^(SERIAL_BITS - 1) - 1)]. For a sequence number s, the result of that addition, s', is defined as:
s' = (s + n) modulo (2 ^ SERIAL_BITS)
the addition and modulus operations here act on values that are non-negative values of unbounded size, using the usual rules of integer arithmetic π§.
adding a value outside the range [0 .. (2^(SERIAL_BITS - 1) - 1)] is undefined π.
3.2. Comparison π¦
any two serial numbers, s1 and s2, can be compared. Here's how the result of that comparison works π.
for the purposes of this definition, think of two integers, i1 and i2, from the unbounded set of non-negative integers, where i1 and s1 have the same numeric value, and i2 and s2 have the same numeric value too. Arithmetic and comparisons on i1 and i2 use ordinary unbounded integer arithmetic π.
then, s1 is equal to s2 if and only if i1 is equal to i2. In all other cases, s1 is not equal to s2 π«Ά.
s1 is less than s2 if, and only if, s1 is not equal to s2, and:
(i1 < i2 and i2 - i1 < 2^(SERIAL_BITS - 1)) or
(i1 > i2 and i1 - i2 > 2^(SERIAL_BITS - 1))
s1 is greater than s2 if, and only if, s1 is not equal to s2, and:
(i1 < i2 and i2 - i1 > 2^(SERIAL_BITS - 1)) or
(i1 > i2 and i1 - i2 < 2^(SERIAL_BITS - 1))
there are some pairs of values s1 and s2 where s1 is not equal to s2, but s1 is neither greater than nor less than s2. Using these ordering operators on such pairs of values gives an undefined result π.
the reason is that for those pairs, any simple definition that said s1 is less than s2 would also usually say s2 is less than s1 when the pair is flipped to (s2, s1). That means the particular order you pick for a test could change the result, which would lead to unpredictable implementations π.
sure, you could define the test so the inequality doesn't have this weird property and is defined for all pairs of values. But that definition would be unnecessarily burdensome to implement and hard to understand, and it would still allow cases like this, which is just as non-intuitive:
s1 < s2 and (s1 + 1) > (s2 + 1)
so the problem case is left undefined. Implementations are free to return either result or to flag an error, and users must take care not to depend on any particular outcome. Usually this means avoiding letting those particular pairs of numbers exist at the same time π₯.
the relationships greater than or equal to, and less than or equal to, follow naturally from the definitions above π .
4. Corollaries πΈ
these definitions lead to some results worth noting π.
4.1. Corollary 1 β¨
for any sequence number s and any integer n where adding n to s is well defined, (s + n) >= s. Further, (s + n) == s only when n == 0. In all other defined cases, (s + n) > s π.
4.2. Corollary 2 π
if s' is the result of adding the non-zero integer n to the sequence number s, and m is another integer from the range that can be added to a sequence number, and s" is the result of adding m to s', then it's undefined whether s" is greater than or less than s. It is known, though, that s" is not equal to s π¦.
4.3. Corollary 3 π
if s" from the previous corollary is incremented further, then there's no longer any known relationship between the result and s π.
4.4. Corollary 4 π
if in corollary 2 the value (n + m) is such that adding the sum to sequence number s would produce a defined result, then corollary 1 applies, and s" is known to be greater than s π.
5. Examples π§
5.1. A trivial example π
the simplest meaningful serial number space has SERIAL_BITS == 2 πΈ. In this space, the integers that make up the serial number space are 0, 1, 2, and 3. That is, 3 == 2^SERIAL_BITS - 1 π.
in this space, the largest integer that's meaningful to add to a sequence number is 2^(SERIAL_BITS - 1) - 1, or 1 β¨.
so, as defined, 0+1 == 1, 1+1 == 2, 2+1 == 3, and 3+1 == 0. Further, 1 > 0, 2 > 1, 3 > 2, and 0 > 3. It's undefined whether 2 > 0 or 0 > 2, and whether 1 > 3 or 3 > 1 π.
5.2. A slightly larger example π¦
consider the case where SERIAL_BITS == 8. In this space, the integers that make up the serial number space are 0, 1, 2, ... 254, 255. 255 == 2^SERIAL_BITS - 1 π.
in this space, the largest integer that's meaningful to add to a sequence number is 2^(SERIAL_BITS - 1) - 1, or 127 π.
addition works how you'd expect in this space. For example: 255+1 == 0, 100+100 == 200, and 200+100 == 44 π
.
comparison is more interesting: 1 > 0, 44 > 0, 100 > 0, 100 > 44, 200 > 100, 255 > 200, 0 > 255, 100 > 255, 0 > 200, and 44 > 200 π₯.
note that 100+100 > 100, but (100+100)+100 < 100. Incrementing a serial number can make it "smaller" π. Of course, incrementing by a smaller number lets you do many more increments before this happens. Still, it's always something to be aware of: it can cause surprising errors, or be useful, since it's the only defined way to actually make a serial number decrease π.
the pairs of values 0 and 128, 1 and 129, 2 and 130, and so on, up to 127 and 255, are not equal. But in each pair, neither number is defined as greater than or less than the other π.
it could be defined (arbitrarily) that 128 > 0, 129 > 1, 130 > 2, ..., 255 > 127, by changing the comparison operator definitions as mentioned above. However, note that this would cause 255 > 127, while (255 + 1) < (127 + 1), as 0 < 128. Apart from being arbitrary, a definition like that would also be more costly to implement π§.
8. Document Updates β¨
okay so this section is lowkey a plot twist π RFC1034 and RFC1035 (the big DNS docs) both talk about "sequence space arithmetic," and this document says that wherever they say that, you should read it as serial number arithmetic instead. so the DNS docs get a little glow-up by pointing to this one π π
9. Security Considerations π
okay bestie, the security part is short but I need you to actually read it π«Ά this document does not consider security. like at all. it just doesn't go there π
what it does say is that nothing in here is believed to add to any security issues the DNS already has, and it also doesn't do anything to lessen them either π so it's neutral territory, not a fix and not a new hole. just know the security stuff isn't handled here, so don't assume it is π
References π
- [RFC1034] Domain Names - Concepts and Facilities, P. Mockapetris, STD 13, ISI, November 1987.
- [RFC1035] Domain Names - Implementation and Specification P. Mockapetris, STD 13, ISI, November 1987
- [RFC793] Transmission Control protocol Information Sciences Institute, STD 7, USC, September 1981
- [IEN-74] Sequence Number Arithmetic William W. Plummer, BB&N Inc, September 1978
Acknowledgements πΈ
big thank yous to the people who made this happen π«Ά Rob Austein gets credit for suggesting we clarify the undefined comparison operators (the vibe check that made everything make sense), and Michael Patton gets props for trying to dig up another reference for this procedure π΅οΈββοΈ we also love the IETF DNSIND working group from 1995-6 and especially Paul Mockapetris π
Authors' Addresses π¦
Robert Elz Randy Bush
Computer Science RGnet, Inc.
University of Melbourne 10361 NE Sasquatch Lane
Parkville, Vic, 3052 Bainbridge Island, Washington, 98110
Australia. United States.
EMail: kre@munnari.OZ.AU EMail: randy@psg.com
and that's the whole spec, bestie!! πβ¨ two authors, one serial number arithmetic glow-up, and zero security promises π π
π¦ where this page comes from
- ietf: rfc1982 1996-08
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms