NTP server

 Posted by  Programming  Add comments  Tagged with:
Jul 132010
 

Few days ago I stumbled upon problem. I had three Windows 7 computers without Internet access and I needed time synchronization between them. It wasn’t really important that time is correct – it was important that time is same. Solution was simple – just make one of computers NTP server and let others synchronize to it (using standard Windows time synchronization). While Windows 7 synchronizes time perfectly over Internet and/or when you are member of domain, it does not include NTP server.

As I tried to install some other software it became clear that I need to stop and DISABLE “Windows Time” service. NTP servers can only work if they can use UDP port 123. As long as “Windows Time” service is running that port is taken by it. For my scenario this service does nothing so disabling it caused no problems.

As I tried few NTP server solutions I got more and more desperate – either they weren’t free (yes, I am cheap bastard) or they would not work as service under Windows 7. After some time I just decided to make my own program. How hard can it be?

While I consider most of RFCs technical descriptions pure beauty, somebody made a mess of this one. All information was there, how to synchronize, which algorithms to use, probably even genealogy of authors – only thing not there was pure and simple ASCII format of UDP packet. Fortunately authors of SNTP (which is mostly compatible with NTP) did much better work with it. That combined with old pal WireShark made this program possible.

As any program that is written in one afternoon, this one has fair share of things not done. First of all, this program was only tested with Windows XP and Windows 7 as clients. While other versions should work, I spent no time in actually testing it.

This server is also not fully NTP compliant. All fields are there and all clients will consider it valid time source but stratum, precision, root delay and root dispersion numbers are just hard-coded instead of calculated. This should present no trouble in local network and if precision in seconds is satisfactory, but it is definitely not time server you would use if every microsecond is important.

Program requires .NET 2.0 and there is no setup. When you extract it to desired folder first order of day is performing installation from administrator prompt (cmd with Run as Administrator is fine). There we just run program with /install as parameter (“tempora.exe /install”) and service will be installed and started (if you remembered to DISABLE “Windows Time” service first). As long as you don’t uninstall it (“tempora.exe /uninstall”) it will start at each startup and it will return current time to all it’s clients.

Download is here.

P.S. Do not forget to DISABLE “Windows Time” service. ;)

  2 Responses to “NTP server”

Comments (2)
  1. What to do on the client side?
    Regards
    Wim

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>