1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
|
<pre>Network Working Group R. Elz
Request for Comments: 1982 University of Melbourne
Updates: <a href="./rfc1034">1034</a>, <a href="./rfc1035">1035</a> R. Bush
Category: Standards Track RGnet, Inc.
August 1996
<span class="h1">Serial Number Arithmetic</span>
Status of this Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
Abstract
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 which has been widely understood. This memo
supplies the missing definition. It is intended to update <a href="./rfc1034">RFC1034</a>
and <a href="./rfc1035">RFC1035</a>.
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
The serial number field of the SOA resource record is defined in
<a href="./rfc1035">RFC1035</a> as
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.
<a href="./rfc1034">RFC1034</a> uses the same terminology when defining secondary server zone
consistency procedures.
Unfortunately the term "sequence space arithmetic" is not defined in
either <a href="./rfc1034">RFC1034</a> or <a href="./rfc1035">RFC1035</a>, nor do any of their references provide
further information.
This phrase seems to have been intending to specify arithmetic as
used in TCP sequence numbers [<a href="./rfc793" title="USC">RFC793</a>], and defined in [<a href="#ref-IEN-74" title="BB&N Inc">IEN-74</a>].
Unfortunately, the arithmetic defined in [<a href="#ref-IEN-74" title="BB&N Inc">IEN-74</a>] is not adequate for
the purposes of the DNS, as no general comparison operator is
<span class="grey">Elz & Bush Standards Track [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc1982">RFC 1982</a> Serial Number Arithmetic August 1996</span>
defined.
To avoid further problems with this simple field, this document
defines the field and the operations available upon it. This
definition is intended merely to clarify the intent of <a href="./rfc1034">RFC1034</a> and
<a href="./rfc1035">RFC1035</a>, and is 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 to implement any kind of "sequence space arithmetic",
however that may have been interpreted, and further, ignoring the
requirement that the value wraps. Nothing can be done with these
implementations, beyond extermination.
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Serial Number Arithmetic</span>
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, the maximum is always one
less than a power of two.
When considered as serial numbers however no value has any particular
significance, there is no minimum or maximum serial number, every
value has a successor and predecessor.
To define a serial number to be used in this way, the size of the
serial number space must be given. This value, called "SERIAL_BITS",
gives the power of two which results in one larger than the largest
integer corresponding to a serial number value. This also specifies
the number of bits required to hold every possible value of a serial
number of the defined type. The operations permitted upon serial
numbers are defined in the following section.
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Operations upon the serial number</span>
Only two operations are defined upon serial numbers, addition of a
positive integer of limited range, and comparison with another serial
number.
<span class="h3"><a class="selflink" id="section-3.1" href="#section-3.1">3.1</a>. Addition</span>
Serial numbers may be incremented by the addition of 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 such an addition, s', is defined as
s' = (s + n) modulo (2 ^ SERIAL_BITS)
<span class="grey">Elz & Bush Standards Track [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc1982">RFC 1982</a> Serial Number Arithmetic August 1996</span>
where the addition and modulus operations here act upon values that
are non-negative values of unbounded size in the usual ways of
integer arithmetic.
Addition of a value outside the range
[0 .. (2^(SERIAL_BITS - 1) - 1)] is undefined.
<span class="h3"><a class="selflink" id="section-3.2" href="#section-3.2">3.2</a>. Comparison</span>
Any two serial numbers, s1 and s2, may be compared. The definition
of the result of this comparison is as follows.
For the purposes of this definition, consider two integers, i1 and
i2, from the unbounded set of non-negative integers, such that i1 and
s1 have the same numeric value, as do i2 and s2. Arithmetic and
comparisons applied to i1 and i2 use ordinary unbounded integer
arithmetic.
Then, s1 is said to be equal to s2 if and only if i1 is equal to i2,
in all other cases, s1 is not equal to s2.
s1 is said to be 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 said to be 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))
Note that there are some pairs of values s1 and s2 for which s1 is
not equal to s2, but for which s1 is neither greater than, nor less
than, s2. An attempt to use these ordering operators on such pairs
of values produces an undefined result.
The reason for this is that those pairs of values are such that any
simple definition that were to define s1 to be less than s2 where
(s1, s2) is such a pair, would also usually cause s2 to be less than
s1, when the pair is (s2, s1). This would mean that the particular
order selected for a test could cause the result to differ, leading
to unpredictable implementations.
While it would be possible to define the test in such a way that the
inequality would not have this surprising property, while being
defined for all pairs of values, such a definition would be
<span class="grey">Elz & Bush Standards Track [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc1982">RFC 1982</a> Serial Number Arithmetic August 1996</span>
unnecessarily burdensome to implement, and difficult to understand,
and would still allow cases where
s1 < s2 and (s1 + 1) > (s2 + 1)
which is just as non-intuitive.
Thus 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 will mean
avoiding allowing those particular pairs of numbers to co-exist.
The relationships greater than or equal to, and less than or equal
to, follow in the natural way from the above definitions.
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Corollaries</span>
These definitions give rise to some results of note.
<span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. Corollary 1</span>
For any sequence number s and any integer n such that addition of 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.
<span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. Corollary 2</span>
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 defined as able to
be added to a sequence number, and s" is the result of adding m to
s', then it is undefined whether s" is greater than, or less than s,
though it is known that s" is not equal to s.
<span class="h3"><a class="selflink" id="section-4.3" href="#section-4.3">4.3</a>. Corollary 3</span>
If s" from the previous corollary is further incremented, then there
is no longer any known relationship between the result and s.
<span class="h3"><a class="selflink" id="section-4.4" href="#section-4.4">4.4</a>. Corollary 4</span>
If in corollary 2 the value (n + m) is such that addition of the sum
to sequence number s would produce a defined result, then corollary 1
applies, and s" is known to be greater than s.
<span class="grey">Elz & Bush Standards Track [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc1982">RFC 1982</a> Serial Number Arithmetic August 1996</span>
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Examples</span>
<span class="h3"><a class="selflink" id="section-5.1" href="#section-5.1">5.1</a>. A trivial example</span>
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 it is meaningful to add to a
sequence number is 2^(SERIAL_BITS - 1) - 1, or 1.
Then, 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 is undefined whether
2 > 0 or 0 > 2, and whether 1 > 3 or 3 > 1.
<span class="h3"><a class="selflink" id="section-5.2" href="#section-5.2">5.2</a>. A slightly larger example</span>
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 it is meaningful to add to a
sequence number is 2^(SERIAL_BITS - 1) - 1, or 127.
Addition is as expected 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 that (100+100)+100 < 100. Incrementing
a serial number can cause it to become "smaller". Of course,
incrementing by a smaller number will allow many more increments to
be made before this occurs. However this is always something to be
aware of, it can cause surprising errors, or be useful as it is the
only defined way to actually cause a serial number to decrease.
The pairs of values 0 and 128, 1 and 129, 2 and 130, etc, to 127 and
255 are not equal, but in each pair, neither number is defined as
being 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 that would cause
255 > 127, while (255 + 1) < (127 + 1), as 0 < 128. Such a
definition, apart from being arbitrary, would also be more costly to
implement.
<span class="grey">Elz & Bush Standards Track [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc1982">RFC 1982</a> Serial Number Arithmetic August 1996</span>
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Citation</span>
As this defined arithmetic may be useful for purposes other than for
the DNS serial number, it may be referenced as Serial Number
Arithmetic from <a href="./rfc1982">RFC1982</a>. Any such reference shall be taken as
implying that the rules of sections <a href="#section-2">2</a> to <a href="#section-5">5</a> of this document apply to
the stated values.
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. The DNS SOA serial number</span>
The serial number in the DNS SOA Resource Record is a Serial Number
as defined above, with SERIAL_BITS being 32. That is, the serial
number is a non negative integer with values taken from the range
[0 .. 4294967295]. That is, a 32 bit unsigned integer.
The maximum defined increment is 2147483647 (2^31 - 1).
Care should be taken that the serial number not be incremented, in
one or more steps, by more than this maximum within the period given
by the value of SOA.expire. Doing so may leave some secondary
servers with out of date copies of the zone, but with a serial number
"greater" than that of the primary server. Of course, special
circumstances may require this rule be set aside, for example, when
the serial number needs to be set lower for some reason. If this
must be done, then take special care to verify that ALL servers have
correctly succeeded in following the primary server's serial number
changes, at each step.
Note that each, and every, increment to the serial number must be
treated as the start of a new sequence of increments for this
purpose, as well as being the continuation of all previous sequences
started within the period specified by SOA.expire.
Caution should also be exercised before causing the serial number to
be set to the value zero. While this value is not in any way special
in serial number arithmetic, or to the DNS SOA serial number, many
DNS implementations have incorrectly treated zero as a special case,
with special properties, and unusual behaviour may be expected if
zero is used as a DNS SOA serial number.
<span class="grey">Elz & Bush Standards Track [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc1982">RFC 1982</a> Serial Number Arithmetic August 1996</span>
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. Document Updates</span>
<a href="./rfc1034">RFC1034</a> and <a href="./rfc1035">RFC1035</a> are to be treated as if the references to
"sequence space arithmetic" therein are replaced by references to
serial number arithmetic, as defined in this document.
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Security Considerations</span>
This document does not consider security.
It is not believed that anything in this document adds to any
security issues that may exist with the DNS, nor does it do anything
to lessen them.
References
[<a id="ref-RFC1034">RFC1034</a>] Domain Names - Concepts and Facilities,
P. Mockapetris, STD 13, ISI, November 1987.
[<a id="ref-RFC1035">RFC1035</a>] Domain Names - Implementation and Specification
P. Mockapetris, STD 13, ISI, November 1987
[<a id="ref-RFC793">RFC793</a>] Transmission Control protocol
Information Sciences Institute, STD 7, USC, September 1981
[<a id="ref-IEN-74">IEN-74</a>] Sequence Number Arithmetic
William W. Plummer, BB&N Inc, September 1978
Acknowledgements
Thanks to Rob Austein for suggesting clarification of the undefined
comparison operators, and to Michael Patton for attempting to locate
another reference for this procedure. Thanks also to members of the
IETF DNSIND working group of 1995-6, in particular, 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
Elz & Bush Standards Track [Page 7]
</pre>
|