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?

Fida Hasan
  • 21
  • 1
  • 3
  • 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 04 '17 at 01: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). –  Sep 04 '17 at 10:14
  • 1
    NTP/SNTP are doing this - it's not a trivial task. – Zac67 Sep 04 '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. –  Sep 04 '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 04 '17 at 14:53
  • Hi @Elias , Do you really think that system needs to perform triangulation operation to develop gps time on it? This should be the sole task of a GPS receiver! Any other system just try to fetch it as accurately as possible. As far as I know, Linux uses RTC only boot up time to get and to store time. Rest of the cases, it uses system clock. So, for a continuous running Linux system, what is the point for a extremely accurate RTC to play any role? –  Sep 05 '17 at 01:14
  • NTP calculates an offset for each server it talks to which is the difference between the local clock and the remote clock corrections for packet transfer times- yet you seem to state it is not capable of doing it. In what way is the offest of NTP not the value you are after? – Ross Sep 05 '17 at 08:14
  • That's a good question. NTP does use RTT to calculate both delays and offsets. It does perform some additional computations to select the servers to be followed and also for some adjustments is my understanding. Suppose, you have two systems are synch separately with a common server. In both cases, you can see that the systems are sync with an accuracy (offsets) with the server is very close. Now if you use pair2pair connection between them and call NTP to compute the differences between the system you would not get the reflection of the individual adjustments! –  Sep 05 '17 at 08:38
  • Means, NTP is not helping to measure the absolute time differences between two systems! In my experiment, I sync one system with gps where ntp gives a value of 1 micro accuracy between the gps and system. But when I compare the time of two such developed systems, the offsets are large and not around even 2 micros! So, this seems not straight forward. –  Sep 05 '17 at 08:42
  • This question is off topic here, as it is about a protocol above OSI layer 4 (NTP). It may be on topic on [sf] or [su]. – Teun Vink Sep 05 '17 at 08:57

2 Answers2

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

Ross
  • 133
  • 1
  • 11
  • 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 07 '17 at 02: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 07 '17 at 02: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 07 '17 at 04: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 07 '17 at 04: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 07 '17 at 07:04
  • Sorry. I missed the chat room! Yes, if you use a single server as the reference then there is no point to talk about the accuracy of physical time. Whatever the server keeps is the time for the rest of the clients. However, if you want to measure the performance with real physical time values then this is an issue. – Fida Hasan Sep 08 '17 at 05:47
  • My belief is you don't have access to real physical time - all you have is a server set to a GPS clock with some error - another server to to a GPS clock with some error and you want to measure the error between these two - I chose to use a third server to make the measurement errors symmetrical ie both have the same measurement method – Ross Sep 08 '17 at 05:56
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.

  • 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. –  Sep 05 '17 at 04:51