Class SntpMessage

java.lang.Object
net.time4j.clock.SntpMessage

public final class SntpMessage extends Object

Message for the SNTP-protocol (RFC 4330).

NTP-timestamps will be calculated at best in microsecond precision.

Since:
2.1
Author:
Meno Hochschild
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    convert​(double ntpTimestamp)
    Converts given NTP-timestamp to a microsecond value relative to the UNIX- epoch.
    byte
    Yields the LI-bits as appointment of a coming leap second.
    byte
    Displays the mode.
    double
    NTP-timestamp when the client request was sent.
    int
    Yields the maximum interval between two successful server messages in seconds as exponent for base 2.
    int
    Yields the precision of the server clock in seconds as exponent for the base 2.
    double
    NTP-timestamp when the server received the client request.
    Identifies a reference source.
    double
    NTP-timestamp when the time of the server was set or corrected last time.
    double
    Yields the total delay in seconds relative to the primary source.
    double
    Yields the maximum error in seconds relative to the primary source.
    short
    Displays the stratum-value indicating the distance of the original time source.
    double
    NTP-timestamp when the client or server request was sent.
    byte
    Displays the NTP-version.
    Returns a human-readable form of the internal state.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • getLeapIndicator

      public byte getLeapIndicator()

      Yields the LI-bits as appointment of a coming leap second.

      • 0 - no warning.
      • 1 - last minute of day has 61 seconds.
      • 2 - last minute of day has 59 seconds.
      • 3 - alert state (missing clock synchronization).
      Returns:
      byte
      Since:
      2.1
    • getVersion

      public byte getVersion()

      Displays the NTP-version.

      Returns:
      3 (if only IPv4 is supported) else 4
      Since:
      2.1
    • getMode

      public byte getMode()

      Displays the mode.

      Returns:
      3 (client-mode) or 4 (server-mode) oder 5 (broadcast)
      Since:
      2.1
    • getStratum

      public short getStratum()

      Displays the stratum-value indicating the distance of the original time source.

      Usually it is the count of involved clock servers respective layers. The value 0 indicates a kiss-o'-death-message by which the server signals to the client that repeated requests should be immediately stopped.

      Returns:
      0 (unspecified) oder 1 (direkt) oder 2-15 (sekundär)
      Since:
      2.1
    • getPollInterval

      public int getPollInterval()

      Yields the maximum interval between two successful server messages in seconds as exponent for base 2.

      This property is only relevant if the server is sending messages in the broadcast-mode. In all other cases the server should send the value0.

      Returns:
      broadcast-mode: value in range 4 <= pollInterval <= 17
      Since:
      2.1
    • getPrecision

      public int getPrecision()

      Yields the precision of the server clock in seconds as exponent for the base 2.

      Returns:
      int in the usual range -6 <= precision <= -23
      Since:
      2.1
    • getRootDelay

      public double getRootDelay()

      Yields the total delay in seconds relative to the primary source.

      This information only concerns the NTP-server, not the actual network traffic with the client.

      Returns:
      round-trip-delay in seconds
      Since:
      2.1
    • getRootDispersion

      public double getRootDispersion()

      Yields the maximum error in seconds relative to the primary source.

      This information only concerns the NTP-server, not the actual network traffic with the client.

      Returns:
      maximum error in seconds
      Since:
      2.1
    • getReferenceIdentifier

      public String getReferenceIdentifier()

      Identifies a reference source.

      If the connected server is a primary NTP-server (stratum = 1) then the return value will usually be a string from following list:

      • LOCL - uncalibrated local clock
      • CESM - calibrated Cesium clock
      • RBDM - calibrated Rubidium clock
      • PPS - calibrated quartz clock or other pulse-per-second source
      • IRIG - Inter-Range Instrumentation Group
      • ACTS - NIST telephone modem service
      • USNO - USNO telephone modem service
      • PTB - PTB (Germany) telephone modem service
      • TDF - Allouis (France) Radio 164 kHz
      • DCF - Mainflingen (Germany) Radio 77.5 kHz
      • MSF - Rugby (UK) Radio 60 kHz
      • WWV - Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz
      • WWVB - Boulder (US) Radio 60 kHz
      • WWVH - Kauai Hawaii (US) Radio 2.5, 5, 10, 15 MHz
      • CHU - Ottawa (Canada) Radio 3330, 7335, 14670 kHz
      • LORC - LORAN-C radionavigation getChronology
      • OMEG - OMEGA radionavigation getChronology
      • GPS - Global positioning getChronology

      A secondary IPv4-server will return a 32-bit-IP-address else the return value represents the first 32 bits of a MD5-hash value of a IPv6- or NSAP-address of the synchronization source.

      In case of a (stratum == 0) - reply of the server the return value describes a kiss-or-death-message. The client should then not repeat the request (or at least not within the next minute). A non-exhausting selection:

      • ACST - Association belongs to an anycast server
      • AUTH - Server authentication failed
      • AUTO - Autokey sequence failed
      • BCST - Association belongs to a broadcast server
      • CRYP - Cryptographic authentication or identification failed
      • DENY - Access denied by remote server
      • DROP - Lost peer in symmetric mode
      • RSTR - Access denied due to local policy
      • INIT - Association has not yet synchronized for the first time
      • MCST - Association belongs to a manycast server
      • NKEY - No key found. Either the key was never installed or is not trusted
      • RATE - Rate exceeded. The server has temporarily denied access because the client exceeded the rate threshold
      • RMOT - Somebody is tinkering with the association from a remote host running ntpdc. Not to worry unless some rascal has stolen your keys
      • STEP - A step change in getChronology time has occurred, but the association has not yet resynchronized
      Returns:
      String
      Since:
      2.1
    • getReferenceTimestamp

      public double getReferenceTimestamp()

      NTP-timestamp when the time of the server was set or corrected last time.

      The method yields 0 if no request has been sent yet.

      Returns:
      NTP-time in seconds since 1900-01-01
      Since:
      2.1
    • getOriginateTimestamp

      public double getOriginateTimestamp()

      NTP-timestamp when the client request was sent.

      The method yields 0 if no request has been sent yet.

      Returns:
      NTP-time in seconds since 1900-01-01
      Since:
      2.1
    • getReceiveTimestamp

      public double getReceiveTimestamp()

      NTP-timestamp when the server received the client request.

      The method yields 0 if no request has been sent yet.

      Returns:
      NTP-time in seconds since 1900-01-01
      Since:
      2.1
    • getTransmitTimestamp

      public double getTransmitTimestamp()

      NTP-timestamp when the client or server request was sent.

      Returns:
      NTP-time in seconds since 1900-01-01
      Since:
      2.1
    • toString

      public String toString()

      Returns a human-readable form of the internal state.

      Overrides:
      toString in class Object
      Returns:
      String
    • convert

      public static long convert(double ntpTimestamp)

      Converts given NTP-timestamp to a microsecond value relative to the UNIX- epoch.

      Parameters:
      ntpTimestamp - NTP-timestamp (seconds since 1900-01-01)
      Returns:
      long-Wert relative to 1970-01-01 in microseconds without leap seconds
      Since:
      2.1