Documentation ¶
Index ¶
- Constants
- 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 InPacket
- type JSONStats
- type MeasurementConfig
- type MeasurementResult
- type PHC
- type RunResult
- type SPTP
- type Servo
- type Stats
- func (s *Stats) CollectSysStats() error
- 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) SetTickDuration(tickDuration time.Duration)
- type StatsServer
- type SysClock
- type UDPConn
- type UDPConnTS
- type UDPConnWithTS
Constants ¶
const ( FilterNone = "" FilterMedian = "median" FilterMean = "mean" )
Supported path delay filters
Variables ¶
This section is empty.
Functions ¶
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 string, targetPort int, clockID ptp.ClockIdentity, eventConn UDPConnWithTS, cfg *Config, stats StatsServer) (*Client, error)
NewClient initializes sptp client
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 }
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 InPacket ¶
type InPacket struct {
// contains filtered or unexported fields
}
InPacket is input packet data + receive timestamp
func NewInPacket ¶
NewInPacket returns a new instance of InPacket
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 PathDelayDiscardAbove time.Duration `yaml:"path_delay_discard_above"` // discard path delays that are above this threshold }
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 }
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 string 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 }
Servo abstracts away servo
type Stats ¶
Stats is an implementation of
func (*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) SetTickDuration ¶
SetTickDuration atomically sets the gmsTotal
type StatsServer ¶
type StatsServer interface { SetGmsTotal(gmsTotal int) SetGmsAvailable(gmsAvailable int) SetTickDuration(tickDuration time.Duration) IncFiltered() IncRXSync() IncRXAnnounce() IncRXDelayReq() IncTXDelayReq() IncUnsupported() SetGMStats(stat *gmstats.Stat) CollectSysStats() error }
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 interface { ReadFromUDP(b []byte) (int, *net.UDPAddr, error) WriteTo(b []byte, addr net.Addr) (int, error) Close() error }
UDPConn describes what functionality we expect from UDP connection
type UDPConnTS ¶
UDPConnTS is a wrapper around udp connection and a corresponding fd
func NewUDPConnTS ¶
NewUDPConnTS initialises a new struct UDPConnTS
func NewUDPConnTSConfig ¶
NewUDPConnTSConfig initialises a new struct UDPConnTS
func (*UDPConnTS) ReadPacketWithRXTimestamp ¶
ReadPacketWithRXTimestamp reads bytes and a timestamp from underlying fd
type UDPConnWithTS ¶
type UDPConnWithTS interface { UDPConn WriteToWithTS(b []byte, addr net.Addr) (int, time.Time, error) ReadPacketWithRXTimestamp() ([]byte, unix.Sockaddr, time.Time, error) }
UDPConnWithTS describes what functionality we expect from UDP connection that allows us to read TX timestamps