This invention discloses an
algorithm for improving
time synchronization accuracy in a master-slave
network topology. The
algorithm comprises the following steps: S1, establishing a master-slave
network topology; S2, exchanging messages to obtain four timestamps and calculating the master-
slave clock offset and average link
delay, sending an Optimize_Req message to the
master clock; S3, selecting the optimal master-
slave clock offset from multiple offsets and calculating the asymmetric link
delay ratio for each synchronization; S4, if the current link
delay is approximately symmetrical, the master-
slave clock offset is used to update the slave
clock; S5, if the current link delay is asymmetric, the
clock offset estimate is obtained using the maximum likelihood
estimation algorithm, and an Optimize_Resp message is sent to the slave
clock to update it. This invention improves the PTP
time synchronization protocol by using the above algorithm, adding two message transmissions. The
master clock receives the synchronization results from multiple slave clocks, further performs filtering and optimization, and then sends the updated results to the slave clocks, allowing the slave clocks to adjust themselves.