NtpClientOptions Class

Configuration options for NtpClient.

public sealed class NtpClientOptions

Constructors

NameDescription
NtpClientOptions()

NtpClientOptions()

NtpClientOptions.cs
public NtpClientOptions()

No documentation is available.

Properties

NameDescription
PortGets or sets the server port. Default is 123.
TimeoutGets or sets the timeout for querying a single resolved address. Default is 5 seconds. Use Timeout.InfiniteTimeSpan for no timeout.
ValidateResponseGets or sets a value indicating whether responses are validated before being returned. Default is true.
VersionGets or sets the NTP protocol version to use. Default is NtpVersion.V4.

Gets or sets the server port. Default is 123.

public int Port { get; set; }

Property value

int

Gets or sets the timeout for querying a single resolved address. Default is 5 seconds. Use Timeout.InfiniteTimeSpan for no timeout.

public TimeSpan Timeout { get; set; }

Property value

TimeSpan

Remarks

A host name can resolve to several addresses, and each one gets this much time, so a query can take up to Timeout × addressCount overall. Use the cancellationToken of NtpClient.QueryAsync to bound the total duration.

ValidateResponse

NtpClientOptions.cs

Gets or sets a value indicating whether responses are validated before being returned. Default is true.

public bool ValidateResponse { get; set; }

Property value

bool

Remarks

When enabled, a response is only accepted if its originate timestamp echoes the transmit timestamp of the request (RFC 5905 TEST2), its version is 3 or 4, its stratum is not 0 (Kiss-o'-Death), and the server does not report an alarm condition. Responses that fail are ignored and the client keeps waiting for a valid one until NtpClientOptions.Timeout elapses.

The originate timestamp is what ties a reply to this specific request, so disabling this makes the client accept a forged reply from anyone who can guess its source port. Only turn it off to interoperate with a server known to be non-compliant, and do not use the result to make a security decision. This library never authenticates the server cryptographically: it implements neither NTS (RFC 8915) nor symmetric key authentication.

Gets or sets the NTP protocol version to use. Default is NtpVersion.V4.

public NtpVersion Version { get; set; }

Property value

NtpVersion