nxp-archive / openil_linuxptp

PTP IEEE 1588 stack for Linux
GNU General Public License v2.0
136 stars 60 forks source link

How to determine the value of PHC_PPS_OFFSET_LIMIT in the phc2sys #50

Open lhz168 opened 8 months ago

lhz168 commented 8 months ago

Hi, Here is the code: `

        /* Check if it is close to the start of the second. */
        if (phc_ts % NS_PER_SEC > PHC_PPS_OFFSET_LIMIT) {
            pr_warning("PPS is not in sync with PHC"
                   " (0.%09lld)", phc_ts % NS_PER_SEC);
            continue;
        }

        phc_ts = phc_ts / NS_PER_SEC * NS_PER_SEC;
        pps_offset = pps_ts - phc_ts;`

In the code, the PHC_PPS_OFFSET_LIMIT is defined as 10 milliseconds. My setup consists of a GM200 device, a SUNDRAY switch, and an SCE5164-B78 board. After the board synchronizes with the Server PTP, the system time on the board deviates from the current absolute time by more than 20 seconds after approximately 20 minutes. Adjusting it back takes a long time, around 10 minutes, and then the deviation occurs again. This is because most of the values obtained by my device for phc_ts % NS_PER_SEC are greater than 10 milliseconds, which is the value of PHC_PPS_OFFSET_LIMIT. As a result, the device isn't effectively synchronizing and the deviation is significant. Later, I modified the PHC_PPS_OFFSET_LIMIT to 50 milliseconds and 100 milliseconds, which increased the number of cases where phc_ts % NS_PER_SEC < PHC_PPS_OFFSET_LIMIT, and indeed improved the accuracy and adjustment speed of time synchronization.

I would like to ask, how is the value of PHC_PPS_OFFSET_LIMIT determined? Does it need to be adjusted based on specific devices and environments? If I change this value, for example from 10 milliseconds to 100 milliseconds, what impact will it have on the entire PTP synchronization process?