Documentation ¶
Index ¶
- Constants
- func LookupNetIP(addr string) (netip.Addr, error)
- func ReqAnnounce(clockID ptp.ClockIdentity, portID uint16, ts time.Time) *ptp.Announce
- func ReqDelay(clockID ptp.ClockIdentity, portID uint16) *ptp.SyncDelayReq
- type BackoffConfig
- type Client
- type Clock
- type Config
- type FreeRunningClock
- type JSONStats
- type MeasurementConfig
- type MeasurementResult
- type PHC
- type RunResult
- type SPTP
- type Servo
- type Stats
- func (s *Stats) CollectSysStats()
- func (s *Stats) GetCounters() map[string]int64
- func (s *Stats) GetGMStats() gmstats.Stats
- func (s *Stats) IncFiltered()
- func (s *Stats) IncRXAnnounce()
- func (s *Stats) IncRXDelayReq()
- func (s *Stats) IncRXSync()
- func (s *Stats) IncTXDelayReq()
- func (s *Stats) IncUnsupported()
- func (s *Stats) SetGMStats(stat *gmstats.Stat)
- func (s *Stats) SetGmsAvailable(gmsAvailable int)
- func (s *Stats) SetGmsTotal(gmsTotal int)
- func (s *Stats) SetServoState(state int)
- func (s *Stats) SetTickDuration(tickDuration time.Duration)
- type StatsServer
- type SysClock
- type UDPConn
- type UDPConnNoTS
- type UDPConnTS
- type UDPConnWithTS
Constants ¶
const ( FilterNone = "" FilterMedian = "median" FilterMean = "mean" )
Supported path delay filters
Variables ¶
This section is empty.
Functions ¶
func LookupNetIP ¶
LookupNetIP returns netip.Addr from addr string, which can be either IP or hostname
func ReqAnnounce ¶
ReqAnnounce is a helper to build ptp.Announce It's used for external pingers such as ptping and not required for sptp itself
func ReqDelay ¶
func ReqDelay(clockID ptp.ClockIdentity, portID uint16) *ptp.SyncDelayReq
ReqDelay is a helper to build ptp.SyncDelayReq
Types ¶
type BackoffConfig ¶
BackoffConfig describes configuration for backoff in case of unavailable GM
func (*BackoffConfig) Validate ¶
func (c *BackoffConfig) Validate() error
Validate BackoffConfig is sane
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a part of PTPNG that talks to only one server
func NewClient ¶
func NewClient(target netip.Addr, targetPort int, clockID ptp.ClockIdentity, eventConn UDPConnWithTS, cfg *Config, stats StatsServer) (*Client, error)
NewClient initializes sptp client
func (*Client) SendAnnounce ¶
SendAnnounce sends an announce message via event socket It's used for external pingers such as ptping and not required for sptp itself
func (*Client) SendEventMsg ¶
SendEventMsg sends an event message via event socket
type Clock ¶
type Clock interface { AdjFreqPPB(freq float64) error Step(step time.Duration) error FrequencyPPB() (float64, error) MaxFreqPPB() (float64, error) SetSync() error }
Clock is the iface for clock device controls
type Config ¶
type Config struct { Iface string Timestamping timestamp.Timestamp MonitoringPort int Interval time.Duration ExchangeTimeout time.Duration DSCP int FirstStepThreshold time.Duration Servers map[string]int MaxClockClass ptp.ClockClass MaxClockAccuracy ptp.ClockAccuracy Measurement MeasurementConfig MetricsAggregationWindow time.Duration AttemptsTXTS int TimeoutTXTS time.Duration FreeRunning bool Backoff BackoffConfig SequenceIDMaskBits uint SequenceIDMaskValue uint ParallelTX bool ListenAddress string }
Config specifies SPTP run options
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns Config initialized with default values
func PrepareConfig ¶
func PrepareConfig(cfgPath string, targets []string, iface string, monitoringPort int, interval time.Duration, dscp int) (*Config, error)
PrepareConfig prepares final version of config based on defaults, CLI flags and on-disk config, and validates resulting config
func ReadConfig ¶
ReadConfig reads config from the file
func (*Config) GenerateMaskAndValue ¶
GenerateMaskAndValue returns the mask that must be applied to sequence id and the constant value to use
type FreeRunningClock ¶
type FreeRunningClock struct{}
FreeRunningClock is a dummy clock that does nothing
func (*FreeRunningClock) AdjFreqPPB ¶
func (c *FreeRunningClock) AdjFreqPPB(_ float64) error
AdjFreqPPB adjusts PHC frequency
func (*FreeRunningClock) FrequencyPPB ¶
func (c *FreeRunningClock) FrequencyPPB() (float64, error)
FrequencyPPB returns current PHC frequency
func (*FreeRunningClock) MaxFreqPPB ¶
func (c *FreeRunningClock) MaxFreqPPB() (float64, error)
MaxFreqPPB returns maximum frequency adjustment supported by PHC
func (*FreeRunningClock) SetSync ¶
func (c *FreeRunningClock) SetSync() error
SetSync sets clock status to TIME_OK
type JSONStats ¶
type JSONStats struct {
*Stats
}
JSONStats is what we want to report as stats via http
type MeasurementConfig ¶
type MeasurementConfig struct { PathDelayFilterLength int `yaml:"path_delay_filter_length"` // over how many last path delays we filter PathDelayFilter string `yaml:"path_delay_filter"` // which filter to use, see supported path delay filters const PathDelayDiscardFilterEnabled bool `yaml:"path_delay_discard_filter_enabled"` // controls filter that allows us to discard anomalously small path delays PathDelayDiscardBelow time.Duration `yaml:"path_delay_discard_below"` // discard path delays that are below this threshold PathDelayDiscardFrom time.Duration `yaml:"path_delay_discard_from"` // do not apply discard filter to the values below this threshold PathDelayDiscardMultiplier int `yaml:"path_delay_discard_multiplier"` // discard path delays that are above path delay multiplied by this value }
MeasurementConfig describes configuration for how we measure offset
func (*MeasurementConfig) Validate ¶
func (c *MeasurementConfig) Validate() error
Validate MeasurementConfig is sane
type MeasurementResult ¶
type MeasurementResult struct { Delay time.Duration Offset time.Duration S2CDelay time.Duration C2SDelay time.Duration CorrectionFieldRX time.Duration CorrectionFieldTX time.Duration Timestamp time.Time Announce ptp.Announce T1 time.Time T2 time.Time T3 time.Time T4 time.Time BadDelay bool }
MeasurementResult is a single measured datapoint
type PHC ¶
type PHC struct {
// contains filtered or unexported fields
}
PHC groups methods for interactions with PHC devices
func (*PHC) AdjFreqPPB ¶
AdjFreqPPB adjusts PHC frequency
func (*PHC) FrequencyPPB ¶
FrequencyPPB returns current PHC frequency
func (*PHC) MaxFreqPPB ¶
MaxFreqPPB returns maximum frequency adjustment supported by PHC
type RunResult ¶
type RunResult struct { Server netip.Addr Measurement *MeasurementResult Error error }
RunResult is what we return from single client-server interaction
type SPTP ¶
type SPTP struct {
// contains filtered or unexported fields
}
SPTP is a Simple Unicast PTP client
type Servo ¶
type Servo interface { SyncInterval(float64) Sample(offset int64, localTs uint64) (float64, servo.State) SetMaxFreq(float64) SetLastFreq(float64) MeanFreq() float64 IsSpike(offset int64) bool GetState() servo.State UnsetFirstUpdate() }
Servo abstracts away servo
type Stats ¶
Stats is an implementation of
func (*Stats) CollectSysStats ¶
func (s *Stats) CollectSysStats()
CollectSysStats gathers cpu, mem, gc statistics
func (*Stats) GetCounters ¶
GetCounters returns an map of counters
func (*Stats) GetGMStats ¶
GetGMStats returns an all gm stats
func (*Stats) IncFiltered ¶
func (s *Stats) IncFiltered()
IncFiltered atomically adds 1 to the rxsync
func (*Stats) IncRXAnnounce ¶
func (s *Stats) IncRXAnnounce()
IncRXAnnounce atomically adds 1 to the rxAnnounce
func (*Stats) IncRXDelayReq ¶
func (s *Stats) IncRXDelayReq()
IncRXDelayReq atomically adds 1 to the rxDelayReq
func (*Stats) IncTXDelayReq ¶
func (s *Stats) IncTXDelayReq()
IncTXDelayReq atomically adds 1 to the txDelayReq
func (*Stats) IncUnsupported ¶
func (s *Stats) IncUnsupported()
IncUnsupported atomically adds 1 to the unsupported
func (*Stats) SetGMStats ¶
SetGMStats sets GM stats for particular gm
func (*Stats) SetGmsAvailable ¶
SetGmsAvailable atomically sets the gmsTotal
func (*Stats) SetGmsTotal ¶
SetGmsTotal atomically sets the gmsTotal
func (*Stats) SetServoState ¶
SetServoState atomically sets the servoState
func (*Stats) SetTickDuration ¶
SetTickDuration atomically sets the gmsTotal
type StatsServer ¶
type StatsServer interface { SetGmsTotal(gmsTotal int) SetGmsAvailable(gmsAvailable int) SetTickDuration(tickDuration time.Duration) SetServoState(state int) IncFiltered() IncRXSync() IncRXAnnounce() IncRXDelayReq() IncTXDelayReq() IncUnsupported() SetGMStats(stat *gmstats.Stat) CollectSysStats() }
StatsServer is a stats server interface
type SysClock ¶
type SysClock struct{}
SysClock groups methods for interacting with system clock
func (*SysClock) AdjFreqPPB ¶
AdjFreqPPB adjusts PHC frequency
func (*SysClock) FrequencyPPB ¶
FrequencyPPB returns current PHC frequency
func (*SysClock) MaxFreqPPB ¶
MaxFreqPPB returns maximum frequency adjustment supported by PHC
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDPConn is a wrapper around udp connection and a corresponding fd
func NewUDPConn ¶
NewUDPConn initialises a new struct UDPConn
func (*UDPConn) ReadPacketBuf ¶
ReadPacketBuf reads bytes from underlying fd
type UDPConnNoTS ¶
type UDPConnNoTS interface { WriteTo(b []byte, addr unix.Sockaddr) (int, error) ReadPacketBuf(buf []byte) (int, netip.Addr, error) Close() error }
UDPConnNoTS describes what functionality we expect from UDP connection
type UDPConnTS ¶
type UDPConnTS struct { UDPConn // contains filtered or unexported fields }
UDPConnTS is a wrapper around udp connection and a corresponding fd
func NewUDPConnTS ¶
func NewUDPConnTS(address net.IP, port int, ts timestamp.Timestamp, iface string, dscpValue int) (*UDPConnTS, error)
NewUDPConnTS initialises a new struct UDPConnTS
type UDPConnWithTS ¶
type UDPConnWithTS interface { WriteToWithTS(b []byte, addr unix.Sockaddr) (int, time.Time, error) ReadPacketWithRXTimestampBuf(buf, oob []byte) (int, unix.Sockaddr, time.Time, error) Close() error }
UDPConnWithTS describes what functionality we expect from UDP connection that allows us to read TX timestamps