GuerrillaNtp - Simple NTP client for .NET

GuerrillaNtp is a RFC4330 SNTP/NTP client written in C# that can be embedded in desktop .NET applications to provide them with accurate network time even when the system clock is unsynchronized.


Get GuerrillaNtp from NuGet:

PM> Install-Package GuerrillaNtp -Version 2.0.1

Or clone sources from GitHub or Bitbucket. Sources and binaries are distributed under Apache License 2.0. The only dependency is .NET Standard 2.0, which should work on every platform.


For the most basic use, instantiate NtpClient with some NTP server (e.g. or your private NTP server) and call NtpClient.GetCorrectionOffset() method. You can then use the returned time offset to adjust all time values in your application. Here's a short example:

// query the SNTP server
TimeSpan offset;
    using (var ntp = new NtpClient(Dns.GetHostAddresses("")[0]))
        offset = ntp.GetCorrectionOffset();
catch (Exception ex)
    // timeout or bad SNTP reply
    offset = TimeSpan.Zero;

// use the offset throughout your app
DateTime accurateTime = DateTime.UtcNow + offset;

One instance of NtpClient can be used repeatedly to perform more queries against the same server. You can also call NtpClient.Query() method to gain access to NtpPacket returned by the server. NtpPacket.CorrectionOffset property returns the same value as NtpClient.GetCorrectionOffset(), but NtpPacket has many other useful properties, for example RoundTripTime.


GuerrillaNtp doesn't have built-in polling mechanism. Polling and multi-server policy is handled by the application. It is your responsibility to be a good netizen and use reasonable polling intervals as well as exponential backoff in case of errors, especially when querying public NTP servers.


GuerrillaNtp is based on Netduino NTP client that I have found on NuGet. I've ported it to desktop .NET Framework and later .NET Standard and added numerous patches. Some of the patches are based on SNTP client from Valer Bocan that has numerous mutations circulating around the Internet. Platform.NET contains fairly competent NTP client, which I have discovered after creating GuerrillaNtp.


GuerrillaNtp was developed by Robert Važan with significant contributions from Markus Stöger. If you have any suggestions, report an issue (GitHub, Bitbucket), including requests for documentation, or submit a pull request (GitHub, Bitbucket). You can reach the author via email .