emNet Add-Ons - NTP Client
The emNet Network Time Protocol (NTP) client is an optional extension which can be seamlessly integrated into your application. The NTP client implementation allows an embedded system to use real timestamps from a remote NTP server without using a Real Time Clock (RTC).
- Low memory footprint.
- Seamless integration with the emNet stack.
- Time synchronization with local and remote NTP clocks.
The NTP protocol is a service on top of the UDP/IP protocol. It provides a way of synchronizing the target time with a local or remote NTP server over the network.
Using NTP, an emNet based application can use an accurate time obtained from NTP servers. These NTP servers could be in local network and in global network.
To obtain the IP address of clocks in the global network, the NTP client could be configured by the user with IPv4 or IPv6 addresses and/or use a server pool.
When using server pools, the NTP client performs a DNS request with a server pool name (for example "0.pool.ntp.org") and will get a reply with the IP addresses of some clocks. Once the clock IP addresses are obtained, the NTP client sends synchronization requests to all clocks (through a gateway for clocks in the global network) and uses their replies to compute the time offset.
Synchronization messages sent between the client and server clocks contain time information exchange. The clients send a request with a timestamp. The server stores the time of the request arrival and send it back along with its sending time. The client stores the time of the reply arrival and can compute the time offset with the four known times.
The emNet NTP client implementation requires the emNet TCP/IP stack.
In order to use a server pool, a DNS environment needs to be present and configured.
The emNet NTP client has some parameters for its configuration. These parameters are per default set with valid values.
The maximum number of server pools and monitored clock could be modified:
#define NTP_MAX_POOL 4 // Maximum number of configured pools. #define NTP_MAX_SERVER 8 // Maximum number of monitored servers.
The NTP version 4 specification requires to keep for each monitored clocks lots of data in memory and have quite a complex processing. The emNet NTP implements this algorithm but also provides a simpler one which requires fewer resources. This could be chosen with a compilation switch:
#define NTP_USE_SIMPLER_VERSION 1 // Don't follow strictly RFC but use much fewer resources.
The ROM usage depends on the compiler options, the compiler version and the used CPU. The memory requirements of the NT client presented in the tables below have been measured on a Cortex-M4 with the default configuration.
The NTP client implements the relevant parts of the NTP v4 Request For Comments (RFC).
|[RFC 5905]||Direct Link: Network Time Protocol Version 4: Protocol and Algorithms Specification|