Expand description
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§
- Date
Format - 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.
- Short
Format - 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.
- Timestamp
Format - 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§
- Kiss
OfDeath - 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.
- Leap
Indicator - 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.
- Primary
Source - A four-octet, left-justified, zero-padded ASCII string assigned to the reference clock.
- Reference
Identifier - 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§
- Const
Packed Size Bytes - Types that have a constant size when written to or read from bytes.
- From
Bytes - Parse a type from a byte slice, returning the parsed value and the number of bytes consumed.
- Read
Bytes - A trait for reading any of the Network Time Protocol types from network-endian bytes.
- Read
From Bytes - Network Time Protocol types that may be read from network endian bytes.
Requires the
stdfeature. - ToBytes
- Serialize a type into a byte slice, returning the number of bytes written.
- Write
Bytes - A trait for writing any of the Network Time Protocol types to network-endian bytes.
- Write
ToBytes - Network Time Protocol types that may be written to network endian bytes.
Requires the
stdfeature.
Type Aliases§
- Packet
Byte1 - The consecutive types within the first packed byte in the NTP packet.