[][src]Module broker_ntp::protocol

Types and constants that precisely match the specification.

Provides ReadBytes and WriteBytes implementations which extend the byteorder crate WriteBytesExt and ReadBytesExt traits with the ability to read and write types from the NTP protocol respectively.

Documentation is largely derived (and often copied directly) from IETF RFC 5905.

Structs

DateFormat

NTP Date Format - The prime epoch, or base date of era 0, is 0 h 1 January 1900 UTC, when all bits are zero. Dates are relative to the prime epoch; values greater than zero represent times after that date; values less than zero represent times before it.

Packet

Packet Header - The most important state variables from an external point of view are the packet header variables described here.

ShortFormat

NTP Short Format - Used in delay and dispersion header fields where the full resolution and range of the other formats are not justified. It includes a 16-bit unsigned seconds field and a 16-bit fraction field.

Stratum

An 8-bit integer representing the stratum.

TimestampFormat

NTP Timestamp Format - Used in packet headers and other places with limited word size. It includes a 32-bit unsigned seconds field spanning 136 years and a 32-bit fraction field resolving 232 picoseconds.

Version

A 3-bit integer representing the NTP version number, currently 4.

Enums

KissOfDeath

If the Stratum field is 0, which implies unspecified or invalid, the Reference Identifier field can be used to convey messages useful for status reporting and access control. These are called Kiss-o'-Death (KoD) packets and the ASCII messages they convey are called kiss codes.

LeapIndicator

A 2-bit integer warning of an impending leap second to be inserted or deleted in the last minute of the current month with values defined below:

Mode

A 3-bit integer representing the mode.

PrimarySource

A four-octet, left-justified, zero-padded ASCII string assigned to the reference clock.

ReferenceIdentifier

A 32-bit code identifying the particular server or reference clock.

Constants

MAXDISP

Maximum dispersion (16 s).

MAXDIST

Distance threshold (1 s).

MAXPOLL

Maximum poll exponent (36 h).

MAXSTRAT

Maximum stratum number.

MINDISP

Minimum dispersion increment (s).

MINPOLL

Minimum poll exponent (16 s).

PORT

NTP port number.

TOLERANCE

Frequency tolerance PHI (s/s).

Traits

ConstPackedSizeBytes

Types that have a constant size when written to or read from bytes.

ReadBytes

A trait for reading any of the Network Time Protocol types from network-endian bytes.

ReadFromBytes

Network Time Protocol types that may be read from network endian bytes.

WriteBytes

A trait for writing any of the Network Time Protocol types to network-endian bytes.

WriteToBytes

Network Time Protocol types that may be written to network endian bytes.

Type Definitions

PacketByte1

The consecutive types within the first packed byte in the NTP packet.