diff --git a/client.c b/client.c index bd6b535..e686f51 100644 --- a/client.c +++ b/client.c @@ -1789,10 +1789,9 @@ print_report(const char *format, ...) else print_freq_ppm(dbl); break; - case 'R': /* reference ID in quad-dotted notation */ + case 'R': /* reference ID in hexdecimal */ long_uinteger = va_arg(ap, unsigned long); - printf("%lu.%lu.%lu.%lu", long_uinteger >> 24, (long_uinteger >> 16) & 0xff, - (long_uinteger >> 8) & 0xff, long_uinteger & 0xff); + printf("%lX", long_uinteger); break; case 'S': /* offset with unit */ dbl = va_arg(ap, double); diff --git a/doc/chronyc.adoc b/doc/chronyc.adoc index 3dfac95..a3807b3 100644 --- a/doc/chronyc.adoc +++ b/doc/chronyc.adoc @@ -127,7 +127,7 @@ The *tracking* command displays parameters about the system's clock performance. An example of the output is shown below. + ---- -Reference ID : 203.0.113.15 (foo.example.net) +Reference ID : CB00710F (foo.example.net) Stratum : 3 Ref time (UTC) : Fri Feb 3 15:00:29 2012 System time : 0.000001501 seconds slow of NTP time @@ -150,10 +150,14 @@ computer is currently synchronised. For IPv4 addresses, the reference ID is equal to the address and for IPv6 addresses it is the first 32 bits of the MD5 sum of the address. + -If it is _127.127.1.1_ it means the computer is not synchronised to any -external source and that you have the _local_ mode operating (via the -<> command in *chronyc*, or the +If the reference ID is _7F7F0101_ and there is no name or IP address, it means +the computer is not synchronised to any external source and that you have the +_local_ mode operating (via the <> command in *chronyc*, or the <> directive in the configuration file). ++ +The reference ID is printed as a hexadecimal number. Note that in older +versions it used to be printed in quad-dotted notation and could be confused +with an IPv4 address. *Stratum*::: The stratum indicates how many hops away from a computer with an attached reference clock we are. Such a computer is a stratum-1 computer, so the diff --git a/doc/faq.adoc b/doc/faq.adoc index da9a94f..0a1ac71 100644 --- a/doc/faq.adoc +++ b/doc/faq.adoc @@ -287,12 +287,15 @@ authentication (`commandkey` directive). === Why does `chronyc tracking` always print an IPv4 address as reference ID? -The reference ID is a 32-bit value and is always printed in quad-dotted -notation, even if the reference source doesn't have an IPv4 address. For IPv4 -addresses, the reference ID is equal to the address, but for IPv6 addresses it -is the first 32 bits of the MD5 sum of the address. For reference clocks, the -reference ID is the value specified with the `refid` option in the `refclock` -directive. +The reference ID is a 32-bit value and in versions before 3.0 it was printed in +quad-dotted notation, even if the reference source did not actually have an +IPv4 address. For IPv4 addresses, the reference ID is equal to the address, but +for IPv6 addresses it is the first 32 bits of the MD5 sum of the address. For +reference clocks, the reference ID is the value specified with the `refid` +option in the `refclock` directive. + +Since version 3.0, the reference ID is printed as a hexadecimal number to avoid +confusion with IPv4 addresses. If you need to get the IP address of the current reference source, use the `-n` option to disable resolving of IP addresses and read the second field (printed diff --git a/test/simulation/110-chronyc b/test/simulation/110-chronyc index 34ee283..690026e 100755 --- a/test/simulation/110-chronyc +++ b/test/simulation/110-chronyc @@ -11,7 +11,7 @@ sourcestats" run_test || test_fail check_chronyd_exit || test_fail -check_chronyc_output "^Reference ID : 192\.168\.123\.1 \(192\.168\.123\.1\) +check_chronyc_output "^Reference ID : C0A87B01 \(192\.168\.123\.1\) Stratum : 2 Ref time \(UTC\) : Fri Jan 01 00:1.:.. 2010 System time : 0\.0000..... seconds (slow|fast) of NTP time