Host clocks should be synchronized using PTP with a NIC that supports hardware timestamping. If the used NIC is not the same as that used for the process communication, the PTP hardware clock of the process bus NIC must be synchronized with phc2sys. For instance, if enp4s0 is used for PTP synchronization and enp5s0 is used for process communication, the PTP HW clock of enp5s0 must be synchronized with the PTP HW clock of enp4s0: phc2sys -c enp5s0 -s enp4s0 -O 0
The time synchronization is handled by the timemaster service. It sets up and starts the ptp4l and phc2sys daemons for handling the PTP traffic, and runs the chrony daemon which handles the actual clock sync. Configuration is done through /etc/linuxptp/timemaster.conf on Ubuntu, and /etc/timemaster.conf on Fedora.
The configuration file is divided into sections, one for each functionality. The PTP functionality is setup using the ptp_domain and ptp4l.conf sections, while chrony is setup with the chrony.conf section. Below is an example that can be used with PRP networks.
# Configuration file for timemaster
[ptp_domain 0]
interfaces enp4s0 enp5s0
[timemaster]
ntp_program chronyd
[chrony.conf]
makestep 0.1 -1
logchange 0.1
lock_all
sched_priority 60
combinelimit 0
[ptp4l.conf]
step_threshold 0.1
network_transport L2
delay_mechanism P2P
[chronyd]
path /usr/sbin/chronyd
[phc2sys]
path /usr/sbin/phc2sys
[ptp4l]
path /usr/sbin/ptp4l
For the ptp_domain section, the domain number for the PTP traffic is indicated in the section name. Multiple domains can be configured if needed. The ptp4l.conf section can be used to configure PTP settings common for all PTP instances. network_transport should be either L2 or UDP, delay_mechanism should be either P2P or E2E. L2 and P2P are the most commonly used settings. If multiple PTP domains with different settings need to be supported. The domain specific settings should be specified under the domain section, prepended with ntp_options. Possible ntp.conf section should be removed from the timemaster configuration to avoid a situation where NTP is used to syncronize the clocks.
Below is an example with two separate PTP configurations, where the PTP master connected to interface enp4s0 should be preferred.
[ptp_domain 0]
interfaces enp4s0
ntp_options trust
[ptp_domain 0]
interfaces enp5s0
Below is an example of the chronyd configuration section.
[chrony.conf]
makestep 0.1 -1
logchange 0.1
lock_all
sched_priority 60
combinelimit 0
If VLAN is used on the network, a VLAN interface needs to be used for the PTP synchronization. To setup a VLAN interface on, for example, interface enp4s0, run sudo ip link add link enp4s0 name enp4s0.vlan1 type vlan id 1 and use the enp4s0.vlan1 interface in the ptp_domain section of the configration.
[ptp_domain 0]
interfaces enp4s0.vlan1
Set priority of linuxptp sudo systemctl edit timemaster
[Service]
CPUSchedulingPriority=40
CPUSchedulingPolicy=rr
Finally enable and run the timemaster service
sudo systemctl enable timemaster
sudo systemctl start timemaster
The SSC600 SW requires one additional service ptp_status.sh (../template/kvm/ptp_status.sh) to run on the host that outputs the ptp4l synchronization status to file. This is required to make sure that the virtual protection relay application is aware of the synchronization quality. The service is distributed with SSC600 SW product. By default the service writes the current PTP status to a file under /var/lib/libvirt/images/ptp/. If this location is unsuitable override the PTP_STATUS_FOLDER variable in the service file. Execute sudo systemctl edit ptp_status, and add the below:
[Section]
Environment=PTP_STATUS_FOLDER=<absolute path to ptp status folder>
Run the below to enable the PTP monitoring
sudo systemctl enable ptp_status.service
sudo systemctl start ptp_status.service