Skip to main content

Appendix B. NTP Control Messages

This appendix describes the NTP Control Message format, which provides a mechanism for monitoring and controlling NTP implementations. The control message is an optional feature and need not be implemented in all cases. When implemented, the control message is used only in client/server mode and is not intended for broadcast mode. The control message is formatted as a standard NTP message, with the mode field set to 6 (control message).

The control message provides a simple query/response mechanism for monitoring and controlling NTP implementations. It is intended primarily for use in managing and monitoring the NTP implementation, providing access to the internal variables maintained by the protocol machine. These variables can be examined and, in some cases, modified by external management applications. The control message provides a way to examine the status and performance of the implementation without interfering with normal protocol operations.

B.1. NTP Control Message Format

The NTP Control Message is formatted as follows:

 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|LI | VN | Mode |R|E|M| OpCode | Sequence |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Status | Association ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Offset | Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
. .
. Data .
. .
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Key Identifier (optional) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Message Digest (optional) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Field Descriptions

Leap Indicator (LI): This is a two-bit code warning of an impending leap second as defined in the NTP message format.

Version Number (VN): This is a three-bit integer indicating the NTP version number, currently 3.

Mode: This is a three-bit integer indicating the mode. For control messages, this field is set to 6.

Response Bit (R): Set to 0 for queries, set to 1 for responses.

Error Bit (E): Set to 0 for normal response, set to 1 for error response.

More Bit (M): Set to 1 if more data follows this fragment, set to 0 for the last fragment.

Operation Code (OpCode): This is a five-bit code specifying the operation to be performed:

ValueOperation
0Reserved
1Read Status
2Read Variables
3Write Variables
4Read Clock Variables
5Write Clock Variables
6Set Trap Address
7Trap Response
8-31Reserved

Sequence: This is a 16-bit integer used to match requests with responses.

Status: This is a 16-bit code indicating the status of the system, peer or clock.

Association ID: This is a 16-bit integer identifying a particular peer association. A value of 0 indicates the system variables.

Offset: This is a 16-bit integer specifying the offset of the first octet in the data area.

Count: This is a 16-bit integer specifying the number of octets in the data area.

Data: This variable-length field contains the data for the request or response. The format depends on the operation code.

Authenticator (optional): When authentication is implemented, this field contains the Key Identifier and Message Digest as defined in Appendix C.

B.2. Status Words

The status field in the control message header contains a 16-bit code providing information about the system, peer or clock. The format depends on the type of status being reported.

B.2.1. System Status Word

The system status word appears in the status field of the response to a read status command with a zero association identifier. The format is:

 0                   1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LI | Source | Count | Code|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Leap Indicator (LI): This is a two-bit code warning of an impending leap second.

Clock Source (Source): This is a four-bit code indicating the current synchronization source:

ValueSource
0unspecified or unknown
1atomic clock
2VLF radio
3HF radio
4UHF radio
5local net
6NTP
7UDP/TIME
8wristwatch
9modem

System Event Counter (Count): This is a four-bit integer indicating the number of system exception events that have occurred since the last time the system status word was read.

System Event Code (Code): This is a four-bit integer identifying the most recent system exception event:

ValueEvent
0unspecified
1system restart
2system fault
3system clock reset
4association event
5operating mode change
6-15reserved

B.2.2. Peer Status Word

The peer status word appears in the status field of the response to a read status command with a non-zero association identifier. The format is:

 0                   1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Status | Sel | Count| Code |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Peer Status (Status): This is a five-bit code indicating the status of the peer:

BitMeaning when set
0configured (peer.config)
1authentication enabled
2authentication okay
3reachability okay
4reserved

Peer Selection (Sel): This is a three-bit integer indicating the status of the peer selection process:

ValueSelection
0rejected
1passed sanity checks
2passed correctness checks
3passed candidate checks
4passed outlier checks
5current synchronization source
6backup synchronization source
7reserved

Peer Event Counter (Count): This is a four-bit integer indicating the number of peer exception events.

Peer Event Code (Code): This is a four-bit integer identifying the most recent peer exception event.

B.2.3. Clock Status Word

The clock status word appears in the status field of the response to a read clock variables command. The format is implementation-dependent.

B.2.4. Error Status Word

The error status word appears in the status field of an error response. The format is:

 0                   1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Error Code |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Error Code: This is a 16-bit integer identifying the error condition:

ValueError
0no error
1incompatible implementation
2unimplemented request
3permission denied
4invalid message format
5invalid message length

B.3. Commands

The control message commands provide a mechanism for reading and writing the system, peer and clock variables. The following commands are defined:

Read Status: This command returns the status word for the system (association ID = 0) or for a specific peer (association ID != 0).

Read Variables: This command returns the values of one or more variables for the system or for a specific peer. The data field contains a list of variable names separated by commas.

Write Variables: This command sets the values of one or more variables. The data field contains a list of variable=value pairs separated by commas.

Read Clock Variables: This command returns the values of one or more reference clock variables.

Write Clock Variables: This command sets the values of one or more reference clock variables.

Set Trap Address: This command sets the address of a trap receiver. When significant events occur, the implementation sends unsolicited trap response messages to the specified address.

Trap Response: This is an unsolicited message sent to a trap receiver when a significant event occurs.

The control message facility provides a powerful mechanism for monitoring and managing NTP implementations. However, it should be used with care to avoid disrupting normal protocol operations or compromising security.