Operating System - HP-UX
1826215 Members
2845 Online
109691 Solutions
New Discussion

Re: HP Support Statement for XNTPD Leap Second Processing

 
SOLVED
Go to solution
Todd Whitcher
Esteemed Contributor

HP Support Statement for XNTPD Leap Second Processing

This data is provided from HP's Expert center in response to questions about XNTPD and leap second processing.

Leap Second processing in HP's xntpd

Purpose

The purpose of this document is to explain the processing of leap
seconds in HP's xntpd.

Leap Second Overview

For the benefit of readers who are not aware of the leap second
terminology, this section explains the concept of the leap
second. Readers familiar with the leap second concept may wish to
skip this section.

While the Earth is expected to make one complete rotation about its
own axis in 86400 seconds (one mean solar day), in reality it is not
the case. Earth takes slightly more than 86400 seconds to make one
complete rotation and hence one mean solar day is slightly longer than
86400 seconds. This introduces a slight error in the time calculations
used by the atomic clocks, because the atomic clocks were designed
to consider 86400 seconds as one day. In order to synchronize the
time derived from the atomic clocks with the astronomical time,
the concept of leap second was introduced.

Leap seconds were meant to synchronize the standard time (UTC)
with the astronomical time. However an exact synchronization is
not maintained. Leap seconds only guarantee that the UTC time does
not deviate more that 0.9 seconds from the astronomical time. Leap
seconds can be either positive or negative. A positive leap second
denotes a second to be added to the time on which it is applied,
while a negative leap second denotes a second to be removed.

Since a positive leap second adds an extra second to the time, the
UTC clock during midnight advances as follows :

23:59:58
23:59:59
23:59:60 <= leap second
00:00:00
00:00:01

Note the presence of an extra second - the positive leap second -
at 23:59:60.

Application of a negative leap second causes the UTC clock to advance
in the following fashion during midnight :

23:59:58
00:00:00
00:00:01

Note that the clock jumps directly from 23:59:58 to 00:00:00. The
59th second is skipped.

As of the date of publication of this document there has never been
an instance of negative leap second adjustment to UTC.

NTP and leap seconds

NTP has provisions in the packet to denote leap second adjustments. A
2-bit provision in NTP packet called the Leap Indicator (LI) can
denote the occurrence of either a positive leap second or a negative
leap second.

HP's xntpd and LI

HP's xntpd can handle LI in NTP packets and adjust the time
accordingly. Both positive and negative leap seconds are handled by
xntpd. xntpd implements positive leap seconds by going backward in
time and negative leap seconds by going forward in time. The default
behavior of xntpd is to step the clock in the right direction, when
xntpd needs to apply the leap second. Positive leap adjustments are
done by stepping the clock backward and negative leap adjustments
are done by stepping the clock forward. However this sudden step of
time can cause harm to certain applications. For example databases
can have problems when a positive leap second triggers xntpd to step
the system time backward. When this stepping of time is undesirable,
administrators may consider the option of starting xntpd with the
'-x' option. The '-x' option causes xntpd to always do a slew instead
of a step, to perform time adjustments. When the '-x' option is
set, xntpd slews the time in the right direction (either forward
or backward) when leap second occurs. However the consequences of
slewing must be completely understood before deciding to use the
'-x' option. See xntpd(1M) for more details.

When xntpd performs leap second adjustments it displays the following
messages in syslog ( at LOG_NOTICE level ) :

For positive leap adjustments, xntpd displays
"leap second occurred, stepped time back 1 second"

and for negative leap adjustments, xntpd displays
"leap second occurred, stepped time forward 1 second"

However xntpd logs the above mentioned messages only if sync events
or sys events are enabled in xntpd's conditional log mask. See the
logconfig command in ntp.conf(5) for more details. Unless altered,
xntpd by default logs sync events and hence logs the above mentioned
leap second related messages.

Note that irrespective of whether xntpd did a step or a slew, it
displays the message "..., stepped time ...". This message can cause
system administrators to wrongly believe that xntpd always performs
leap second adjustments by stepping. Note that with the -x option,
xntpd will perform leap second adjustments by slewing but displays
a wrong message.

Summary

This section summarizes the behavior of HP's xntpd with respect to
leap second adjustments.

o xntpd can perform both positive and negative leap second adjustments.

o xntpd can perform leap second adjustments by either stepping or
slewing the clock in the right direction. The default behavior of
xntpd is to the step the time, but the -x option causes xntpd to
slew the time to make leap second adjustments.

o xntpd displays the following messages in syslog. "leap second
occurred, stepped time back 1 second" is displayed for positive
leap second adjustments and "leap second occurred, stepped time
forward 1 second" is displayed for negative leap second adjustments.

o Positive leap second step adjustments can cause the clock to go
back slightly in time. If this is not desirable, customers may
consider starting xntpd with the -x option, which ensures that xntpd
performs time adjustments by slewing. The consequences of slewing
must be completely understood before deciding to use the '-x' option.

o A minor bug causes xntpd to always display the message "...,
stepped time ..." even if xntpd makes leap second adjustments by
slewing the clock.


18 REPLIES 18
Devender Khatana
Honored Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Thanks for the info Todd, it will be really helpful.

Regards,
Devender
Impossible itself mentions "I m possible"
Borislav Perkov
Respected Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Thank you Todd.

This information is very useful for me.

Regards,
Borislav
Sameer_Nirmal
Honored Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Thanks Todd for sharing the useful and valuable information.

Thanks to HP's Expert Center for putting efforts to share this information at ITRC.


James R. Ferguson
Acclaimed Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Hi Todd:

This is quite a nice document. I presume that it is already (or will be soon) added to the TKB. It certainly deserves to be!

Regards!

...JRF...
Todd Whitcher
Esteemed Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Hi James, yes I am going to add it today.

Thanks !
Todd Whitcher
Esteemed Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

I've created an Application note for the knowledge base for future reference.

Doc ID: KBAN00001231

It should be posted in 24-48 hours.



James R. Ferguson
Acclaimed Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Hi (again) Todd:

Thanks for the TKB and thanks for the nice work!

Regards!

...JRF...
Victor BERRIDGE
Honored Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

A nice job Todd!

I appreciate


Thanks again

All the best
Victor
Florian Heigl (new acc)
Honored Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

That was a really great read for me as a NTP-lover.

Thank You very much,
florian
yesterday I stood at the edge. Today I'm one step ahead.
Steven E. Protter
Exalted Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

I found this fascinating.

If not totally relavent to my job, I really, really enjoyed it.

I encourage others at HP do do this.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Uwe Zessin
Honored Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Bill Hassell
Honored Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

So the recommendation is to set -x in /etc/rc.config.d/netdaemons for xntpd options? Since there is a minor bug in logging, will there be a patch that includes an updated man page with leap second info? Would a patch also be created for 11.00? Are there any concerns about running xntpd -x?

It appears that leap seconds may occur yearly but the exact date for this event is determined after extensive measurements. Here is a great article from the US Naval Observatory: http://tycho.usno.navy.mil/leapsec.html


Bill Hassell, sysadmin
Todd Whitcher
Esteemed Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Bill,

There is a section in the man page that talks about slew. Its a little long so I did not want to post it. Users would have to determine if their applications would be affected. HP generally doesnt recommend using slew, see "man 1m xntpd"

At this time I don't think there is an enhancement to update the man pages but I can certainly check and if not request one.

Thanks for posting the link.

Todd
Sandman!
Honored Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Awesome job in putting together this document and making the itrc community aware of its presence.

regards!
Todd Whitcher
Esteemed Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Here are some additional references:

URL Reference

http://www.ntp.org/ntpfaq/NTP-s-time.htm#Q-TIME-LEAP-SECOND

During a leap second, either one second is removed from the current day, or a second is added. In both cases this happens at the end of the UTC day. If a leap second is inserted, the time in UTC is specified as 23:59:60. In other words, it takes two seconds from 23:59:59 to 0:00:00 instead of one. If a leap second is deleted, time will jump from 23:59:58 to 0:00:00 in one second instead of two. See also Section 5.2.



Laboratories:

http://tycho.usno.navy.mil/leapsec.html (Master Clock)
http://www.npl.co.uk/time/leap_second.html

Discussion about a leap second

http://www.ucolick.org/~sla/leapsecs/onlinebib.html

According to the IERS a leap second will be introduced Jan 1 2006.

http://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat

Other References
http://tf.nist.gov/general/leaps.htm

http://www.cl.cam.ac.uk/~mgk25/time/leap/

http://tf.nist.gov/timefreq/pubs/bulletin/leapsecond.htm

http://www.livescience.com/technology/050705_leap_second.html

http://www.leapsecond.com/

Enjoy and thanks for the feedback.

Todd

A. Clay Stephenson
Acclaimed Contributor

Re: HP Support Statement for XNTPD Leap Second Processing

Of course the other side of the coin is that UNIX time as measured in epoch seconds has no notion of leap seconds and every day has exactly 86400 seconds. This also means that functions like mktime() will silently coerce the seconds into the range 0-59.

Because the tidal forces are always making the days longer --- and moving the moon farther away ---, the leap seconds are always expected to be positive. There are other mechanism in play which cause the rotational period of the earth to vary but the tidal forces are the first-order forces. Because angular momentum must be conserved, about the only mechanism (other than a collision with a rather large body) that could cause a negative leap second to be added would be an incredibly violent tectonic event. In either of those cases, I doubt very much that knowing the "correct" time will matter very much.

There is also a movement to do away with leap seconds to make timekeeping easier although the astronomical community is very opposed to this.
If it ain't broke, I can fix that.
Fedon Kadifeli
Super Advisor
Solution

Re: HP Support Statement for XNTPD Leap Second Processing

What I understand from this explanation is that in HP-UX (with no -x option to xntpd) we will have a scenario like this:

23:59:58
23:59:59
00:00:00
00:00:00 <== "leap second occurred, stepped time back 1 second"
00:00:01

And not like this:

23:59:58
23:59:59
23:59:60
00:00:00
00:00:01

I am correct?
Fedon Kadifeli
Super Advisor

Re: HP Support Statement for XNTPD Leap Second Processing

Just out of my curiosity I wrote a simple program that logs the time roughly every 250 milliseconds to a file. A ran that program on several machines. I also looked at the system logs. Here are the results:

Linux systems:
==============
system1 (kernel: 2.6.9-22)
--------------------------
/var/log/messages:
Jan 1 01:59:59 system1 kernel: Clock: inserting leap second 23:59:60 UTC
Jan 1 02:29:06 system1 ntpd[2234]: kernel time sync enabled 0001

Results from my program:
...
01/01/06 01:59:58.866391
01/01/06 01:59:59.118342
01/01/06 01:59:59.370286
01/01/06 01:59:59.622226
01/01/06 01:59:59.874171
01/01/06 01:59:59.126121 <<=== Note here
01/01/06 01:59:59.378062
01/01/06 01:59:59.630009
01/01/06 01:59:59.881953
01/01/06 02:00:00.133904
...

system2 (kernel: 2.6.9-5):
--------------------------
/var/log/messages:
Jan 1 01:59:59 system2 kernel: Clock: inserting leap second 23:59:60 UTC
Jan 1 02:32:06 system2 ntpd[2132]: kernel time sync enabled 0001


system3 (kernel: 2.4.21-20):
----------------------------
/var/log/messages:
Jan 1 01:21:48 system3 ntpd[19207]: kernel time discipline status change 11
Jan 1 01:59:59 system3 kernel: Clock: inserting leap second 23:59:60 UTC
Jan 1 02:30:05 system3 ntpd[19207]: kernel time discipline status change 1

Results from my program:
...
01/01/06 01:59:58.935352
01/01/06 01:59:59.195363
01/01/06 01:59:59.455370
01/01/06 01:59:59.715380
01/01/06 01:59:59.975388
01/01/06 01:59:59.235399 <<=== Note here
01/01/06 01:59:59.495409
01/01/06 01:59:59.755416
01/01/06 02:00:00.015423
...

HP-UX
=====
system4 (kernel: B.11.00):
--------------------------
/var/adm/syslog/syslog.log:
Jan 1 02:00:01 system4 xntpd[1096]: leap second occurred, stepped time back 1 second

Results from my program:
...
01/01/06 01:59:58.927018
01/01/06 01:59:59.187032
01/01/06 01:59:59.447046
01/01/06 01:59:59.707136
01/01/06 01:59:59.967033
01/01/06 02:00:00.227297
01/01/06 02:00:00.487192
01/01/06 02:00:00.747122
01/01/06 02:00:01.007174
01/01/06 02:00:01.267101
01/01/06 02:00:01.527165
01/01/06 02:00:01.787064
01/01/06 02:00:02.047041
01/01/06 02:00:02.307016
01/01/06 02:00:02.567112
01/01/06 02:00:02.827070
01/01/06 02:00:02.087247 <<=== Note here
01/01/06 02:00:02.347235
01/01/06 02:00:02.607201
01/01/06 02:00:02.867181
01/01/06 02:00:03.127217
...

The results show that both Linux and HP-UX systems inserted the leap second roughly on time 02:00 am; this is because the systems run on EET (i.e., UTC+2) time zone.

Linux systems inserted the leap second AFTER 01:59:59, so my program logged the time period 01:59:59 - 02:00:00 two times (note that there was no time 01:59:60).

HP-UX systems inserted the leap second AFTER 02:00:01; but actually my program logged the time period 02:00:02 - 02:00:03 two times.

This is just an information for curious people like me. :)

The program is attached...