types

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2025 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExternalReferenceSourceCode

type ExternalReferenceSourceCode string

ExternalReferenceSourceCode represents the external reference source code.

const (
	// Uncalibrated local clock.
	ExternalReferenceSourceLocal ExternalReferenceSourceCode = "LOCL"
	// Calibrated Cesium clock.
	ExternalReferenceSourceCesium ExternalReferenceSourceCode = "CESM"
	// Calibrated Rubidium clock.
	ExternalReferenceSourceRubidium ExternalReferenceSourceCode = "RBDM"
	// Calibrated quartz clock or other pulse-per-second source.
	ExternalReferenceSourcePulsePerSecond ExternalReferenceSourceCode = "PPS"
	// Inter-Range Instrumentation Group.
	ExternalReferenceSourceIRIG ExternalReferenceSourceCode = "IRIG"
	// NIST telephone modem service.
	ExternalReferenceSourceACTS ExternalReferenceSourceCode = "ACTS"
	// USNO telephone modem service.
	ExternalReferenceSourceUSNO ExternalReferenceSourceCode = "USNO"
	// PTB (Germany) telephone modem service.
	ExternalReferenceSourcePTB ExternalReferenceSourceCode = "PTB"
	// Allouis (France) Radio 164 kHz.
	ExternalReferenceSourceTDF ExternalReferenceSourceCode = "TDF"
	// Mainflingen (Germany) Radio 77.5 kHz.
	ExternalReferenceSourceDCF ExternalReferenceSourceCode = "DCF"
	// Rugby (UK) Radio 60 kHz.
	ExternalReferenceSourceMSF ExternalReferenceSourceCode = "MSF"
	// Ft. Collins (US) Radio 2.5, 5, 10, 15, 20 MHz.
	ExternalReferenceSourceWWV ExternalReferenceSourceCode = "WWV"
	// Boulder (US) Radio 60 kHz.
	ExternalReferenceSourceWWVB ExternalReferenceSourceCode = "WWVB"
	// Kauai Hawaii (US) Radio 2.5, 5, 10, 15 MHz.
	ExternalReferenceSourceWWVH ExternalReferenceSourceCode = "WWVH"
	// Ottawa (Canada) Radio 3330, 7335, 14670 kHz.
	ExternalReferenceSourceCHU ExternalReferenceSourceCode = "CHU"
	// LORAN-C radionavigation system.
	ExternalReferenceSourceLORAN ExternalReferenceSourceCode = "LORC"
	// OMEGA radionavigation system.
	ExternalReferenceSourceOMEGA ExternalReferenceSourceCode = "OMEG"
	// Global Positioning Service.
	ExternalReferenceSourceGPS ExternalReferenceSourceCode = "GPS"
)

type KissOfDeathCode

type KissOfDeathCode string

KissOfDeathCode is a kiss code that can be sent by an NTP server to a client to indicate that the client should stop sending requests.

const (
	// The association belongs to an anycast server.
	KissOfDeathCodeAssocitation KissOfDeathCode = "ACST"
	// Server authentication failed.
	KissOfDeathCodeAuthentication KissOfDeathCode = "AUTH"
	// Autokey sequence failed.
	KissOfDeathCodeAutokey KissOfDeathCode = "AUTO"
	// The association belongs to a broadcast server.
	KissOfDeathCodeBroadcast KissOfDeathCode = "BCST"
	// Cryptographic authentication or identification failed.
	KissOfDeathCodeCryptographic KissOfDeathCode = "CRYP"
	// Access denied by remote server.
	KissOfDeathCodeDeny KissOfDeathCode = "DENY"
	// Lost peer in symmetric mode.
	KissOfDeathCodeLostPeer KissOfDeathCode = "DROP"
	// Access denied due to local policy.
	KissOfDeathCodeLocalPolicy KissOfDeathCode = "RSTR"
	// The association has not yet synchronized for the first time.
	KissOfDeathCodeNotSynchronized KissOfDeathCode = "INIT"
	// The association belongs to a manycast server.
	KissOfDeathCodeManycast KissOfDeathCode = "MCST"
	// No key found. Either the key was never installed or is not trusted.
	KissOfDeathCodeNoKeyFound KissOfDeathCode = "NKEY"
	// Rate exceeded. The server has temporarily denied access because the client exceeded the rate threshold.
	KissOfDeathCodeRateExceeded KissOfDeathCode = "RATE"
	// Somebody is tinkering with the association from a remote host running ntpdc.
	KissOfDeathCodeRemote KissOfDeathCode = "RMOT"
	// A step change in system time has occurred, but the association has not yet resynchronized.
	KissOfDeathCodeStepNotSynchronized KissOfDeathCode = "STEP"
)

type LeapIndicator

type LeapIndicator uint8

LeapIndicator signifies whether a leap second will be added or subtracted at midnight.

const (
	// No leap second adjustment is required.
	LeapIndicatorNoAdjustment LeapIndicator = 0
	// Last minute of the day has 61 seconds.
	LeapIndicatorAddSecond LeapIndicator = 1
	// Last minute of the day has 59 seconds.
	LeapIndicatorSubtractSecond LeapIndicator = 2
	// Leap second state is unknown.
	LeapIndicatorAlarmCondition LeapIndicator = 3
)

type Mode

type Mode uint8

Mode defines the operation mode of the SNTP packet.

const (
	// Reserved mode.
	ModeReserved Mode = 0
	// Symmetric active.
	ModeSymmetricActive Mode = 1
	// Symmetric passive.
	ModeSymmetricPassive Mode = 2
	// Client mode.
	ModeClient Mode = 3
	// Server mode.
	ModeServer Mode = 4
	// Broadcast mode.
	ModeBroadcast Mode = 5
	// NTP control message.
	ModeControlMessage Mode = 6
	// Private use.
	ModePrivate Mode = 7
)

type Packet

type Packet struct {
	// Includes Leap Indicator, Version Number, and Mode.
	LiVnMode uint8
	// Indicates the level of the local clock.
	Stratum StratumLevel
	// Maximum interval between successive messages.
	Poll PollInterval
	// Precision of the local clock.
	Precision PrecisionLevel
	// Total round trip delay to the primary reference source.
	RootDelay uint32
	// Maximum error relative to the primary reference source.
	RootDispersion uint32
	// Identifier of the particular server or reference clock.
	ReferenceID uint32
	// Time when the system clock was last set or corrected.
	RefTimestamp uint64
	// Time at the client when the request departed.
	OrigTimestamp uint64
	// Time at the server when the request arrived.
	RecvTimestamp uint64
	// Time at the server when the response left.
	XmitTimestamp uint64
}

Packet represents an SNTP packet.

func (*Packet) GetLeapIndicator

func (p *Packet) GetLeapIndicator() LeapIndicator

GetLeapIndicator gets the leap indicator of the packet.

func (*Packet) GetMode

func (p *Packet) GetMode() Mode

GetMode gets the mode of the packet.

func (*Packet) GetVersion

func (p *Packet) GetVersion() Version

GetVersion gets the version number of the packet.

func (*Packet) SetExternalReferenceSource

func (p *Packet) SetExternalReferenceSource(code ExternalReferenceSourceCode)

SetExternalReferenceSource sets the external clock reference source for stratum 1 servers.

func (*Packet) SetKissOfDeath

func (p *Packet) SetKissOfDeath(code KissOfDeathCode)

SetKissOfDeath sets the kiss of death code for the packet.

func (*Packet) SetLeapIndicator

func (p *Packet) SetLeapIndicator(leap LeapIndicator)

SetLeapIndicator sets the leap indicator of the packet.

func (*Packet) SetMode

func (p *Packet) SetMode(mode Mode)

SetMode sets the mode of the packet.

func (*Packet) SetVersion

func (p *Packet) SetVersion(version Version)

SetVersion sets the version number of the packet.

type PollInterval

type PollInterval int8

PollInterval represents encoded poll intervals in logarithmic scale.

const (
	// Minimum poll interval (16 seconds).
	PollIntervalMinimum PollInterval = 4
	// Default poll interval (64 seconds).
	PollIntervalDefault PollInterval = 6
	// Maximum poll interval (1024 seconds).
	PollIntervalMaximum PollInterval = 10
)

type PrecisionLevel

type PrecisionLevel int8

PrecisionLevel represents common precision levels of the local clock in logarithmic scale.

const (
	// Clock precision is 1 second.
	PrecisionOneSecond PrecisionLevel = 0
	// Clock precision is 1 millisecond.
	PrecisionOneMillisecond PrecisionLevel = -10
	// Clock precision is 1 microsecond.
	PrecisionOneMicrosecond PrecisionLevel = -20
	// Clock precision is 1 nanosecond.
	PrecisionOneNanosecond PrecisionLevel = -30
)

type StratumLevel

type StratumLevel uint8

StratumLevel defines the stratum level of the SNTP server.

const (
	// Unspecified or invalid stratum level.
	StratumUnspecified StratumLevel = 0
	// Primary reference (e.g., GPS).
	StratumPrimary StratumLevel = 1
	// Secondary reference (via NTP, using another server).
	StratumSecondary StratumLevel = 2
	// Tertiary and beyond.
	StratumTertiary StratumLevel = 3
	// Reserved for future use or custom definitions.
	StratumReserved StratumLevel = 255
)

type Version

type Version uint8

Version represents the version number of the SNTP packet.

const (
	// Version 1.
	Version1 Version = 1
	// Version 2.
	Version2 Version = 2
	// Version 3.
	Version3 Version = 3
	// Version 4 (current).
	Version4 Version = 4
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL