[ntp:questions] NTP Hardware Support

Charles Swiger cswiger at mac.com
Mon Jun 22 15:28:56 UTC 2015

On Jun 22, 2015, at 3:54 AM, David Garijo <dgmangas at live.com> wrote:
> Hello,
> I've been thinking of the possibility of adding hardware 
> support for NTP so that it can timestamp the packets sent and received more accurately.

OK.  NTP talks to local hardware which provides timestamps via clock drivers.
Unless you're a vendor releasing a new line of hardware, you'd probably want
to use the existing SHM clock driver:


> An example of this would be to overwrite the timestamp of the packets (by hardware) right
> before sending/receiving them with the actual time of departure/arrival if a "hardware support" option is enabled (like some kind of timestamp unit).

A common example would be IEEE 1588 Precision Time Protocol timestamp format
which is somewhat commonly implemented in ethernet hardware.

> It sounds as if I would need to modify the project heavily, so I suppose the best 
> and most realistic approach would be to add a new option to the (Linux) 
> kernel instead of rewriting the ntp programs offered.

Hardware timestamp support already exists in the Linux kernel.  Consider:


> The code for the NTP daemon (ntpd) is quite complex, so I'm not quite sure 
> how nor when the packets are sent/received/timestamped. On the other 
> hand, as far as I've noticed, sntp uses libevent and recvfrom/sendto to handle the packets, so I tend to think that maybe I should start by taking a look at sys/socket.h instead of worrying about anything ntp related. Any suggestions? Do you know of an ideal file/function that I should edit?

Well, first you need to figure out whether you're changing kernel drivers to
support a new hardware timestamp source, or whether you want to talk to ntpd
via SHM or your own clock driver.


More information about the questions mailing list