kids encyclopedia robot

Network Time Protocol facts for kids

Kids Encyclopedia Facts
Quick facts for kids
Network Time Protocol
Network Time Protocol servers and clients.svg
International standard RFC 5905
Developed by David L. Mills, Harlan Stenn, Network Time Foundation
Introduced 1985; 40 years ago (1985)


The Network Time Protocol (NTP) is a special set of rules for computers to keep their clocks in sync. Imagine all your devices, like your phone, computer, and game console, always showing the exact same time. NTP helps make this happen across the internet. It's one of the oldest internet rules still used today, first created before 1985 by David L. Mills from the University of Delaware.

NTP aims to make sure all connected computers show time that's super close to Coordinated Universal Time (UTC). This means they are usually within a few thousandths of a second of each other. It uses smart ways to pick the best time servers and deals with delays that can happen on the internet. Over the public internet, NTP can usually keep time within a few hundredths of a second. On a local network, it can be even more accurate, sometimes within a thousandth of a second!

Computers using NTP often work like a "client" asking a "server" for the time. But they can also work as "peers," where both computers share time with each other. They send and receive time information using a special internet port number, 123. NTP also warns about upcoming leap seconds, which are extra seconds added to the year to keep our clocks aligned with the Earth. However, it doesn't tell you about time zones or daylight saving time. The current version of NTP is version 4 (NTPv4), and it works with older versions too.

How NTP Started

DL Mills-2
NTP was designed by David L. Mills.

The idea of syncing computer clocks over a network began a long time ago. In 1979, a type of network time syncing was shown off at a big computer conference in New York. This was possibly the first time internet services ran over a satellite network across the Atlantic Ocean.

Later, in 1985, the very first version of NTP (NTPv0) was created. Even with the slower computers and internet connections back then, it could sync clocks within a tenth of a second across the Atlantic. On local networks, it was even faster.

Over the years, NTP got better and better. New versions were released, adding more features and making the time syncing even more accurate. For example, NTPv2 added ways to manage the protocol and use digital signatures to make sure the time messages were real. NTPv3, released in 1992, could figure out which time server was the best to use when several disagreed.

The current version, NTPv4, came out in 2010. Since David L. Mills retired, a team of people now works on keeping NTP updated as an open-source project.

Simple Network Time Protocol (SNTP)

While NTP is very powerful, sometimes a simpler way to get time is needed. This is where Simple Network Time Protocol (SNTP) comes in. It was created in 1992. SNTP is like a lighter version of NTP. It's easier to use because it doesn't need to store as much information over time.

SNTP works perfectly with NTP. However, because it uses simpler methods, it might not be as super accurate as full NTP. So, it's usually not recommended to rely on an SNTP source if you need extremely precise time.

How Clocks Are Organized (Strata)

Usno-amc
The U.S. Naval Observatory Alternate Master Clock at Schriever AFB (Colorado) is a stratum 0 source for NTP.
Network Time Protocol servers and clients
Yellow arrows indicate a direct connection; red arrows indicate a network connection.

NTP uses a layered system to organize time sources, like a pyramid. Each layer is called a stratum, and it has a number. The most accurate clocks are at the top, starting with zero. A server that gets its time from a stratum n server becomes a stratum n + 1 server. This numbering helps prevent computers from getting stuck in a loop trying to sync with each other.

Here's what the different strata mean:

  • Stratum 0: These are super-accurate time devices. Think of atomic clocks, GPS receivers, or other radio clocks. They create a very precise signal that computers can use. NTP servers can't call themselves stratum 0.
  • Stratum 1: These are computers directly connected to a stratum 0 device. They are called primary time servers. They keep their own time within a few millionths of a second of the super-accurate source.
  • Stratum 2: These are computers that get their time over a network from stratum 1 servers. They might ask several stratum 1 servers for time to make sure they get the most accurate reading.
  • Stratum 3: These computers get their time from stratum 2 servers. They work in a similar way to stratum 2 computers and can also act as time servers for computers at stratum 4, and so on.

The highest stratum number is 15. If a device shows stratum 16, it means it's not synchronized at all.

NTP also uses special codes to show where a server gets its time. For example, "GPS" means it's getting time from a GPS satellite. These codes help prevent computers from getting stuck in time loops.

Common time reference identifiers (refid) codes
Refid Clock Source
GOES Geosynchronous Orbit Environment Satellite
GPS Global Positioning System
GAL Galileo Positioning System
PPS Generic pulse-per-second
IRIG Inter-Range Instrumentation Group
WWVB LF Radio WWVB Fort Collins, Colorado 60 kHz
DCF LF Radio DCF77 Mainflingen, DE 77.5 kHz
HBG LF Radio HBG Prangins, HB 75 kHz (ceased operation)
MSF LF Radio MSF Anthorn, UK 60 kHz
JJY LF Radio JJY Fukushima, JP 40 kHz, Saga, JP 60 kHz
LORC MF Radio Loran-C station, 100 kHz
TDF MF Radio Allouis, FR 162 kHz
CHU HF Radio CHU Ottawa, Ontario
WWV HF Radio WWV Fort Collins, Colorado
WWVH HF Radio WWVH Kauai, Hawaii
NIST NIST telephone modem
ACTS NIST telephone modem
USNO USNO telephone modem
PTB German PTB time standard telephone modem
MRS (Informal) Multi Reference Sources
GOOG (Unofficial) Google Refid used by Google NTP servers as time4.google.com

Sometimes, these codes are used to tell a client to stop asking for time, for example, if the server is too busy.

How NTP Calculates Time

NTP-Algorithm
Round-trip delay time δ

When your computer (the client) wants to know the time, it sends a request to an NTP server. The server sends back a response. NTP uses four timestamps to figure out the exact time and how long it took for the messages to travel:

  • t0: When your computer sends the request.
  • t1: When the server gets your request.
  • t2: When the server sends its response.
  • t3: When your computer gets the server's response.

Using these four times, NTP can calculate:

  • Time offset: How much your computer's clock is different from the server's clock.
  • Round-trip delay: How long it took for the message to go from your computer to the server and back.

NTP then uses these calculations to slowly adjust your computer's clock. It's like a feedback loop, constantly making small corrections to keep your time perfect.

Different NTP Programs

Many different programs help computers use NTP. Here are a few common ones:

Windows Time

All versions of Microsoft Windows since Windows 2000 have a service called Windows Time (W32Time). This service can sync your computer's clock to an NTP server. It was first made to help with a security system called Kerberos, which needs clocks to be very close to each other. Newer versions of Windows can be set up to be quite accurate, sometimes within a thousandth of a second.

OpenNTPD

OpenNTPD is a program created by the OpenBSD project. It focuses on being very secure and simple. While it might not be as super-accurate as some other NTP programs, it's great for general use and has strong security features.

NTPsec

NTPsec is a version of the main NTP program that has been made much more secure. It was created in 2015 after some security problems were found in the original program. The developers removed old, unsafe features and support for outdated systems, making the code smaller and easier to check for problems.

Chrony

chrony is another independent NTP program. It's known for being simple, secure, and using fewer computer resources. It can sync time very quickly and accurately, even on computers that are often turned off, go to sleep, or have unstable internet connections. It's also good for virtual machines, which can be tricky to keep time on. Chrony is considered very reliable and can achieve even better accuracy on local networks by using special hardware.

Other Programs

  • systemd-timesyncd: This is a simple SNTP program built into a common system tool called systemd, used by many Linux computers.

Leap Seconds

A leap second is an extra second added to the year to keep our clocks in sync with the Earth's rotation. When a leap second happens, NTP programs get a warning. Even though the clock might pause for a moment during this event, NTP makes sure that any programs asking for the time still see it moving forward, even if by a tiny amount. This helps keep everything in the correct order.

Some companies, like Google and Amazon, use a different method called "leap smearing." Instead of adding one whole second at once, they spread out the extra second over 24 hours. This means the time is slowly adjusted, so there's no sudden jump.

Security for NTP

Because NTP changes your computer's system time, it needs special permissions to run. Over the years, some security issues have been found in NTP programs. For example, in 2014, a problem was found that could allow attackers to take control of a computer. Companies like Apple even used their automatic updates to fix this quickly.

NTP servers can also be tricked by attackers. If a bad guy sends fake NTP messages, they could make your computer's clock wrong. This could cause problems for many internet services that rely on accurate time, like secure websites or online payments.

NTP has also been used in "distributed denial of service" (DDoS) attacks. This is where attackers flood a target with so much internet traffic that it crashes. They do this by sending small requests to NTP servers, making it look like the requests came from the target. The NTP servers then send back much larger responses to the target, overwhelming it. To prevent this, NTP servers can be updated or set up to ignore requests from outside their network.

Safer NTP Options

NTP has ways to check if a server is real. Older methods used shared secret keys, but these weren't always strong enough against certain attacks. A newer system called "autokey" was better but still had some flaws.

A much safer version of NTP is called Network Time Security (NTS). NTS uses advanced encryption to make sure time messages are real and haven't been tampered with. The great thing about NTS is that it handles the complex security checks only once. This means that even if the security server goes down, you can still get accurate time safely. NTS is now supported by many time servers and programs like NTPsec and chrony.

Microsoft also has its own way to authenticate NTP messages within a Windows network, which helps keep time syncing secure in those environments.

Images for kids

See also

Kids robot.svg In Spanish: Network Time Protocol para niños

kids search engine
Network Time Protocol Facts for Kids. Kiddle Encyclopedia.