9.3   Using the SNTP Server

To include the SNTP server, reconfigure your VxWorks image. The relevant configuration macro is INCLUDE_SNTPS. VxWorks automatically calls sntpsInit( )during system startup. Depending on the value of the SNTP Server Mode Selection (set by the configuration constant SNTPS_MODE), the server executes in one of two modes, SNTP_PASSIVE or SNTP_ACTIVE.

If the SNTP Server Mode Selection is set to SNTP_PASSIVE, the server waits for requests from clients and sends replies containing an NTP timestamp. If the SNTP Server Mode Selection is set to SNTP_ACTIVE, the server periodically transmits NTP timestamp information at fixed intervals.

When executing in active mode, the SNTP server uses two other configuration settings, the SNTP Server Destination Address (configuration constant SNTPS_DSTADDR) and the SNTP Server Update Interval (configuration constant SNTPS_INTERVAL) to determine the target IP address and broadcast interval. By default, the server transmits the timestamp information to the local subnet broadcast address every 64 seconds. To change these settings after system startup, call the sntpsConfigSet( )routine. The SNTP server operating in active mode can also respond to client requests as they arrive.

The SNTP Client/Server Port (configuration constant SNTP_PORT) assigns the source and destination UDP port. The default port setting is 123 as specified by the RFC 1769.

Finally, the SNTP server requires access to a reliable external time source. To do this, you must provide a routine of the form:

STATUS sntpsClockHook (int request, void *pBuffer);

Until this routine is hooked into SNTP, the server cannot provide timestamp information. There are two ways to hook this routine into the SNTP server. The first is to configure VxWorks with the SNTPS Time Hook (configuration constant SNTPS_TIME_HOOK) set to the appropriate routine name. You can also call sntpsClockSet( ). See the reference entry fro sntpsClockSet( )for more information.