Introduction

edit

NTP (Network Time Protocol) is how computers get the time from a server. Two packages implement it, versions 3 and 4:

PackageUse it to
Meziantou.Framework.NtpClientAsk an NTP server for the time, and compute the offset of the local clock and the round-trip delay. See Querying a server.
Meziantou.Framework.NtpServerAnswer NTP queries with the time of the machine, or of any TimeProvider, for instance in tests. See Running a server.

Both are in the Meziantou.Framework.Ntp namespace and are compatible with trimming.

What you can do with them

  • Check the clock of a machine: compare it with a time server, and alert when the offset is too large.
  • Get a reliable time when the local clock cannot be trusted, by adding the offset to it.
  • Test code that reads the time over NTP: run a server on the loopback interface whose clock is a fake TimeProvider, at any date.
  • Serve the time on an isolated network, from a machine whose clock is accurate.

Neither package sets the clock of the machine: the client measures, and the server answers. Neither authenticates the other side. See Limitations.

Next steps