Precision Time Protocol

29
Precision Time Protocol Steven Kreuzer [email protected] NYCBUG July 2015

Transcript of Precision Time Protocol

Page 1: Precision Time Protocol

Precision Time ProtocolSteven Kreuzer

[email protected]

NYCBUGJuly 2015

Page 2: Precision Time Protocol

Why Clocks Drift• Accuracy is determined by the stability of the

oscillator

• No oscillator perfectly generates a specified frequency

• Stability describes how well the oscillator resists fluctuations such as variation in temperature, vibration, supply voltage

Page 3: Precision Time Protocol

Reducing Clock Drift• Use a better oscillator

• TCXO, MCXO, and OCXO

• Atomic beam standard

• Use a time distribution protocol

• GPS, WWVB, IRIG-B

• Daytime, NTP, PTP

Page 4: Precision Time Protocol

What is PTP• IEEE standard to synchronize time across an

ethernet network for systems requiring very high accuracies

• Fills a niche not well served by NTP and GPS

• GPS receivers are expensive or signals are inaccessible

• NTP can be accurate to about a millisecond under ideal conditions

Page 5: Precision Time Protocol

Second

1.000000000000

Page 6: Precision Time Protocol

Millisecond (ms)

0.001000000000

Page 7: Precision Time Protocol

Microsecond (μs)

0.000001000000

Page 8: Precision Time Protocol

Nanosecond (ns)

0.000000001000

Page 9: Precision Time Protocol

Picosecond (ps)

0.000000000001

Page 10: Precision Time Protocol

Synchronization Basics

• Master clock provides synchronization messages that slaves use to correct their local clock

• Sync message is transmitted to all slaves at a fixed interval of between 1 and 64 messages per second, configurable by the master clock

• Four timestamps are captured between the master and slave

Page 11: Precision Time Protocol

Master Clock Slave ClockTim

e

Page 12: Precision Time Protocol

Master Clock Slave ClockTim

eSyncT1

T2

Page 13: Precision Time Protocol

Master Clock Slave ClockTim

eSync

Sync Followup

T1

T2

Page 14: Precision Time Protocol

Master Clock Slave ClockTim

eSync

Sync Followup

Delay Request

T1

T2

T3

T4

Page 15: Precision Time Protocol

Master Clock Slave ClockTim

eSync

Sync Followup

Delay Request

Delay Response

T1

T2

T3

T4

Page 16: Precision Time Protocol

Master to Slave Offset

ms_diff = T2 - T1

Page 17: Precision Time Protocol

Slave to Master Offset

sm_diff =T4 - T3

Page 18: Precision Time Protocol

One Way Delay

owd =(ms_diff + sm_diff) /

2

Page 19: Precision Time Protocol

Slave Clock Offset

offset = ms_diff - owd

-or-

((T2-T1) - (T4 -T3)) / 2

Page 20: Precision Time Protocol

Implementation Methods

GrandmasterClock

SlaveClock

SlaveClock

SlaveClock

SlaveClock

SlaveClock

GPS

Ethernet Switch

Page 21: Precision Time Protocol

Implementation Methods

GrandmasterClock

SlaveClock

SlaveClock

SlaveClock

SlaveClock

SlaveClock

GPS

Transparent Switch

Page 22: Precision Time Protocol

Implementation Methods

GrandmasterClock

SlaveClock

GPS

Transparent Switch

Boundary Clock

SlaveClock

SlaveClock

Boundary Clock

SlaveClock

SlaveClock

Boundary Clock

SlaveClock

Page 23: Precision Time Protocol

PTPd• Complete Implementation of the IEEE-1588

v2 specification for a standard clock

• Very well tested on FreeBSD and Linux

• Supports Mac OS X, NetBSD, OpenBSD and Solaris as well

• BSD License

Page 24: Precision Time Protocol

PTPd Features• Can run as a grandmaster and successfully

service 1000 slaves running at 1 sync/sec and 1 delay/sec

• Can run as a slave on a client

• Uses PCAP/BPF timestamps for enhanced accuracy on FreeBSD

• Provide performance and quality metrics

Page 25: Precision Time Protocol

PTPd Quality Measurement

• Provides a method to examine synchronization by using an external event that all slaves see

• Record the sequence id and arrival time of SYNC packets

• SYNC is multicast so all slaves should see it at the same time

• Post processing shows how well synchronized two slaves are

Page 26: Precision Time Protocol

PTPd 2.3.1 Features• Improved sync and delay filtering with statistical

filters and an advanced outlier filter

• Extensive support for unicast transmission including unicast negotiation

• Improvements to leap second handling: support for leap second announcement in master state, leap seconds file support, support for leap second smearing

• Simple interface failover support

Page 27: Precision Time Protocol

http://github.com/ptpd

Page 28: Precision Time Protocol

pkg install net/ptpd2

Page 29: Precision Time Protocol

Questions