PTP support on SONiC
- Standardized protocol, IEEE1588
- Synchronize the clocks in local computing systems and devices
- Microsecond to sub-microsecond accuracy and precision
- Administration free
- Capability to autonomously decide time server(master)
- called Best Master Clock Algorithm (BMCA)
Time offset between master and slave clocks is calculated based on timestamps at packet sending and receiving.
path delay = ((t4-t1) - (t3-t2))/2
offset from master clock = (t2 - t1) - path delay
Achieving high precision requires hardware timestamping
- Hardware assisted timestamp at PHY or MAC layer
- Get time from PTP Hardware Clock (PHC) on NIC
- PTP protocol is implemented on user-land
- Kernel feature for PTP
- Socket option SO_TIMESTAMPING for packet timestamping
- Hardware timestamping
- PHC subsystem
- Allow to access PHC via clock_gettime/settime/adjtime system calls
- Socket option SO_TIMESTAMPING for packet timestamping
- ptp4l
- Implementation of PTP (Ordinary Clock, Boundary Clock)
- phc2sys
- Synchronize two clocks (typically PHC and system clock)
ptp4l adjust PHC, phc2sys adjusts system clock.
ptp4l has PI (proportional-integral) controller servo
- A kind of feedback loop
- Determine frequency set to PHC
Requirements:
- Trap PTP packet/events
- NETDEV device support SO_TIMESTAMP option
- Develop PHC driver