NtpClientOptions Class
Configuration options for NtpClient.
public sealed class NtpClientOptionsConstructors
| Name | Description |
|---|---|
| NtpClientOptions() |
NtpClientOptions()
NtpClientOptions.cspublic NtpClientOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| AuthenticationKey | Gets or sets the symmetric key that authenticates the requests and the replies (RFC 5905, RFC 8573), or null to send unauthenticated requests. Default is null. |
| Port | Gets or sets the server port. Default is 123. |
| RetryCount | Gets or sets the number of times a request is sent again to the same address when no valid reply arrives within NtpClientOptions.Timeout. Default is 0. |
| Timeout | Gets or sets the timeout for querying a single resolved address. Default is 5 seconds. Use Timeout.InfiniteTimeSpan for no timeout. |
| ValidateResponse | Gets or sets a value indicating whether responses are validated before being returned. Default is true. |
| Version | Gets or sets the NTP protocol version to use. Default is NtpVersion.V4. |
AuthenticationKey
NtpClientOptions.csGets or sets the symmetric key that authenticates the requests and the replies (RFC 5905, RFC 8573), or null to send unauthenticated requests. Default is null.
public NtpAuthenticationKey? AuthenticationKey { get; set; }Property value
Remarks
When set, the client appends a message authentication code (MAC) to every request, and ignores every reply that does not end with a valid MAC computed with the same key, whatever NtpClientOptions.ValidateResponse is. The server must be configured with the same key identifier, algorithm and key.
RetryCount
NtpClientOptions.csGets or sets the number of times a request is sent again to the same address when no valid reply arrives within NtpClientOptions.Timeout. Default is 0.
public int RetryCount { get; set; }Property value
Exceptions
ArgumentOutOfRangeException- The value is negative.
Remarks
Each attempt sends a new request and waits NtpClientOptions.Timeout for its reply, so an address can take Timeout × (RetryCount + 1). Only a missing reply is retried, not a network error.
Timeout
NtpClientOptions.csGets 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
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.csGets or sets a value indicating whether responses are validated before being returned. Default is true.
public bool ValidateResponse { get; set; }Property value
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. Disabling it does not disable NtpClientOptions.AuthenticationKey.
Version
NtpClientOptions.csGets or sets the NTP protocol version to use. Default is NtpVersion.V4.
public NtpVersion Version { get; set; }