NTP Packet

The NTP packet module provides functionality to manipulate the NTP header.

NTP_PACKET_LI_POS

Bit positions and masks for ntp_packet.h::ntp_packet_t::li_vn_mode.

1
(6U)

Leap indicator position

NTP_PACKET_LI_MASK

leap indicator mask

1
(0xc0)
NTP_PACKET_VN_POS

version position

1
(3U)
NTP_PACKET_VN_MASK

version mask

1
(0x38)
NTP_PACKET_MODE_MASK

mode mask

1
(0x07)
enum ntp_mode_t
NTP_MODE_RESERVED = 0
reserved
NTP_MODE_SYM_ACTIVE
symmetric active
NTP_MODE_SYM_PASSIVE
symmetric passive
NTP_MODE_CLIENT
client
NTP_MODE_SERVER
server
NTP_MODE_BROADCAST
broadcast
NTP_MODE_PRIV
reserved for private use
void ntp_packet_set_li(ntp_packet_t * packet, uint8_t li)

Set leap indicator in a NTP packet.

Parameters

packet:The NTP packet
li:Leap indicator

void ntp_packet_set_vn(ntp_packet_t * packet)

Set version in a NTP packet.

Parameters

packet:The NTP packet

void ntp_packet_set_mode(ntp_packet_t * packet, ntp_packet.h::ntp_mode_t mode)

Set mode in a NTP packet.

Parameters

packet:The NTP packet
mode:Mode

uint8_t ntp_packet_get_li(ntp_packet_t * packet)

Get leap indicator from a NTP packet.

Parameters

packet:The NTP packet

Return values

  • The leap indicator of packet
uint8_t ntp_packet_get_vn(ntp_packet_t * packet)

Get version from a NTP packet.

Parameters

packet:The NTP packet

Return values

  • The version of packet
ntp_packet.h::ntp_mode_t ntp_packet_get_mode(ntp_packet_t * packet)

Get mode from a NTP packet.

Parameters

packet:The NTP packet

Return values

  • The version of packet
NTP_VERSION

NTP version.

1
(4U)
NTP_PORT

NTP port number.

1
(123U)
NTP_UNIX_OFFSET

Offset in seconds of NTP timestamp (seconds from 1990-01-01 00:00:00 UTC) to UNIX timestamp (seconds from 1970-01-01 00:00:00 UTC).

1
(2208988800)
struct ntp_timestamp_t

NTP timestamp.

byteorder.h::network_uint32_t seconds

seconds since 1 January 1900 00:00 UTC

byteorder.h::network_uint32_t fraction

fraction of seconds in 232 picoseconds

struct ntp_packet_t

NTP packet.

uint8_t li_vn_mode

leap indicator, version and mode

uint8_t stratum

stratum

uint8_t poll

poll in log2 seconds

uint8_t precision

precision in log2 seconds

byteorder.h::network_uint32_t root_delay

root delay in NTP short format

byteorder.h::network_uint32_t root_dispersion

root dispersion in NTP short format

byteorder.h::network_uint32_t reference_id

reference ID

ntp_timestamp_t reference

reference timestamp

ntp_timestamp_t origin

origin timesptamp

ntp_timestamp_t receive

receive timestamp

ntp_timestamp_t transmit

transmit timestamp