coreSNTP v1.3.1
Client library for synchronizing device time with internet time using Simple Network Time Protocol (SNTP)
 
Loading...
Searching...
No Matches
Constants

Constants defined in the coreSNTP library. More...

Macros

#define SNTP_DEFAULT_SERVER_PORT   ( 123U )
 The default UDP port supported by SNTP/NTP servers for client-server communication.
 
#define SNTP_PACKET_BASE_SIZE   ( 48U )
 The base packet size of request and response of the (S)NTP protocol.
 
#define SNTP_FRACTION_VALUE_PER_MICROSECOND   ( 4295U )
 Number of SNTP timestamp fractions in 1 microsecond.
 
#define SNTP_TIME_AT_UNIX_EPOCH_SECS   ( 2208988800U )
 The seconds part of SNTP time at the UNIX epoch time, which represents an offset of 70 years (in seconds) between SNTP epoch and UNIX epoch time. SNTP uses 1st Jan 1900 UTC as the epoch time, whereas UNIX standard uses 1st Jan 1970 UTC as the epoch time, thereby, causing an offset of 70 years between them.
 
#define SNTP_TIME_AT_LARGEST_UNIX_TIME_SECS   ( 61505151U )
 The seconds value of SNTP timestamp for the largest UNIX time when using signed 32-bit integer for seconds. The largest time representable with a 32-bit signed integer in UNIX time is 19 Jan 2038 3h 14m 7s UTC. However, as the SNTP time overflows at 7 Feb 2036 6h 28m 16s UTC, therefore, the SNTP time for the largest UNIX time represents the time duration between the 2 timestamps.
 
#define UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME   ( 2085978496U )
 The UNIX time (in seconds) at the smallest SNTP time in era 1, i.e. UNIX time at 7 Feb 2036 6:28:16 UTC/.
 
#define SNTP_KISS_OF_DEATH_CODE_LENGTH   ( 4U )
 The fixed-length of any Kiss-o'-Death message ASCII code sent in an SNTP server response.
 
#define SNTP_KISS_OF_DEATH_CODE_NONE   ( 0U )
 The value for the SntpResponseData_t.rejectedResponseCode member when that the server response packet does not contain a Kiss-o'-Death message, and therefore, does not have a "kiss code". The server sends a "kiss-code" only when it rejects an SNTP request with a Kiss-o'-Death message.
 

Detailed Description

Constants defined in the coreSNTP library.

Macro Definition Documentation

◆ SNTP_DEFAULT_SERVER_PORT

#define SNTP_DEFAULT_SERVER_PORT   ( 123U )

The default UDP port supported by SNTP/NTP servers for client-server communication.

Note
It is possible for a server to use a different port number than the default port when using the Network Time Security protocol as the security mechanism for SNTP communication. For more information, refer to Section 4.1.8 of RFC 8915.

◆ SNTP_PACKET_BASE_SIZE

#define SNTP_PACKET_BASE_SIZE   ( 48U )

The base packet size of request and response of the (S)NTP protocol.

Note
This is the packet size without any authentication headers for security mechanism. If the application uses a security mechanism for communicating with an (S)NTP server, it can add authentication data after the SNTP packet is serialized with the Sntp_SerializeRequest API function.

◆ SNTP_FRACTION_VALUE_PER_MICROSECOND

#define SNTP_FRACTION_VALUE_PER_MICROSECOND   ( 4295U )

Number of SNTP timestamp fractions in 1 microsecond.

The fraction's part of an SNTP timestamp is 32-bits wide, thereby, giving a resolution of 2^(-32) seconds ~ 232 picoseconds.

Note
The application can use this value to convert microseconds part of system time into SNTP timestamp fractions. For example, if the microseconds part of system time is n microseconds, the fractions value to be used for the SNTP timestamp part will be n * SNTP_FRACTION_VALUE_PER_MICROSECOND.

◆ SNTP_TIME_AT_UNIX_EPOCH_SECS

#define SNTP_TIME_AT_UNIX_EPOCH_SECS   ( 2208988800U )

The seconds part of SNTP time at the UNIX epoch time, which represents an offset of 70 years (in seconds) between SNTP epoch and UNIX epoch time. SNTP uses 1st Jan 1900 UTC as the epoch time, whereas UNIX standard uses 1st Jan 1970 UTC as the epoch time, thereby, causing an offset of 70 years between them.

Difference of 70 years = ((70 * 365) + 17 leap days) * 24 * 3600 seconds

Note
If your system follows UNIX time, the application can use this value to convert seconds part of a system time to seconds part of the equivalent SNTP time. For example, if the seconds part of system time is n seconds, the seconds value to be used for the SNTP timestamp will be n + SNTP_TO_UNIX_OFFSET_SECS.

◆ SNTP_TIME_AT_LARGEST_UNIX_TIME_SECS

#define SNTP_TIME_AT_LARGEST_UNIX_TIME_SECS   ( 61505151U )

The seconds value of SNTP timestamp for the largest UNIX time when using signed 32-bit integer for seconds. The largest time representable with a 32-bit signed integer in UNIX time is 19 Jan 2038 3h 14m 7s UTC. However, as the SNTP time overflows at 7 Feb 2036 6h 28m 16s UTC, therefore, the SNTP time for the largest UNIX time represents the time duration between the 2 timestamps.

SNTP Time at Largest Time Duration in the range Signed 32-bit UNIX time = [7 Feb 2036 6:28:16, 19 Jan 2038 3:14:07]

◆ UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME

#define UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME   ( 2085978496U )

The UNIX time (in seconds) at the smallest SNTP time in era 1, i.e. UNIX time at 7 Feb 2036 6:28:16 UTC/.

Time Duration = 7 Feb 6:28:16 UTC (SNTP Era 1 Epoch) - 1 Jan 1970 0:0:0 UTC (UNIX epoch) = 66 years, 37 days, 6 hours, 28 minutes and 16 seconds = ((66 * 365) + 16 leap days) * 24 * 3600) + (6 * 3600)

  • (28 * 60) + 16

◆ SNTP_KISS_OF_DEATH_CODE_LENGTH

#define SNTP_KISS_OF_DEATH_CODE_LENGTH   ( 4U )

The fixed-length of any Kiss-o'-Death message ASCII code sent in an SNTP server response.

Note
An SNTP server sends a Kiss-o'-Death message to reject a time request from the client. For more information on the Kiss-o'-Death codes, refer to the SNTPv4 specification Section 8.