NtpServerOptions Class

Configuration options for NtpServer.

public sealed class NtpServerOptions

Constructors

NameDescription
NtpServerOptions()

NtpServerOptions()

NtpServerOptions.cs
public NtpServerOptions()

No documentation is available.

Properties

NameDescription
AuthenticationKeysGets the symmetric keys the server accepts to authenticate requests (RFC 5905, RFC 8573). Default is empty.
BindAddressGets or sets the address to bind to. Default is IPAddress.Any, which serves every network interface. Use IPAddress.Loopback to serve only the local machine.
MaxRequestsPerSecondGets or sets the maximum number of requests answered per second per source address. Default is 100. Set to 0 to disable rate limiting.
PortGets or sets the port to listen on. Default is 0 (auto-assign).
ReferenceIdentifierGets or sets the reference identifier, up to four ASCII characters. Default is LOCL, the conventional identifier for an undisciplined local clock.
RequireAuthenticationGets or sets a value indicating whether the server ignores the requests that are not authenticated with one of NtpServerOptions.AuthenticationKeys. Default is false.
RootDispersionGets or sets the maximum error the server advertises for its own clock (the root dispersion). Default is 100 milliseconds.
StratumGets or sets the stratum level to advertise. Default is 2.
TimeProviderGets or sets the time provider used to answer queries. Default is TimeProvider.System.

AuthenticationKeys

NtpServerOptions.cs

Gets the symmetric keys the server accepts to authenticate requests (RFC 5905, RFC 8573). Default is empty.

public ICollection<NtpAuthenticationKey> AuthenticationKeys { get; }

Property value

ICollection<NtpAuthenticationKey>

Remarks

A request that ends with a valid message authentication code (MAC) computed with one of these keys gets a reply authenticated with the same key. A request whose MAC uses an unknown key identifier, or is not valid, gets a crypto-NAK: a reply with no time, that tells the client that the server could not authenticate it.

The key identifiers must be unique. A request without a MAC gets an unauthenticated reply, unless NtpServerOptions.RequireAuthentication is true. The server reads the keys when it is created: later changes to this collection do not apply to it.

Gets or sets the address to bind to. Default is IPAddress.Any, which serves every network interface. Use IPAddress.Loopback to serve only the local machine.

public IPAddress BindAddress { get; set; }

Property value

IPAddress

MaxRequestsPerSecond

NtpServerOptions.cs

Gets or sets the maximum number of requests answered per second per source address. Default is 100. Set to 0 to disable rate limiting.

public int MaxRequestsPerSecond { get; set; }

Property value

int

Remarks

The limit is approximate: source addresses are mapped onto a fixed number of buckets so that memory cannot grow with the number of distinct (and easily spoofed) source addresses seen, and colliding addresses share a budget.

Rate limiting is measured against the real system clock rather than NtpServerOptions.TimeProvider, so that a simulated or frozen clock cannot disable it or wedge it permanently.

Gets or sets the port to listen on. Default is 0 (auto-assign).

public int Port { get; set; }

Property value

int

ReferenceIdentifier

NtpServerOptions.cs

Gets or sets the reference identifier, up to four ASCII characters. Default is LOCL, the conventional identifier for an undisciplined local clock.

public string ReferenceIdentifier { get; set; }

Property value

string

RequireAuthentication

NtpServerOptions.cs

Gets or sets a value indicating whether the server ignores the requests that are not authenticated with one of NtpServerOptions.AuthenticationKeys. Default is false.

public bool RequireAuthentication { get; set; }

Property value

bool

RootDispersion

NtpServerOptions.cs

Gets or sets the maximum error the server advertises for its own clock (the root dispersion). Default is 100 milliseconds.

public TimeSpan RootDispersion { get; set; }

Property value

TimeSpan

Remarks

Clients use this as the error bound on the offset they compute. Zero claims a perfectly accurate clock, which is never true, so the default is a deliberately conservative bound for an undisciplined software clock. Lower it if the underlying NtpServerOptions.TimeProvider is disciplined and you know its accuracy.

Gets or sets the stratum level to advertise. Default is 2.

public byte Stratum { get; set; }

Property value

byte

Remarks

Stratum 1 claims a directly attached reference clock such as GPS. A server answering from NtpServerOptions.TimeProvider has no such clock, so the honest value is 2 or higher; set NtpServerOptions.ReferenceIdentifier to match if you do attach one.

Gets or sets the time provider used to answer queries. Default is TimeProvider.System.

public TimeProvider TimeProvider { get; set; }

Property value

TimeProvider