APP下载

Research and Application on the Timestamp Synchronization Mechanism of NTP Network Applications

2015-11-25DonglingWngXuyngLiHongxinWng

电工技术学报 2015年1期

Dongling Wng Xuyng Li Hongxin Wng

(1.Information Centre,Beijing University of Civil Engineering and Architecture1.School of Civil and Transportation Engineering of BUCEAa 2.China National Publications Import and Export (Group) Corporationb)

1 Introduction

NTP (Network Time Protocol) is an Internet standard protocol used for time synchronization,which was first developed by David L.Mills from the University of Delaware in U.S.The purpose of NTP is to synchronize the computer time with the specified time standard in a way to enable a uniform clock for all application equipment.The currently applied time standard is UTC (Universal Time Coordinated).The working mechanism of NTP is applicable to the Internet environment of various sizes,speeds and connection routes,and boasts high flexibility,practicability,validity,self-adjustability and stability in time keeping.The time accuracy provided by NTP is calculated with tens of milliseconds on WAN,and with sub-milliseconds or minor on LAN.As the Internet applications develop rapidly and spread to all aspects of the society,a precise and reliable time,i.e.timestamp(network timing) is necessary for those such as network real time transactions,process control,network equipment security design,distributed network calculation and processing,network traffic control and database file management.Therefore,it is of great significance to implement time synchronization on the Internet.

Network time synchronization involves application in two aspects.The first aspect is that the time of all network equipment on the Internet is synchronized with the common time source.That is,a uniform time server (NTP) will issue a unified time to all network equipment.The second aspect is the redundancy in time sources for network time synchronization.Redundant time sources are quite necessary for networks with wide-spread areas,such as buildings located in different regions,networks with varied spans and huge demands for data traffic,networks in departments of critical missions,networks calling for data links of high reliability,and the like.The purpose of redundancy in time sources is to ensure that all workstations can keep their time synchronous during network linkage interruptions.

Based on the research on the demands of many types of equipment in the LAN of my university for the time correction and synchronization provided by NTP time server in practical application,the applied research of this paper is conducted on hundreds of switches,routers and other equipment on campus LAN through the arrangement of NTP servers.The research-oriented application in this paper has provided verifications for the properties of NTP.Besides,it is of immeasurable significance in practical administration for solving the problems of inaccuracy and disunity in LAN equipment times.

2 The Development Status Quo and Principle of NTP

2.1 The Status Quo and Phases of NTP Development

2.1.1 The Development Status Quo of NTP

Network Time Protocol (NTP) is used mainly to provide for network equipment with high-precision time correction and frequency synchronism technology,which now has been widely applied in many fields.In actual network environments,whether NTP should be applied for time correction and synchronization depends on the requirement for time precision within the network.Generally,the NTP timing precision is 1~50 ms in WAN,and 1 ms in LAN[1].With the development of studies on NTP time synchronization technology,there emerged some improved NTPs.For example,there is an NTP model which can physically generate and process timestamp marks to reduce delay in protocol processing by technological means,and which can measure and evaluate the influence of server operation performance and changes of network linkages on NTP time synchronization.There is also a NTP model that can analyze and evaluate the influence of changes in environment temperature on NTP performances.At present,applications of NTP has become quite common in foreign countries,while in China,researches on and applications of NTP servers in recent years have stepped in a rapid development phase.

2.1.2 Development Phase of NTP

(1) NTP v0 Protocol:The concept of time protocol was first proposed in Internet Engineering Note [IEN-173],and after that the time protocol standard [RFC 778]was formulated.However,it was only via the timestamp and timestamp answer message in the Internet Control Message Protocol (ICMP) that the time protocol could provide services then.Therefore,the NTP version in this time period was called NTPv0.The major function of NTPv0 was to provide time synchronization for ARPA network and its defect was the lack of frequency error compensation,filtration and synchronization algorithms.

(2) From NTPv1 to NTPv3 protocols:In 1988,the complete NTPv1 standard [RFC 1059]and description algorithm was developed,which mainly adopted client/server mode and symmetry operations.The defect was that it did no support authentication and NTP’s control messages.In 1989,NTPv2 [RFC1119]was officially published,which was based on the solutions of the defects of NTPv1.In 1992,NTPv3[RFC 1305]was published,based on conclusions and combinations of previous NTP versions and the advantages of DTSS.The advantage of NTPv3 [RFC 1305]is that it introduced the correction principle and the broadcast mode of time messaging [2],and that it improved lock selection and clock filtering algorithms.

(3) Researches since the NTP v3 protocol version:As an important function of NTP is to adjust the clocks in the computer operating system,since the publication of NTP v3 protocol version,experts have been conducting improvement researches,such as the research on improving the time keeping function in the operating system kernel,and the research on the kernel model of precise time keeping.Although the NTP V4 has not been published yet,experts will still categorize researches based on local clock adjustment algorithm,communication mode,new clock driver,adaption rules and related algorithms and rules into the NTPv4 protocol version.In addition,due to the rapid development of the next-generation Internet;various applied researches based on Ipv6 network have also taken great changes.Therefore,researches on application directions for the future of Ipv6 have also emerged as one of the research directions of NTPv4.

2.2 Principle of NTP

Network time protocol (NTP) is configured to issue precise time throughout the whole network based on TCP/IP protocol.The transmission of NTP itself is based on UDP protocol.The basic principle graphs of NTP vary into several ways,such as layer structure[2-3]and its deformations as shown in Fig.1.

Fig.1 is a structure graph showing the basic working principle of NTP.As shown in the graph,user side equipment and the server side are connected by the network,both with their independent system clock respectively.

Fig.1 NTP basic principle graph

The communication processes of system timing between the user side and the server side are as followed:

(1) The user side transmits a NTP time acquisition data package to the server side,making the timestamp T1.

(2) At receiving the NTP time acquisition data package from the user side,the server side modifies the timestamp into its own,i.e.T2.

(3) When the NTP time acquisition data package exits the server side,the former re-modifies its timestamp into T3.

(4) When the user side receives the NTP time acquisition data package that has returned,it modifies the timestamp into its own,T4.

Since the NTP time acquisition data package takes time in its round tripping and produces the time difference,the user side can only receive the correct time from the server side provided that the time difference produced by the round tripping of data package is determined[4-5].The calculation methods are as followed:

(1) To determine the time difference between T2 and T1:As the time amounts of T1 and T2 are variable and should be positive value,their absolute values should be adopted in calculation.The calculation formula for a cycle time delay of NTP messages is as shown in Formula 1.

(2) To determine the time difference between Gwa and Gwb:The calculation formula for it is as shown in Formula 2:

(3) By the results of Formula 1 and Formula 2 above,Gwa can set its own time clock to be synchronous with that of Gwb.

3 Applied Research on NTP

3.1 Applications of NTP in LAN

LAN applications involve many aspects,such as equipment like computer terminals,servers,switches,routers and other software management systems.All the aforesaid equipment and systems require a precise time to locate the failure events.Otherwise,problems cannot be solved effectively when failures occur.Applications of NTP on LAN can be roughly classified into the following aspects.

3.1.1 Management of LAN Equipment

Both campus and company network applications involve such equipment as switches,routers,firewalls,VPNs and computer terminals.When failures occur or downtime is caused by external faults,the internal event processing programs of these network equipment will timely record information about these critical events or failures.And failure information so closely connected with timestamps that if the equipment time is wrong or inaccurate,the real time when the failures occur cannot be determined.As such,neither the identification of causes nor the solution to failures can be enabled in a timely and accurate way.

3.1.2 Management of LAN Servers

In LAN,all various data records of the application server,including management,confirmation and authorization,require a high-precision time to base on for the different events and failures to be solved.Otherwise,it would make no sense to record the data.Especially for the major configuration events and system wrong information in the interface status,safety alarm and CPU overload processing of the server to be settled,accurate timestamps are quite necessary.

3.1.3 Management of Stability in LAN

Critical network events in LAN,such as bandwidth utilization,error diagnosis,connection error,buffer overflow and data packet dropout,are all captured,recorded and reported by the RMONs in the server,routers and special instruments.If the network is crashed because of the root-cause,then the system will display a list of RMON event reports with an index of timestamps.If the time is synchronous,then each event will be listed by time sequence.Otherwise,it will be difficult for the root-cause to determine the internal connections between the failure events and as a result leave the failures unsolved and the network crashed.

3.2 Commonly Used Algorithms of NTP

After years of development,theoretical researches on NTP are getting established and its applications are getting wider.NTP protocol mainly involves four algorithms,i.e.time filtering algorithm,time selection algorithm,clustering algorithm and clock adjusting algorithm.

3.2.1 Time Filtering Algorithm

The function of time filtering algorithm is to confirm the validity of data package,i.e.a process of selecting the best sample time in the several given time reference sources.The validity of data package comprises soundness check and filtering.

Soundness check includes uniqueness of the data package,content conformance of the data package,working normality of the server,rationality of the round-trip delay and deviation values and the like.Filtering is a process that stores information,through the time parameter register arrays,of such four timestamps as the posting time of NTP message switching,the opposite terminal receiving time,opposite terminal loopback time and the loopback receiving time,and then calculate the round-trip time delay and deviation of the data package[9].

3.2.2 Time Selection Algorithm

Time selection algorithm is used mainly to select the best time reference source.NTP applies filtering algorithm to identify the valid time thresholds of each time source,and then verify them one by one to determine the valid time threshold at last.

3.2.3 Clustering Algorithm

Based on the calculations by the time filtering algorithm and the time selection algorithm for the best time reference source recorded inside the NTP,clustering algorithm re-calculate and optimize the time sources by the accuracy standard.The purpose of clustering algorithm is to get better optimized time reference sources and reduce the adverse effects caused by the network time drifting[8].

3.2.4 Clock Adjusting Algorithm

In the application of NTP,the dithering caused by network response speed and the drifting caused by the oscillator frequency stability are the two major factors that influence the time precision.Clock adjusti[8]ng algorithm is a process that adjusts the time accuracy by the stability and precision of the clock oscillator,for the purpose of fixing the frequency error and correcting the clock time.

4 Applied Research on NTP in Campus LAN

4.1 Topology Structure of Campus LAN

Currently in university campus LAN,network equipment mainly involves switches and routers,and application equipment includes servers,VPNs and firewalls.Take my universities as an example,as there are two campuses with many users,the network structure is rather complicated and leaves huge difficulties in daily management.At present,the major problems in managing the LAN network of my campus is the inaccuracy and disunity in servers,switches and other network equipment.As a result,when a failure occurs,the precise time point and location of the failure cannot be determined accurately and quickly,thus delaying the time for troubleshooting.To solve the problems in the LAN of my university,this paper Figure 2 is a diagram showing the topology structure of the campus LAN in my university.

As part of the overall planning and development goal of building a university with first-class constructions,both the user population density and the network equipment in the new campus will increase in numbers.Therefore,in dealing with the problems in the LAN management of my university,the author took into consideration such factors as the features of the network topology structure as shown in Fig.2,the requirements for long term development and the needs in practical management,and decided to deploy an NTP time server in the network computer room on the new campus.Meanwhile,to reduce time dither and delay,the author connected the NTP server with layer 3 core switch straight-through.In this way,the serve will connect to the public network through only two switching nodes,ensuring the precision of the time received.

4.2 Deployment of Campus NTP Servers

4.2.1 Installation of the NTP Time Server

After overall consideration of the safety performance of server system in practical application,this research adopts an open source Linux system of the version CentOS release 5.3 (Final),with the kernel as core-3.1.The specific installation is shown in Tabl.1 as follows.

Tab.1 NTP server software package installation

4.2.2 Configuration of the NTP Time Server

(1) Edit the configuration file/etc/ntp.conf,as shown in Table 2.

Tab.2 Configuration of NTP server side

Considering the security of information,this research made modifications to the real data and generated the data involved in Tab.2.According to the configuration file as shown in Tab.2,the file defined default access rules by the key words of“restrict”and“default”;defined the inhibition of remote host to modify the configuration of local servers by key word“nomodify”;defined the rejection for special ntpdq to capture messages by key word“notrap”;defined the rejection for btodq/ntpdc to query the server status by key word“noquery”;and by“restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap”defined that all serves from 192.168.1.1 to 254 can synchronize the time through the NTP servers.The IP address of NTP time server LAN was configured as“server 192.168.2.1”.

To ensure the continued service provided by the NTP time server,the research defined“server127.1.1.0#local clock”when the connection is interrupted between the local server and the public NTP time server,so as to provide time service for the user side with the local server.

(2) Opening the port of the NTP time server,as the NTP time server uses UDP protocol,port 1,2,3 needs to be opened.

(3) Start the service of the NTP time server,and the configuration command is shown in Tab.3 as follows.

Tab.3 Start NTP server configuration

(4) User side configuration of the NTP time server

User side configuration can be set up as either manual synchronization or automated system synchronization.To perform manual synchronization,just execute“ntpdate 192.168.2.1”on the user-side equipment.Considering the difficulties in practical management resulted from a large number of equipment in the LAN of my university,the research set the user side to be automated time synchronization.The configuration command is as shown in Tab.4.

Tab.4 application equipments synchronize time configuration automatically with NTP servers

The configuration command shown in Table 4 means that,application equipments will synchronize the time with the NTP server every 12 hours,so as to ensure time synchronization.

4.2.3 Synchrony Detection of the NTP Time Server

After the configuration of both server and user side is completed,the command“#ntpq–p”can be used to detect the synchrony status of the time server.

4.2.4 Before-and-after Comparison of the Time synchrony in LAN Equipments

To test the working result of the NTP time server,the research conducted tests on one of the switches.The results are as shown in Tab.5.

Tab.5 Before-and-after data comparison of time synchrony on LAN equipments

Tab.5 shows the comparison of event logging data before and after the time synchronization conducted by the LAN switch.Before the time synchronization,as the real time cannot be determined,the operation time when an engineer logged on the switch cannot be located precisely;while after the time synchronization,the engineer who logged on the switch and the operations he had conducted can be located by the time stamp“2014-04-10 20:03”in Table 5.In this way,the source for fixing up or restoring the equipment configuration file can be found so as to solve the practical troubles as soon.

By the several steps above,the system clock on the local NTP server can be synchronized with that of the public NTP server on WAN.Meanwhile,the local NTP server can be used as the LAN time host to provide time synchronization service to all equipment on LAN,and achieve the objective of synchronous clock.

5 Conclusion

The application of NTP is relatively wider out of China.However,as the Internet application services continue to grow,the range of NTP application in China is increasing in momentum.Based on examples of the LAN equipments in my university,this paper introduced the advantages of clock synchronization in university LAN equipment.That is,network equipment logging can precisely and realistically reflect the events that have practically occurred,thus the system administrator can then detect and solve the system errors in a timely way.Otherwise,event logging with sequential disorder cannot help to solve the failures in network equipment effectively and timely,thus offers no help to LAN administration.

At present,the experiment described in this paper conducted tests only on the hundreds of switches and routers in the LAN of my university,which are from various manufacturers and of different brands.And all the tests have produced with precise information,which has provided immeasurable help in managing the campus LAN of my university.Going forward,the author will at first,employing the established campus NTP time server,and work to provide time synchronization service to all network equipment in the university,so as to manage the university network in a better way.In addition,further studies on NTP will be conducted to provide more precise techniques.Finally,researches on the future application range and technology of NTP on the Internet will also be implemented.

[1]Internet Network Time Protocol.Computer Engineering,2002,2.vol28,No2:275-277.

[2]Hong Zhang,Zhiqiang Wang,Qianbin Chen.The Application of NTP protocol in the Telecommunication Network.Journal of Computer Applications,2004,24(zl).

[3]Caituan Jiang.The basic principle of network time protocol and its application in campus network.Journal of Longyan Teachers college,2004,22(3).

[4]Yan Song,Shang Zhu.A Network Time Service System Based on NTP.Computer Engineer and applications,2003,39(36).

[5]David L.Mills.Long-rang Dependency Effects in Network Timekeeping.http://www.ntp.org/,2004,8,2.

[6]David L.Mills.Network Time Protocol (Version 3)Specification,Implementation and Analysis-RFC1305.1992,3:1-106

[7]David Deeths,Glenn Brunette.Using NTP to Control and Synchronize system Clocks–Part I:NTP Monitoring and Trouble shooting.Sun BluePrints™OnLine,2001,7.Revision 1:12-16..

[8]David L.Mills.NTP Architecture,Protocol and Algorithms.http://www.ntp.org/,2004,8,2.

[9]David Deeths,Glenn Brunette.Using NTP to Control and Synchronize System Clocks Part Ⅱ:Basic NTP Administration and Architecture.Sun BluePrints ™OnLine,2001,8:83-97.