by shigemk2

当面は技術的なことしか書かない

Precision Time Protocol on Linux: Introduction to linuxptp #linuxcon

  • background
  • overview of precison time protocol PTP
  • about ptp on linux

  • Event ordering is very important

  • for incident analysis, performance analysis and so on
  • Event ordering is based on timestamps
  • Timestamps are collected from multiple servers
  • If prescisions and accuracy of clock synchronization are bad, event ordering can reverse against actual time.

NTP is not enough

NTP provides millisecond level synchronization

  • Maybe enough for remote machine,s, but not enough for locally cooperating machines

Precision Time Protocol(PTP)

  • standardized protocol IEEE1588

この時間同期技術の輪郭をつかむ:期待を背負うIEEE 1588-2008 (1/2) - EDN Japan

Term explanation

  • grandmaster clock(ordinary clock) original time source for the ptp network
  • boundary clock typically it's switch
  • slave clock(ordinary clock) synchronize its clock to a master

  • time offset between master and slave clocks is calculated based on timestamps at packet sending and receiving

  • packet timestamp accuracy important for PTP

Timestamp timing

ideally, we want timestamps of the time just sending (or receiving) packet

Type of timestamping

  • software timestamping (Application or OS layer)
  • hardware timestamping (hardware assisted timestamp at PHY or MAC layer)

minimize error

Linux kernel assists PTP

The protocol itself is implemented on user-land

kernel features for PTP Socket option SO_TIMESTAMPING

The Linux PTP Project

The Linux PTP Project

Richard Cochran

Linuxptp Applications

ptp4l(Implementation of PTP)

Ordinary / Boundary colock

phc2sys (Synchronize two clocks (typically PHC and system clock)

How about software timestamping

When you are using Software timestamping ptp4l directly

Typical usage of ptp4l

  • start as a slave node
  • Use eth0

observe synchronization of ptp4l

  • Log is handed over to syslog
  • or, you can print if into stdout by using -m option

Typical usage of phc2sys

# phc2sys -s eth0 -c CLOCK_ReALTIME -w

pmc (PTP Management Client)

  • send ptp management messages oto PTP nodes
  • ptp management messages are specified in IEEE1588
  • Many PTP devices have not supported management messages yet.

Typical usage of pmc

  • send a message to localhost's node
  • Get Values of CURRENT_DATA_SET
# pmc -u -b 0 'GET CURRENT_DATA_SET'

what's happening

  • GM sends a timestamp including huge error
  • GM's next timestamp does not include so much error
  • The offsets between PHC and system clock observed by phc2sys

ptp4l has servo mechanism

ptp4l has PI(proportional-integral) controller servo

tuning sensitivity

/etc/ptp4l.conf in fedora

two diffrent configurations

improve system clock stability

  • Dynamic ticks make system clock stability worse
  • you can disable dynamic tics

Attempt to fix the issue on upstream

Miroslav Lichvar and John Stultz are working to fix the issue

FYI Running linuxptp on qemu-kvm

  • Run two virtual machines for GM and Slave and use recent Fedora, RHEL 6.5 7.0
  • Use virtual NIC emulationg e10000 (supports software timestamping)
  • don't forget to define appropriate firewall rules to allow multi-cast
  • dont' expect high precision and accuracy