Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am troubleshooting a latency network issue on a network. It is probably a nic or cabling issue, but while I was going through the process of figuring it out, I was looking at the timings of a ping packet leaving a network card and arriving at another server. Both linux.

So I have tcpdump running on both, and I issue a ping from one to the other, and back again, and looking at the timing differences might have shed light on where the latency is coming from.

It is an academic exercise now, as I need to eliminate some more fundamental causes, but I was curious as to how this could be achieved. Given that ntpd is installed and running on two servers, how can I confirm the current time discrepency between the two servers, to whatever level of accuracy is possible - given that we are talking about latency on a local lan, which is ideally a millisecond or so.

NTP itself is accurate to a couple of ms under good conditions, and as both servers are in the same environment, they should (presumably) achieve a similar level of accuracy, and so should have a time discrepency between them of a only few ms - but how can I check this?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

If the two servers are NTP peers, use

  ntpq -p

Which will show current offsets

Note that NTP takes into account network latency. If you know each server's offset from a common NTP server, that is about as accurate as you can get using standard tools.


UPDATE

I have two unix servers using NTP. Lets see what sort of time they are keeping:

$ sudo /usr/sbin/ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 hufu.ki.iif.hu  185.219.2.214    2 u   12   64    1   71.755   -0.073   0.001
 web.puflet.info 188.138.107.156  3 u   11   64    1   78.248    0.417   0.001
 84.2.44.19      10.20.75.140     2 u   10   64    1   74.721   -1.076   0.001

$ sudo /usr/sbin/ntpq -p otherbox
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp2.exa-networ 195.66.241.10    2 u  799 1024  377   43.405    7.796 218.471
+mantaray.netine 249.240.53.144   3 u  289 1024  377   34.782    8.484 212.631
*rilynn.me.uk    81.2.117.228     2 u  765 1024  377   45.665    6.804 142.023
+ntp.thirdlight. 193.67.79.202    2 u  791 1024  377   38.322    9.871 223.397

They are using different servers because they use servers from the ntp pool.

I'll temporarily add otherbox to this server's config so I can directly measure the time offset

$ sudo vi /etc/ntp.conf
 (added `server otherbox`)

$ sudo /sbin/service ntpd restart

$ sudo /usr/sbin/ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 gamma.h3x.no    78.70.33.22      3 u    4   64    1   34.840   -0.964   0.001
 web.puflet.info 188.138.107.156  3 u    3   64    1   78.148   -1.243   0.001
 alpha.rueckgr.a 129.69.1.153     2 u    2   64    1   61.495   -2.362   0.001
 otherbox.exampl 60.155.73.34     3 u    1   64    1    0.604  -11.286   0.001

It looks like timestamps on my two servers are about 11 ms different.

share|improve this answer
    
They aren't, they independently get their time from ntp servers –  Paul Apr 5 '12 at 9:40
    
@Paul: See update –  RedGrittyBrick Apr 5 '12 at 10:20
    
Cool, I like it! –  Paul Apr 5 '12 at 12:54
    
When you added your local NTP server to the /etc/ntp.conf of the client, I am assuming you did it as such server 192.168.1.70 iburst. Furthermore, did you remove all other servers from the client's list? –  puk Nov 13 '13 at 1:30
add comment

ntpdate -q does what you want.

Example:

root@host1:~# ntpdate -q host2 
server host2, stratum 4, offset 109.584520, delay 0.77560
17 Apr 21:48:16 ntpdate[28849]: no server suitable for synchronization found

In this case, the servers have a difference of about 110 seconds.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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