Configuring the PTP Service

To configure the PTP service on a system:
  1. Install the linuxptp package.
    sudo dnf install linuxptp
  2. Edit /etc/sysconfig/ptp4l and define the start-up options for the ptp4l daemon.

    Grandmaster clocks and secondary clocks require that you define only one interface.

    For example, to use hardware time stamping with interface eno1 on a secondary clock:

    OPTIONS="-f /etc/ptp4l.conf -i eno1 -s"

    To use software time stamping instead of hardware time stamping, specify the -S option:

    OPTIONS="-f /etc/ptp4l.conf -i eno1 -S -s"

    Note:

    The -s option specifies that the clock operates only as a secondary (clientOnly mode). Don't specify this option for a grandmaster clock or a boundary clock.

    For a grandmaster clock, omit the -s option, for example:

    OPTIONS="-f /etc/ptp4l.conf -i eno1"

    A boundary clock requires that you define at least two interfaces, for example:

    OPTIONS="-f /etc/ptp4l.conf -i eno1 -i eno2"

    You might need to edit the /etc/ptp4l.conf file to customize ptp4l further, for example:

    • For a grandmaster clock, set the value of the priority1 parameter to a value between 0 and 127, where lesser values have greater priority when the BMC algorithm selects the grandmaster clock. For a configuration that has a single grandmaster clock, a value of 127 is suggested.

    • If you set the value of summary_interval to an integer value N instead of 0, ptp4l writes summary clock statistics to /var/log/messages every 2N seconds instead of every second (20 = 1). For example, a value of 10 would correspond to an interval of 210 or 1024 seconds.

    • The logging_level parameter controls the amount of logging information that ptp4l records. The default value of logging_level is 6, which corresponds to LOG_INFO. To turn off logging, set the value of logging_level to 0. Alternatively, specify the -q option to ptp4l.

    See the ptp4l(8) manual page.

  3. Configure the system firewall to accept access by PTP event and general messages to UDP ports 319 and 320 in the appropriate zone.

    For example:

    sudo firewall-cmd --zone=zone --add-port=319/udp --add-port=320/udp
    sudo firewall-cmd --permanent --zone=zone --add-port=319/udp --add-port=320/udp
  4. Start the ptp4l service and configure it to start following a system reboot.
    sudo systemctl start ptp4l
    sudo systemctl enable ptp4l
  5. To configure phc2sys on a clock system that uses hardware time stamping:
    1. Edit the /etc/sysconfig/phc2sys file and define the start-up options for the phc2sys daemon.

      On a boundary clock or secondary clock, synchronize the system clock with the PTP hardware clock that's associated with the secondary network interface, for example:

      OPTIONS="-c CLOCK_REALTIME -s eno1 -w"

      Note:

      The secondary network interface on a boundary clock is the one that it uses to communicate with the grandmaster clock.

      The -w option specifies that phc2sys waits until ptp4l has synchronized the PTP hardware clock before synchronizing the system clock.

      On a grandmaster clock, which derives its system time from a reference time source such as GPS, CDMA, NTP, or a radio time signal, synchronize the network interface's PTP hardware clock from the system clock, for example:

      OPTIONS="-c eno1 -s CLOCK_REALTIME -w"

      See the phc2sys(8) manual page.

    2. Start the phc2sys service and configure it to start following a system reboot.
      sudo systemctl start phc2sys
      sudo systemctl enable phc2sys

You can use the pmc command to query the status of ptp4l operation. The following example shows the results of running pmc on a slave clock system that's directly connected to the grandmaster clock system without any intermediate boundary clocks:

sudo pmc -u -b 0 'GET TIME_STATUS_NP'
sending: GET TIME_STATUS_NP
	080027.fffe.7f327b-0 seq 0 RESPONSE MANAGEMENT TIME_STATUS_NP 
		master_offset              -98434
		ingress_time               1412169090025854874
		cumulativeScaledRateOffset +1.000000000
		scaledLastGmPhaseChange    0
		gmTimeBaseIndicator        0
		lastGmPhaseChange          0x0000'0000000000000000.0000
		gmPresent                  true
		gmIdentity                 080027.fffe.d9e453
sudo pmc -u -b 0 'GET CURRENT_DATA_SET'
sending: GET CURRENT_DATA_SET
	080027.fffe.7f327b-0 seq 0 RESPONSE MANAGEMENT CURRENT_DATA_SET 
		stepsRemoved     1
		offsetFromMaster  42787.0
		meanPathDelay    289207.0

This output examples include the following useful information:

gmIdentity

The unique identifier of the grandmaster clock, which is based on the MAC address of its network interface.

gmPresent

Whether an external grandmaster clock is available. This value is displayed as false on the grandmaster clock itself.

meanPathDelay

An estimate of how many nanoseconds by which synchronization messages are delayed.

offsetFromMaster

The most recent measurement of the time difference in nanoseconds relative to the grandmaster clock.

stepsRemoved

The number of network steps between this system and the grandmaster clock.

For more information, see the phc2sys(8), pmc(8), and ptp4l(8) manual pages, and IEEE 1588.