
NTP Working Group David L. Mills Technical Report 06-6-1 University of Delaware June 2006 Network Time Protocol Version 4 Reference and Implementation Guide Abstract This document describes the Network Time Protocol Version 4 (NTPv4), which is widely used to synchronize the time for Internet hosts, routers and ancillary devices to Coordinated Universal Time (UTC) as disseminated by national standards laboratories. It describes the core architecture, protocol, state machine, data structures and algorithms. It explains the fundamental on-wire protocol used to exchange time values between peers, servers and clients. It summarizes the clock offset, roundtrip delay and various other statistics used by the mitigation algorithms to calculate the maximum error and nominal error inherent in computing these values. It describes several changes from Version 3 of NTP (NTPv3) originally described in RFC 1305, including the introduction of a modified protocol header to accommodate Internet Protocol Version 6 and a new header extension field to support the Autokey public key authentication scheme. This document is based on the reference implementation available at www.ntp.org. It is intended as a reference and implementation guide, not as a formal standard. The main body of the document describes the basic model data structures and algorithms necessary for an implementation which can interoperate properly with another implementation faithful to this model. This document describes a number of crafted mitigation algorithms which can improve the accuracy and stability of the timekeeping function, especially in NTP subnets with many servers and clients. It also describes the clock discipline function used to adjust the system clock in time and frequency to agree with the available sources of synchronization. As an implementation aid, a code skeleton for the reference implementation is presented in an appendix. It includes most of the data structures and algorithms of that program, but certain features, such as the control and monitoring protocol, Autokey public key authentication scheme, huff-’n-puff scheme and server discovery schemes are not included. These are discussed in companion documents on the Web and in print. Keywords: network time synchronization, computer time synchronization, time synchronization protocol Sponsored by: Naval Surface Weapons Center (Dahlgren) Contract N00178-04-1-9001. Mills Information Track [Page i] TR 06-6-1t NTPv4 Reference and Implementation Guide June 2006 Table of Contents 1. Introduction...................................................................................................................1 2. Modes of Operation......................................................................................................2 3. Definitions ....................................................................................................................4 4. Implementation Model..................................................................................................5 5. Data Types ....................................................................................................................6 6. Data Structures..............................................................................................................9 6.1 Structure Conventions ...........................................................................................9 6.2 Global Parameters ...............................................................................................10 6.3 Packet Header Variables......................................................................................11 7. On-Wire Protocol........................................................................................................14 8. Peer Process................................................................................................................16 8.1 Peer Process Variables.........................................................................................16 8.2 Peer Process Operations ......................................................................................18 8.3 Clock Filter Algorithm ........................................................................................22 9. System Process ...........................................................................................................24 9.1 System Process Variables ....................................................................................24 9.2 System Process Operations..................................................................................25 9.2.1 Selection Algorithm...................................................................................26 9.2.2 Clustering Algorithm .................................................................................28 9.2.3 Combining Algorithm................................................................................29 9.2.4 Clock Discipline Algorithm.......................................................................31 9.3 Clock Adjust Process...........................................................................................36 10. Poll Process.................................................................................................................36 10.1 Poll Process Variables and Parameters................................................................37 10.2 Poll Process Operations.......................................................................................37 11. Simple Network Protocol (SNTP)..............................................................................39 11.1 SNTPv4 Primary Server Configuration...............................................................40 11.2 SNTPv4 Client Configuration .............................................................................41 12. References...................................................................................................................42 Appendix A.NTPv4 Packet Formats .................................................................................43 A.1 NTP Header Field Format ...................................................................................43 A.2 NTPv4 Extension Field Format...........................................................................44 Appendix B.Code Skeleton................................................................................................46 B.1 Global Definitions ...............................................................................................46 B.1.1 Definitions, Constants and Parameters ......................................................46 B.1.2 Packet Data Structures ...............................................................................49 B.1.3 Association Data Structures.......................................................................50 B.1.4 System Data Structures..............................................................................51 B.1.5 Local Clock Data Structure........................................................................52 B.1.6 Function Prototypes ...................................................................................52 B.2 Main Program and Utility Routines ....................................................................53 Mills Information Track [Page ii] TR 06-6-1t NTPv4 Reference and Implementation Guide June 2006 B.3 Kernel Input/Output Interface .............................................................................57 B.4 Kernel System Clock Interface............................................................................57 B.5 Peer Process.........................................................................................................59 B.5.1 receive() .....................................................................................................60 B.5.2 packet() ......................................................................................................64 B.5.3 clock_filter() ..............................................................................................66 B.5.4 fast_xmit()..................................................................................................67 B.5.5 access().......................................................................................................68 B.6 System Process ....................................................................................................68 B.6.1 clock_select() .............................................................................................69 B.6.2 root_dist()...................................................................................................72 B.6.3 accept().......................................................................................................72 B.6.4 clock_update() ...........................................................................................73 B.6.5 clock_combine() ........................................................................................75 B.6.6 local_clock() ..............................................................................................75 B.6.7 rstclock() ....................................................................................................80 B.7 Clock Adjust Process...........................................................................................81 B.7.1 clock_adjust().............................................................................................81 B.8 Poll Process .........................................................................................................82
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages90 Page
-
File Size-