Patent ID: 8817823

Claim:
A method for time synchronization, comprising: transmitting service packets via two lines between a slave device and a master device; selecting, by the slave device, a port of a single-fiber bi-directional line of the two lines as a synchronization port of a 1588 clock protocol, and specifying a work mode of the synchronization port; transmitting 1588 clock synchronization packets via the single-fiber bi-directional line, wherein each of the 1588 clock synchronization packets comprises a synchronization packet and a delay request packet; exchanging the synchronization packet and the delay request packet with the master device through the synchronization port according to the work mode; acquiring a first time and a second time according to a time stamp generated when the synchronization packet is exchanged, wherein the first time is a time of sending the synchronization packet by the master device, and the second time is a time of receiving the synchronization packet by the slave device; acquiring a third time and a fourth time according to a time stamp generated when the delay request packet is exchanged, wherein the third time is a time of sending the delay request packet by the slave device, and the fourth time is a time of receiving the delay request packet by the master device; restoring a system clock according to the 1588 clock synchronization packets; and adjusting the system clock according to the work mode and the first time, the second time, the third time and the fourth time, wherein adjusting the system clock according to the work mode and the first time, the second time, the third time and the fourth time comprises: calculating a time offset by a first formula and a second formula, according to the first time, the second time, the third time, and the fourth time; and adjusting the system clock according to the time offset; wherein the first formula is: t2−t1=Delay+Offset, wherein the second formula is: t4−t3=Delay−Offset, and wherein t1 represents the first time, t2 represents the second time, t3 represents the third time, t4 represents the fourth time, Delay represents path delay, and Offset represents a time offset.