In today's world, where business processes depend on multiple servers and platforms constantly passing transactions back and forth, even slight time differences between servers can make audit trails impossible to decipher. This is where Simple Network Time Protocol (SNTP) comes in. Simply put, SNTP is a means by which client computers can synchronize their system time with a server system. In this article, we'll explore the enhancements to time synchronization capabilities that IBM added into V5R3.
Client or Server
As I mentioned, the concept behind SNTP is pretty basic. An SNTP client computer is able to automatically adjust its system clock to match that of an SNTP server. The big news in V5R3 is that IBM has added SNTP server capabilities to the existing SNTP client support. This means that in the scenario I just described, the iSeries can play both roles. Now, the iSeries can not only be a client to a time server, but also act as a time server to supply time synchronization services to clients. It can also do both at the same time, synchronizing its time from a public time server and then making synchronization services available to client computers on the local network. IBM has also changed the SNTP client by adding support for multiple time servers, by allowing you to define how the time is adjusted, and by changing which clock is updated. Prior to V5R3, the SNTP client would update the software clock. Now, the system clock is updated.
Let's start off by examining how to set up your iSeries as a time server.
Server Configuration
The process to set up your iSeries as an SNTP server is pretty basic. This can be accomplished using the Change SNTP Attribute (CHGNTPA) command. It's important to note that this command is used to configure both server and client SNTP attributes. Three of the command's parameters are used to configure the SNTP server attributes:
CHGNTPA Parameters for Configuring SNTP Server Attributes | |
Parameter | Description |
SVRAUTOSTR | Defines whether or not to automatically start the SNTP server job when TCP/IP services are started with the STRTCP command |
SVRACTLOG | Defines what level of activity logging should be written to the activity logging file located in the IFS folder /QIBM/USERDATA/OS400/TCPIP/NTP/SERVER |
SYNCRQD | Identifies whether the SNTP client should be used to synchronize the time with an external time server before starting the time server |
The auto start parameter (SVRAUTOSTR) accepts a value of either *YES to define that the SNTP server should start automatically when the TCP/IP server is started or *NO to prevent the SNTP server from starting.
The server activity logging parameter (SVRACTLOG) accepts a value of *NONE to identify that no logging will be done. The value *ERROR is used to define that log entries will be written whenever an error occurs during synchronization. All requests made to the SNTP server will result in a log entry if the value *ALL is specified.
The synchronization required (SYNCRQD) accepts a value of *YES or *NO.
The command below would be used to configure the iSeries SNTP server to run at startup with error logging but without synchronization prior to starting.
After executing this command, you can either stop and start TCP/IP using the ENDTCP and STRTCP commands or simply use the STRTCPSVR command as shown below.
Note that the NTPSRV parameter here signifies that the SNTP server service should be started. Once the SNTP server is started, client computers can be configured to utilize the iSeries as a time server.
Client Configuration
The client configuration is also accomplished using the CHGNTPA command. The following seven parameters define SNTP client attributes:
CHGNTPA Parameters for Configuring SNTP Client Attributes | |
Parameter | Description |
RMTSYS | Defines a list of host names or IP addresses of NTP servers to be used for synchronization |
AUTOSTART | Identifies whether the SNTP client should be started automatically when TCP/IP is started |
POLLITV | Defines the interval in minutes between time server connections |
MINADJ | Sets the minimum adjustment difference in milliseconds |
MAXADJ | Sets the maximum adjustment difference in minutes |
ADJTHLD | Sets the adjustment threshold used to determine whether to reset the clock or gradually adjust it |
ACTLOG | Defines the level of client activity log entries to be written to a log file in the IFS folder /QIBM/USERDATA/OS400/TCPIP/NTP |
The remote system parameter (RMTSYS) has been enhanced in V5R3 to allow not only one, but multiple time servers. When multiple time servers are specified, the first available time server is used. This gives the SNTP client greater support for failover in case one or more of the time servers is down. It's important to note that if the time server specified is external to your local network (outside of your firewall), your firewall configuration may need to be changed to allow UDP traffic on port 123.
The auto start parameter (AUTOSTART) is used here much in the same way it's used on the server parameter. If *YES is specified, the SNTP client automatically starts when TCP/IP is started.
The poll interval (POLLITV) parameter identifies the number of minutes that should elapse between connections to the time server.
The min and max adjustment parameters (MINADJ and MAXADJ, respectively) allow you to define minimum and maximum differences between client and server times for which adjustments will be made. If, when a connection is made, the difference between the server time and the client time is less than the min (in milliseconds) or greater than the max (in minutes), the time on the client will not be adjusted.
The adjustment threshold parameter (ADJTHLD) identifies the method that should be used to adjust the time, based on a specified number of seconds difference in time. This new parameter in V5R3 adds support for controlling how the time on the local system is updated. If the difference between the server time and the client time is less than the specified value, the clock will be adjusted gradually up or down until the two clocks match. This is done to prevent sudden clock changes, which could cause havoc with applications that use the time value. If, however, the difference is greater than the number of seconds specified, the clock will simply be reset to the server time. The optional special value of *MAXADJ can be specified to identify that any differences up to the value of the MAXADJ parameter should be gradually adjusted and not simply reset.
The activity log parameter (ACTLOG) accepts a value of *NONE to define that no activity log entries should be written, a value of *CHANGE to define that log entries will be written only when a time change occurs, or a value of *POLL to define that a log entry should be written every time a connection is made to the time server and the server sends a response.
The CHGNTPA command below gives an example of configuring the SNTP client.
POLLITV(1) MINADJ(1000) MAXADJ(10) ADJTHLD(*MAXADJ)
ACTLOG(*POLL)
This configuration will result in an SNTP client configuration containing a single time server that will be polled every minute and for which adjustments will be made only when the difference is more than 10 seconds and less than 10 minutes. Any differences less than the maximum adjustment value will be gradually made over a short time. Any other time difference is ignored. Log entries will be written for each time that the client polls the server.
After issuing this command, the SNTP client will be started automatically the next time that TCP/IP is started. Alternatively, you can manually start the SNTP client using the STRTCPSVR command shown below:
As we saw earlier, the NTPSRV parameter allows us to define whether to start the SNTP client or server. This parameter also accepts a special value of *CFGFILE, which tells the command to check the auto start options defined on the CHGSNTPA command for both server and client. Using this option, you can manually start both client and server with a single command.
Time Zones
When you're retrieving the time from a public time server, it's important to realize that the time server you're using could be anywhere in the world. For that reason, your system must be configured to the correct time zone. Time zone definitions can be found using the Work with Time Zones (WRKTIMZON) command. Figure 1 below shows the WRKTIMZON display.
Figure 1: The WRKTIMZON display is used to set up time zone information. (Click image to enlarge.)
This screen allows us to view and change the definition of available time zones. The offset value determines the number of hours that a given time zone is offset from the world clock (GMT). These values are used in conjunction with the QTIMZON system value to help the SNTP server and client determine what the time is on the local system. You can use option 8 from this screen to update the system value with a given time zone description.
Where Do You Find the Time?
Now that you know how to set up the iSeries to utilize SNTP, you may be wondering where you can get a list of available public time servers. This Web site gives information on servers that are open to the public and those that have closed (private) access. You also might want to check out www.ntp.org for more information on how time synchronization works.
Mike Faust is an application programmer for Fidelity Integrated Financial Solutions in Maitland, Florida. Mike is also the author of the books The iSeries and AS/400 Programmer's Guide to Cool Things and Active Server Pages Primer and SQL Built-in Functions and Stored Procedures. You can contact Mike at
LATEST COMMENTS
MC Press Online