Explain the use of ntpq command in Linux system in detail

Time:2022-5-7

The command “ntpq – Q” outputs the following table:

Copy code

The code is as follows:

remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) .LOCL. 10 l 96h 64 0 0.000 0.000 0.000
*ns2.example.com 10.193.2.20 2 u 936 1024 377 31.234 3.353 3.096

More details
Header

  • Remote – the remote node or server used for synchronization. “Local” means local (appears when no remote server is available)
    Refid – a higher level server that synchronizes with a remote server
    St – stratum level of remote node or server (NTP time synchronization is hierarchical)
    T – type (U: unicast or multicast client, B: broadcast or multicast client, l: local clock, s: symmetric node (for backup), a: anycast server, B: broadcast server, M: multicast server, see “automatic server discovery”)
    When – the time from the last synchronization to the present (the default unit is seconds, “H” for hours and “d” for days)
    Poll – frequency of synchronization: rfc5905 suggests that in ntpv4, this value ranges from 4 (16 seconds) to 17 (36 hours) (i.e. exponential sub seconds of 2). However, it is observed that the actual size of this value ranges from 64 (26) seconds to 1024 (210) seconds
    Reach – an 8-bit left shift register value used to test whether it can connect to the server. Its value will increase every time it is successfully connected, which is displayed in octal
    Delay – round trip time from local to remote node or server communication (MS)
    Offset – the time offset between the host and the remote node or server time source. The closer the offset is to 0, the closer the time between the host and the NTP server is (expressed as root mean square, in milliseconds)
    Jitter – the average deviation of the time source synchronized with the remote node (the offset deviation in multiple time samples, in milliseconds). The smaller the absolute value of this value, the more accurate the host’s time is

Statistics code of the field

The first character (statistical code) in the table is the status identification (see peer status word), including “”, “X”, “-“, “#”, “+”, “*”, “O”:

  • “” “– stateless, indicating:
    Host without remote communication
    “Local” means local
    High level server (not used)
    The remote host uses this machine as the synchronization server
    “X” – no longer in use
    “-” – no longer used
    “#” – good remote node or server but not used (not in the first six nodes sorted by synchronization distance, used as standby node)
    “+” – good and preferred remote node or server (included in the composite algorithm)
    “*” – the remote node or server that is currently the priority primary synchronization object
    “O” – PPS node (when the priority node is valid). The actual system synchronization is derived from the pulse per second (PPS), which may be driven by the PPS clock or through the kernel interface.

reference resourcesClock Select Algorithm.
refid

Refid has the following status values

  • One IP address – the IP address of the remote node or server
        . LOCL. – Native (when no remote node or server is available)
        . PPS. – “Pulse per second” in the time standard
        . IRIG. – Inter range instrumentation group time code
        . ACTS. – NIST standard time telephone modulator
        . NIST. – NIST standard time telephone modulator
        . PTB. – German PTB time standard telephone modulator
        . USNO. – UsNo standard time telephone modulator
        . CHU. – Chu (HF, Ottawa, on, Canada) standard time radio receiver
        . DCFa. – Dcf77 (LF, mainflingen, Germany) standard time radio receiver
        . HBG. – HbG (LF prangins, Switzerland) standard time radio receiver
        . JJY. – JJY (LF Fukushima, Japan) standard time radio receiver
        . LORC. – Loran-C station (MF) standard time radio receiver, note: no longer available (abandoned by eloran)
        . MSF. – MSF (LF, Anthorn, Great Britain) standard time radio receiver
        . TDF. – TDF (MF, allouis, France) standard time radio receiver
        . WWV. – WWV (HF, ft. Collins, Co, America) standard time radio receiver
        . WWVB. – WWVB (LF, ft. Collins, Co, America) standard time radio receiver
        . WWVH. – Wwvh (HF, Kauai, hi, America) standard time radio receiver
        . GOES. – American geostationary environmental observation satellite;
        . GPS. – Us GPS;
        . Gal. – Galileo positioning system European GNSS;
        . ACST. – Anycast server
        . AUTH. – Authentication error
        . AUTO. – The sequence of autokey (an authentication mechanism of NTP) is wrong
        . BCST. – Broadcast server
        . CRYPT. – Autokey protocol error
        . DENY. – Access denied by the server;
        . INIT. – Association initialization
        . MCST. – Multicast server
        . RATE. – (polling) rate exceeded limit
        . TIME. – Association timeout
        . STEP. – The interval length changes, and the offset is smaller than the danger threshold (1000ms) and larger than the interval time (125ms)

Key points of operation

A time server will only report the time information and will not update the time from the client (one-way update), while a node can update the time of other peer nodes and combine a mutually agreed time (two-way update).

At initial start-up:

Unless you use the iburst option, the client usually takes a few minutes to synchronize with the server. If the time difference between the client and the NTP server at startup is greater than 1000 seconds, the daemon will exit and record it in the system log, and let the operator manually set the time difference to be less than 1000 seconds before restarting. If the time difference is less than 1000 seconds but greater than 128 seconds, the interval will be corrected automatically and the daemon will be restarted automatically.

When starting for the first time, the time-frequency file (usually ntp.drift file, recording time offset) does not exist, and the daemon enters a special mode to correct the frequency. When the clock doesn’t meet the specification, it will take 900 seconds. When the correction is completed, the daemon creates a time-frequency file, enters the normal mode, and corrects the remaining deviation step by step.

Equipment of NTP layer 0 (stratum 0), such as atomic clock (cesium, rubidium), GPS clock or other radio clock of standard time, provides time signals for the time server of layer 1 (stratum 1). NTP only reports UTC time (coordinated universal time). The client program uses the time zone to export local time from UTC.

The NTP protocol is highly accurate, and the accuracy used is less than nanoseconds (the – 32nd power of 2). The time accuracy and other parameters of the host (limited by hardware and operating system) are viewed using the command “ntpq – C RL” (see rfc1305 general variables and rfc5905).
“Ntpq – C RL” output parameter

  • Precision is a rounded value and is an idempotent of 2. Therefore, the accuracy is 2 precision (seconds)
    Rootdelay – the total round trip delay with the primary synchronization server in the synchronization network. Note that this value can be positive or negative, depending on the accuracy of the clock.
    Rootdisp – deviation from the primary synchronization server in the synchronization network (seconds)
    TC – NTP algorithm PLL (phase locked loop) or FLL (frequency locked loop) time constant
    Mintc – NTP algorithm PLL / FLL minimum time is always on or “fastest response”
    Offset – the system clock offset (in milliseconds) derived from the combined algorithm
    Frequency – system clock frequency
        sys_ Jitter – the average deviation of the system clock from the combined algorithm (in milliseconds)
        clk_ Jitter – average deviation of hardware clock (MS)
        clk_ Wander – hardware clock offset (ppm – one percent)

Jitter (also known as timing jitter) refers to the frequency with short-term change greater than 10Hz, and wander refers to the frequency with long-term change greater than 10Hz (stability refers to the change of system frequency with time, which is synonymous with aging, drift, trends, etc.)
Key points of operation (Continued)

NTP software maintains a series of continuously updated correction values for frequency changes. For a properly set stable system, in a non congested network, the NTP clock synchronization of modern hardware is usually within milliseconds from the UTC standard time. (what kind of accuracy can be achieved in Gigabit LAN network?)

For UTC time, leap second can be inserted every two years to synchronize changes in the earth’s autobiography. Note that the local time is summer time, and the time will change by one hour. Before resynchronization, the client device will use independent UTC time unless the client uses offset calibration.
What happens when a leap second occurs

When a leap second occurs, it increases or decreases the time of the day by one second. Leap seconds are adjusted at the last second of UTC time. If you add one second, UTC time will appear at 23:59:60. That is, it actually takes 2 seconds between 23:59:59 and 0:00:00. If you reduce one second, the time will jump from 23:59:58 to 0:00:00. See alsoThe Kernel Discipline.

Recommended Today

Oracle manual database creation, installation and deployment super detailed tutorial

catalogue Step 1 specify sid Step 2 determine the environment variables of the Oracle environment Step 3 set the password authentication method of Oracle Step 4 create initialization parameter file Step 5 connect to the database instance Step 6 create SPFILE file Step 7 start the instance Step 8 create a database using the create […]