Time synchronization method, switch system and switch

Through the use of port negotiation messages and clock synchronization messages, the problem of clock synchronization link break in the switch ring network is solved, and time synchronization redundant backup is realized after the switch failure, ensuring the reliability and stability of time synchronization in the ring network.

CN119135303APending Publication Date: 2024-12-13深圳市三旺通信股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411046996.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-12-13

Smart Images

  • Figure CN119135303A_ABST
    Figure CN119135303A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of switches, and discloses a time synchronization method, a switch system and a switch, and the time synchronization method comprises the steps: determining the initial port state of each switch based on a port negotiation message after a plurality of switches start a looped network function; determining an initial master switch and a plurality of initial slave switches in the looped network according to the priority and the clock information message of each switch; sending a clock synchronization message to each initial slave switch through the initial master switch so as to perform time synchronization; when it is identified that the connection ports in the looped network are disconnected, the disconnected connection ports are configured to be in a blocked state, and the connection ports which are not disconnected are configured to be in a forwarding state; and re-determining a new master switch and a plurality of new slave switches according to the priority and the clock information message so as to normally perform time synchronization. According to the invention, the problem of switch ring network time synchronization faults is effectively solved, and the time synchronization reliability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of switches, and in particular to a time synchronization method, a switch system and a switch. Background Art

[0002] With the application of deterministic transmission networks, time-sensitive networks (Time-Sensitive Networking) are becoming more and more widely used. The LAN and MAN time-sensitive network time synchronization specification (IEEE802.1AS) has also begun to be applied in industrial Ethernet switches. However, the traditional generalized precision time protocol (Generalized Precision Time Protocol) test is based on the clock source in a chained form according to Ethernet to send time synchronization messages, and receive path delay measurement messages according to the Precision Time Protocol (PTP) for time synchronization. However, if a switch device fails in the switch ring network, resulting in a disconnected link, other switch devices will be unable to synchronize with the clock source, resulting in confusion in the switch ring network time synchronization. Summary of the invention

[0003] In view of this, the embodiments of the present application provide a time synchronization method, a switch system and a switch, which can effectively solve the problem of switch timing failure and improve the reliability of timing between the slave switch and the master switch.

[0004] In a first aspect, an embodiment of the present application provides a time synchronization method, which is applied to multiple switches, and the method includes:

[0005] After the plurality of switches start the ring network function, the initial port state of each switch is determined based on the port negotiation message, wherein the initial port state includes a blocking state and a forwarding state;

[0006] Obtaining the clock information message of each switch through the port in the forwarding state, and determining an initial master switch and initial multiple slave switches in the ring network according to the priority of each switch and the clock information message;

[0007] Sending a clock synchronization message to each of the initial slave switches through the initial master switch, so that each of the initial slave switches performs time synchronization with the initial master switch according to the clock synchronization message;

[0008] When it is identified that a connection port in the ring network is disconnected, the disconnected connection port is configured to be in a blocking state, and the undisconnected connection port is configured to be in a forwarding state;

[0009] Re-determine a new master switch and multiple new slave switches according to the priority and the clock information message;

[0010] The new master switch sends a clock synchronization message to each of the new slave switches, so that each of the new slave switches performs time synchronization with the new master switch according to the clock synchronization message.

[0011] In a first possible embodiment of the first aspect, each of the switches includes at least two ports, and the method further includes:

[0012] When the new slave switch is time synchronized with the new master switch, the port state of the new master switch is set to the master node state, the port state of the new slave switch is set to the slave node state, and the disconnected port state is set to the fault state;

[0013] The port in the master node state is used to send the clock synchronization message, the port in the slave node state is used to receive the clock synchronization message, and the port in the fault state does not support receiving and sending the clock synchronization message.

[0014] In a second possible embodiment of the first aspect, the method further includes:

[0015] When no connection port disconnection is identified in the ring network, the port states of the initial master switch and each of the initial slave switches are configured as any one of a master node state, a slave node state and a passive state;

[0016] The port in the passive state is used to discard the synchronization information of the received clock synchronization message.

[0017] In a third possible embodiment of the first aspect, configuring the port states of the initial master switch and each of the initial slave switches to be any one of a master node state, a slave node state, and a passive state, respectively, includes:

[0018] The initial port state of the master switch is configured as the master node state, and the initial port state of the slave switch is configured as the slave node state;

[0019] The ports of each of the initial master switch and the initial slave switch are identified to obtain the port number of each port, and the port state of one of the ports is configured to be a passive state according to the port number.

[0020] In a fourth possible embodiment of the first aspect, the identifying the ports of each of the initial master switch and the initial slave switch to obtain the port number of each port, and configuring the port state of one of the ports to be a passive state according to the port number, includes:

[0021] The port that identifies the master node state is the smallest port number. According to the direction in which the initial master switch sends the clock synchronization message, the port numbers of the ports are increased in sequence, and the port state of the port with the largest port number is configured as the passive state.

[0022] In a fifth possible embodiment of the first aspect, the time synchronization method further includes:

[0023] When the priorities of the switches are different, the priorities of the switches are compared in turn by using the best master clock algorithm, and the switch with the highest priority is determined to be in the master state, and the remaining switches are in the slave state;

[0024] When the priorities of the switches are the same, the clock information of each switch is compared according to the clock information message by using the best master clock algorithm, so as to determine the master-slave status of each switch according to the comparison result.

[0025] In a sixth possible embodiment of the first aspect, the identifying that a connection port in the ring network is disconnected includes:

[0026] If it is detected that one of the switches shows a fault of itself or a port fault, it is confirmed that a connection port in the ring network is disconnected.

[0027] In a seventh possible embodiment of the first aspect, after the plurality of switches start the ring network function, determining the initial port state of each switch based on the port negotiation message includes:

[0028] When it is detected that the ring network function is turned on, it is determined to perform port negotiation message processing;

[0029] The port states of the switch are configured as a blocking state and a forwarding state respectively according to the port negotiation message through the port negotiation message processing, wherein the switch port in the blocking state that is not faulty is used to monitor subsequent port negotiation messages.

[0030] In a second aspect, an embodiment of the present application provides a switch system, including multiple switches constituting a ring network, wherein the multiple switches use the above-mentioned time synchronization method for time synchronization.

[0031] In a third aspect, an embodiment of the present application provides a switch, which is applied to a switch ring network, and the switch is used to execute the above-mentioned time synchronization method with other switches in the switch ring network.

[0032] The embodiments of the present application have the following beneficial effects:

[0033] A time synchronization method of an embodiment of the present application is applied to multiple switches, and the time synchronization method includes: when multiple switches start the ring network function, the initial port state of each switch is determined based on the port negotiation message; according to the priority and clock information message of each switch, the initial master switch and the initial multiple slave switches in the ring network are determined; the clock synchronization message is sent to each initial slave switch through the initial master switch to perform time synchronization; when it is identified that there is a connection port disconnection in the ring network, the disconnected connection port is configured as a blocking state, and the undisconnected connection port is configured as a forwarding state; according to the priority and clock information message, a new master switch and a new multiple slave switches are re-determined to perform time synchronization normally. Based on the above scheme, the present application takes the master switch as the optimal clock, organizes the master switch and the slave switch together according to the master-slave hierarchical relationship to form a ring network, synchronizes the clock to each slave node step by step through the optimal clock, and when it is identified that there is a connection port disconnection in the ring network, reconfigures each port in the ring network, so that the time synchronization function of the ring network is not invalid, and avoids the situation where the failure of a certain time node causes the time synchronization of all back-end links to be disordered. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0035] Figure 1 A framework scenario diagram of a switch system according to an embodiment of the present application is shown;

[0036] Figure 2 A first flow chart of the time synchronization method according to an embodiment of the present application is shown;

[0037] Figure 3 A second flow chart of the time synchronization method according to an embodiment of the present application is shown;

[0038] Figure 4 A third flow chart of the time synchronization method according to an embodiment of the present application is shown.

[0039] Description of main component symbols:

[0040] 100-switch system; 110-master switch; 120-slave switch. DETAILED DESCRIPTION

[0041] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0042] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0043] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.

[0044] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.

[0045] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0046] With the increasingly sophisticated demand for time sensitivity in the industrial Internet, in modern communication information networks, the normal operation of most services requires switches to maintain a reasonable level of time error in the switch ring network, requiring relative time synchronization. The present application provides a time synchronization method based on a switch ring network. When one of the switch devices in the switch ring network or the line connection between switches fails, the master-slave state of the switch can be reconfigured to achieve time synchronization between switches, thereby avoiding time synchronization confusion in the switch ring network.

[0047] Before describing the time synchronization method, the structure of the switch system 100 is first introduced accordingly.

[0048] Example 1

[0049] Figure 1 A framework scenario diagram of a switch system 100 according to an embodiment of the present application is shown. Exemplarily, the switch system 100 includes a plurality of switches constituting a ring network, and the plurality of switches are connected in sequence. It can be understood that Figure 1 The number of switches shown is only an example, and is not limited to the switch system 100 including only four switches. The multiple switches include a master switch 110 and multiple slave switches 120. The master switch 110 is used to send a clock synchronization message to the slave switches 120, so that each slave switch 120 performs time synchronization with the master switch 110 according to the clock synchronization message. The multiple switches are used to perform a time synchronization method.

[0050] Specifically, the switch system 100 implements time synchronization between the master switch 110 and the slave switch 120 based on a timing link through a time synchronization protocol (802.1AS). However, when the timing link between the master switch 110 and the slave switch 120 or between each slave switch 120 is disconnected, some switches in the switch system 100 will not be able to perform time synchronization, resulting in the switch system 100 being unable to operate normally. Therefore, the present application provides a time synchronization method, which enables the switch system 100 to perform redundant backup of the time synchronization protocol, and solves the problem that time synchronization cannot be performed when a port or a timing link in the switch system 100 fails. The time synchronization method greatly improves the reliability of the timing of the switch system 100.

[0051] The time synchronization method is described below in conjunction with some specific embodiments.

[0052] Example 2

[0053] Figure 2 A flow chart of a time synchronization method according to an embodiment of the present application is shown. Exemplarily, the time synchronization method is applied to multiple switches and includes the following steps:

[0054] S210, after the ring network function is started by multiple switches, the initial port state of each switch is determined based on the port negotiation message, wherein the initial port state includes a blocking state and a forwarding state.

[0055] Exemplarily, multiple switches process port negotiation messages (BPDU, Bridge Protocol Data Unit) so that the switch ring network can automatically negotiate the port status.

[0056] For example, in one embodiment, after multiple switches start the ring network function, the time synchronization method determines the initial port state of each switch based on the port negotiation message, specifically including: when detecting that the ring network function is turned on, determining to perform port negotiation message processing; configuring the port state of the switch to a blocking state and a forwarding state according to the port negotiation message through port negotiation message processing, wherein the switch port in a non-faulty blocking state is used to listen to subsequent port negotiation messages.

[0057] Specifically, when the switch receives a port negotiation message, it compares its own information with the information of the port negotiation message to determine how to set the port state. The port negotiation message includes a bridge identifier, a path cost value, a root bridge identifier, and a port priority, etc. In the switch ring network, the port state is automatically negotiated through the port negotiation message processing. Among them, a port state in the switch ring network is displayed as a blocking state. The port in the blocking state does not forward data frames and listens to the incoming port negotiation message. The other ports in the switch ring network are in a forwarding state. The port in the forwarding state can perform normal clock information message forwarding.

[0058] It can be understood that when the switch turns on the ring network function, the switch ring network selects a port in a blocked state, so as to achieve the effect of no loop storm in the switch ring network. The switch is used to automatically negotiate the status of the port through port negotiation message processing, without manual intervention, avoiding problems and delays caused by manual configuration errors. At the same time, the port negotiation message also enables the switches to match, negotiate and forward data packets in a timely and accurate manner, ensuring the reliability and stability of the switch ring network.

[0059] S220, obtaining the clock information message of each switch through the port in the forwarding state, and determining the initial master switch 110 and the initial multiple slave switches 120 in the ring network according to the priority and clock information message of each switch;

[0060] Exemplarily, each switch is set with a different priority, and the time synchronization method determines the switch with the highest priority as the master switch 110 by comparing the priorities of each switch. If the priorities of each switch are the same, the time synchronization method uses the Best Master Clock Algorithm (BMCA) to select the optimal clock according to the importance of the clock information, and the optimal clock is used as the master switch 110, and the other switches in the ring network are used as slave switches 120.

[0061] For example, in one embodiment, Figure 3 As shown, the time synchronization method determines the master-slave status of each switch according to the priority and clock information message of each switch, and specifically includes the following steps:

[0062] S221, when the priorities of the switches are different, the priorities of the switches are compared in turn by using the best master clock algorithm, and the switch with the highest priority is determined to be in the master state, and the remaining switches are in the slave state.

[0063] S222: When the priorities of the switches are the same, the clock information of each switch is compared according to the clock information message by using the best master clock algorithm to determine the master-slave status of each switch according to the comparison result.

[0064] Specifically, the process of selecting the master switch 110 by the best master clock algorithm includes: when each switch starts the ring network function, all switches will consider themselves as the master switch 110 at the beginning, each switch device configures the time synchronization function based on the time synchronization protocol, and sends clock information messages through its own port at a certain time frequency; the switch with the highest priority is selected as the master switch 110 according to the priority of the switch; if the switch with the highest priority cannot be selected according to the priority of the switch, the clock information is compared in order according to the importance of each clock information, and the master switch 110 is obtained after comparison. The clock information includes clock level, clock accuracy, address information and availability, etc., and the importance of the clock information can be reduced in order according to the actual application situation.

[0065] S230 , sending a clock synchronization message to each initial slave switch 120 through the initial master switch 110 , so that each initial slave switch 120 performs time synchronization with the initial master switch 110 according to the clock synchronization message.

[0066] Exemplarily, when each switch is not faulty, a switch port state will be displayed as a passive state, so that the initial master switch 110 and the initial slave switch 120 do not perform time synchronization based on the passive state port. The passive state port will discard the synchronization information contained in the received clock synchronization message. The passive state port is used to alleviate the time synchronization loop of the switch ring network, so that the switch ring network is chained when performing time synchronization. The switch ring network only uses the clock information synchronized by the port state of the master state and the port state of the slave state.

[0067] For example, in one embodiment, the time synchronization method further includes: when no connection port disconnection is detected in the ring network, the port states of the initial master switch 110 and each initial slave switch 120 are configured as any one of a master node state, a slave node state and a passive state; wherein the port in the passive state is used to discard the synchronization information of the received clock synchronization message.

[0068] For example, in one embodiment, the time synchronization method configures the port status of the initial master switch 110 and the initial slave switch 120 as any one of the master node status, the slave node status and the passive status, respectively, and specifically includes the following steps: configuring the port status of the initial master switch 110 as the master node status, and configuring the port status of the initial slave switch 120 as the slave node status; identifying the ports of each initial master switch 110 and the initial slave switch 120, obtaining the port number of each port, and configuring the port status of one of the ports to be the passive state according to the port number.

[0069] For example, in one embodiment, the time synchronization method identifies the ports of each initial master switch 110 and the initial slave switch 120, obtains the port number of each port, and configures the port state of one of the ports to be a passive state according to the port number, specifically including: identifying the port in the master node state as the smallest port number, increasing the port number of each port in turn according to the direction in which the initial master switch 110 sends the clock synchronization message, and configuring the port state of the port with the largest port number to be a passive state.

[0070] Specifically, the time synchronization method configures the port number of the main switch 110 to 0, and increases the port number of each switch port in sequence according to the direction in which the main switch 110 sends the clock synchronization message, each port number can be configured to be 1-255, and the port state of the port number 255 is configured to be a passive state. The direction in which the main switch 110 sends the clock synchronization message can be unidirectional clockwise, unidirectional counterclockwise, and bidirectional.

[0071] S240: When it is identified that a connection port in the ring network is disconnected, the disconnected connection port is configured to be in a blocking state, and the undisconnected connection port is configured to be in a forwarding state.

[0072] Exemplarily, the switch ring network identifies whether the switch ring has changed according to the status displayed by each switch. When one of the switch devices fails or the connection port between the switches fails, the connection status of the failed port is displayed as failed, and the switch ring network automatically identifies that the connection port between the switches is in a failed state, thereby determining that the connection port in the switch ring network is disconnected.

[0073] For example, in one embodiment, if it is detected that one of the switches identifies that a connection port in the ring network is disconnected, the time synchronization method includes: if it is detected that one of the switches shows a self-failure or a port failure, then confirming that a connection port in the ring network is disconnected.

[0074] S250: re-determine a new master switch 110 and multiple new slave switches 120 according to the priority and the clock information message.

[0075] S260 , sending a clock synchronization message to each new slave switch 120 through the new master switch 110 , so that each new slave switch 120 performs time synchronization with the new master switch 110 according to the clock synchronization message.

[0076] Exemplarily, the port of the master switch 110 sends synchronization information carried in a clock synchronization message to the port of the slave switch 120, and the slave switch 120 is used to synchronize to the same clock as the master switch 110 according to the synchronization information. The slave switch 120 is also used to display the corresponding timestamp on its own device.

[0077] For example, in one embodiment, each switch includes at least two ports, and the time synchronization method also includes: when the new slave switch 120 performs time synchronization with the new master switch 110, the port state of the new master switch 110 is set to the master node state, the port state of the new slave switch 120 is set to the slave node state, and the disconnected port state is set to the fault state; wherein the port in the master node state is used to send clock synchronization messages, the port in the slave node state is used to receive clock synchronization messages, and the port in the fault state does not support receiving and sending clock synchronization messages.

[0078] Specifically, the clock synchronization message includes a timestamp synchronization message and a confirmation message. The timestamp synchronization message is used to carry the timestamp information of the master switch 110, so that the slave switch 120 will use the timestamp information to calibrate its own clock after receiving the timestamp synchronization message; the confirmation message is used to return the sending time corresponding to the timestamp synchronization message so that the master switch 110 can calculate the synchronization accuracy, thereby informing the master switch 110 that the slave switch 120 has successfully received the timestamp synchronization message and has completed the clock calibration.

[0079] Exemplary, Figure 4 Another flow chart of the time synchronization method according to an embodiment of the present application is shown, which specifically includes the following steps:

[0080] S310, each switch receives a port negotiation message from each other.

[0081] S320, determine whether the switch has enabled the ring network function, if yes, execute S330, if no, end the process.

[0082] S330, performing port negotiation message processing to configure the state of one of the ports in the ring network to be a blocking state, and configure the states of the other ports to be a forwarding state.

[0083] S340 , compare the priorities and clock information of the switches based on the best master clock algorithm to obtain the master switch 110 and the slave switch 120 .

[0084] S350, configure one of the ports in the ring network to be in a passive state, then configure the port state of the master switch 110 to be in a master state, and configure the port of the slave switch 120 to be in a slave state, so as to perform time synchronization of the ring network normally.

[0085] S360, determine whether the connection port in the ring network is disconnected, if yes, execute S370, if not, perform time synchronization of the ring network normally.

[0086] S370: Set the loop state of the disconnected connection port to a blocking state, and set the loop state of the undisconnected connection port to a forwarding state.

[0087] S380, reconfigure the new master-slave status of the switches in the ring network, set the time synchronization status of the faulty port to the faulty status, set the port status of the new master switch 110 to the master status, and set the port status of the new slave switch 120 to the slave status to complete the time synchronization of the ring network.

[0088] The present application also provides a switch, which is applied to a switch ring network, and the switch is used to execute the above-mentioned time synchronization method with other switches in the switch ring network.

[0089] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A time synchronization method, characterized in that: Applied to multiple switches, the method includes: After the plurality of switches start the ring network function, the initial port state of each switch is determined based on the port negotiation message, wherein the initial port state includes a blocking state and a forwarding state; Obtaining the clock information message of each switch through the port in the forwarding state, and determining an initial master switch and initial multiple slave switches in the ring network according to the priority of each switch and the clock information message; Sending a clock synchronization message to each of the initial slave switches through the initial master switch, so that each of the initial slave switches performs time synchronization with the initial master switch according to the clock synchronization message; When it is identified that a connection port in the ring network is disconnected, the disconnected connection port is configured to be in a blocking state, and the undisconnected connection port is configured to be in a forwarding state; Re-determine a new master switch and multiple new slave switches according to the priority and the clock information message; The new master switch sends a clock synchronization message to each of the new slave switches, so that each of the new slave switches performs time synchronization with the new master switch according to the clock synchronization message.

2. The time synchronization method according to claim 1, characterized in that: Each of the switches comprises at least two ports, and the method further comprises: When the new slave switch is time synchronized with the new master switch, the port state of the new master switch is set to the master node state, the port state of the new slave switch is set to the slave node state, and the disconnected port state is set to the fault state; The port in the master node state is used to send the clock synchronization message, the port in the slave node state is used to receive the clock synchronization message, and the port in the fault state does not support receiving and sending the clock synchronization message.

3. The time synchronization method according to claim 1, characterized in that: The method further comprises: When no connection port disconnection is identified in the ring network, the port states of the initial master switch and each of the initial slave switches are configured as any one of a master node state, a slave node state and a passive state; The port in the passive state is used to discard the synchronization information of the received clock synchronization message.

4. The time synchronization method according to claim 3, characterized in that: The step of configuring the port states of the initial master switch and each of the initial slave switches to be any one of a master node state, a slave node state, and a passive state, respectively, includes: The initial port state of the master switch is configured as the master node state, and the initial port state of the slave switch is configured as the slave node state; The ports of each of the initial master switch and the initial slave switch are identified to obtain the port number of each port, and the port state of one of the ports is configured to be a passive state according to the port number.

5. The time synchronization method according to claim 4, characterized in that: The identifying of each port of the initial master switch and the initial slave switch to obtain a port number of each port, and configuring a port state of one of the ports to be a passive state according to the port number, includes: The port that identifies the master node state is the smallest port number. According to the direction in which the initial master switch sends the clock synchronization message, the port numbers of the ports are increased in sequence, and the port state of the port with the largest port number is configured as the passive state.

6. The time synchronization method according to claim 1, characterized in that: Also includes: When the priorities of the switches are different, the priorities of the switches are compared in turn by using the best master clock algorithm, and the switch with the highest priority is determined to be in the master state, and the remaining switches are in the slave state; When the priorities of the switches are the same, the clock information of each switch is compared according to the clock information message by using the best master clock algorithm, so as to determine the master-slave status of each switch according to the comparison result.

7. The time synchronization method according to claim 1, characterized in that: The identifying that a connection port is disconnected in the ring network includes: If it is detected that one of the switches shows a fault of itself or a port fault, it is confirmed that a connection port in the ring network is disconnected.

8. The time synchronization method according to claim 1, characterized in that: After the plurality of switches start the ring network function, determining the initial port state of each switch based on the port negotiation message includes: When it is detected that the ring network function is turned on, it is determined to perform port negotiation message processing; The port states of the switch are configured as a blocking state and a forwarding state respectively according to the port negotiation message through the port negotiation message processing, wherein the switch port in the blocking state that is not faulty is used to monitor subsequent port negotiation messages.

9. A switch system, characterized in that: The invention comprises a plurality of switches constituting a ring network, wherein the plurality of switches are time synchronized by using the time synchronization method described in any one of claims 1 to 8.

10. A switch, characterized in that: Applied to a switch ring network, the switch is used to execute the time synchronization method according to any one of claims 1 to 8 with other switches in the switch ring network.