Network Time Protocol (NTP) Tool

I wrote this little Java app to learn more about Network Time Protocol (NTP).  This all started with my friend's father, Skip Newhall. He has his own Internet Time Server.  It's really cool. He has multiple GPS units that figure out what  time it is within an amazing 10 ns accuracy.  That's the amount of time it takes light to cross a room (about 10 feet).  He then has these servers that let anyone know what time it is.  You can synchronize the clock in your computer to his, if you like.  Check out his web site.

Anyway, this got me interested in the Internet protocol that gives out time.  Also, I wanted my embedded processors to just go get the time so I didn't have to keep setting them all the time.  So I wrote a little learning tool that looks like this:

As you can see, it gives you a hex dump of the packet and then tells you what all the bytes mean.

Here is a runnable JAR file and source code if you are interested.

One fun side story, Skip had a leap second party where he put all his time server clocks in his living room and invited us all over to see if the displays would correctly show the extra second.  Here is an article on it.  I took these three pictures one second apart from each other. 

HAPPY NEW YEAR!!! Wait, it's not really New Year's yet.  This picture was taken during the extra leap second that was added to allow the Earth to catch up to the atomic clocks.  You see the Earth is like an ice skater twirling. Sometimes she pulls her arms in and spins faster, sometimes she lets them out and slows down. Except with the Earth, it's watervapor in clouds.  On rainy years, the Earth's rotation slows ever so slightly because of the mass of the ocean water in the atmosphere. After many days of a slow spinning Earth, it starts to disagree with the almost perfect atomic clocks. If the Earth slows down by a full second, we add a leap second to UTC which puts the sun overhead at noon again.

Back to the party. As you can see above, the displays were all over the place.  Only the Spectracom NETCLOCKs correctly displayed the extra second as "60".

Of course, all his servers gave out the correct NTP time throughout the whole leap second.  Only their displays were wrong.

Then, a second later ...

HAPPY NEW YEAR!!!  Wait, it was 4pm, not midnight.  Time servers work in UTC, not PST. We still had to wait another 8 hours before we could truly celebrate the new year.