2

How can the time differences between two Linux machine be measured accurately? I heard that 'Ping' gives RTT with the association of OS influences therefore not accurate in nanosecond level? If so, what else there have to measure the time difference (offsets) between two machines in Linux based system or Raspi?

| improve this question | | | | |
  • 5
    Can you clarify what you mean by "time difference"? Are you referring to the network latency between the two devices or the offset between the system clocks? – rnxrx Sep 4 '17 at 1:52
  • 1
    It is offset between two system clocks. I would like to sync GPS with two systems and then wanted to measure the differences of their clock time (which probably would be a result in nano/micro second). – Fida Hasan Sep 4 '17 at 10:14
  • 1
    NTP/SNTP are doing this - it's not a trivial task. – Zac67 Sep 4 '17 at 11:09
  • 1
    Okay, I understand that it is not piece of cake. But I know only ntp/sntp is not capable of doing it. There are some other ways should be. Calculating RTT is another way of calculating offsets. But it is not as precise as the system clocks might be. However, ntp/sntp can be used to fetch GPS time where this sort of daemon used to do some additional computations to reduce jitters while developing the system clock. In many times that may create offsets is also another point is my understanding. Irrespective of GPS included or not, I just wanted to calculate the time offsets betn 2 systems. – Fida Hasan Sep 4 '17 at 11:16
  • 2
    Most linux devices do not have accurate enough system clock to be able to use ns accuracy for triangulation etc. You would have to have an extremely accurate RTC on the device. – Elias Sep 4 '17 at 14:53
2

This is my attempt to how do you measure the accuracy of a clock with no reference clock.

I chose a server - and said this is my reference - I made some , fairly small, effort to reduce or measure the changes in the "reference clock" - these changes in the end were to make its reference one clock and to record the jitter.

I then measured all other clocks offset from my designated reference I use NTP to do this as it makes an attempt to fix the measurement error of the time for the packet to traversing the network and, I believe, fix the error due to the processing time at both ends.

I probably should do some least squares analysis of all the offets or perhaps even look at how much the reference gets corrected by or the frequency it is running at - instead I just graph it , you might want to improve on that

So I had multiple NTP daemons on linux boxes (and windows , routers) these all synced to either the same or different time sources and I wanted to see what the errors were

To measure the differences I have one additional box with an NTP daemon which is setup to query each of the other boxes but NOT ever select them as a time source. I also set it to logging statistics and thus it logs the offset from itself to each of the servers at intervals

I selected one NTP server as this ones actual NTP server clock source to stabilize its clock frequency

This has produced graphs which at least showed me that Windows is very poor at keeping time , and that the other server did discipline the clocks and became more stable aver time.

This is only accurate to low tens of ms except windows which is 200ms of difference

My NTP config file on the monitor machine looks like

restrict default noquery nopeer nomodify notrap    
restrict -6 default noquery nopeer nomodify notrap    
restrict 127.0.0.1   
restrict -6 ::1  
driftfile "C:\Program Files (x86)\NTP\etc\ntp.drift"  
server time.windows.com
enable stats  
statsdir "C:\Program Files (x86)\NTP\etc\"  
statistics loopstats peerstats
server 1.2.3.4 noselect minpoll 6 maxpoll 6   
server 1.2.3.5 noselect minpoll 6 maxpoll 6   
server 1.2.3.6 noselect minpoll 6 maxpoll 6

i then end up with daily "peerstats" files in C:\Program Files (x86)\NTP\etc\ which have the servers and the offsets from the local machine - which I then insert into SQL and graph

| improve this answer | | | | |
  • You said something about Linux Box, whether they are a virtual box or actual machine? The experiment you have made is quite interesting. I was just wondering to know the results in average! – Fida Hasan Sep 7 '17 at 2:01
  • From work I have results from a few virtual Windows server 2008 R2 machines on VMWare, a few physical Windows server 2008 R2 machines , an ESXi host, some Cisco switches/routers, being collected by a Windows box. I'd be happy to share the graphs but I don't think this question is the correct place - separately (my home network) I have a Raspberry PI, and an Ubuntu machine - they are not so interesting - and I don't actually graph the results – Ross Sep 7 '17 at 2:49
  • This thread has been shifted from 'Network' to this 'Serverfault' site to discuss. So I believe there are no other issues may problem. So, the performances of the server is certainly an issue while getting high accuracy but did you check that the original time sources are precise or not! How did you fetch the time for your server? From the internet or standalone sources like GPS? You said, you have varied the server and connected them into SAME and DIFFERENT time sources. How did you choose the time sources in your experiment? I have a feeling that the performances also relies on it. – Fida Hasan Sep 7 '17 at 4:46
  • This might be better in chat - I created one - pretty much I agree with everything you said - I have around 30 NTP clocks I was comparing the performance of - – Ross Sep 7 '17 at 4:55
  • How do you measure the accracy of a time source? My choice was to say this server is my reference. And measure all others by their offset to it. – Ross Sep 7 '17 at 7:04
0

The latency will vary depending on the link(s) characteristics - higher latency may result from highly utilized links, for example.

I think could have a periodic ping and export/syslog that to a system that can chart current latency for you, as well as past values for you.

| improve this answer | | | | |
  • Yes, I agree! If possible I would use ad-hoc wifi channel to make the comparison to get the offsets. However, my primary target is to find the offsets and I would like to measure it any possible ways that can give a precise result. Any dedicated link can be used to avoid the utilization constraint. – Fida Hasan Sep 5 '17 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.