Documentation ¶
Index ¶
Constants ¶
const ( // MathDefaultHistory is a default number of samples to keep MathDefaultHistory = 100 // MathDefaultM is a default formula to calculate M MathDefaultM = "mean(clockaccuracy, 100) + abs(mean(offset, 100)) + 1.0 * stddev(offset, 100)" // MathDefaultW is a default formula to calculate W MathDefaultW = "mean(m, 100) + 4.0 * stddev(m, 100)" // MathDefaultDrift is a default formula to calculate default drift MathDefaultDrift = "1.5 * mean(freqchangeabs, 99)" )
const ManagedPTPDevicePath = string(fbclock.PTPPath)
ManagedPTPDevicePath is the path we will set up a copy of iface's PHC device, so that fbclock clients can access it without explicit configuration.
const MathHelp = `` /* 1161-byte string literal not displayed */
MathHelp is a help message used by flags in main
Variables ¶
This section is empty.
Functions ¶
func SetupDeviceDir ¶
SetupDeviceDir creates a PHC device path from the interface name
Types ¶
type CSVLogger ¶
type CSVLogger struct {
// contains filtered or unexported fields
}
CSVLogger logs Sample as CSV into given writer
func NewCSVLogger ¶
NewCSVLogger returns new CSVLogger
type Config ¶
type Config struct { PTPClientAddress string // where should fbclock connect to RingSize int // must be at least the size of N samples we use in expressions Math Math // configuration for calculation we'll be doing Interval time.Duration // how often do we poll ptp4l and update data in shm Iface string // network interface to use LinearizabilityTestInterval time.Duration // perform the linearizability test every so often SPTP bool // wherever we run in sptp or ptp4l mode LinearizabilityTestMaxGMOffset time.Duration // max offset between GMs before linearizability test considered failed }
Config represents configuration we expect to read from file
func ReadConfig ¶
ReadConfig reads config and unmarshals it from yaml into Config
func (*Config) EvalAndValidate ¶
EvalAndValidate makes sure config is valid and evaluates expressions for further use.
type Daemon ¶
type Daemon struct { DataFetcher // contains filtered or unexported fields }
Daemon is a component of fbclock that runs continuously, talks to ptp4l, does the math and populates shared memory for client library to read from.
type DataFetcher ¶
type DataFetcher interface { //function to gm data FetchGMs(cfg *Config) (targest []string, err error) //function to fetch stats FetchStats(cfg *Config) (*DataPoint, error) }
DataFetcher is the data fetcher interface
type DataPoint ¶
type DataPoint struct { // IngressTimeNS represents ingress time in NanoSeconds IngressTimeNS int64 // MasterOffsetNS represents master offset in NanoSeconds MasterOffsetNS float64 // PathDelayNS represents path delay in NanoSeconds PathDelayNS float64 // FreqAdjustmentPPB represents freq adjustment in parts per billion FreqAdjustmentPPB float64 // ClockAccuracyNS represents clock accurary in nanoseconds ClockAccuracyNS float64 }
DataPoint is what we store in DataPoint ring buffer
func (*DataPoint) SanityCheck ¶
SanityCheck checks datapoint for correctness
type DummyLogger ¶
type DummyLogger struct {
// contains filtered or unexported fields
}
DummyLogger logs M and W to given writer
func NewDummyLogger ¶
func NewDummyLogger(w io.Writer, sampleRate int) *DummyLogger
NewDummyLogger returns new DummyLogger
func (*DummyLogger) Log ¶
func (l *DummyLogger) Log(s *LogSample) error
Log implements Logger interface
type HTTPFetcher ¶
type HTTPFetcher struct {
DataFetcher
}
HTTPFetcher provides data fetcher implementation using http
func (*HTTPFetcher) FetchGMs ¶
func (hf *HTTPFetcher) FetchGMs(cfg *Config) (targets []string, err error)
FetchGMs fetches GMs via http
func (*HTTPFetcher) FetchStats ¶
func (hf *HTTPFetcher) FetchStats(cfg *Config) (*DataPoint, error)
FetchStats fetches GMs via http
type JSONStats ¶
type JSONStats struct {
Stats
}
JSONStats is what we want to report as stats via http
type LogSample ¶
type LogSample struct { MasterOffsetNS float64 MasterOffsetMeanNS float64 MasterOffsetStddevNS float64 PathDelayNS float64 PathDelayMeanNS float64 PathDelayStddevNS float64 FreqAdjustmentPPB float64 FreqAdjustmentMeanPPB float64 FreqAdjustmentStddevPPB float64 MeasurementNS float64 MeasurementMeanNS float64 MeasurementStddevNS float64 WindowNS float64 ClockAccuracyMean float64 }
LogSample has all the measurements we may want to log
func (*LogSample) CSVRecords ¶
CSVRecords returns all data from this sample as CSV. Must by synced with `header` variable.
type Math ¶
type Math struct { M string // Measurement, our value for clock quality W string // window of uncertainty, without adjustment for potential holdover Drift string // drift in PPB, for holdover multiplier calculations // contains filtered or unexported fields }
Math stores our math expressions for M ans W values in two forms: string and parsed
type SockFetcher ¶
type SockFetcher struct {
DataFetcher
}
SockFetcher provides data fetcher implementation using ptp4l Sock
func (*SockFetcher) FetchGMs ¶
func (sf *SockFetcher) FetchGMs(cfg *Config) (targets []string, err error)
FetchGMs fetches gm data from ptp4l socket
func (*SockFetcher) FetchStats ¶
func (sf *SockFetcher) FetchStats(cfg *Config) (*DataPoint, error)
FetchStats fetches stats from ptp4l socket
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats is an implementation of
func (*Stats) SetCounter ¶
SetCounter will set a counter to the provided value.
func (*Stats) UpdateCounterBy ¶
UpdateCounterBy will increment counter