Hello, I have a project where I need to run two NTP systems in parallel on a Linux system. The reason for this is that I need two time domains: One using the real time obtained from an external NTP server, and one to control a local time. The first NTP system, obtaining the time from an external NTP server will be an unmodified version of the NTP source code, while the second is changed in two aspects: First, the network communication will be moved to another port that 123. Let's assume it's 1234 for now. Second, rather than using clock_gettime() and adjtime() it will use calls that modify a second clock which is implemented in the Linux kernel.
I have tried doing the first by creating a new entry in my /etc/services called "ntp2" which maps to 1234/tcp and 1234/udp. The source of NTP has also been changed to use 1234 rather than 123 where it is hard-coded. Right now I am running this modified NTP system alone, i.e. no ordinary NTP server is running on either of my test machines. There are two machines: PC1 (ip: 10.0.0.1) and PC2 (10.0.0.2), with the following configuration files for ntpd: PC1: ntp.conf === driftfile /tmp/ntp.drift peer 10.0.0.2 PC2: ntp.conf === driftfile /tmp/ntp.drift peer 10.0.0.1 server 127.127.1.1 fudge 127.127.1.1 stratum 5 If I run the modified ntpd with the above configurations, it seems that the communicate with each other. However, ntpq behaves strange. Running "ntpq -c peers" on PC2 gives: remote refid st t when poll reach delay offset jitter ============================================================================== Running "ntpq -c lassociations" on PC2 gives: ind assID status conf reach auth condition last_event cnt =========================================================== 1 10139 8000 yes yes none reject 2 10140 9614 yes yes none sys.peer reachable 1 The output on PC1 is the same: The peer does not show up in "peers" but does so in "lassociations". If I use an unmodified version of NTP the output is more logical (run on PC2): > ntpq -c peers remote refid st t when poll reach delay offset jitter ============================================================================== PC1 .INIT. 16 u 43 64 0 0.000 0.000 0.000 *LOCAL(1) .LOCL. 5 l 4 64 3 0.000 0.000 0.001 > ntpq -c lassociations ind assID status conf reach auth condition last_event cnt =========================================================== 1 47207 8000 yes yes none reject 2 47208 9614 yes yes none sys.peer reachable 1 So it seems that changing the network port used somehow destroys functionality. I am using ntp-dev-4.2.5p82, and apply the patch attached listed below to change the network port. Can anyone help me solve this problem? Cheers, Paul diff -urN unmod/ntp-dev-4.2.5p82/include/ntp.h ntp-dev-4.2.5p82/include/ntp.h --- unmod/ntp-dev-4.2.5p82/include/ntp.h 2007-10-04 13:03:26.000000000 +0200 +++ ntp-dev-4.2.5p82/include/ntp.h 2009-09-11 14:03:39.000000000 +0200 @@ -98,7 +98,7 @@ */ #define NTP_VERSION ((u_char)4) /* current version number */ #define NTP_OLDVERSION ((u_char)1) /* oldest credible version */ -#define NTP_PORT 123 /* included for non-unix machines */ +#define NTP_PORT 1234 /* included for non-unix machines */ /* * Poll interval parameters diff -urN unmod/ntp-dev-4.2.5p82/ntpd/version.c ntp-dev-4.2.5p82/ntpd/version.c --- unmod/ntp-dev-4.2.5p82/ntpd/version.c 2009-09-14 13:05:38.000000000 +0200 +++ ntp-dev-4.2.5p82/ntpd/version.c 2009-09-14 09:45:23.000000000 +0200 @@ -2,4 +2,4 @@ * version file for ntpd */ #include <config.h> -const char * Version = "ntpd 4.2.5...@1.1618-o Mon Sep 14 11:05:38 UTC 2009 (1)"; +const char * Version = "ntpd 4.2.5...@1.1618-o Mon Sep 14 07:45:23 UTC 2009 (5)"; diff -urN unmod/ntp-dev-4.2.5p82/ntpdate/version.c ntp-dev-4.2.5p82/ntpdate/version.c --- unmod/ntp-dev-4.2.5p82/ntpdate/version.c 2009-09-14 13:05:39.000000000 +0200 +++ ntp-dev-4.2.5p82/ntpdate/version.c 2009-09-14 09:45:28.000000000 +0200 @@ -2,4 +2,4 @@ * version file for ntpdate */ #include <config.h> -const char * Version = "ntpdate 4.2.5...@1.1618-o Mon Sep 14 11:05:39 UTC 2009 (1)"; +const char * Version = "ntpdate 4.2.5...@1.1618-o Mon Sep 14 07:45:28 UTC 2009 (5)"; diff -urN unmod/ntp-dev-4.2.5p82/ntpdc/ntpdc.c ntp-dev-4.2.5p82/ntpdc/ntpdc.c --- unmod/ntp-dev-4.2.5p82/ntpdc/ntpdc.c 2007-10-14 13:04:17.000000000 +0200 +++ ntp-dev-4.2.5p82/ntpdc/ntpdc.c 2009-09-14 10:29:09.000000000 +0200 @@ -489,7 +489,7 @@ struct addrinfo hints, *ai = NULL; register const char *cp; char name[LENHOSTNAME]; - char service[5]; + char service[9]; /* * We need to get by the [] if they were entered @@ -516,7 +516,7 @@ * will return an "IPv4-mapped IPv6 address" address if you * give it an IPv4 address to lookup. */ - strcpy(service, "ntp"); + strcpy(service, "ntp2"); memset((char *)&hints, 0, sizeof(struct addrinfo)); hints.ai_family = ai_fam_templ; hints.ai_protocol = IPPROTO_UDP; diff -urN unmod/ntp-dev-4.2.5p82/ntpdc/version.c ntp-dev-4.2.5p82/ntpdc/version.c --- unmod/ntp-dev-4.2.5p82/ntpdc/version.c 2009-09-14 13:05:41.000000000 +0200 +++ ntp-dev-4.2.5p82/ntpdc/version.c 2009-09-14 10:31:13.000000000 +0200 @@ -2,4 +2,4 @@ * version file for ntpdc */ #include <config.h> -const char * Version = "ntpdc 4.2.5...@1.1618-o Mon Sep 14 11:05:41 UTC 2009 (1)"; +const char * Version = "ntpdc 4.2.5...@1.1618-o Mon Sep 14 08:31:13 UTC 2009 (6)"; diff -urN unmod/ntp-dev-4.2.5p82/ntpq/ntpq.c ntp-dev-4.2.5p82/ntpq/ntpq.c --- unmod/ntp-dev-4.2.5p82/ntpq/ntpq.c 2007-10-14 13:04:17.000000000 +0200 +++ ntp-dev-4.2.5p82/ntpq/ntpq.c 2009-09-14 10:05:25.000000000 +0200 @@ -656,7 +656,7 @@ struct addrinfo hints, *ai = NULL; register const char *cp; char name[LENHOSTNAME]; - char service[5]; + char service[9]; /* * We need to get by the [] if they were entered @@ -683,7 +683,7 @@ * will return an "IPv4-mapped IPv6 address" address if you * give it an IPv4 address to lookup. */ - strcpy(service, "ntp"); + strcpy(service, "ntp2"); memset((char *)&hints, 0, sizeof(struct addrinfo)); hints.ai_family = ai_fam_templ; hints.ai_protocol = IPPROTO_UDP; diff -urN unmod/ntp-dev-4.2.5p82/ntpq/version.c ntp-dev-4.2.5p82/ntpq/version.c --- unmod/ntp-dev-4.2.5p82/ntpq/version.c 2009-09-14 13:05:44.000000000 +0200 +++ ntp-dev-4.2.5p82/ntpq/version.c 2009-09-14 10:05:33.000000000 +0200 @@ -2,4 +2,4 @@ * version file for ntpq */ #include <config.h> -const char * Version = "ntpq 4.2.5...@1.1618-o Mon Sep 14 11:05:44 UTC 2009 (1)"; +const char * Version = "ntpq 4.2.5...@1.1618-o Mon Sep 14 08:05:33 UTC 2009 (6)"; diff -urN unmod/ntp-dev-4.2.5p82/sntp/internet.c ntp-dev-4.2.5p82/sntp/internet.c --- unmod/ntp-dev-4.2.5p82/sntp/internet.c 2004-11-08 07:02:36.000000000 +0100 +++ ntp-dev-4.2.5p82/sntp/internet.c 2009-09-14 10:30:38.000000000 +0200 @@ -192,7 +192,7 @@ network format. This is assumed not to be obtained from a network service! Note that a port number is not assumed to be 16 bits. */ - if ((service = getservbyname("ntp","udp")) != NULL) { + if ((service = getservbyname("ntp2","udp")) != NULL) { *port = service->s_port; if (verbose > 2) fprintf(stderr,"Using port %d for NTP\n",port_to_integer(*port)); diff -urN unmod/ntp-dev-4.2.5p82/sntp/internet.h ntp-dev-4.2.5p82/sntp/internet.h --- unmod/ntp-dev-4.2.5p82/sntp/internet.h 2004-11-08 07:02:36.000000000 +0100 +++ ntp-dev-4.2.5p82/sntp/internet.h 2009-09-14 10:30:49.000000000 +0200 @@ -28,7 +28,7 @@ #define local_to_address(x,y) ((x)->s_addr = htonl((unsigned long)y)) #define network_to_address(x,y) ((x)->s_addr = (y)) -#define NTP_PORT htons((unsigned short)123) /* If not in /etc/services */ +#define NTP_PORT htons((unsigned short)1234) /* If not in /etc/services */ #define port_to_integer(x) (ntohs((unsigned short)(x))) _______________________________________________ questions mailing list questions@lists.ntp.org https://lists.ntp.org/mailman/listinfo/questions