Network Time ProtocolDefined in RFC958, NTPv4 in RFC5905
Network Time Protocol is an Internet Standard for time synchronization. It is used in networks of all types and sizes for synchornization of servers, workstations, and other networked equipment.
The base unit of time in Linux and Unix-like kernels is the Unix Epoch, the number of seconds since 1979, 01, 01, 00:00 UTC minus leap seconds. The unix kernel uses two separate clocks to maintain time; one a battery powered real time clock which keeps track of time when the system is turned off. The second clock is a software counter called the Kernel Clock, which receives regular interrupts from a timing circuit such as a crystal oscillator. This clock does not exist unless the system is running, so it references the RTC at boot time. These clocks often drift apart from each other, so the simplest way to keep them on time is the measure their drift rates and apply correction factors in software. RTC utilizes clock(8) and hwclock(8) system calls at boot time for corrections, where the system clock is corrected by adjusting the rate at which system time is advanced with each timer interrupt using the adjtimex(8), or adj standard library functions, this is known as "slewing the clock".
System time is always offset from UTC by some amount, and NTP is designed to receive timing information from external sources. This leads to imperfection across certain distances as NTP assumes a linear route to its destination despite certain router configurations and buffer congestion -- though even across the internet time tends to be correct to at least around 1 milisecond. Despite this, NTP is constantly trying to keep your system zeroing in on the one true time. It does this through a method known as polling.
NTP conducts polling by requesting data on NTP servers through UDP via port 123, in order to obtain current time, NTP polls these servers for their current time, measures how long it takes to get the request back, and analyses the results to determine which source represents best true time. NTP polls happen at intervals ranging from 8 seconds to 36 hours, with 64 seconds to 1024 seconds being the default range. The NTP daemon will automatically adjust its polling interval for each source based on the previous responses it has received.
NTP updates your system time through an authoritative method, by querying a pool of NTP servers where time is sourced from accurate external sources like atomic clocks (the type in GPS satellites). These servers are called "stratums", stratum 0 is the origin server, the main source of time, and stratum 1 references stratum 0, and stratum 2 references stratum 1, typically up to stratum 4 or 5.