Archive for the ‘Uncategorized’ Category

Understanding Computer Timestamps with NTP

Monday, September 8th, 2008

The way a computer deals with time is totally different to the ways humans perceive it. We arrange time into seconds, minutes, hours, days, weeks, months and years, while computers on the other hand arrange time as a single number representing the seconds that have passed from a single point in time, known as the prime epoch.

Most computers use NTP (Network Time Protocol) to deal with time and on networks many are synchronised using a dedicated NTP time server.  NTP knows nothing about days, years or centuries, only the seconds from the prime epoch.  This prime epoch is set (for most systems) at midnight at the turn of the century twentieth century that for a human would be recorded as something like: 00:00 – 01,01,1900.

Computers, however, count time as the number of seconds past this point. If a computer was around in 1900 its timestamp on midnight January 1 would be 0 while in 1972 at the same date the timestamp would be 2,272,060,800, which represents the number of seconds since 1900.

The timestamps restart every 136 years with the next wrap around due in 2036, this has caused uneasiness amongst some who fear a Millennium Bug type scenario, although most doubt such events would occur, however, when a wrap-around of the timestamp does happen an era integer will be added (+1), to allow computers to deal with time spans that cover more than one wrap-around.  If computers and NTP need to deal with time that spans before the prime epoch a negative integer is used (for the year 1500 a -3 will be used to represent three cycles of 136 years).

Timestamps are used in virtually every transaction that modern computers are tasked to do such as sending emails, debugging and programming. Because time is linear, a computer knows that each timestamp is always greater than the previous one and therefore computers and NTP find it difficult to deal with inaccuracies in time, particularly when time suddenly appears to go backwards.

This can happen if computers are not synchronised to the same time. If an email is sent to a machine with a slower clock, it appears to the computer to have been received before it has been sent.  Lack of synchronisation can serious problems and can even leave a system vulnerable to malicious attacks and even fraud.

Because of this, most computer networks are synchronised to UTC (Coordinated Universal Time). UTC is a global timescale and the same for everybody worldwide it is based on the time told by atomic clocks which are highly accurate, neither gaining nor losing a second in millions of years.

Most computer networks use a dedicated NTP time server to receive a UTC time to synchronise their computers too.  UTC is available from across the Internet (although unsecured), via the GPS network (Global Positioning System), or by receiving national time and frequency broadcasts via long wave.

NTP synchronises a computer by checking the received UTC time and adding to or holding a computer’s timestamp until it perfectly matches UTC. By using a dedicated NTP time server UTC can be maintained on a network to a few milliseconds of UTC time.

GPS Time Server and NTP (Network Time Protocol)?

Monday, September 8th, 2008

We are all used to Satellite Navigation by now. More and more people are installing those little black boxes into their cars and throwing away their old paper road maps. The advantages of satellite navigation are many fold – from constant updates keeping the maps current to being able to pin point your location miles from any landmarks or road signs but GPS has more uses than merely triangulating a position for direction finding, it can be utilized to provide time and frequency information worldwide.

Since the early 1990’s the Global Positioning system (GPS) has been the worlds’ only fully functioning Global Navigational Satellite System (GNSS). Run by the American military, GPS (sometimes referred to as NAVSTAR) has allowed accurate timing and location finding all over the world.

To accurately pinpoint a location, all GNSS systems require an absolute time source, that is a time source as accurate as humanely possible such as that from an atomic clock. Without knowing exactly what the time is a GNSS satellite would not be able to accurately pin point a location (as the Earth, satellites and people are all moving about a location can only be defined by a position and time). Because of the distance of the satellites away from the Earth, even an inaccuracy of a second or two could mean a sat nav’s location could be miles out.

For this reason each satellite has a highly accurate atomic clock onboard which can also be used by NTP (Network Time Protocol) servers to synchronise computer networks. GPS is an ideal time and frequency source because it can provide highly accurate time anywhere in the world using relatively cheap components.

A GPS receiver decodes the signal sent from the GPS antenna to a computer readable protocol which can be utilised by most time servers and operating systems including, Windows, LINUX and UNIX.

The GPS receiver also outputs a precise pulse every second that GPS NTP servers and computer time servers may utilise to provide ultra-precise timing. The pulse-per-second timing on most receivers is accurate to within 0.001 of a second of UTC (Coordinated Universal Time or Temps Universel Coordonné).

GPS is ideal in providing NTP time servers or stand-alone computers with a highly accurate external reference for synchronisation. Even with relatively low cost equipment, accuracy of hundred nanoseconds (a nanosecond = a billionth of a second) can be reasonably achieved using GPS as an external reference.

In 2002, the European Space Agency and European Union agreed to build Europe’s own GNSS called Galileo. To compete with the new and more advanced GNSS technologies the GPS programme is currently being upgraded and it is expected that when Galileo begins relaying signals both systems will become interoperable allowing even more accuracy in timing and positioning.

Choosing a dedicated GPS Time Server

Monday, September 8th, 2008

Because of the advancement in satellite navigation technologies and the increased coverage of the American GPS satellite network, many more administrators are choosing GPS as a source for a timing reference to synchronize their time servers too.

Traditionally many more people opted to receive a timing source from either across the Internet or via specialist national time and frequency transmissions.  However, the Global Positioning System is now by far the most popular method to receive a UTC time source from.

UTC (Coordinated Universal Time) is the global timescale based on the time told by atomic clocks which are the most accurate of time keeping devices.

A GPS time server is a relatively simple piece of hardware. Normally it consists of a dedicated NTP server with software, a GPS receiver and a GPS antenna. The antenna is the only drawback in using a dedicated GPS time server as it has to be positioned on the roof to have a clear view of the sky, although some dedicated GPS time servers can still keep time synchronized if they only receive a signal for a few hours a day, although this is not the most accurate way of time synchronization.

Once connected, the GPS time server will receive the time signal from the GPS satellites and then distribute it to all devices that require synchronization.

Most time servers, whether they receive a GPS signal or not, will use Network Time Protocol (NTP) to distribute the time signal to all devices.

NTP is one of the Internet’s oldest protocols and is by far the most widespread time synchronization protocols used. NTP is under constant development and can accurately synchronise a network to within a few milliseconds of UTC time via a dedicated GPS time server.

Configuring a NTP Time Server using Windows XP

Monday, September 8th, 2008

Microsoft Windows XP has a time synchronisation utility built into the operating system called Windows Time (w32time.exe) which can be configured to operate as a network time server. It can be configured to both synchronise a network using the internal clock or an external time source.

NTP (Network Time Protocol) is a protocol already installed on Windows XP and Windows Time uses it to keep machines synchronised to the single time source. There are several timing sources available on the Internet but Microsoft and others strongly recommend that you configure a time server with a hardware source rather than from the Internet where there is no authentication.

Specialist NTP time servers are available that can receive a reliable time source via the GPS signal or specialist radio transmissions that get their time from atomic clocks.

If you wish to configure Windows XP to operate as a time server then first thing is to locate the Windows Time subkey. To do this:
Run Regedit (Click start/run/then type REGEDIT/and click enter.

Note: editing your system registry can cause problems with your system. It is advisable to back up your system before editing the registry.

Now locate the following subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\parameters\
Right click the right-hand side and click Modify. In the Edit Value box, under Value Data, type NTP and then click OK.
Now go to the Config folder and right-click AnnounceFlags, Modify and in the Edit DWORD Value box, under Value Data, type 5, and then click OK.

Locate this subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient\

Right-click in the right-side window and Modify. Edit the DWORD value box and type the number of seconds you want for each poll under Value data, i.e.: 900 will equal 15 minutes. The poll field represents the polling interval between NTP poll packets.

To enable the NTP server locate the subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer\
Right click enabled (in the right-hand window) then Modify. Edit the DWORD Value and type 1. Right-click NtpServer, then Modify and in the Edit DWORD Value under Value Data type Peers, then click OK.

Locate:  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\config
In the right pane, right-click MaxPosPhaseCorrection, then Modify, in the Edit DWORD Value box, under Base, click Decimal, under Value Data, type a time in seconds such as 3600 (an hour) then click OK. This adjusts the connection settings.

Now go back and click:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\config

In the right pane, right-click MaxNegPhaseCorrection, then Modify.
In the Edit DWORD box under base, click Decimal, under value data type the time in seconds you want to poll such as 3600 (an hour).

Exit Registry then restart windows time service by clicking Start/Run then typing:
net stop w32time && net start w32time.
on each computer, other than the domain controller, type: W32tm/resync/rediscover.
The time server should be now up and running.

Configuring a Network Time Server on Windows

Monday, September 8th, 2008

All versions of Windows Server since 2000 have included a time synchronization facility, called Windows Time Service (w32time.exe), built into the operating system. This can be configured to operate as a network time server synchronizing all machines to a specific time source.

Windows Time Service uses a version of NTP (Network Time Protocol), normally a simplified version, of the Internet protocol which is designed to synchronise machines on a network, NTP is also the standard for which most computer networks across the global use to synchronise with.

Choosing the correct time source is vitally important. Most networks are synchronized to UTC (Coordinated Universal Time) source. UTC is a global standardized time based on atomic clocks which are the most accurate time sources.

UTC can be obtained over the Internet from such places as time.nist.gov (us Naval Observatory) or time.windows.com (Microsoft) but it must be noted that internet time sources can not be authenticated which can leave a system open to abuse and Microsoft and others advise using an external hardware source as a reference clock such as a specialized network time server.

Network time servers receive their time source from either a specialist radio transmission from national physics laboratories which broadcast UTC time taken from an atomic clock source or by the GPS network which also relays UTC as a consequence of needing it to pin point locations.

NTP can maintain time over the public Internet to within 1/100th of a second (10 milliseconds) and can perform even better over LANs.

To configure Windows Time Service to use an external time source simply follow these instructions.

Locate the registry subkey.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters

Right click type then Modify the Value by inserting NTP in the Value Data box.

Right click ReliableTimeSource, then Modify the Edit DWORD Value box, by inserting 0 (zero).

Right-click NtpServer then Modify the Edit Value by typing the Domain Name System (DNS), (note each DNS must be unique).

Now locate the original subkey and right-click Period Modify the Edit DWORD Value box with the poll interval (how often a NTP server polls the time), under Value Data (recommended 24)

Run the following command line, Net stop w32time && net start w32time.

Now enable NTP by locating the subkey, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer\

Right click Enabled and modify the Value data box by typing 1.

Right Click SpecialPollInterval in the right pain of the subkey HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient\SpecialPollInterval. Edit the DWORD value box the time you want for each poll (900 will poll every 15 minutes)

Locate HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\config

To configure the time correction settings right click MaxPosPhaseCorrection, then modify the DWORD Value box with a time in seconds such (select decimal under base first, 3600 = one hour)

Now do the same for MaxNegPhaseCorrection the restart windows time service by running (or alternatively use the command prompt facility) net stop w32time && net start w32time.

To synchronise each machine simply type W32tm/ -s in the command prompt and the time server should now be working correctly (note it may take several polls before the correct time is displayed).