1

I have a Windows 7 and two Linux (Ubuntu 16.04) computers (W1, L1 & L2) connected via WiFi - a wired connection is unfortunately not possible. The Linux computers run chrony for time synchronization, L1 is set as source on L2, that works perfectly fine. The clocks should be as close together as possible, a 50 ms offset would already start causing problems. But for the Linux systems using chrony that's no problem at all. Now I also have to sync the time on W1 to L1 and unfortunately there is no chrony available for Windows. So I took this script here with the L1 IP as peer: https://gist.github.com/thedom85/dbeb58627adfb3d5c3af One-time synchronization works, but there are some flaws:

  1. The by far most problematic one: The time on the Windows system drifts away from the Linux time pretty quick. The drift is roughly about 1 s per 10 minutes on average. The easy solution - just re-syncing the clocks frequently - doesn't work due to problem 2 and 3
  2. On the Windows system the sync only succeeds if there is a major time offset to the time master. If It's just a few seconds no sync happens.
  3. On the Windows system the sync only gets applied after running the script, then disconnecting from the WiFi and connecting again. The clock jumps at the very moment the connection is established again.

Are there any ways to solve these problems or are there better approaches? Unfortunately I can't just steer all clocks to some high accuracy internet timing servers or GPS time since at least the Windows system is never connected to the internet and the Linux systems also can't rely on their internet connection. At first I thought problem 1 might be caused by chrony steering the L1 clock away, but deactivating chrony after the initial sync doesn't seem to have any effect on this problem.

Here are some pictures showing the problem. W1 constantly sends messages to L2 with the current L1 time, L2 adds his timestamp on arrival and the plot shows the difference between both timestamps as observed by L2. enter image description here

EDIT: L1 and L2 are both battery powered - both by the very same source. Since solely the CMOS battery should be responsible for the RTC I didn't think that this might cause any problems. However it turned out that it is. Powering these computers by AC (so AC -> AC/DC converter -> computer instead of battery -> DC/DC converter -> computer) reduces the drift significantly. But it's still not good enough: enter image description here

EDIT2: Solution / Workaround I disabled the crappy Windows time service (w32time) and installed a port of the Linux NTP program instead. With quite aggressive poll rate settings this works fine: enter image description here

14
  • Thanks for the comment, I added the OS versions. Unfortunately it's Windows 7. I posted it here since I found quite some stuff about time synchronization here on stackoverflow, but you're be right, it would also fit to superuser.
    – user3296542
    Jan 12, 2018 at 16:48
  • You say L2 is using L1 as a ntp source, why not do the same on windows? It's just a regedit to do so, you can set it to sync to any server you'd like? (I don't know if this will fix the sync issues but maybe worth a try. Jan 15, 2018 at 15:50
  • The standard Windows NTP synchronisation code is obviously inadequate, but you should be able to write your own Windows NTP client which gets the time from L1 and immediately calls SetSystemTime() with full subsecond resolution. Since you originally posted on stackoverflow.com, I presume that you'll be able to handle the programming.
    – AFH
    Jan 15, 2018 at 18:52
  • You said that the Windows machine is never connected to the internet but I would assume that it has local network connectivity as you're trying to use another computer as a time server. Are the two machines on the same subnet and can you ping/establish connectivity between the Windows machine and L1? Jan 16, 2018 at 13:26
  • Unless these are VMs, 1 second drift per 10 minutes is really bad! You might want to look into the cause of that as well.
    – mtak
    Jan 16, 2018 at 13:31

0

You must log in to answer this question.

Browse other questions tagged .