chaotic serial numbers

Mark.Andrews at nominum.com Mark.Andrews at nominum.com
Tue Jun 26 14:21:42 UTC 2001


	The serial number uses Serial Number Arithmetic.  This is
	formally defined in RFC 1982.  It's also what TCP uses for
	its sequence space.

	The serial number is a 32 bit number.
	Its range is 0..4294967295.
	x > y if x is in the range
		 (y+1)%4294967296 .. (y+2147483647)%4294967296
	x < y if x is in the range
		 (y-1)%4294967296 .. (y-2147483647)%4294967296

	You will note this leaves (y+/-2147483648)%4294967296 which
	is opposite y but neither greater than or less than y.

	A slave will update itself if when it performs its refresh
	check it discovers that its serial is less than that of
	the master.

	The following program can be used to compute the serial
	numbers required to get you to any final serial number
	starting at any serial number and bring all the slaves into
	sync provided you stay at each value (including the first)
	for at least a refresh period.  It assumes a 32 bit long.

	Mark

#include <stdlib.h>
#include <limits.h>
#include <stdio.h>

#define SEQ_GT(a,b)   ((long)((a)-(b)) > 0)
#define STEP 0x7fffffffUL

main(argc,argv)
	int argc;
	char **argv;
{
	unsigned long t2;
	unsigned long start, end;
	char *e;
	
	if (argc < 3)
		exit(1);
	start= strtoul(argv[1], &e, 10);
	if (*e != '\0')
		printf("bad start \"%s\"\n", argv[1]);
	end = strtoul(argv[2], &e, 10);
	if (*e != '\0')
		printf("bad end \"%s\"\n", argv[1]);

	t2 = start + STEP;

	printf("%lu %lu", start, t2);
	t2 += STEP;
	while (SEQ_GT(end, t2)) {
		printf(" %lu", t2);
		t2 += STEP;
	}
	printf(" %lu\n", end);
	exit(0);
}
--
Mark Andrews, Nominum Inc.
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: Mark.Andrews at nominum.com


More information about the bind-users mailing list