Equipment election method and device, electronic equipment and storage medium

By sending detection messages and receiving reply messages between network element devices, and combining the priority information of the VRRP protocol, the main network element device and backup network element device are selected, which solves the problems of high cost and dual main network element state in the traditional VRRP protocol, and achieves more reliable device elections and network fault tolerance.

CN119728377AActive Publication Date: 2025-03-28CHINA TELECOM CLOUD TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411752568.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-28
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

When traditional network element devices use VRRP protocol, the cost of transmission through the heartbeat line is high and there is a problem of dual main network element state; although the cost of transmission through shared data packet links is low, there is a problem of unilateral network element state that leads to dual main network element state.

Method used

The detection message is sent and the reply message is received through the interface network address. The first and second fault-tolerant protocol messages are sent to the countertop network element device according to the sending and receiving status of the detection message and reply message, including the priority information of the network element device of the sending end. When the detection message sending and receiving status meets the preset conditions, the main network element device and the backup network element device are selected based on the message sending and receiving status and priority information.

Benefits of technology

By actively sending detection messages and receiving reply messages, we ensure that the data link is normal and then sending fault-tolerant protocol messages, avoiding the problem of dual main network element equipment caused by network unilateral abnormalities or heartbeat line failures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728377A_ABST
    Figure CN119728377A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an equipment election method and device, electronic equipment and a storage medium. The method comprises the following steps: sending a detection message through an interface network address and receiving a reply message corresponding to the detection message; sending a first fault-tolerant protocol message to the opposite-end network element equipment and receiving a second fault-tolerant protocol message sent by the opposite-end network element equipment according to the detection message transceiving states of the detection message and the reply message, wherein the first fault-tolerant protocol message and the second fault-tolerant protocol message comprise priority information of the network element equipment of the sending end; when the message receiving and transmitting state is detected to meet the preset message condition, the main network element equipment and the standby network element equipment are selected from the network element equipment and the opposite-end network element equipment according to the message receiving and transmitting state and the priority information, the detection message is actively sent, the data link is judged to be normal only after the reply message is received, and the fault-tolerant protocol message is sent, so that the fault-tolerant protocol message is detected to be normal. The problem of double-main network element equipment caused by network single-side abnormity or heartbeat line faults can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer network technology, and in particular to a device election method, device, electronic device and storage medium. Background Art

[0002] When traditional manufacturers use two network element devices to form a group of logical network element devices, the two network element devices each have one (or more) data message transmission links connected to the switch port. By adding a heartbeat line between the two network element devices, VRRP (Virtual Router Redundancy Protocol) is a fault-tolerant protocol that can transmit VRRP fault-tolerant protocol messages through the heartbeat line or through a shared data message link.

[0003] However, the related technology has a high transmission cost through the heartbeat line, and there is a possibility that when the current main network element device is down, the backup network element device cannot receive the VRRP fault-tolerant protocol message sent by the main network element device through the heartbeat line, a dual-main network element state will occur; although the transmission cost through a shared data message link is lower, there is a possibility of unilateral network anomalies. When the backup network element does not receive the VRRP fault-tolerant protocol message sent by the main network element device, the problem of dual-main network elements will also occur. Summary of the invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide a device election method, apparatus, electronic device and storage medium that overcome the above problems or at least partially solve the above problems.

[0005] According to a first aspect of the present invention, a device election method is provided, which is applied to a network element device, wherein the network element device includes an interface network address, and the method includes: Sending a detection message through the interface network address and receiving a reply message corresponding to the detection message; Sending a first fault-tolerant protocol message to a peer network element device and receiving a second fault-tolerant protocol message sent by the peer network element device according to the detection message sending and receiving status of the detection message and the reply message, wherein the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the network element device at the sending end; When the detection message sending and receiving state meets the preset message condition, a master network element device and a backup network element device are selected from the network element device and the opposite network element device according to the message sending and receiving state and the priority information.

[0006] Optionally, the network element devices transmit data with a switch via a shared data link; The sending of the detection message through the interface network address and receiving a reply message corresponding to the detection message include: Using the interface network address as the source network address and the switch network address as the destination network address; According to a preset detection interval, the detection message is sent from the source network address to the destination network address, and the reply message corresponding to the detection message is received.

[0007] Optionally, the sending a first fault-tolerant protocol message to a peer network element device and receiving a second fault-tolerant protocol message sent by the peer network element device according to the detection message receiving and sending status of the detection message and the reply message includes: Determine the detection message receiving state of the detection message and the reply message, wherein the detection message receiving state includes a first detection message sending and receiving state and a second detection message sending and receiving state; When the first detection message is in the sending and receiving state, sending a first fault-tolerant protocol message to the opposite network element device through a shared data link; In the second detection message sending and receiving state, the number of detection times in which the detection message receiving state is the second detection message sending and receiving state is counted, and the second fault-tolerant protocol message is sent to the opposite network element device through the shared data link according to the numerical relationship between the number of detections and the detection threshold.

[0008] Optionally, when the second detection message is in the transceiver state, counting the number of detections in which the detection message reception state is the second detection message transceiver state, and sending the second fault-tolerant protocol message to the opposite network element device through the shared data link according to the numerical relationship between the number of detections and the detection threshold, includes: When the second detection message is in the receiving and sending state, counting the number of detections in which the detection message receiving state is the receiving and sending state of the second detection message; If the number of detection times is greater than the detection threshold, the second fault-tolerant protocol message with preset priority information is sent to the opposite network element device through the shared data link.

[0009] Optionally, when the detection message sending and receiving state meets the preset message condition, selecting a master network element device and a backup network element device from the network element device and the opposite network element device according to the message sending and receiving state and the priority information includes: When the detection message transceiving state is the first detection message transceiving state, parsing the second fault-tolerant protocol message to obtain priority information of the network element device at the sending end; Comparing the priority information, and selecting a master network element device and a backup network element device from the network element device and the opposite network element device based on the comparison result; When the detection message transceiving state is the second detection message transceiving state and the number of detections is greater than a detection threshold, the opposite network element device is elected as the master network element device.

[0010] Optionally, comparing the priority information, and selecting a master network element device and a backup network element device from the network element device and the opposite network element device based on the comparison result, includes: Comparing the priority of the current network element device with the priority of the opposite network element device; When the priority of the current network element device is higher than the priority of the opposite network element device, electing the current network element device as the master network element device; When the priority of the current network element device is lower than the priority of the opposite network element device, the opposite network element device is elected as the master network element device.

[0011] Optionally, the method further comprises: The master network element device sends an address resolution protocol to the switch through the interface network address according to the maintenance cycle.

[0012] According to a second aspect of the present invention, there is provided a device election apparatus, which is applied to a network element device, wherein the network element device includes an interface network address, and the apparatus includes: A detection message processing module, used for sending a detection message through the interface network address and receiving a reply message corresponding to the detection message; A fault-tolerant protocol message processing module, configured to send a first fault-tolerant protocol message to a peer network element device and receive a second fault-tolerant protocol message sent by the peer network element device according to the detection message receiving and sending status of the detection message and the reply message, wherein the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the network element device at the sending end; The device election module is used to select a master network element device and a backup network element device from the network element device and the opposite network element device according to the message sending and receiving status and the priority information when the detection message sending and receiving status meets the preset message condition.

[0013] According to a third aspect of the present invention, there is provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to implement the steps of the above-mentioned device election method when executing the program stored in the memory.

[0014] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned device election method are implemented.

[0015] The embodiments of the present invention include the following advantages: In an embodiment of the present invention, a detection message is sent and a reply message corresponding to the detection message is received through an interface network address; a first fault-tolerant protocol message is sent to a peer network element device and a second fault-tolerant protocol message sent by the peer network element device is received according to the detection message transceiving status of the detection message and the reply message, the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the sending network element device; when the detection message transceiving status meets the preset message condition, a master network element device and a backup network element device are selected from the network element device and the peer network element device according to the message transceiving status and the priority information, and the detection message is actively sent, and only after receiving the reply message, it is determined that the data link is normal and a fault-tolerant protocol message is sent, thereby avoiding the problem of dual-master network element devices caused by unilateral network abnormalities or heartbeat line failures.

[0016] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] Figure 1 is a flow chart of the heartbeat line solution provided by an embodiment of the present invention; Figure 2 is a flow chart of a shared data link provided by an embodiment of the present invention; Figure 3 is a flowchart of a device election method embodiment of the present invention; Figure 4 It is a structural block diagram of an embodiment of a device election apparatus of the present invention; Figure 5 is a schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention; Figure 6 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.

[0020] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0021] In conjunction with the accompanying drawings, a device election method, apparatus, electronic device and storage medium provided by an embodiment of the present invention are described in detail through specific embodiments and application scenarios.

[0022] VRRP (Virtual Router Redundancy Protocol) is a fault-tolerant protocol, a communication protocol used to avoid single point failures and improve network availability. Through VRRP, two physical network element devices can form a group of logical network element devices, which are in the master and backup states respectively; when the master network element device fails, the backup network element device switches to the master state in time and becomes the new master network element device, sending free ARP (Address Resolution Protocol) to the outside world, and directing network traffic to the new master network element device, thereby avoiding network interruption and unavailability caused by the failure of a single network element device.

[0023] VRRP message: It is a fault-tolerant protocol message, which is constructed based on VRRP and is an IP multicast message transmitted between network devices. The main message fields are ID (Identity document), priority information, and virtual IP (Internet Protocol). The ID usually indicates which service it belongs to; the priority indicates the priority level of the network element configuration. The network element with a higher priority becomes the master network element during VRRP negotiation. A priority of 0 means that the master network element immediately abandons the master network element status. The backup network element must immediately switch to the master network element when receiving a message with a priority of 0; the virtual IP is the IP that this group of logical network elements uniformly provides services to the outside world. Only network element devices in the master network element status are allowed to configure virtual IP. When the network element device switches to the master network element status, it sends a free ARP message of the virtual IP to divert network traffic.

[0024] Reference Figure 1 , shows a flowchart of the heartbeat line solution provided by an embodiment of the present invention, which may specifically include the following contents: When the traditional method uses two network element devices to form a group of logical network element devices, the two network element devices each have one (or more) data links (data link A and data link B) connected to the switch port, and data packets are transmitted through the data links. In addition, a heartbeat line is added between the two network element devices to transmit VRRP packets.

[0025] When the network element device starts, it sends VRRP packets through the heartbeat line. The VRRP packets carry information such as priority, and receive VRRP packets sent by the opposite network element. The network element device with a higher priority becomes the master network element state, and publishes free ARP on the data link. The switch updates the ARP table and forwards the traffic to the master network element device. If the current master network element device is down, the backup network element device cannot receive the VRRP packets sent by the master network element device through the heartbeat line. After the timeout, the backup network element device will actively switch to the master network element state, and generate free ARP on the data link interface. The switch re-updates the ARP table and forwards the traffic to the new master network element device, which leads to the problem of dual master network element devices.

[0026] Reference Figure 2 , shows a flow chart of a shared data link provided by an embodiment of the present invention, which may specifically include the following contents: exist Figure 2The heartbeat line is cancelled, and VRRP messages and data messages are transmitted through shared data link A and shared data link B. Although the disadvantages of the heartbeat line solution such as high cost and heartbeat line failure are avoided, there are still some problems. For example, sharing the same shared data link with data messages will be affected by the network card driver of the shared data link, network card hardware failure, fiber optic socket failure, fiber optic bandwidth reaching bottlenecks, etc., and there will be unilateral network abnormalities. The backup network element does not receive the VRRP message sent by the main network element device, and then actively switches to the main network element state. The original main network element will also maintain the main network element state due to its high priority, so there will also be a situation of dual-main network element devices.

[0027] By comparison, the transmission cost through the heartbeat line is relatively high, and there is a possibility that the current master network element device is down, and the backup network element device cannot receive the VRRP declaration message sent by the master network element device through the heartbeat line, resulting in a dual-master network element state; although the transmission cost through the shared data message link is lower, there is a possibility of unilateral network anomalies. When the backup network element does not receive the VRRP message sent by the master network element device, the dual-master network element problem also occurs.

[0028] Reference Figure 3 , shows a flow chart of a device election method embodiment of the present invention, which may specifically include the following steps: Step 301, sending a detection message through the interface network address and receiving a reply message corresponding to the detection message; In this embodiment, an independent interface IP is configured in the network element device, that is, the interface network address, a detection message is sent to the switch through the interface IP, and a reply message is received after the switch receives the detection message. Therefore, there is no need to publish and divert traffic through free ARP like a virtual IP. Static ARP table entries can be configured on the switch to prevent the interface IP from being mistakenly preempted by other devices.

[0029] In actual applications, an ICMP echo request message can be sent to a switch as a detection message, and an ICMP echo reply message sent by the switch after receiving the detection message can be received as a reply message.

[0030] Step 302: sending a first fault-tolerant protocol message to a peer network element device and receiving a second fault-tolerant protocol message sent by the peer network element device according to the detection message receiving and sending status of the detection message and the reply message, wherein the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the network element device at the sending end; The detection message receiving and sending status includes: receiving an ICMP echo reply message from the switch after the current network element device sends an ICMP echo request message to the switch, and not receiving an ICMP echo reply message from the switch after the current network element device sends an ICMP echo request message to the switch; If the current network element device receives an ICMP echo reply message from the switch after sending an ICMP echo request message to the switch, a VRRP message is sent to the opposite network element device, and the VRRP message sent to the opposite network element device is used as the first fault-tolerant protocol message; if a VRRP message sent by the opposite network element device is received, the VRRP message received from the opposite network element device is used as the second fault-tolerant protocol message.

[0031] In actual applications, the most important message fields of VRRP messages include ID, priority information, and virtual IP. Therefore, the priority of the current network element device and the opposite network element device can be determined by the priority information in the first fault-tolerant protocol message and the second fault-tolerant protocol message.

[0032] Step 303, when the detection message sending and receiving state meets the preset message condition, select a master network element device and a backup network element device from the network element device and the opposite network element device according to the message sending and receiving state and the priority information.

[0033] After the current network element device sends an ICMP echo request message to the switch and receives an ICMPecho reply message from the switch, the current network element device sends a VRRP message to the opposite network element device and receives the VRRP message sent by the opposite network element device. The VRRP message is then parsed to obtain the priority information corresponding to the VRRP message. The primary network element device and the backup network element device are then selected from the current and opposite network element devices based on the priority information of the current network element device and the priority information of the opposite network element device. The priority information represents the priority of the network element device that sends the VRRP message.

[0034] Specifically, determine whether the priority of the current network element device is higher than that of the opposite network element device. If so, elect or maintain the current network element device as the main network element device and elect the opposite network element device as the backup network element device. Otherwise, elect the opposite network element device as the main network element device.

[0035] In an embodiment of the present invention, a detection message is sent and a reply message corresponding to the detection message is received through an interface network address; a first fault-tolerant protocol message is sent to a peer network element device and a second fault-tolerant protocol message sent by the peer network element device is received according to the detection message transceiving status of the detection message and the reply message, the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the sending network element device; when the detection message transceiving status meets the preset message condition, a master network element device and a backup network element device are selected from the network element device and the peer network element device according to the message transceiving status and the priority information, and the detection message is actively sent, and only after receiving the reply message, it is determined that the data link is normal and a fault-tolerant protocol message is sent, thereby avoiding the problem of dual-master network element devices caused by unilateral network abnormalities or heartbeat line failures.

[0036] In one embodiment of the present invention, the network element devices transmit data with a switch via a shared data link; The sending of the detection message through the interface network address and receiving a reply message corresponding to the detection message include: Using the interface network address as the source network address and the switch network address as the destination network address; According to a preset detection interval, the detection message is sent from the source network address to the destination network address, and the reply message corresponding to the detection message is received.

[0037] In the embodiment of the present invention, the current network element device and the opposite network element device transmit data with the switch via a shared data link. The current network element device and the opposite network element device use their own interface IP as the source IP and the switch IP as the destination IP to send ICMP echo request messages. Only after receiving the ICMP echo reply message from the switch can the network element device send a VRRP message to the opposite network element device to participate in the device election. Only after receiving the corresponding reply message can it be determined that the shared data link is normal, and then the VRRP message is sent to the opposite network element device and the VRRP message is received from the opposite network element device according to the preset detection interval.

[0038] By setting up a detection mechanism, you can avoid the problem of dual-active network element devices caused by network unilateral abnormalities, heartbeat line failures, or the heartbeat line's inability to sense data link changes.

[0039] In an embodiment of the present invention, sending a first fault-tolerant protocol message to a peer network element device and receiving a second fault-tolerant protocol message sent by the peer network element device according to the detection message receiving and sending status of the detection message and the reply message include: Determine the detection message receiving state of the detection message and the reply message, wherein the detection message receiving state includes a first detection message sending and receiving state and a second detection message sending and receiving state; When the first detection message is in the sending and receiving state, sending a first fault-tolerant protocol message to the opposite network element device through a shared data link; In the second detection message sending and receiving state, the number of detection times in which the detection message receiving state is the second detection message sending and receiving state is counted, and the second fault-tolerant protocol message is sent to the opposite network element device through the shared data link according to the numerical relationship between the number of detections and the detection threshold.

[0040] Specifically, an ICMP echo reply message received from the switch after the current network element device sends an ICMP echo request message to the switch is set to the first detection message sending and receiving state, and an ICMP echo reply message not received from the switch after the current network element device sends an ICMP echo request message to the switch is set to the second detection message sending and receiving state.

[0041] In the embodiment of the present invention, different measures are taken by judging whether the detection message receiving and sending state is in the first detection message receiving and sending state or the second detection message receiving and sending state.

[0042] When it is determined that the detection message sending and receiving state is the first detection message sending and receiving state, the shared data link is normal at this time. Sending a VRRP message to the opposite network element device through the shared data link can ensure that the opposite network element device can receive the VRRP message, and there will be no unilateral abnormality in the network. When it is determined that the detection message sending and receiving state is the second detection message sending and receiving state, the shared data link is abnormal at this time. At this time, it is necessary to count the number of detection times in which the detection message receiving state is in the second detection message sending and receiving state; then, according to the numerical relationship between the detection number and the detection threshold, the specific content of the VRRP message sent to the opposite network element device through the shared data link is determined based on the judgment result.

[0043] The abnormal severity level of the shared data link can be determined by the numerical relationship between the detection times and the detection threshold. When the abnormal severity level of the shared data link is high, necessary measures can be taken to avoid the problem of dual-active network element devices.

[0044] In an embodiment of the present invention, when the second detection message is in the transceiver state, counting the number of detections in which the detection message receiving state is the second detection message transceiver state, and sending the second fault-tolerant protocol message to the opposite network element device through the shared data link according to the numerical relationship between the number of detections and the detection threshold, includes: When the second detection message is in the receiving and sending state, counting the number of detections in which the detection message receiving state is the receiving and sending state of the second detection message; If the number of detection times is greater than the detection threshold, the second fault-tolerant protocol message with preset priority information is sent to the opposite network element device through the shared data link.

[0045] Specifically, according to the preset detection interval, an ICMP echo request message is sent to the switch and an ICMP echo reply message is received from the switch at a regular interval.

[0046] When the detection message sending and receiving state is the second detection message sending and receiving state, the number of detection times is recorded as 1. Then, according to the preset detection interval, the ICMP echo request message is resent to the switch and the ICMP echo reply message replied by the switch is received. If the detection message sending and receiving state is still the second detection message sending and receiving state at this time, the number of detection times is recorded as 2. Similarly, according to the preset detection interval, the ICMP echo request message is resent to the switch and the ICMP echo reply message replied by the switch is received, and the final number of detection times is counted.

[0047] If the detection message sending and receiving state changes to the first detection message sending and receiving state after the ICMP echo request message is sent to the switch for the third time and the ICMP echo reply message is received from the switch, the detection times are reset to zero and the detection times are counted again, where the detection times represent the number of times the detection message sending and receiving state is the second detection message sending and receiving state.

[0048] When the number of detections is greater than the detection threshold, it means that a unilateral network abnormality may have occurred in the shared data link. In this case, it is necessary to send a VRRP message with a priority of 0 to the peer network element device so that the peer network element can switch to the primary network element device as soon as possible to avoid the problem of dual-primary network element devices caused by unilateral network abnormalities.

[0049] For example, if the current network element device is in the master network element device state before the device election, the current network element device periodically sends VRRP packets to the peer network element device. Before sending VRRP packets, it must first send ICMP echo request packets to the switch. If it receives the ICMP echo reply packet from the switch, it can send VRRP packets. If an ICMP echo request message is sent to the switch and no ICMP echo reply message is received from the switch, and this is repeated 5 times according to the preset detection interval and no ICMP echo reply message is received from the switch, it is considered that the current shared data link is in a detection abnormal state, and the current network element device sends a VRRP message with a priority of 0 to the opposite network element device and automatically switches to the standby network element device state. The purpose of the current network element device sending a VRRP message with a priority of 0 to the opposite network element device is to make the opposite network element switch to the master network element device state as soon as possible.

[0050] If the current network element device is in the backup network element device state before the device election, after receiving the VRRP message sent by the opposite network element device, if the parsing shows that the priority of the opposite network element device is higher than that of the current network element device, the number of consecutive disconnections of the opposite network element is reset to 0, and the current network element device is elected as the backup network element device, and the opposite network element device is elected as the main network element device; if no VRRP message from the opposite end is received within the preset detection interval, the number of consecutive disconnections of the opposite network element device is increased by 1; if no VRRP message from the opposite end is received for 5 consecutive times, or the opposite network element device announces a VRRP message with a priority of 0, first send an ICMP echo request message to the switch to determine whether the ICMP echo reply message of the switch is received. If the ICMP echo reply message of the switch can be received, If the switch receives a reply message, the current network element device immediately switches to the primary network element device and sends a free ARP broadcast message of the virtual IP to the switch through the interface IP according to the maintenance cycle. After receiving the free ARP, the switch forwards the message with the destination IP as the virtual IP to the primary network element device to avoid traffic abnormality caused by aging of the switch's ARP table entries.

[0051] In an embodiment of the present invention, when the detection message sending and receiving state meets the preset message condition, selecting a master network element device and a backup network element device from the network element device and the opposite network element device according to the message sending and receiving state and the priority information includes: When the detection message transceiving state is the first detection message transceiving state, parsing the second fault-tolerant protocol message to obtain priority information of the network element device at the sending end; Comparing the priority information, and selecting a master network element device and a backup network element device from the network element device and the opposite network element device based on the comparison result; When the detection message transceiving state is the second detection message transceiving state and the number of detections is greater than a detection threshold, the opposite network element device is elected as the master network element device.

[0052] In actual applications, if the detection message receiving and sending state is the first detection message receiving and sending state, the shared data link is normal at this time, and the received VRRP message can be directly parsed to obtain the priority of the opposite network element device, and then compared with the priority of the current network element device, and the master network element device and the backup network element device are selected from the current network element device and the opposite network element device based on the comparison result; If the detection message sending and receiving status is the second detection message sending and receiving status, the shared data link is abnormal at this time. When the number of detections is greater than the detection threshold, it means that there may be unilateral network abnormalities. In order to avoid the situation where the network element device may be in a normal state of sending messages but abnormal state of receiving messages due to application BUG (program error), network card driver abnormality, network card hardware failure, switch bandwidth limitation, etc., and cannot receive the messages sent by the opposite network element device in a timely and accurate manner, which leads to the situation of dual-master network element devices, the opposite network element device is elected as the master network element device. Optionally, before electing the opposite network element device as the main network element device, it is necessary to determine whether the opposite network element device can send an ICMP echo request message to the switch and then receive an ICMP echo reply message from the switch, that is, to determine whether the opposite network element device is in the first detection message sending and receiving state. If the opposite network element device is in the first detection message sending and receiving state, the opposite network element device can be elected as the main network element device; otherwise, an alarm prompt is issued to the user to remind the user to deal with the network abnormality in time.

[0053] In an embodiment of the present invention, comparing the priority information and selecting a master network element device and a backup network element device from the network element device and the peer network element device based on the comparison result includes: Comparing the priority of the current network element device with the priority of the opposite network element device; When the priority of the current network element device is higher than the priority of the opposite network element device, electing the current network element device as the master network element device; When the priority of the current network element device is lower than the priority of the opposite network element device, the opposite network element device is elected as the master network element device.

[0054] In this embodiment, when the detection message sending and receiving state is the first detection message sending and receiving state, the VRRP message received from the opposite network element device can be directly parsed to obtain the priority of the opposite network element device, and then compared with the priority of the current network element device. If the priority of the current network element device is higher than the priority of the opposite network element device, the current network element device is elected as the main network element device, wherein if the current network element device is in the main network element device state before the election, the main network element device state is maintained; if the priority of the current network element device is lower than the priority of the opposite network element device, the opposite network element device is elected as the main network element device.

[0055] In one embodiment of the present invention, the method further comprises: The master network element device sends an address resolution protocol to the switch through the interface network address according to the maintenance cycle.

[0056] Specifically, the primary network element device needs to send a free ARP broadcast message of the virtual IP to the switch through the interface IP according to the maintenance cycle. After receiving the free ARP, the switch forwards the message with the destination IP as the virtual IP to the primary network element device to avoid traffic abnormalities caused by aging of the switch's ARP table entries.

[0057] In actual applications, the maintenance cycle can include changes in the main network element device or preset detection intervals. When the main network element device changes or according to the preset detection interval, a free ARP broadcast message of the virtual IP is sent to the switch through the interface IP. After receiving the free ARP, the switch forwards the message with the destination IP as the virtual IP to the main network element device. Among them, the maintenance cycle can be set according to the device election and network status, and this application does not limit this.

[0058] In an embodiment of the present invention, a detection message is sent and a reply message corresponding to the detection message is received through an interface network address; a first fault-tolerant protocol message is sent to a peer network element device and a second fault-tolerant protocol message sent by the peer network element device is received according to the detection message transceiving status of the detection message and the reply message, the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the sending network element device; when the detection message transceiving status meets the preset message condition, a master network element device and a backup network element device are selected from the network element device and the peer network element device according to the message transceiving status and the priority information, and the detection message is actively sent, and only after receiving the reply message, it is determined that the data link is normal and a fault-tolerant protocol message is sent, thereby avoiding the problem of dual-master network element devices caused by unilateral network abnormalities or heartbeat line failures.

[0059] Reference Figure 4 , shows a structural block diagram of an embodiment of a device election apparatus of the present application, which may specifically include the following modules: A detection message processing module 401, used for the detection message processing module, is used to send a detection message through the interface network address and receive a reply message corresponding to the detection message; A fault-tolerant protocol message processing module 402 is used to send a first fault-tolerant protocol message to a peer network element device and receive a second fault-tolerant protocol message sent by the peer network element device according to the detection message receiving and sending status of the detection message and the reply message, wherein the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the network element device at the sending end; The device election module 403 is used to select a master network element device and a backup network element device from the network element device and the opposite network element device according to the message sending and receiving status and the priority information when the detection message sending and receiving status meets the preset message condition.

[0060] In an embodiment of the present application, the automatic driving device provided in the embodiment of the present application sends a detection message and receives a reply message corresponding to the detection message through an interface network address; sends a first fault-tolerant protocol message to the opposite network element device and receives a second fault-tolerant protocol message sent by the opposite network element device according to the detection message sending and receiving status of the detection message and the reply message, and the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the sending network element device; when the detection message sending and receiving status meets the preset message conditions, selects the main network element device and the backup network element device from the network element device and the opposite network element device according to the message sending and receiving status and the priority information, and actively sends the detection message, and only after receiving the reply message, it is determined that the data link is normal, and sends the fault-tolerant protocol message, so as to avoid the problem of dual-main network element devices caused by unilateral network abnormalities or heartbeat line failures.

[0061] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0062] In addition, refer to Figure 5 An embodiment of the present invention also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned device selection method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0063] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned device election method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0064] An embodiment of the present invention also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned device selection method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0065] Figure 5 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.

[0066] The electronic device 600 includes but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, a processor 810, and a power supply 811. Those skilled in the art will appreciate that Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.

[0067] It should be understood that in the embodiment of the present invention, the radio frequency unit 601 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 610 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 601 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 601 can also communicate with the network and other devices through a wireless communication system.

[0068] The electronic device provides users with wireless broadband Internet access through the network module 602, such as helping users to send and receive emails, browse web pages, and access streaming media.

[0069] The audio output unit 603 can convert the audio data received by the RF unit 601 or the network module 602 or stored in the memory 609 into an audio signal and output it as sound. Moreover, the audio output unit 603 can also provide audio output related to a specific function performed by the electronic device 600 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 603 includes a speaker, a buzzer, a receiver, etc.

[0070] The input unit 604 is used to receive audio or video signals. The input unit 604 may include a graphics processor (GPU) 6041 and a microphone 6042. The graphics processor 6041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 606. The image frame processed by the graphics processor 6041 can be stored in the memory 609 (or other storage medium) or sent via the radio frequency unit 601 or the network module 602. The microphone 6042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 601 in the case of a telephone call mode.

[0071] The electronic device 600 also includes at least one sensor 605, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 6061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 6061 and / or the backlight when the electronic device 600 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 605 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.

[0072] The display unit 606 is used to display information input by the user or information provided to the user. The display unit 606 may include a display panel 6061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0073] The user input unit 607 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 607 includes a touch panel 6071 and other input devices 6072. The touch panel 6071, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by users using fingers, styluses, or any other suitable objects or accessories on or near the touch panel 6071). The touch panel 6071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact point coordinates, and then sends it to the processor 810, receives the command sent by the processor 610 and executes it. In addition, the touch panel 6071 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 6071, the user input unit 607 may also include other input devices 6072. Specifically, other input devices 6072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.

[0074] Furthermore, the touch panel 6071 may be overlaid on the display panel 6061. When the touch panel 6071 detects a touch operation on or near it, it is transmitted to the processor 610 to determine the type of touch event. Subsequently, the processor 810 provides corresponding visual output on the display panel 6061 according to the type of touch event. Figure 5 In the figure, the touch panel 6071 and the display panel 6061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 6071 and the display panel 6061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.

[0075] The interface unit 608 is an interface for connecting an external device to the electronic device 600. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 608 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 600 or may be used to transmit data between the electronic device 600 and an external device.

[0076] The memory 609 can be used to store software programs and various data. The memory 609 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 609 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0077] The processor 810 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 609 and calling data stored in the memory 609, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 810 may include one or more processing units; preferably, the processor 610 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 610.

[0078] The electronic device 600 may also include a power supply 611 (such as a battery) for supplying power to various components. Preferably, the power supply 611 may be logically connected to the processor 610 via a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.

[0079] In addition, the electronic device 600 includes some functional modules not shown, which will not be described in detail here.

[0080] like Figure 6 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 701 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the device election method described in the above embodiment.

[0081] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0082] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0083] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.

[0084] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0085] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0086] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0087] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0088] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0089] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or optical disk, etc., various media that can store program codes.

[0090] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A device election method, characterized in that: Applied to a network element device, the network element device includes an interface network address, and the method includes: Sending a detection message through the interface network address and receiving a reply message corresponding to the detection message; Sending a first fault-tolerant protocol message to a peer network element device and receiving a second fault-tolerant protocol message sent by the peer network element device according to the detection message sending and receiving status of the detection message and the reply message, wherein the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the network element device at the sending end; When the detection message sending and receiving state meets the preset message condition, a master network element device and a backup network element device are selected from the network element device and the opposite network element device according to the message sending and receiving state and the priority information.

2. The method according to claim 1, characterized in that The network element devices transmit data via a shared data link with the switch; The sending of the detection message through the interface network address and receiving a reply message corresponding to the detection message include: Using the interface network address as the source network address and the switch network address as the destination network address; According to a preset detection interval, the detection message is sent from the source network address to the destination network address, and the reply message corresponding to the detection message is received.

3. The method according to claim 1, characterized in that The sending of a first fault-tolerant protocol message to a peer network element device and receiving a second fault-tolerant protocol message sent by the peer network element device according to the detection message receiving and sending status of the detection message and the reply message includes: Determine the detection message receiving state of the detection message and the reply message, wherein the detection message receiving state includes a first detection message sending and receiving state and a second detection message sending and receiving state; When the first detection message is in the sending and receiving state, sending a first fault-tolerant protocol message to the opposite network element device through a shared data link; In the second detection message sending and receiving state, the number of detection times in which the detection message receiving state is the second detection message sending and receiving state is counted, and the second fault-tolerant protocol message is sent to the opposite network element device through the shared data link according to the numerical relationship between the number of detections and the detection threshold.

4. The method according to claim 3, characterized in that When the second detection message is in the transceiver state, counting the number of detections in which the detection message receiving state is the second detection message transceiver state, and sending the second fault-tolerant protocol message to the opposite network element device through the shared data link according to the numerical relationship between the number of detections and the detection threshold, includes: When the second detection message is in the receiving and sending state, counting the number of detections in which the detection message receiving state is the receiving and sending state of the second detection message; If the number of detection times is greater than the detection threshold, the second fault-tolerant protocol message with preset priority information is sent to the opposite network element device through the shared data link.

5. The method according to claim 1, characterized in that: When the detection message sending and receiving state meets the preset message condition, selecting a master network element device and a backup network element device from the network element device and the opposite network element device according to the message sending and receiving state and the priority information, including: When the detection message transceiving state is the first detection message transceiving state, parsing the second fault-tolerant protocol message to obtain priority information of the network element device at the sending end; Comparing the priority information, and selecting a master network element device and a backup network element device from the network element device and the opposite network element device based on the comparison result; When the detection message transceiving state is the second detection message transceiving state and the number of detections is greater than a detection threshold, the opposite network element device is elected as the master network element device.

6. The method according to claim 5, characterized in that The comparing the priority information and selecting a master network element device and a backup network element device from the network element device and the opposite network element device based on the comparison result includes: Comparing the priority of the current network element device with the priority of the opposite network element device; When the priority of the current network element device is higher than the priority of the opposite network element device, electing the current network element device as the master network element device; When the priority of the current network element device is lower than the priority of the opposite network element device, the opposite network element device is elected as the master network element device.

7. The method according to claim 1, characterized in that The method further comprises: The master network element device sends an address resolution protocol to the switch through the interface network address according to the maintenance cycle.

8. A device election device, characterized in that: Applied to a network element device, the network element device includes an interface network address, and the device includes: A detection message processing module, used for sending a detection message through the interface network address and receiving a reply message corresponding to the detection message; A fault-tolerant protocol message processing module, configured to send a first fault-tolerant protocol message to a peer network element device and receive a second fault-tolerant protocol message sent by the peer network element device according to the detection message receiving and sending status of the detection message and the reply message, wherein the first fault-tolerant protocol message and the second fault-tolerant protocol message include priority information of the network element device at the sending end; The device election module is used to select a master network element device and a backup network element device from the network element device and the opposite network element device according to the message sending and receiving status and the priority information when the detection message sending and receiving status meets the preset message condition.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 7 when executing the program stored in the memory.

10. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • VRRP (Virtual Router Redundancy Protocol) access method, device and system, as well as VRRP routing equipment

    CN101764744A

  • Method for network traffic recovery and routing device

    CN102724073A

  • Method and application for breaking ring in VRRP (Virtual Router Redundancy Protocol) scene

    CN114244770A

  • DHCP-based MLAG dynamic double-master detection method, apparatus and device, and medium

    CN115208854A

  • Communication method and related equipment

    CN118301023A