r10 - 2013-05-14 - 23:36:48 - MarcioAzevedoYou are here: NTP >  Support Web > OtherImplementations > JavaSntpClient
NTP users are strongly urged to take immediate action to ensure that their NTP daemons are not susceptible to being used in distributed denial-of-service (DDoS) attacks. Please also take this opportunity to defeat denial-of-service attacks by implementing Ingress and Egress filtering through BCP38.

ntp-4.2.8p9 was released on 21 November 2016. It addresses 1 high- (Windows only), 2 medum-, 2 medum-/low-, and 5 low-severity security issues, 28 bugfixes, and contains other improvements over 4.2.8p8.

Please see the NTP Security Notice for vulnerability and mitigation details.

Are you using Autokey in production? If so, please contact Harlan - he's got some questions for you.
REFACTOR See JavaSntpClientDev for discussion of this topic.

13.3. Java SNTP Client

This is a Java implementation of an NTP client, and is released under the GPL license. It handles NTP parameters as native Java types, making it Java-programmer-friendly. The algorithm used to calculate the local clock offset is the SNTP algorithm as specified in RFC2030. However, this code may be easily updated to use the more complex RFC 1305 NTP algorithms with no change to NtpMessage class.

The Java implementation consists of the following two classes:

  • NtpMessage.java
    Represents an NTP message, exposing members as native java types. Include a NtpMessage(byte[] array) constructor to import a raw NTP message, and a toByteArray() method to export a raw NTP message.
  • NtpMessageJ2ME.java
    File like the original "NtpMessage.java" adjustments made in order to reconcile the class to run on embedded devices with J2ME .
  • SntpClient.java
    NTP client which instances an NtpMessage and uses the SNTP algorithm to calculate local clock offset. Note that this class merely performs the NTP process and displays the results - it does not actually modify the system clock.


This implementation is a first attempt, and is possibly nave in its approach. In particular, it is subject to the following issues:

  • SntpClient.java determines the current time of day using System.currentTimeMills(). Firstly, the value returned is of millisecond accuracy. How accurate should the client timestamps be? Secondly, under Win32 the value is limited to a precision of 10ms. What impact does this have on precision?

  • Timestamps are maintained as double values. Timestamps are converted from fixed point format to double during NtpMessage creation and back to fixed point format again during toByteArray(). How much error does this introduce?

-- AdamBuckley - 22 Jan 2004

Topic attachments
I Attachment Action Size Date Who Comment
javajava NtpMessage.java manage 14.4 K 2013-05-14 - 23:29 MarcioAzevedo undoing changes, original file of AdamBuckley .
javajava NtpMessageJ2ME.java manage 15.3 K 2013-05-14 - 23:30 MarcioAzevedo Adaptation of "NtpMessage.java" to run on embedded devices with J2ME
javajava SntpClient.java manage 4.0 K 2004-08-28 - 03:35 AdamBuckley Updated as per comments page
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r10 < r9 < r8 < r7 < r6 | More topic actions
SSL security by CAcert
Get the CAcert Root Certificate
This site is powered by the TWiki collaboration platform
IPv6 Ready
Copyright & 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding the site? Send feedback