Currently, I am doing a NTP time synchronization between two ubuntu pcs connected by a LAN cable. After I finish the setup, I find that the delay is around 0.170s (170ms), which is not acceptable since I expect a delay less than 30ms. What could be the reasons causing the delay? And how could I solve it?
I assume you use
ntpq, which gives delay in milliseconds. 0.170 in the delay column of
ntpq -p means a delay of 0.170ms, not 0.170 seconds.
0.170ms is a reasonable delay over a switched ethernet. 170ms does not make a lot of sense.
Explanation of the output is given in the ntpq documentation:
Obtains a current list peers of the server, along with a summary of each peer's state. Summary information includes the address of the remote peer, the reference ID (0.0.0.0 if this is unknown), the stratum of the remote peer, the type of the peer (local, unicast, multicast or broadcast), when the last packet was received, the polling interval, in seconds, the reachability register, in octal, and the current estimated delay, offset and dispersion of the peer, all in milliseconds. The character at the left margin of each line shows the synchronization status of the association and is a valuable diagnostic tool. The encoding and meaning of this character, called the tally code, is given later in this page.