nxp-archive / openil_linuxptp

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

Time synchronous jump protection #32

Open rondaydayup opened 2 years ago

rondaydayup commented 2 years ago

After the time synchronization is stable, if the master clock has an abnormal jump (for example, the time suddenly jumps for 100ms or more), how can the slave side set and recognize this abnormal jump, and synchronize the local time with a maximum amplitude (for example, 1ms) (similar to the maxwrite configuration of Chrony)

vladimiroltean commented 2 years ago

man ptp4l, step_threshold

rondaydayup commented 2 years ago

when the step_threshold is seted 0.001s, if the master time has an abnormal jump 0f 100ms, the slave will sync the time of 0.001s?

vladimiroltean commented 2 years ago

When a time jump is detected in the master clock, by default (when step_threshold is 0), ptp4l will try to compensate through frequency adjustment. Obviously this will take a long time, proportional to the time delta. When step_threshold has a non-zero and positive value, ptp4l will still compensate through frequency adjustment on time deltas smaller than step_threshold. When the time delta exceeds the step_threshold, ptp4l will also create a time jump in its local clock, which will bring it in sync much faster to the master.

orangewsc commented 2 years ago

Excuse me@vladimiroltean,If I do not want to see slave sync it's local clock when master produce a huge jump(since many time sensitive sensor will crash). Is there any way to config a max sync offset to slave? example: last cycle: master time: 100ms slave time( sync with master correctly):100ms next cycle: master time:150ms(produce abnormal jump 50ms)
slave time( can not accept such a huge jump, maximum 1ms):101ms(expected value)

when master jump we consider master is disability, so slave sync time with it's local clock. Is this idea possible? Thanks a lot.

vladimiroltean commented 2 years ago

So you want to trigger a BMCA master re-election when the servo's step_threshold is exceeded, and somehow, a different master clock to be chosen next time, based on some undetermined criterion. Interesting, I don't think it is possible, I see that servo.c doesn't trigger any event. You may want to present your use case to linuxptp-users@lists.sourceforge.net. This isn't the official support forum for the project, just a fork.

orangewsc commented 2 years ago

OK, thanks a lot

rondaydayup commented 2 years ago

Excuse me@vladimiroltean,As orangewsc described the situation, I would say that if the master have a huge jump, can the slave synchronize with a set maximum synchronization amplitude(for compensation)?

vladimiroltean commented 2 years ago

As Miroslav Lichvar explains on linuxptp-users, you are probably looking for the max_frequency option, documented in the ptp4l man page: https://sourceforge.net/p/linuxptp/mailman/linuxptp-users/thread/YimtxAqjKKDy3etN%40localhost/#msg37623436