Master-slave switchover control method and device, electronic equipment and medium

By periodically synchronizing TCP and ACK packets during the primary/standby switchover process and compensating according to the packet relationships, the problem of TCP connection interruption after the standby main control board becomes the primary main control board is solved, thus achieving the stability and continuity of the TCP connection.

CN116264536BActive Publication Date: 2026-01-06CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111520710.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-13
Publication Date
2026-01-06
Estimated Expiration
2041-12-13

AI Technical Summary

Technical Problem

During the primary/standby switchover process, after the standby main control board becomes the primary main control board, it is unable to acknowledge newly received TCP packets, resulting in the interruption of the TCP connection.

Method used

By periodically receiving TCP packets and ACK packets synchronized from the primary control board, the backup control board is promoted to the primary control board during primary/standby switchover. The first ACK packet sent by the primary control board after the switchover is the last ACK packet stored by the backup control board before the switchover, and compensation is performed based on the relationship between the first received TCP packet and the first sent ACK packet.

Benefits of technology

It effectively prevents TCP connection interruptions, improves the success rate of primary/standby switchover, and ensures the continuity of subsequent TCP packet transmission. It is suitable for both active and passive switchover scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116264536B_ABST
    Figure CN116264536B_ABST
Patent Text Reader

Abstract

The present disclosure provides a kind of master backup switching control method, device, electronic equipment and medium, it is related to communication technical field.The method comprises: receiving transmission control protocol (TCP) message and acknowledgement character (ACK) message transmitted by main control board synchronously in time;When master backup switching, control backup main control board to be main control board, the ACK message first sent by main control board after switching is the ACK message last stored before main control board switching;According to the relationship between the TCP message first received by main control board and the ACK message first sent, to determine whether to compensate ACK message to be sent.The present disclosure provides a kind of master backup switching control method, device, electronic equipment and medium, after master backup switching, the ACK message first sent by main control board after switching is the ACK message last stored before backup main control board switching, according to the TCP message first received and the ACK message first sent, determine whether to compensate TCP message, guarantee the continuity of TCP connection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of communication technology, and in particular to a primary / backup switching control method, apparatus, electronic device, and medium. Background Technology

[0002] Modern information society is increasingly reliant on the internet, leading to higher demands for network reliability and availability, particularly in fields such as security, finance, and data centers. Networks are built from related equipment and transmission lines. As the adoption of IP (Internet Protocol, the protocol for interconnecting networks) increases, the proportion of data network equipment (including fixed and mobile networks) is also rising, thus placing ever higher demands on the reliability and availability of this data network equipment.

[0003] Data network equipment consists of hardware and software running on top of it. To enhance reliability and availability, core network equipment is typically deployed in a primary / backup configuration. Core high-capacity switching equipment often employs a dual-master control setup. In some applications, several devices are grouped into a virtual system, with each device acting as a primary / backup for the other. To ensure uninterrupted service when the primary device fails, the software between the primary and backup master control boards, or between the primary and backup devices in a virtual system, needs hot-swap functionality. This is typically achieved using NSR (Non-Stopping Routing) technology. NSR is a high-reliability technology in data network equipment and forms the basis for hot migration. Its implementation relies on data synchronization between the primary and backup master control boards. When the primary master control board fails, a primary / backup switchover occurs, and the backup master control board comes online using synchronized data, ensuring uninterrupted routing and forwarding.

[0004] Commonly used protocols such as BGP (Border Gateway Protocol) and LDP (Label Distribution Protocol) use TCP (Transmission Control Protocol) as the transport layer protocol. The prerequisite for uninterrupted routing and forwarding is that the TCP connection is not interrupted during hot migration and primary / standby switchover.

[0005] However, in related technologies, due to the time interval between the synchronization of data between the primary and backup main control boards, the TCP packets stored on the backup and primary main control boards may differ regardless of the data synchronization method used. Therefore, after the backup main control board becomes the primary main control board, it cannot acknowledge newly received TCP packets, resulting in the interruption of the TCP connection.

[0006] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0007] This disclosure provides a primary / standby switchover control method, apparatus, electronic device, and medium, which at least to some extent overcomes the problem that the primary / standby switchover method provided in the related art may cause TCP connection interruption.

[0008] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part by practice of this disclosure.

[0009] According to one aspect of this disclosure, a primary / standby switchover control method is provided, comprising:

[0010] It periodically receives TCP packets and ACK packets synchronously transmitted from the main control board.

[0011] When the primary and backup are switched over, the backup main control board is promoted to the primary main control board. The first ACK message sent by the primary main control board after the switchover is the last ACK message stored by the backup main control board before the switchover.

[0012] When the switched-off primary control board receives a TCP packet, it determines whether to compensate the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the switched-off primary control board.

[0013] In one embodiment of this disclosure, determining whether to compensate for the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the primary control board after the switchover includes:

[0014] When the sequence number of the first received TCP packet is greater than the acknowledgment number of the first sent ACK packet, determine whether the local device has already received the TCP packet.

[0015] If not received, the acknowledgment number of the ACK packet to be sent is compensated, and the compensated ACK packet is sent.

[0016] In one embodiment of this disclosure, the acknowledgment number of the compensated ACK packet is assigned the sum of the sequence number and data length of the TCP packet.

[0017] In one embodiment of this disclosure, the method further includes:

[0018] If the local device has already received the TCP packet, then it sends an ACK packet corresponding to the TCP packet.

[0019] In one embodiment of this disclosure, determining whether to compensate for the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the primary control board after the switchover includes:

[0020] When the sequence number of the first received TCP packet is equal to the acknowledgment number of the first sent ACK packet, the TCP connection between the switched primary control board and the peer device is normal, and the ACK packet corresponding to the TCP packet is sent.

[0021] In one embodiment of this disclosure, determining whether to compensate for the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the primary control board after the switchover includes:

[0022] If the sequence number of the first received TCP packet is less than the acknowledgment number of the first sent ACK packet, the first received TCP packet is discarded.

[0023] When a TCP packet is received again, an ACK packet corresponding to the TCP packet is sent.

[0024] In one embodiment of this disclosure, when a primary / standby switchover occurs, the method of controlling the standby main control board to become the primary main control board further includes:

[0025] Set the Timestamp Echo stored on the local device to 0 to determine whether the primary control board after the switchover is sending an ACK packet for the first time or receiving a TCP packet for the first time.

[0026] According to another aspect of this disclosure, a primary / standby switchover control device is provided, comprising:

[0027] The data synchronization module is used to periodically receive TCP packets and ACK packets from the main control board for synchronous transmission.

[0028] The primary / standby switchover module is used to control the standby main control board to become the primary main control board when the primary / standby switchover occurs. The first ACK message sent by the primary main control board after the switchover is the last ACK message stored by the standby main control board before the switchover.

[0029] The message compensation module is used to determine whether to compensate the ACK message to be sent when the primary control board receives a TCP message after the switchover, based on the relationship between the first TCP message received and the first ACK message sent by the primary control board after the switchover.

[0030] According to another aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the above-described primary / standby switchover control method by executing the executable instructions.

[0031] According to another aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described primary / standby switchover control method.

[0032] The embodiments of this disclosure provide a primary / standby switchover control method, apparatus, electronic device, and medium. The primary control board and the standby control board periodically synchronize TCP connection information. After a primary / standby switchover, the standby control board becomes the primary control board. At this time, the first ACK packet sent by the primary control board is the last ACK packet stored by the standby control board before the switchover. Based on the first received TCP packet and the first sent ACK packet, it is determined whether to compensate for the ACK packet to be sent, effectively preventing the TCP connection between the local and remote devices from being interrupted, thereby improving the success rate of TCP connection primary / standby switchover without affecting subsequent TCP packet transmission. This primary / standby switchover control method is simple and can be used in any TCP protocol stack that requires primary / standby switchover or hot backup. It can handle both active and passive switchover scenarios and has a wide range of applications.

[0033] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0034] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0035] Figure 1 This diagram illustrates the system architecture of a network device according to an embodiment of the present disclosure.

[0036] Figure 2 This diagram illustrates a primary / standby switchover control method according to an embodiment of the present disclosure.

[0037] Figure 3 This diagram illustrates a primary / standby switchover control method according to yet another embodiment of the present disclosure.

[0038] Figure 4 The timing diagram of TCP packet transmission before and after primary / standby switchover in the embodiments of this disclosure is shown.

[0039] Figure 5 This illustration shows a timing diagram of TCP packet transmission before and after primary / standby switchover in yet another embodiment of this disclosure;

[0040] Figure 6 This diagram illustrates a primary / standby switchover control device according to an embodiment of the present disclosure.

[0041] Figure 7 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0042] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0043] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0044] Figure 1 A system architecture diagram of an exemplary network device that can be applied to the primary / standby switchover control method or primary / standby switchover control device in the embodiments of this disclosure is shown.

[0045] like Figure 1 As shown, network devices may include rack-mounted local devices 10 with dual master controllers, peer devices 20 in a stacked system, and devices in a virtual switching system. These devices may be switches, routers, PON (Passive Optical Network) central office equipment, PTN (Packet Transport Network) equipment, or other similar devices.

[0046] The network device's software system includes operating system software, BSP (Board Support Package) / driver software, software interface management software, Layer 2 protocol modules, TCP / IP (Transmission Control Protocol / Internet Protocol) stack modules, Layer 3 software modules, and network management modules. The network device hardware and operating system kernel form the hardware and software foundation of the network device. Hardware drivers, TCP / IP protocol stacks, Layer 2 protocol modules, Layer 3 protocol modules, and network management modules all depend on this hardware and software foundation. Hardware drivers are used to enable the hardware to function properly and include at least serial port drivers, network port drivers, or drivers for some hardware chips. The software interface management module is responsible for managing the parameter configuration of physical ports, trunk (aggregation) interfaces, VLAN (Virtual Local Area Network) interfaces, and IP interfaces. It also receives data from these interfaces and passes it to upper-layer software, or receives data from upper-layer software and sends it to the hardware through these interfaces.

[0047] The TCP stack module handles the sending and receiving of IP network data, including IP-based protocol data and data based on UDP (User Datagram Protocol) or TCP. The Layer 2 protocol module refers to the Layer 2 protocols used in network devices, such as STP (Spanning Tree Protocol). Each Layer 2 protocol receives or sends protocol data to the interface management layer and completes its corresponding function according to its own protocol flow. The Layer 3 protocol module refers to the Layer 3 protocols used in network devices, such as BGP (Border Gateway Protocol) routing protocol. Each Layer 3 protocol receives or sends protocol data to the interface management layer through sockets and completes its corresponding function according to its own protocol flow.

[0048] In the TCP protocol, it is stipulated that the message includes a sequence number and an acknowledgment number field. When the sender sends data to the receiver, it uses a TCP message. The TCP message includes a sequence number field to mark the order of the data. When the receiver receives the TCP message, it sends an ACK message with an acknowledgment number field to confirm that the data has been received. Due to security considerations and the characteristics of the TCP sliding window, the sender will not resend the data that the receiver has already acknowledged as received.

[0049] Furthermore, the TCP protocol also specifies that a timestamp field and a timestamp echo field can be defined in the message. The timestamp field is used to indicate the time when the TCP message was sent, and the timestamp echo field is used to indicate the timestamp field in the last correctly received TCP message.

[0050] If the receiver and sender communicate via TCP, and the sender sends a segment to the receiver, then:

[0051] The Timestamp field stores the following information: When the sender sends message S1 to the receiver, the Timestamp in message S1 stores the kernel time Ta1 when the sender sends message S1.

[0052] The Timestamp Echo field stores the following information: the receiver receives message S1 and sends an ACK message S2 containing an acknowledgment number to the sender. In message S2, the Timestamp is the kernel time Tb of the sender at this time, while the TimestampEcho field is the kernel time Ta1 of the sender when sending message S1, which is parsed from message S1.

[0053] Round-trip time (RTT) can be calculated using a timestamp, as shown in the following calculation:

[0054] When the sending end receives the ACK packet S2 sent by the receiving end, the kernel time of the sending end is Ta2. The sending end can parse the sending time of the ACK packet S2 from the Timestamp Echo option of the ACK packet S2 and find that it is Ta1. Therefore, the round-trip time RTT = the time of receiving the ACK packet S2 - the time of sending the packet S1 = Ta2 - Ta1.

[0055] Both Ta2 and Ta1 originate from the sending kernel, so no clock synchronization is required at either end of the TCP connection.

[0056] Specifically, in this application, the local device 10 includes a primary main control board 101 and a backup main control board 102, and communicates with the peer device 20 via a TCP connection. During normal operation, the primary main control board 101 establishes a TCP connection with the peer device 20. When the primary main control board 10 actively switches over or is passively switched over due to a fault, the backup main control board 102 becomes the primary main control board, replacing the original primary main control board 102, and establishes a TCP connection with the peer device 20.

[0057] To address the issue of TCP connection interruption during hot migration and master / slave switchover, where discrepancies may exist between the primary and backup master control boards 101 and 102, causing the backup board 102 to fail to acknowledge newly received TCP packets after becoming the primary board, this disclosure provides a solution that periodically synchronizes TCP connection information between the primary and backup master control boards. After the switchover, the backup board becomes the primary board, and the first ACK packet sent by the primary board is the last ACK packet stored before the switchover. Based on the relationship between the first received TCP packet and the first sent ACK packet, it determines whether to compensate for the ACK packet to be sent, effectively preventing TCP connection interruption between the local and remote devices, thereby improving the success rate of TCP connection master / slave switchover without affecting subsequent TCP packet transmission.

[0058] The following detailed description of this exemplary implementation method is provided in conjunction with the accompanying drawings and embodiments.

[0059] First, this disclosure provides a primary / standby switchover control method, which can be executed by any system with computing power.

[0060] Figure 2 This diagram illustrates a primary / standby switchover control method according to an embodiment of the present disclosure. Figure 2 As shown in the embodiments of this disclosure, the primary / standby switchover control method includes the following steps:

[0061] S202. Periodically receive TCP packets and ACK packets synchronously transmitted by the main control board.

[0062] Specifically, the primary control board encapsulates the configuration information of the software in the system that needs to implement synchronization (such as the TCP / IP stack module and the TCP application module) and the current status information of the TCP protocol into a synchronization packet, and sends it to the backup control board through the primary-backup synchronization communication module. The current status information includes TCP packets and ACK packets generated by the primary control board and the peer device through the TCP connection. When the backup control board receives the configuration information and status information, it establishes the corresponding data structure and updates the data periodically.

[0063] S204. When the main and backup are switched over, the backup main control board is promoted to the main main control board. The first ACK message sent by the main main control board after the switchover is the last ACK message stored by the backup main control board before the switchover.

[0064] In this embodiment, a passive switchover will be initiated when the primary control board experiences a software or hardware failure; alternatively, an active switchover will be implemented as needed. The timing and implementation method of the switchover between the primary and backup control boards are existing technologies and will not be elaborated upon here.

[0065] When the backup main control board is promoted to the primary main control board, the primary main control board at this time is the original backup main control board. When the primary main control board after the switchover receives a TCP packet transmitted by the peer device, the first ACK packet sent by the primary main control board to the peer device after the switchover is the last ACK packet stored by the backup main control board before the switchover. By comparing the relationship between the ACK packet and the TCP packet, it is determined whether there are any cases of missed transmission, duplicate transmission, or incorrect transmission of TCP packets.

[0066] Specifically, in order to determine whether the ACK packet sent by the primary control board after the switchover is the first ACK packet sent after the switchover, and whether the TCP packet received by the primary control board after the switchover is the first TCP packet received after the switchover, in this embodiment, when the primary / standby switchover occurs, the standby control board is controlled to become the primary control board, and the Timestamp Echo stored in the local device is set to 0. That is, if the Timestamp Echo parsed from the TCP protocol is 0, it indicates that the ACK packet or TCP packet is the first ACK packet sent or the first TCP packet received by the primary control board after the switchover; if the Timestamp Echo parsed from the TCP protocol is not 0, it indicates that the ACK packet or the TCP packet is not the first ACK packet sent or the first TCP packet received by the primary control board after the switchover.

[0067] S206. When the switched-off primary control board receives a TCP packet, it determines whether to compensate the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the switched-off primary control board.

[0068] Specifically, since the first TCP packet received by the primary control board after the switchover carries a sequence number indicating the data order, and the first ACK packet sent by the primary control board after the switchover carries the acknowledgment number of the last ACK packet stored by the backup control board before the switchover, by comparing the relationship between the sequence number of the TCP packet and the acknowledgment number of the ACK packet, it can be determined whether there are any issues such as missed transmissions, duplicate transmissions, or misaligned transmissions in the TCP packets received by the primary control board after the switchover. Furthermore, when the above situations occur, the ACK packets are promptly compensated to ensure that the TCP connection between the primary control board and the peer device remains uninterrupted after the switchover and to guarantee the accuracy of the transmitted data.

[0069] This embodiment provides a primary / standby switchover control method that periodically synchronizes TCP connection information between the primary and standby main control boards. After a switchover, the standby main control board becomes the primary main control board. The first ACK packet sent by the primary main control board after the switchover is the last ACK packet stored by the standby main control board before the switchover. Based on the relationship between the first received TCP packet and the first sent ACK packet, it is determined whether to compensate for the ACK packet to be sent, effectively preventing the TCP connection between the local and remote devices from being interrupted, thereby improving the success rate of TCP connection primary / standby switchover without affecting subsequent TCP packet transmission. This primary / standby switchover control method is simple and can be used in any TCP protocol stack that requires primary / standby switchover or hot backup. It can handle both active and passive switchover scenarios and has a wide range of applications.

[0070] In one embodiment of this disclosure, step S206, based on the relationship between the first TCP packet received and the first ACK packet sent by the switched-off primary control board, determines whether to compensate for the ACK packet to be sent, including:

[0071] When the sequence number of the first received TCP packet is greater than the acknowledgment number of the first sent ACK packet, determine whether the local device has already received the TCP packet.

[0072] If not received, the acknowledgment number of the ACK packet to be sent is compensated, and the compensated ACK packet is sent.

[0073] In this embodiment, the acknowledgment number of the ACK packet to be sent is assigned the sum of the sequence number and data length of the TCP packet.

[0074] After a primary / standby switchover, the new primary control board and the peer device exchange packets via TCP. If the sequence number of the first TCP packet sent by the peer device to the new primary control board is greater than the ACK packet sent by the new primary control board to the peer device, the local device checks whether it has received the TCP packet. If the local device does not store the TCP packet, it means that the local device has not received the TCP packet. The local device then stores the TCP packet and compensates for the acknowledgment number of the ACK packet to be sent, in order to send an ACK packet to the peer device to confirm receipt of the TCP packet. The acknowledgment number of the ACK packet should be the sum of the sequence number and the data length of the TCP packet. This completes the packet exchange and ensures the continuity of the TCP connection.

[0075] In this embodiment, as Figure 4As shown, before the primary / standby switchover, the last ACK packet stored on the standby main control board had a sequence number Seq of 800, an acknowledgment number ACK of 1100, and a data length len of 0. When the primary / standby switchover occurs, the Timestamp Echo is set to 0. After the switchover, the first TCP packet received by the primary main control board after the switchover has a sequence number Seq of 1200, an acknowledgment number ACK of 800, and a data length len of 100. Subsequently, the ACK packet sent by the primary main control board to the peer device is the last ACK packet stored by the standby main control board before the switchover. At this time, the ACK packet has a sequence number Seq of 800, an acknowledgment number ACK of 1100, and a data length len of 0. After sending this ACK packet, the primary main control board requests the peer device to send a TCP packet with a sequence number Seq of 1200, an acknowledgment number ACK of 800, and a data length len of 100, i.e., to retransmit the TCP packet.

[0076] It can be seen that the sequence number of the first received TCP packet is greater than the acknowledgment number of the first sent ACK packet. Furthermore, if the local device does not store the TCP packet, it is determined that the failure to store the TCP packet is due to a primary / backup switchover. After the TCP packet is retransmitted, the acknowledgment number of the corresponding ACK packet needs to be corrected based on the sequence number of the retransmitted TCP packet. In other words, the acknowledgment number of the ACK packet needs to be compensated. After compensation, the acknowledgment number of the ACK packet is the sum of the sequence number of the TCP packet and the data length.

[0077] Furthermore, the method also includes:

[0078] If the local device has already received the TCP packet, it sends an ACK packet corresponding to the TCP packet.

[0079] In this embodiment, by querying the TCP packets stored on the local device, if the local device has already received the TCP packet, it is determined that the primary / backup switchover has not affected the TCP connection. When the TCP packet is received again, the corresponding ACK packet can be sent normally. In this case, there is no need to compensate the TCP packet, and the TCP connection can still be normal.

[0080] In one embodiment of this disclosure, step S206, which determines whether to compensate for the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the switched-off primary control board, specifically includes:

[0081] When the sequence number of the first received TCP packet is equal to the acknowledgment number of the first sent ACK packet, the TCP connection between the switched primary control board and the peer device is normal, and the ACK packet corresponding to the TCP packet is sent.

[0082] In this embodiment, as Figure 5 As shown, before the primary / standby switchover, the last ACK packet stored on the standby main control board had a sequence number Seq of 800, an acknowledgment number ACK of 1200, and a data length len of 0. When the primary / standby switchover occurs, the Timestamp Echo is set to 0. After the switchover, the first TCP packet received by the primary main control board after the switchover has a sequence number Seq of 1200, an acknowledgment number ACK of 800, and a data length len of 100. Subsequently, the ACK packet sent by the primary main control board after the switchover is the last ACK packet stored by the standby main control board before the switchover, with a sequence number Seq of 800, an acknowledgment number ACK of 1200, and a data length len of 0. Based on this ACK packet, the TCP packet received by the local device from the peer device has a sequence number Seq of 1300, an acknowledgment number ACK of 800, and a data length len of 100.

[0083] Since the sequence number of the first received TCP packet is the same as the acknowledgment number of the first sent ACK packet, it is determined that there are no missed transmissions, retransmissions, or mistransmissions in the TCP connection, and the TCP connection is normal. The ACK packet corresponding to the TCP packet can be sent directly.

[0084] The primary / standby switchover control method provided in this embodiment determines that the TCP connection is normal when the sequence number of the first received TCP packet is the same as the acknowledgment number of the first sent ACK packet. There is no missing transmission, retransmission, or mistransmission, and no compensation is required for the TCP packet. This ensures that the TCP connection between the local device and the peer device is normal, improves the success rate of TCP connection primary / standby switchover, and does not affect the subsequent TCP packet transmission.

[0085] In one embodiment of this disclosure, step S206, which determines whether to compensate for the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the switched-off primary control board, includes:

[0086] If the sequence number of the first received TCP packet is less than the acknowledgment number of the first sent ACK packet, the first received TCP packet is discarded.

[0087] When a TCP packet is received again, an ACK packet corresponding to the TCP packet is sent.

[0088] In this embodiment, the sequence number of the first received TCP packet is less than the acknowledgment number of the first sent ACK packet, indicating that the local device has stored the first received TCP packet. Since this TCP packet is a duplicate transmission, it is discarded and a new TCP packet is received.

[0089] This embodiment provides a primary / standby switchover control method. When the sequence number of the first received TCP packet is less than the acknowledgment number of the first sent ACK packet, it indicates that the local device has stored the TCP packet and discards it, thereby effectively preventing duplicate transmission and improving packet transmission efficiency.

[0090] To facilitate understanding of the primary / standby switchover control method disclosed in this paper, the following section will combine... Figure 2 and Figure 3 Please provide a detailed explanation.

[0091] This disclosure provides a primary / standby switchover control method, which specifically includes the following steps:

[0092] S202. Periodically receive TCP packets and ACK packets synchronously transmitted by the main control board;

[0093] S302. When the main and backup are switched, the backup main control board is promoted to the main main control board and the Timestamp Echo stored in the local device is set to 0.

[0094] S304. The switched-off master control board re-receives TCP packets, where the TCP packets include sequence numbers;

[0095] S306. Determine whether the primary control board after the switchover is receiving TCP packets for the first time. If yes, proceed to step S3010; otherwise, proceed to step S308.

[0096] S308. Send ACK packets corresponding to the received TCP packets;

[0097] S3010. The primary control board after the switchover sends an ACK packet, which is the last ACK packet stored by the backup control board before the switchover, and then receives TCP packets again.

[0098] S3012. Determine whether the sequence number of the first received TCP packet is equal to the acknowledgment number of the first ACK packet sent by the main control board. If they are equal, proceed to step S308; if they are not equal, proceed to step S3014.

[0099] S3014. Determine whether the sequence number of the first received TCP packet is less than the acknowledgment number of the first ACK packet sent by the main control board. If yes, proceed to step S3016; otherwise, proceed to step S3018.

[0100] S3018. Determine whether the local device has received the TCP packet. If it has been received, proceed to step S3020. If it has not been received, proceed to step S308.

[0101] S3020. Compensate the acknowledgment number of the ACK packet to be sent, wherein the acknowledgment number of the ACK packet to be sent is assigned the sum of the sequence number and the data length of the TCP packet, and then execute step S308.

[0102] S3016. Discard the received TCP packet, receive the TCP packet again, and execute step S308.

[0103] Based on the same inventive concept, this disclosure also provides a primary / standby switching control device, as described in the following embodiments. Since the principle by which this device solves the problem is similar to that of the method embodiments described above, the implementation of this device embodiment can refer to the implementation of the method embodiments described above, and repeated details will not be elaborated further.

[0104] Figure 6 This diagram illustrates a primary / standby switchover control device according to an embodiment of the present disclosure, such as... Figure 6 As shown, the device includes a data synchronization module 601, a primary / standby switchover template 602, and a message compensation module 603, wherein:

[0105] The data synchronization module 601 is used for the primary main control board to periodically transmit control protocol TCP packets and acknowledgment character ACK packets to the backup main control board.

[0106] The primary / standby switchover module 602 is used to control the standby main control board to become the primary main control board when the primary main control board and the standby main control board switch over. The first ACK message sent by the primary main control board after the switchover is the last ACK message stored by the primary main control board before the switchover.

[0107] The message compensation module 603 is used to determine whether to compensate the ACK message to be sent based on the relationship between the TCP message received for the first time by the master control board after the switchover and the ACK message sent for the first time.

[0108] This embodiment provides a primary / standby switchover control device that synchronizes TCP connection information between a primary control board and a standby control board at regular intervals. After a primary / standby switchover, the standby control board becomes the primary control board. The first ACK packet sent by the primary control board is the last ACK packet stored before the switchover. Based on the relationship between the first received TCP packet and the first sent ACK packet, it is determined whether to compensate for the ACK packet to be sent, effectively preventing the TCP connection between the local and remote devices from being interrupted, thereby improving the success rate of TCP connection primary / standby switchover without affecting subsequent TCP packet transmission. This primary / standby switchover control method is simple and can be used in any TCP protocol stack that requires primary / standby switchover or hot backup. It can handle both active and passive switchover scenarios and has a wide range of applications.

[0109] In one embodiment of this disclosure, the message compensation module 603 includes a judgment module not shown in the figures.

[0110] The judgment module is used to determine whether the local device has received a TCP packet when the sequence number of the first received TCP packet is greater than the acknowledgment number of the first sent ACK packet.

[0111] The message compensation module 603 is specifically used to compensate the acknowledgment number of the ACK message to be sent if the TCP message has not been received before, and then send the compensated ACK message.

[0112] Specifically, the acknowledgment number of the ACK packet to be sent is assigned the sum of the sequence number and the data length of the TCP packet.

[0113] In one embodiment of this disclosure, the message compensation module 603 is further configured to send a corresponding ACK message when the local device receives a TCP message again if the local device has already received the TCP message.

[0114] In one embodiment of this disclosure, the message compensation module 603 is further configured to ensure that the TCP connection between the primary control board and the peer device is normal when the sequence number of the first received TCP message is equal to the acknowledgment number of the first sent ACK message, and to send a corresponding ACK message when a TCP message is received again.

[0115] In one embodiment of this disclosure, the message compensation module 603 is further configured to discard the first received TCP message when the sequence number of the first received TCP message is less than the acknowledgment number of the first sent ACK message.

[0116] When a TCP packet is received again, a corresponding ACK packet is sent.

[0117] In one embodiment of this disclosure, the primary / standby switchover module 602 is specifically used to control the standby main control board to become the primary main control board when the primary main control board and the standby main control board switch over, and to set the Timestamp Echo stored in the local device to 0, so as to determine whether the primary main control board after the switchover is sending an ACK packet for the first time or receiving a TCP packet for the first time.

[0118] Those skilled in the art will understand that various aspects of the present invention can be implemented as systems, methods, or program products. Therefore, various aspects of the present invention can be specifically implemented in the following forms: entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuits,” “modules,” or “systems.”

[0119] This embodiment provides a primary / standby switchover control method and apparatus. It synchronizes TCP connection information between the primary and standby main control boards periodically. After a primary / standby switchover, the standby main control board becomes the primary main control board. The first ACK packet sent by the primary main control board is the last ACK packet stored before the switchover. Based on the relationship between the first received TCP packet and the first sent ACK packet, it determines whether to compensate for the ACK packet to be sent. This effectively prevents TCP connection interruptions between the local and remote devices, thereby improving the success rate of TCP connection primary / standby switchover without affecting subsequent TCP packet transmission. This primary / standby switchover control method is simple and can be used in any TCP protocol stack that requires primary / standby switchover or hot backup. It can handle both active and passive switchover scenarios and has a wide range of applications.

[0120] The following reference Figure 7 To describe an electronic device 700 according to this embodiment of the present invention. Figure 7 The electronic device 700 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0121] like Figure 7 As shown, the electronic device 700 is manifested in the form of a general-purpose computing device. The components of the electronic device 700 may include, but are not limited to: at least one processing unit 710, at least one storage unit 720, and a bus 730 connecting different system components (including storage unit 720 and processing unit 710).

[0122] The storage unit stores program code that can be executed by the processing unit 710, causing the processing unit 710 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 710 can perform actions such as... Figure 2 The timing shown indicates that the primary control board synchronously receives Transmission Control Protocol (TCP) packets and Acknowledgment (ACK) packets. During primary / standby switchover, the standby control board is promoted to primary control board. The first ACK packet sent by the primary control board after the switchover is the last ACK packet stored by the standby control board before the switchover. When the primary control board after the switchover receives a TCP packet, it determines whether to compensate for the ACK packet to be sent based on the relationship between the first TCP packet received and the first ACK packet sent by the primary control board after the switchover.

[0123] Storage unit 720 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 7201 and / or cache memory 7202, and may further include a read-only memory (ROM) 7203.

[0124] The storage unit 720 may also include a program / utility 7204 having a set (at least one) program module 7205, such program module 7205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0125] Bus 730 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.

[0126] Electronic device 700 can also communicate with one or more external devices 740 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable a user to interact with system 800, and / or with any device that enables electronic device 700 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 750. Furthermore, system 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 760. As shown, network adapter 760 communicates with other modules of electronic device 700 via bus 730. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0127] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0128] In exemplary embodiments of this disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the methods described above is stored. In some possible embodiments, various aspects of the invention may also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform the steps of the various exemplary embodiments of the invention described in the "Exemplary Methods" section of this specification.

[0129] A program product for implementing the above-described method according to embodiments of the present invention is described. This product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0130] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0131] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.

[0132] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0133] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0134] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0135] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0136] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.

[0137] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A method of controlling a switchover of a master and a backup, characterized by, The method comprises the steps of: timely receiving a transmission control protocol (TCP) message and an acknowledgement character (ACK) message synchronously transmitted by a master control board; when a master-backup switchover occurs, controlling a backup control board to become a master control board, and the ACK message first sent by the master control board after the switchover being the ACK message last stored by the backup control board before the switchover; when the master control board after the switchover receives a TCP message, determining whether to compensate a to-be-sent ACK message according to a relationship between the TCP message first received by the master control board after the switchover and the ACK message first sent by the master control board after the switchover; wherein the step of determining whether to compensate the to-be-sent ACK message according to the relationship between the TCP message first received by the master control board after the switchover and the ACK message first sent by the master control board after the switchover comprises the steps of: when a sequence number of the TCP message first received is greater than an acknowledgement number of the ACK message first sent, determining whether the local device has received the TCP message; if not, compensating the acknowledgement number of the to-be-sent ACK message and sending the compensated ACK message.

2. The method according to claim 1, wherein the acknowledgement number of the compensated ACK message being assigned as a sum of the sequence number of the TCP message and a data length.

3. The method of claim 1, wherein The method further comprises the step of: if the local device has received the TCP message, sending an ACK message corresponding to the TCP message.

4. The method of claim 1, wherein The step of determining whether to compensate the to-be-sent ACK message according to the relationship between the TCP message first received by the master control board after the switchover and the ACK message first sent by the master control board after the switchover comprises the step of: when the sequence number of the TCP message first received is equal to the acknowledgement number of the ACK message first sent, the TCP connection between the master control board after the switchover and a peer device being normal, and an ACK message corresponding to the TCP message being sent.

5. The method of claim 1, wherein The step of determining whether to compensate the to-be-sent ACK message according to the relationship between the TCP message first received by the master control board after the switchover and the ACK message first sent by the master control board after the switchover comprises the step of: when the sequence number of the TCP message first received is less than the acknowledgement number of the ACK message first sent, discarding the TCP message first received; when a TCP message is received again, sending an ACK message corresponding to the TCP message.

6. The method according to any one of claims 1 to 5, wherein The method further comprises the step of: setting a Timestamp Echo stored by the local device to 0 to determine whether the master control board after the switchover is to first send an ACK message or first receive a TCP message.

7. A master / standby switchover control device characterized by comprising: The method comprises: a data synchronization module configured to timely receive a transmission control protocol (TCP) message and an acknowledgement character (ACK) message synchronously transmitted by a master control board; a master-backup switchover module configured to, when a master-backup switchover occurs, control a backup control board to become a master control board, and the ACK message first sent by the master control board after the switchover being the ACK message last stored by the backup control board before the switchover; The packet compensation module is configured to, when the switched master control board receives a TCP packet, determine whether to compensate a to-be-sent ACK packet according to a relationship between the first received TCP packet and the first sent ACK packet of the switched master control board. The packet compensation module is configured to, when a sequence number of the first received TCP packet is greater than a confirmation number of the first sent ACK packet, determine whether the local device has received the TCP packet. If not, the confirmation number of the to-be-sent ACK packet is compensated, and the compensated ACK packet is sent.

8. An electronic device, comprising: The method comprises: a processor; and a memory configured to store executable instructions of the processor; wherein the processor is configured to execute the executable instructions to perform the master-backup switching control method according to any one of claims 1-6.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the master-backup switching control method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Method, device and system for restoring TCP connection sequence numbers

    CN106230747A

  • Adaptively maintaining sequence numbers on high availability peers

    US8363549B1