Tuesday 24 March 2009

What time is it?

And the answer to the question is NOT Chico time.  The correct answer is 'it depends'.  One of the core network services, but one that often gets overlooked is having an accurate time across all IT systems.  Back in the time before the railways,  the time of an area was generally set by sunrise and sunset.  This was fine when people only travelled a few miles each day.  But when you could journey several hundred miles across the country in a day, you could end up with massive problems, especially when you wanted to catch a connecting train.  If your intermediary station was on a different time to your watch and the timetable set at your departing station, you could be in all sorts of trouble.  Hence the adoption of GMT and 'Railway Time',  a commonly agreed standard time across the country and around the world, regardless of your location. 

And so to the modern age of time synchronisation across a computer network.   Why is this so important you might ask?  Well, having the correct time is less important than making sure every computer clock is set the same.   However, it does make it easier if everything is set to the correct time as well.  From allowing people to login at certain times of the day, to analysing logs from different devices as you pass through the network, if everything is on the same time,  correlating activity can be an easier task if everything is synchronised.  Back before the days of flexible working where you were expected to clock on at 9am and clock off at 5.30pm, you needed to know that you were on the same time as the boss, otherwise there'd be hell to pay!

The company I work for operates two time servers.  These servers run network time services which check both with time servers out on the Internet and each other to decide on the correct time.  The reason for this multiple checking is that as time data is sent across the Internet, the inherent time delay and number of hops can skew the time out leading to inaccurate information.  However,  the accuracy shown is generally accurate to about 10ms,  plenty enough for what we require.  Users of more accurate time servers such as finance services and broadcasting have access to far more accurate time sync services and generally synchronise with what is known as stratum 0 devices. 

Time servers are referred to being in stratum groups - Stratum 0 are the 'core' clocks, be they atomic, gps or radio clocks and display the most accurate time available.  These are generally not available to the network, but are connected to Stratum 1 servers.   These level '1' devices receive the time feed from the 0 level, and then feed that down to Stratum 2 computers.  Our time devices are Stratum 2 devices synchronising with several stratum 1 servers.   These servers also check the time with each other to verify that neither are wildly off.  The companies servers, routers and other 'core' devices query these level 2 servers and become Stratum 3 devices.  Finally, your computers which synchronise with these servers become Stratum 4 devices.   It is possible to have upto 256 stratum levels, but generally 5-6 is seen.   However, stratum level DOES NOT INDICATE ACCURACY.  Because of the multiple check paths available to lower stratum devices, these can be more accurate than individual level 0 or 1 devices, because of this compare and contrast work that they do.  It simply notes how far 'away' from the central clock it is.

We could reduce the layers of stratum services within the company - the easiest way to do this is to invest in GPS time clocks.  GPS navigation requires each satellite to know precisely what time it is, in order that the receiver can compare the signals and work out how far away each satellite is, and therefore where it is in the world.  This can be harnessed using high quality GPS receivers to calculate the time, and passed to local stratum 1 servers, for example in the core data centres.  But is it worth it?  Probably not.

Another key requirement of the network time service is to ensure the clocks are regularly synchronised.  Computer 'Real-time-clocks' can be wildly inaccurate, often losing or gaining several seconds per day, especially when machines get switched off and on.  Our Stratum 2 servers synchronise every hour with the Internet and themselves, but generally lower stratums update every 4, 8 or 24hrs, or when machines are first switched on.   If you find that your clock is inaccurate, and you do not have the ability to update it,  try rebooting your computer and it should come back into line.

Network time is stored as UTC (Coordinated Universal Time) which to the casual user generally means GMT. This means that no matter what time zone you are in, or if its daylight savings,  your computer will be able to work out the correct time for your location, even if you're based in Australia, the Falklands Islands or Central London (provided the time zone database on your computer is accurate).

So when you put your clocks forward this weekend (1am Sunday becomes 2am Sunday), at least you know that the clock at work SHOULD be correct.

No comments: