Patent Description:
With the development of network technology, time synchronization between network devices has been gradually improved, and has reached the level of nanosecond (ns). At present, the network devices mainly use the second version (V2) of the <NUM> protocol released by IEEE in <NUM> for time synchronization. The <NUM> protocol uses a Precision Time Protocol (PTP) packet structure to carry time information. And only a few data packing formats, such as IEEE802. <NUM>, Ethernet, PTP based on the network address version <NUM> (IPv4) and PTP based on the network address version <NUM> (IPv6), are specified. The time information is synchronized through a Media Access Control (MAC) layer or a higher layer.

It is found in practice that when time information is transmitted in this way, and the synchronization is performed based on the time information, there are problems of low synchronization accuracy, long synchronization and convergence process, and a limited scope of use because in some cases, a receiving end cannot extract the time information for synchronization.

Patent <CIT> discloses a system and method for improving a timestamp precision in a precision timestamp protocol (PTP) device. The present invention provides for dynamic adjustment of otherwise uncertainty of the latency of a connection between two devices connected together through a gearbox and/or a block sync circuit. The dynamic adjustment is accomplished by identifying the alignment of data within the gearbox and block sync and adjusting the timestamp assigned to the data based upon the identified alignment to remove the jitter associated with the gearbox and the block sync, thereby improving the timestamp precision in the PTP device. In a particular embodiment, the invention is employed in a serial-deserializer (SERDES) device.

In view of this, embodiments of the invention are intended to provide a time synchronization method, a network device to at least partially solve the above problems.

The technical solution of the invention is further described in detail below in combination with the accompanying drawings and specific embodiments.

It is found that when time information packed based on the <NUM> protocol is transmitted among multiple devices requiring time information synchronization, a receiving end needs to unpack the time information layer by layer after receiving it, which usually needs to use physical resources of an MAC layer or a higher layer above the MAC layer in a device for processing, resulting in the large processing complexity, so the synchronization convergence process takes a long time, and the delay is large. Meanwhile, when the data is transmitted transparently, a transit device does not recognize the meaning expressed by the content of the data, which leads to the failure of synchronization between a transparent transmission device and a sending end, resulting in narrow application scenarios. More importantly, a physical layer port is directly connected to a transmission medium layer, if a time carrier needs the MAC layer or the higher layer above the MAC layer for processing to obtain the time information and pack it into a package, the time itself consumes a lot of time, and the time consumption is ignored during the synchronization of time information, resulting in the decrease of synchronization precision. In view of this, the embodiment of the invention directly uses a port very close to a physical transmission medium to carry directly a locating synchronization block for synchronization. After receiving a signal carrying an ST, the port of the receiving end can obtain the ST directly at a Physical Media Adaption (PMA) sublayer of the physical layer. It is apparent that this distance is shorter than the distance between the MAC layer and the physical medium, thus reducing the problem of poor synchronization effect caused by the time consumption caused by this transmission distance, improving the synchronization effect, and realizing the synchronization at the ns level. Meanwhile, because the MAC layer and the high layers above the MAC layer are not required to participate in data packing and unpacking, resource consumption of a network device is reduced, and the time consumed in packing and unpacking is reduced, so that the synchronization efficiency is higher and a synchronization convergence speed is higher. Furthermore, because the ST is directly inserted into a bit where the port is, even if it is transparently forwarded, a forwarding device has no need to extract information represented by a signal, but directly extracts the ST, thus realizing the synchronization and expanding an application scope.

As shown in <FIG>, an embodiment provides a time synchronization method, which is applied to a first network device, and the method may include the following steps.

At S110, an ST is inserted into a signal to be sent, the ST including a synchronization byte used for positioning and a timing byte used for carrying synchronization information of a second network device for time synchronization.

At S120, the signal to be sent in which the ST is inserted is sent.

In the embodiment, the first network device may be a device initiating the time synchronization, and other network devices synchronize with it.

In the embodiment, the synchronization information synchronizes the timing of two network devices. In addition to keeping clock synchronization of timers, two network devices need to synchronize the time information. The clock synchronization here is that two timers time equally for the same physical period of time. For example, a certain physical period of time is <NUM> second, timer A times <NUM> second, and timer B times <NUM> seconds, which is clock synchronization. After the clock synchronization is completed, the timer A may time the current time as t1, and the timer B may time the current time as t2, at this point, the timing of the current time of the timer A and the timer B needs to be unified. This synchronization is the synchronization of the time information in the application, also referred to as time synchronization.

In the embodiments of the invention, before the time synchronization is performed, the time information for synchronization needs to be transmitted.

In the embodiment, the ST is directly inserted into the signal to be sent. The signal to be sent here is a bit sequence to be sent.

For example, the first network device includes: a physical layer interface module, which may be a serial interface module for sending a serial signal or a parallel interface module for sending a parallel signal.

In the embodiment, the typical serial interface module may include a serializer and a deserializer, and the combination of the serializer and the deserializer referred to as SerDes. The SerDes will insert the ST into the signal to be sent. The ST includes two parts, one part is a synchronization block for locating the ST, and the other part is a timing block. Usually the bit sequence corresponding to the synchronization block is known or predetermined. The timing block is used for carrying time information to be transmitted or indication information related to the time information and used for indicating realization information. In the embodiment, the time information and/or the indication information is collectively called synchronization information.

In S120, the signal to be sent carrying the ST will be sent, so that the ST for time synchronization can be received and recognized through a physical layer interface, regardless of whether the peer (i.e., a second network device) needs to parse the received signal or transmit it transparently. Thus, the transmission of time information is easily completed.

In the embodiments of the invention, both the synchronization byte and locating byte may include: one or more bytes. For example, in some embodiments, both the synchronization byte and the timing byte include only one byte, so that one of the STs consumes <NUM> bits. If the synchronization byte is a high-order byte, then the timing byte is a low-order byte. If the synchronization byte is a low-order byte, then the timing byte is a high-order byte. Taking that the synchronization byte and the timing byte are both one byte as an example, optionally the high-order byte is high <NUM> bits, and the low-order byte is low <NUM> bits. In some other embodiments, both the synchronization byte and the timing byte may include: two or more than two bytes.

Optionally, as shown in <FIG> S110 may include S111. S111 may include that: the ST is inserted into the parallel signal. The ST includes: the synchronization byte used for positioning and the timing byte used for carrying the synchronization information of the second network device for time synchronization.

The method may further include S101, in which the parallel signal in which the ST is inserted is converted to a serial signal.

S120 may include S121. S121 may include: the serial signal is sent.

The physical interface module included in the first network device provided in the embodiment is a serial interface module, which will convert multiple low-speed parallel signals into the serial signals and send. For example, by the Serdes in the first network device, then the parallel signal is extracted from an FIFO queue. The ST is inserted into the parallel signal. The parallel signal in which the ST is inserted is sent to an encoder and/or a scrambler for encoding and/or scrambling processing. The encoded and/or scrambled signal is transmitted to the serializer, and then the serializer converts multiple parallel signals to a serial signal, and the serial signal is submitted to the transmission medium, for example, a transmission cable or an optical cable, by a driver to be transmitted to the peer.

In the embodiment, the ST is directly inserted into the parallel signal, and Parallel-serial conversion is performed after the ST is inserted. In some other embodiments, the ST may also be directly inserted into the serial signal after the Parallel-serial conversion is completed and then sent out.

In the embodiment, the ST is inserted in the parallel signal. Thus the problem of low recognition rate at the receiving end caused by multiple consecutive "<NUM>" or multiple consecutive "<NUM>" caused by the signal to be sent itself and/or by inserting the ST is avoided through the processing of the parallel signal by the encoder and/or the scrambler, and the signal recognition rate may be improved.

S111 may include the following steps: the ST carrying first time information is inserted into the parallel signal; after the ST carrying second time information which is sent by the second network device is received, third time information that the ST carrying the second time information is received is inserted, through the ST, into the parallel signal sent to the second network device. The first time information, the second time information, the third time information and fourth time information that the second network device receives the ST carrying the third time information are jointly used for the second network device to calculate a time offset from the first network device.

The step of the time offset is calculated may include: a first time difference between the first time corresponding to the first time information and the second time corresponding to the second time information is calculated; a second time difference between the third time corresponding to the third time information and the fourth time corresponding to the fourth time information is calculated; <NUM>/<NUM> of the difference between the first time difference and the second time difference is calculated as the time offset; and the second network device may directly adjust its timing information according to the time offset, so as to realize the time synchronization.

Optionally, N STs form an ST group, N being an integer not less than <NUM>. There may be more than one value, for example, the value may be any positive integer not less than <NUM>. In the embodiment, the value of N is determined by the number of bits needed to carry the synchronization information and the number of bits provided by a single timing byte. For example, <NUM> bits are needed to carry the synchronization information, and each of the timing bytes may provide <NUM> bits, then the value of N is not less than <NUM>/<NUM>. Generally, N=Y1/X= <NUM>+Y2/X. The Y1 is the number of bits consumed by a piece of synchronization information, and the Y2 is the number of bits consumed by the time information. The synchronization information may include time information and indication information. The X is the number of bits provided by a single timing byte. For example, the time information needs <NUM> bits, the indication needs <NUM> bits, and one timing byte provides <NUM> bits, then N=(<NUM>+<NUM>)/<NUM>=<NUM>, or N=<NUM>+<NUM>/<NUM>=<NUM>.

In the embodiment, multiple STs form an ST group. The STs are inserted in the order of each ST. For example, if the x-th of the STs is inserted at the previous insertion time, then the (x+<NUM>)-th ST is inserted at the current insertion time.

For example, taking that an ST group includes <NUM> STs as an example, the STs may be numbered from <NUM> to <NUM>, and are represented by S1T1, S2T2, S3T3, S4T4, S5T5, S6T6, S7T7, S8T8, and S9T9 respectively, Sx representing the synchronization byte of the x-th ST, and Tx representing the timing byte of the x-th ST. The values of x may be integers from <NUM> to <NUM>.

The timing byte T1 in the first synchronization timing block S1T1 is used for carrying one of the following information:.

A purpose type indicator, which may be used for indicating the purpose of the time information currently sent. For example, the time information is sending time, receiving time or no time carried.

So, in some embodiments, the time parameter indicator includes at least one of the following:.

In an embodiment, T1 in an ST may not carry the specific time information, but carry a variety of indication information. One or more of T2 to TN are used to carry the time information.

In this way, after receiving the first inserted S1T1, the receiving end may know whether the SxTx in the subsequent received signals carries the time information and for what purpose.

Optionally, the information type indicator includes at least one of the following: a time quality level, synchronization modes, a query request, and an update request.

The synchronization modes include a first mode, a second mode and a third mode. When a port mode is the first mode, it is a device that does not participate in the time synchronization, when the port mode is the second mode, it is a time issuer that provides the time information, and when the port mode is the third mode, it is a time receiver that receives the time information. In some embodiments, the first mode is also an asynchronous mode, and the second mode and the third mode are synchronous modes. The synchronous mode may also be divided into the second mode providing synchronization and the third mode participating in synchronization.

The query request is used for requesting a query for the peer device to provide the synchronization information, requesting a query for the synchronization mode of the peer, and requesting a query for the starting time determined by a synchronization provider and other information.

The update request is used for providing an update of the synchronization information to the peer device, and providing some synchronization related update information about itself to the peer; for example, the update of its own synchronization mode, the update of its own information type and the update of the starting time may all be realized through the update request.

Optionally, in order to achieve a high recognition rate of synchronization between the network devices and avoid the problem of low synchronization efficiency caused by the low recognition rate, the contents of the synchronization bytes are usually different. For example, the contents of the synchronization bytes of multiple adjacent STs in an ST group are different. This difference may be represented by the difference of one or more bits in a bit sequence. Typically, for example, the bit sequences are opposite. In the embodiment, that the bit sequences are opposite means that the corresponding bit of one of the two bit sequences is "<NUM>", and the corresponding bit of the other bit sequence is "<NUM>". For example, the opposite bit sequence of the bit sequence "<NUM>" is "<NUM>".

In order to improve the recognition rate and thus achieve accurate synchronization, two optional structures for the bit sequence of the ST group are provided below.

The first structure is that:
when the ST group includes an odd number of STs, the ST group includes: the first type of ST group and the second type of ST group. The synchronization byte in the first type of ST group has an opposite value to that in the second type of ST group.

When the ST group is inserted, the first type of ST and the second type of ST are inserted at intervals.

The second structure is that:
y STs distributed adjacently in the ST group are an ST subgroup, and the synchronization bytes of two adjacent synchronization block subgroups have opposite values. In this way, when the ST group includes an even number of STs, only one type of ST group is needed. If the ST group includes an even number of STs, sequence reverse may also be achieved among multiple subgroups of each type of ST group, which may improve the recognition rate of the receiving end again.

As shown in <FIG>, an embodiment provides a time synchronization method applied to a second network device, which may include the following steps.

At S210, a signal sent by the first network device is received.

At S220, the ST is extracted from the received signal by matching with a local timing byte, and the synchronization information carried by the timing byte in the ST is obtained.

At S230, time synchronization is performed with the first network device based on the synchronization information.

In the embodiment, the second network device is a network device that participates in synchronization and needs to synchronize its own time with the first network device.

First, the second network device may receive, through a network interface, the signal sent by the first network device and transmitted from the transmission medium. The local synchronization byte is used to match the received signal. If matched, the ST is considered detected, and the synchronization information is extracted from the ST. The synchronization information here may include the time information and/or the indication information.

Optionally, S210 may include that: the serial signal sent by the first network device is received.

The method may further include that: the serial signal is converted to the parallel signal.

S220 may include: the ST is extracted from the parallel signal by matching with the local timing byte, and the synchronization information carried by the timing byte in the ST is obtained.

In the embodiment, the composition of the ST may be seen in a related embodiment of a time information transmission method applied to the first network device.

Furthermore, S220 may further include the following step: by matching with the local timing byte, the first time information is extracted from the timing byte, which is successfully matched with the local timing byte, of the ST.

The method may further include the following steps: the second time information that the ST carrying the first time information is received is recorded; the ST carrying the second time information is inserted into the signal sent to the first network device; the signal sent by the first network device is received. The ST carrying the third time information is inserted into the signal, and the third time information is the time information that the first network device receives the ST carrying the second time information; the fourth time information that the ST carrying the third time information is received is recorded; the time offset from the first network device is calculated based on the first time information, the second time information, the third time information and the fourth time information; the time information of the second network device is calibrated according to the time offset.

In the embodiment, the second network device and the first network device calculate the time offset through two synchronization information interactions, and the time information of the second network device is calibrated based on the calculated time offset, so as to complete the synchronization.

In some other embodiments, the first network device and the second network device may calculate the time offset based on the receiving and sending of the synchronization information only once.

In an exemplary embodiment, the method may further include: a synchronization condition with the first network device is determined according to a receiving condition of the ST, and the synchronization condition includes: a synchronous state in sync with the first network device, and/or an asynchronous state out of sync with the first network device.

Herein, the step of the synchronization condition with the first network device is determined according to the receiving condition of the ST may include: when it is determined that the two STs sent by the first network device are successfully received, it can be determined that the second network device and the first network device are in the synchronous state, otherwise they are in the asynchronous state; and/or, when the second network device successfully obtains the first time information, the second time information, the third time information and the fourth time information mentioned above, it can be determined that the second network device and the first network device are in the synchronous state, otherwise they are in the asynchronous state.

In some other embodiments, after the second network device calculates the time offset by using the above method and completes the calibration of time information, the method may also include:.

If it is determined that they are in the asynchronous state, it is necessary to perform the next receiving and sending of the ST and continue the time synchronization.

As shown in <FIG>, the embodiment provides a network device. The network device is the first network device and may include an inserting module <NUM> and a sending module <NUM>.

The inserting module <NUM> is configured to insert the ST into the signal to be sent. The ST includes: the synchronization byte used for positioning and the timing byte used for carrying the synchronization information of the second network device for time synchronization.

The sending module <NUM> is configured to send the signal to be sent in which the ST is inserted.

Corresponding to a processing chip for inserting bits in the bit sequence or bit stream, the inserting module <NUM> may be a processing chip and/or circuit of the physical layer.

The sending module <NUM> belongs to the PMA sublayer of the physical layer, corresponding to the network interface of the network device.

Optionally, the inserting module <NUM> is configured to insert the ST into the parallel signal. The ST includes: the synchronization byte used for positioning and the timing byte used for carrying the synchronization information of the second network device for time synchronization.

The network device may further include a serial-parallel conversion module.

The serial-parallel conversion module, which corresponds to the Serial-parallel converter, may be configured to convert the parallel signal in which the ST is inserted to the serial signal.

The sending module <NUM> is configured to send the serial signal.

Optionally, the inserting module <NUM> is configured to insert the ST carrying the first time information into the parallel signal.

The sending module <NUM> is further configured to, after receiving the ST carrying second time information which is sent by the second network device, insert, through the ST, the third time information that the ST carrying the second time information is received into the parallel signal sent to the second network device. The first time information, the second time information, the third time information and fourth time information that the second network device receives the ST carrying the third time information are jointly used for the second network device to calculate the time offset from the first network device.

Optionally, N STs form an ST group, N being an integer not less than <NUM>. The timing byte T1 in the first synchronization timing block S1T1 is used for carrying one of the following information: the time parameter indicator, used for indicating the purpose of the time information carried by the timing byte Tn in the current ST group, the value of n being <NUM> to N; the information type indicator, used for indicating the information type carried by the timing byte Tn in the current ST group; the insertion interval indicator, used for indicating the interval bits and/or interval bytes between the synchronization byte S and the timing byte T in one ST; and the indication content field, used for carrying the detailed information corresponding to the information type.

Optionally, the time parameter indicator includes at least one of the following: the starting time indicator, used for indicating the starting time of time synchronization; the sending time indicator, used for indicating the time of sending the S1T1; the receiving time indicator, used for indicating the receiving time of the peer device based on the S1T1; and the blank indicator, used for indicating that the Tn does not carry the time information.

Optionally, the information type indicator includes at least one of the following:.

Optionally, when the ST group includes an odd number of STs, the ST group includes: the first type of ST group and the second type of ST group. The synchronization byte in the first type of ST group has an opposite value to that in the second type of ST group; the first type of ST group and the second type of ST group are inserted into the sequence to be sent at intervals; and/or, y STs distributed adjacently in the ST group are the ST subgroup; and the synchronization bytes of two adjacent synchronization block subgroups have opposite values.

As shown in <FIG>, the embodiment provides a network device. The network device is the second network device and may include a receiving module <NUM>, an extracting module <NUM>, and a synchronizing module <NUM>.

The receiving module <NUM>, corresponding to the interface of the PMA sublayer of the physical layer, may be configured to receive the signal sent by the first network device.

The extracting module <NUM>, corresponding to the processing chip and/or circuit of the physical layer, may be configured to extract the ST from the received signal by matching with the local timing byte, and obtain the synchronization information carried by the timing byte in the ST.

The synchronizing module <NUM>, corresponding to the processing chip and/or circuit of the physical layer, may be configured to perform time synchronization with the first network device based on the synchronization information.

The receiving module <NUM> may be configured to receive the serial signal sent by the first network device.

The second network device may further include a serial-parallel conversion module and an extracting module <NUM>.

The serial-parallel conversion module, which includes the Serial-parallel converter, is configured to convert the serial signal to the parallel signal.

The extracting module <NUM> may be specifically configured to extract the ST from the parallel signal by matching with the local timing byte, and obtain the synchronization information carried by the timing byte in the ST.

The extracting module <NUM> is specifically configured to extract, by matching with the local timing byte, the first time information from the timing byte, which is successfully matched with the local timing byte, of the ST.

The second network device may further include: a recording unit, a communication module, a receiving module <NUM>, a recording module, a calculating module, a calibrating module, and a determining module.

The recording unit includes a storage medium and may be configured to record the second time information that the ST carrying the first time information is received.

The communication module is configured to insert the ST carrying the second time information into the signal sent to the first network device.

The receiving module <NUM> is configured to receive the signal sent by the first network device. The ST carrying the third time information is inserted into the signal, and the third time information is the time information that the first network device receives the ST carrying the second time information.

The recording module is configured to record the fourth time information that the ST carrying the third time information is received.

The calculating module, corresponding to a calculator and the like, may be configured to calculate the time offset from the first network device based on the first time information, the second time information, the third time information and the fourth time information.

The calibrating module, corresponding to the processing chip and/or the processing circuit, may be configured to calibrate the time information of the second network device according to the time offset.

The second network device may further include a determining module.

The determining module is further configured to determine the synchronization condition with the first network device according to the receiving condition of the ST. The synchronization condition includes: the synchronous state in sync with the first network device, and/or the asynchronous state out of sync with the first network device.

As shown in <FIG>, the embodiment provides a network device, which may include: an interface <NUM>, an inserting module <NUM>, and a Serial-parallel converter <NUM>.

The interface <NUM> is configured to receive the parallel signal according to FIFO.

The inserting module <NUM> is connected with the interface <NUM> and configured to insert the ST into the parallel signal. The ST includes: the synchronization byte used for positioning and the timing byte used for carrying the synchronization information of the second network device for time synchronization.

The Serial-parallel converter <NUM> is connected with the inserting module <NUM> and configured to convert the parallel signal in which the ST is inserted to the serial signal.

The interface <NUM> is the physical layer interface <NUM>.

The inserting module <NUM>, corresponding to the processing chip and processing circuit, may be configured to insert the ST.

The Serial-parallel converter <NUM> is configured to perform conversion between the serial signal and the parallel signal.

The network device may further include a signal processing module <NUM>.

The signal processing module <NUM> includes: an encoder and/or a scrambler between the inserting module and the Serial-parallel converter, configured to encode and/or scramble the parallel signal in which the ST is inserted.

Optionally, the first network device may further include: a timer <NUM> and a collecting module <NUM>.

The timer <NUM> is configured for timing.

The collecting module <NUM> is connected with the timer and configured to collect the time information of the timer. The time information is a component of the synchronization information.

Furthermore, the interface <NUM> is further configured to receive the serial signal from the transmission medium.

The Serial-parallel converter <NUM> is further configured to convert the serial signal to the parallel signal.

The network device may further include: an extracting module and a calculating module.

The extracting module is configured to match the parallel signal with the local synchronization byte, extract the ST from the received signal and obtain the synchronization information carried by the timing byte in the ST.

The calculating module is connected with the extracting module and configured to calculate the time offset based on the synchronization information.

The timer is connected with the calculating module and configured to calibrate its own time information according to the time offset.

The network device provided by the embodiment may be the first network device or the second network device mentioned above.

The embodiments of the invention provide a computer storage medium for storing a computer program. After being executed, the computer program can implement the time synchronization method provided by one or more technical solutions mentioned above, for example, can perform one or more time synchronization methods applied to the first network device, or can perform one or more time synchronization methods applied to the second network device.

The computer storage medium can be various types of storage medium, such as a mobile hard disk, an optical disc, and a magnetic tape, and can be a non-instantaneous storage medium.

A few specific examples are provided below in combination with any of the above embodiments.

The embodiments of the invention provide a network device. The network device may include: a serial interface SerDes. The technical solution for achieving high precision time synchronization between the network devices through the ST may include the followings.

First, data structure for carrying the time information.

An ST may be two bytes with a total of <NUM> bits, the first byte (low <NUM> bits) is the synchronization byte S(Synchronization), and the second byte (high <NUM> bits) is the timing byte T(Timing). The synchronization byte S is used for synchronization, namely locating, of the ST on a SerDes data transmission channel. The timing byte T is used for transmitting time synchronization related information and a time stamp. The synchronization related information here may be one of the above indication information. The time stamp is an abbreviation and may be one of the above time information.

The ST group may be composed of <NUM> STs, which may be respectively written as S1T1, S2T2, S3T3, S4T4, S5T5, S6T6, S7T7, S8T8, and S9T9. The ST group may be divided into two types. The synchronization byte of the first type of ST group has an opposite value to that of the second type of ST group.

For example, the first type of ST group may be as follows:
S1=M1, S2=M2, S3=M3, S4=~M1(M1 is converted in bits), S5=~M2(is converted in bits), S6 =~M3(M3 is converted in bits), S7=M1, S8=M2, and S9=M3.

For another example, the second type of ST group may be as follows:.

The value of the synchronization byte may be determined or selected from a value table of the synchronization byte. The value table includes alternative values for a variety of synchronization bytes.

The value of the synchronization byte (S) may be selected from one of the following <NUM>:
{M3, M2, M1}={B'hs1s2, B'hs1s2, B'hs1s2}, where B represents the number of bits included in one timing byte, h represents hexadecimal system, and s1s2 represents a specific value.

The following is alternative values for three feature bytes with the highest recognition rate (that is, the lowest bit error rate) of the synchronization bytes in Ethernet. That is, {M3, M2, M1} may be selected from one or more of the following values.

{<NUM>'h21, <NUM>'h68, <NUM>'hC1}, {<NUM>'h8E, <NUM>'h71, <NUM>'h9D}, {<NUM>'hE8, <NUM>'h4B, <NUM>'h59}, {<NUM>'h7B, <NUM>'h95, <NUM>'h4D}, {<NUM>'h09, <NUM>'h07, <NUM>'hF5}, {<NUM>'hC2, <NUM>'h14,<NUM>'hDD}, {<NUM>'h26, <NUM>'h4A, <NUM>'h9A}, {<NUM>'h66, <NUM>'h45, <NUM>'h7B}, {<NUM>'h76, <NUM>'h24, <NUM>'hA0}, {<NUM>'hFB, <NUM>'hC9, <NUM>'h68}, {<NUM>'h99, <NUM>'h6C, <NUM>'hFD}, {<NUM>'h55, <NUM>'h91,<NUM>'hB9}, {<NUM>'hB2, <NUM>'hB9, <NUM>'hB9, <NUM>'h5C}, {<NUM>'hBD, <NUM>'hFB, <NUM>'h1A}, {<NUM>'hCA, <NUM>'hC7, <NUM>'h83}, {<NUM>'hCD, <NUM>'h36, <NUM>'h35}, {<NUM>'h4C, <NUM>'h31, <NUM>'hC4}, {<NUM>'hB7, <NUM>'hD6,<NUM>'hAD}, {<NUM>'h2A, <NUM>'h66, <NUM>'h5F}, {<NUM>'hE5, <NUM>'hF0, <NUM>'hC0}.

The timing byte T1 carries the time synchronization related information of the network device, and T2~T9 with a total of <NUM> bits carry a time value. The time value is <NUM> bits in ns, and the natural time is represented by the starting time plus relative time. The starting time is a time starting point set by the network device for timing, and the relative time is a time difference taking the starting time as the starting point. The timer and the time stamp for time synchronization use the relative time.

In the following description, [y2:y1] represents from the y1-th bit to the y2-th bit. The meaning of each of the <NUM> bits in T1 is as follows.

The bit [<NUM>:<NUM>] represents the category indication of time parameters, which may include: <NUM>(START), <NUM>(SEND), <NUM>(FEEDBACK) and <NUM>(NOTIME).

START is used for indicating the starting time.

SEND is a sending time stamp when the ST S1T1 is actively sent to the peer.

FEEDBACK is a receiving time stamp when the time stamp category sent by the peer that is the sent ST S1T1 is received.

The bit [<NUM>:<NUM>] represents information categories, including: <NUM> (time quality level), <NUM> (port mode), <NUM> (query request), <NUM> (update request), and other (reserved).

The bit [<NUM>:<NUM>] represents information contents. When the information category is <NUM>, the values <NUM>~<NUM> represent <NUM> levels, and the smaller the value is, the higher the level is; and the values <NUM>~<NUM> are reserved for use. When the information category is <NUM>, the value <NUM> represents a party not performing time synchronization, the value <NUM> represents a time issuer, the value <NUM> represents a time receiver, and the values <NUM>~<NUM> are reserved for use. When the information category is <NUM>, the value <NUM> represents a query of the time quality level of the peer, the value <NUM> represents a query of the port mode of the peer, the value <NUM> represents a query of the starting time of the peer, and the values <NUM>~<NUM> are reserved for use. When the information category is <NUM>, the values <NUM>~<NUM> are reserved for use.

T2~T9 are used for transmitting the starting time and a sampling time stamp for the receiving and sending of the ST, with <NUM> bits of time value. T2=bit [<NUM>:<NUM>], T3=bit [<NUM>:<NUM>], T4=bit [<NUM>:<NUM>], T5=bit [<NUM>:<NUM>], T6=bit [<NUM>:<NUM>], T7=bit [<NUM>:<NUM>], T8=bit [<NUM>:<NUM>], and T9=bits [<NUM>:<NUM>].

Second, a SerDes time synchronization logic processing procedure.

As shown in <FIG>, the main composition of a SerDes may be divided into four parts, that is, Phase Lock Loop (PLL), a sending module Serializer, a receiving module Deserializer, and a Clock Data Recovery (CDR) module.

The PLL generates a clock signal required by each module of the SerDes, and manages a phase relationship of these clocks.

The Serializer receives, through interface FIFO, a service data parallel signal sent from a network upper interface, and sends it to the 8B and 10B encoder or scrambler, so as to avoid data including extremely long and consecutive <NUM> or <NUM>. After that, the signal is sent to the Serializer for Parallel-serial conversion. Serial data is processed by an equalizer and sent to the transmission medium by the driver.

The Deserializer receives an external serial signal from the transmission medium, and the equalizer adjusts the signal to remove part of the deterministic jitter. The Deserializer performs Serial-parallel conversion to convert the signal to the parallel signal. A 8B and 10B decoder or descrambler completes decoding or descrambling.

The signal is sent to the network upper interface through interface FIFO.

The CDR module extracts a clock from edge information of receiving data serial bit stream to realize clock synchronization.

The above structure does not have the function of time synchronization. In order to realize a technology of achieving, through the ST, high-precision time synchronization between the network devices at the serial interface SerDes of the network device, the following processing procedure is involved.

The synchronous state machine includes a synchronization process and an asynchronization process of the synchronization byte, and a jump between two states.

The synchronization process is that: during the asynchronization state, after the decoder or descrambler of the Deserializer and before the interface FIFO, S1 of the first type of ST group or S1 of the second type of ST group is searched in the data stream, as mentioned above, the two are inverted according to bits. After the S1 is located, S2, S3, S4, S5, S6, S7, S8 and S9 of the group are searched according to the insertion spacing of the ST. If <NUM> synchronization bytes form a first type of ST group, then the next second type of ST group is searched. If <NUM> synchronization bytes form a second type of ST group, then the next first type of ST group is searched. When the consecutive first type of ST group and second type of ST group are searched, the synchronous state is entered. During the synchronization state, the locating of the ST group in the data stream is continued according to the insertion spacing of the ST.

The asynchronization process is that: during synchronization, the synchronization byte (S) is located according to the insertion spacing, and if <NUM> consecutive synchronization bytes do not match, the asynchronous state is entered. The synchronization process is resumed after asynchronization.

<NUM>) A timer and time stamp sampling process.

The timer may provide <NUM> bits of time information, which has the same format as the time value, in ns. The value represents the difference relative to the starting time, and is the relative time. The time issuer uses a local clock to time, and the time receiver uses a synchronous clock output by the CDR module to time.

In the process of inserting the ST into the data stream of the Serializer, when the bit <NUM> of the S1 is inserted, a sampling timer obtains a sending time stamp, which is the relative time.

In the process of synchronization of the data stream of the Deserializer, during the synchronization state, when the bit <NUM> of the S1 is located, the sampling timer obtains a receiving time stamp, which is the relative time. The time stamp is not sampled during asynchronization.

<NUM>) A process of extracting the time information.

In the process of synchronization of the data stream of the Deserializer, during the synchronization state, the timing bytes T1, T2, T3, T4, T5, T6, T7, T8 and T9 are extracted from each located ST. If any synchronization bytes (S) in the ST group do not match, the <NUM> timing bytes in this group are discarded. The time information is extracted from the T1 of the valid ST group according to the meaning of bits mentioned above and sent to a time mode state machine, and the time values are extracted from T2-T9.

<NUM>) A process of time offset calculation and time calibration.

The network device SerDes may obtain four time stamps:.

The offset is calculated by using the time stamp as [(t2_SAMP-t1_GET)-t2_GET-t1_SAMP)], <NUM>. If the port mode is the time receiver, the network device calibrates the time value of the timer. If the port mode is the time issuer, the network device does not calibrate the time value.

The time quality level, the port mode, the starting time and other information of the network device are maintained. The network device performs time information interaction through the sending and receiving of the timing byte (T) between the SerDes, including the time quality level, the port mode, the starting time, etc., and realizes the switch of the port modes.

The network device in an initial state actively sends its own time quality level and other information to the peer, and the device with higher time quality level is preferred as the time issuer, and the device with lower time quality level serves as the time receiver.

Through the ST, the time issuer transmits the starting time to the time receiver, and the time receiver sets its own starting time to be the same as the time issuer.

When the port needs to know the time information of the peer, it sends a query request to the peer, that is, sets the bit [<NUM>:<NUM>] of the T1 to <NUM>. After receiving the query request, the port of the network device sends its own time quality level, port mode, starting time and other information to the peer.

When the time information of the network device is updated, it sends an update request to the peer, that is sets the bit [<NUM>:<NUM>] of the T1 to <NUM>. After receiving the update request, the port of the network device sends a query request to the peer, and automatically updates its own port mode after obtaining the time information of the peer.

Third, as shown in <FIG>, a time synchronization interaction process of the network device SerDes includes the following steps.

The first step is the process of inserting the ST at a sending side. When S1 is inserted, the sending time stamp t1_samp is recorded. The time stamp category of the bit [<NUM>:<NUM>] of the T1 is set as sending, the bit [<NUM>:<NUM>] may carry the time information, and the T2-T9 carry the time stamp value t1_samp.

The second step is a synchronization process at a receiving side. When the S1 is located, the receiving time stamp is recorded. If the time stamp category in the T1 is sending, the time stamp is the receiving time stamp t2_samp.

The third step is a process of extracting the time information at the receiving side. The time stamp t1_get is extracted from the T2-T9 of the ST group the T1 time stamp category of which is sending.

The fourth step is that the receiving time stamp t2_samp is transmitted back to the peer through the ST. The time stamp category of the bit [<NUM>:<NUM>] of the inserted T1 is set as feedback. The bit [<NUM>:<NUM>] may carry the time information. The T2~T9 carry the time stamp value T2_samp.

The fifth step is a process of extracting the time information at the receiving side. The time stamp t2_get is extracted from the T2~T9 of the ST group the T1 time stamp category of which is feedback.

The time issuer and the time receiver perform the first step to the fifth step simultaneously, and obtain four time stamps respectively to calculate the time offset. The two ends performing time synchronization obtain time offset data at the same time, and when the port mode changes, they can switch fast.

As shown in <FIG>, the SerDes provided in the embodiments of the invention may include:
a PLL module, a sending module Serializer, a receiving module Deserializer, and a CDR module. The SerDes may further include:.

As an embodiment of the device of the invention, the structure of modules of the SerDes is shown in <FIG>.

As an embodiment of the device of the invention, the time synchronization process of the network device SerDes is shown in <FIG>, including the following steps.

At the first step, parameters are configured.

The first type of ST group is S1=<NUM>'hC1, S2=<NUM>'h68, S3=<NUM>'h21, S4=<NUM>'h3E, S5=<NUM>'h97, S6=<NUM>'hDE, S7=<NUM>'hC1, S8=<NUM>'h68, S9=<NUM>'h21.

The second type of ST group is S1=<NUM>'h3E, S2=<NUM>'h97, S3=<NUM>'hDE, S4=<NUM>'hC1, S5=<NUM>'h68, S6=<NUM>'h21, S7=<NUM>'h3E, S8=<NUM>'h97, S9=<NUM>'hDE.

The insertion spacing of the ST is set to <NUM> bits.

The time synchronization cycle is set to <NUM> times per second.

The time quality level of the network device <NUM> is <NUM>, and the starting time is set to <NUM> 'h0000_1000_0000_0000.

The time quality level of the network device <NUM> is <NUM>.

At the second step, the network device <NUM> sends its own time quality level (T1=<NUM>'b00100011) to the peer, and the network device <NUM> sends its own time quality level (T1=<NUM>'b01000011) to the peer. After receiving the time quality level of the peer, the network device <NUM> sets the port mode as the time issuer, and the network device <NUM> sets the port mode as the time receiver. The network device <NUM> sends the starting time (T1=<NUM>'h00100101, T2~T9=<NUM>'h0000_1000_0000_0000) to the peer; the network device <NUM> sets its own starting time to the same value after receiving the starting time of the peer.

At the third step, the network device SerDes of the time issuer sends data bits and inserts <NUM> bits of ST every <NUM> bits of service data, and inserts the first type of ST group and the second type of ST group circularly. When the S1 is inserted, the sending time stamp t1_samp is recorded. The port mode is the time issuer, and the time stamp category is sending, that is, T1=<NUM>'b00100101. T2-T9 are equal to the time stamp value t1_samp.

At the fourth step, the network device SerDes of the time issuer searches the ST for synchronization, locates the ST group, and records the receiving time stamp t2_samp if the time stamp category of T1 is sending. t2_samp is transmitted back by the next ST group. The port mode of T1 is the time issuer, and the time stamp category is feedback, that is, T1=<NUM>'b00100110. T2-T9 are equal to the time stamp value t2_samp.

At the fifth step, the network device SerDes of the time issuer extracts the time stamp t1_get (that is, the value of t1_get is equal to the t1_samp of the peer) from the ST group the received time stamp category of which is sending, and extracts the time stamp t2_get (that is, the value of t2_get is equal to the t2_samp of the peer) from the ST group the received time stamp category of which is feedback.

At the sixth step, the network device SerDes of the time receiver sends data bits, inserts the first type of ST group and the second type of ST group circularly according to the inserting spacing, and records the sending time stamp t1_samp when inserting the S1. The port mode is the time receiver, and the time stamp category is sending, that is, T1=<NUM>'b01000101. T2~T9 are equal to the time stamp value t1_samp.

At the seventh step, the network device SerDes of the time receiver searches the ST for synchronization, locates the ST group, and records the receiving time stamp t2_samp if the time stamp category of T1 is sending. t2_samp is transmitted back by the next ST group. The port mode of T1 is the time receiver, and the time stamp category is feedback, that is, T1=<NUM>'b01000110. T2~T9 are equal to the time stamp value t2_samp.

At the eighth step, the network device SerDes of the time receiver extracts the time stamp t1_get from the ST group the received time stamp category of which is sending, and extracts the time stamp t2_get from the ST group the received time stamp category of which is feedback.

At the ninth step, the calibration is performed four times per second according to the time synchronization cycle. The network device of the time receiver calculates the time offset=[(T2_SAMP-T1_GET)-T2_GET-T1_SAMP)], <NUM>, and calibrates the time of the device. The network device of the time issuer calculates the time offset=[(t2_samp-t1_get)-t2_get-t1_samp)], <NUM>, and calibrates the time of the device.

In several embodiments provided by the application, it should be understood that the disclosed device and method may be implemented in another manner. The device embodiment described above is only schematic, and for example, division of the units is only logic function division, and other division manners may be adopted during practical implementation. Part of all of the units may be selected according to a practical requirement to achieve the purposes of the solutions of the embodiments.

In addition, each functional unit in each embodiment of the invention may be integrated into a processing module, each unit may also serve as an independent unit and two or more than two units may also be integrated into a unit. The integrated unit may be implemented in a hardware form and may also be implemented in form of hardware and software functional unit.

Those of ordinary skill in the art should know that all or part of the steps of the method embodiment may be implemented by related hardware instructed through a program, the program may be stored in a computer-readable storage medium, and the program is executed to execute the steps of the method embodiment. The storage medium includes: various media capable of storing program codes such as a mobile storage device, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or a compact disc.

Claim 1:
A time synchronization method, applied to a first network device, comprising:
inserting, at a physical layer, a Synchronization Timing block, ST, into a signal to be
sent, wherein the signal to be sent is a bit sequence to be sent, the ST comprises a synchronization byte and a timing byte, the synchronization byte is used for positioning the ST, and the timing byte is used for carrying synchronization information for a second network device to perform time synchronization; and
sending the signal to be sent, in which the ST is inserted, to a second network device.