Packet synchronization method and apparatus
By receiving and comparing the sequence number and acknowledgment number of the target message, a processing strategy is determined to synchronize the message status of the primary control board, thus solving the problem of low TCP connection synchronization efficiency and achieving efficient message synchronization and TCP connection stability.
Patent Information
- Application Number
- CN202311265342.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2043-09-26
AI Technical Summary
In existing technologies, the synchronous processing efficiency of TCP connections is low during primary/standby switchover, making it unsuitable for high-traffic scenarios.
By receiving target messages sent by peer devices, storing them in a buffer queue, and extracting the sequence number and acknowledgment number, the currently processed message is compared with the next expected sequence number. Based on the comparison result, a processing strategy is determined, which synchronizes the message processing status with the main control board and reduces the interaction process with the main control board.
It improves the efficiency of message synchronization, reduces the interaction process between the primary and backup control boards, ensures the stability and reliability of TCP connections, and is suitable for high-traffic scenarios.
Smart Images

Figure CN117082081B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of network technology and security technology, and more specifically, to a message synchronization method and apparatus. Background Technology
[0002] To ensure uninterrupted TCP (Transmission Control Protocol) connections under NSR (No-Stopping Route, a reliability technology that guarantees uninterrupted data transmission during primary / standby switchover), several technologies employ various approaches. One approach is to add new TCP states to extend the TCP state machine for synchronization. Another approach is for the motherboard to wait for the standby board to finish processing its TCP packets before synchronizing its own. Yet another approach is for the motherboard to process its own TCP packets before synchronizing them to the standby board. As such, these technologies suffer from low synchronization efficiency due to the scheduling timing of the primary and standby processes.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a message synchronization method and apparatus to at least solve the technical problem of low synchronization processing efficiency in related technologies.
[0005] According to one aspect of the embodiments of this application, a message synchronization method is provided, comprising: receiving a target message sent by a peer device; storing the target message in a buffer queue and extracting the sequence number and acknowledgment number of all target messages in the buffer queue; comparing the acknowledgment number of the target message currently being processed in the buffer queue with the next expected sequence number of the target message, determining a processing strategy for the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the master control board; and processing the target message according to the processing strategy of the target message to synchronize with the message processing status of the master control board.
[0006] Optionally, the processing strategy for the target message is determined based on the comparison result, including: if the comparison result indicates that the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message, the processing strategy is to process the next expected target message normally; if the comparison result indicates that the acknowledgment number of the currently processed target message is less than the next expected sequence number of the target message, the processing strategy is to construct a new message for processing until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message; if the comparison result indicates that the acknowledgment number of the currently processed target message is greater than the sequence number of the next expected message, the adjustment strategy is to stop processing the next expected message until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message.
[0007] Optionally, a new message is constructed in the following ways: constructing a first message based on the target message being processed; searching the cache queue for the payload field of the next message to be processed corresponding to the target message being processed, and replacing the payload field in the first message with the payload field of the next message to be processed to obtain a new message.
[0008] Optionally, before receiving the target message sent by the peer device, the method further includes: receiving the primary control board configuration information and the message processing status of the primary control board sent by the primary control board; and adjusting the target configuration information and the target message processing status according to the primary control board configuration information and the message processing status of the primary control board, so that the target configuration information and the target message processing status are synchronized with the primary control board configuration information and the message processing status of the primary control board.
[0009] Optionally, receiving the target message sent by the peer device includes: receiving multiple messages sent by the peer device; and identifying the message belonging to the target protocol among the multiple messages as the target message.
[0010] Optionally, the method further includes: receiving a switching instruction, receiving primary control board configuration information and message processing status of the primary control board sent by the primary control board; and after completing synchronization with the primary control board based on the primary control board configuration information and message processing status of the primary control board, switching the execution mode from standby control board mode to primary control board mode.
[0011] Optionally, when sending a target message to a peer device, the method further includes: storing the target message in a buffer queue and extracting the sequence number and acknowledgment number of all target messages in the buffer queue; comparing the acknowledgment number of the currently sent target message in the buffer queue with the sequence number of the next expected target message, and determining the sending strategy of the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the master control board; and sending the target message according to the sending strategy of the target message to synchronize with the message sending status of the master control board.
[0012] According to another aspect of the embodiments of this application, a message synchronization device is also provided, comprising: a receiving module for receiving a target message sent by a peer device; an extraction module for storing the target message in a buffer queue and extracting the sequence number and acknowledgment number of all target messages in the buffer queue; a comparison module for comparing the acknowledgment number of the target message currently being processed in the buffer queue with the next expected sequence number of the target message, and determining a processing strategy for the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board; and a processing module for processing the target message according to the processing strategy of the target message, so as to synchronize with the message processing status of the main control board.
[0013] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory for storing program instructions; and a processor connected to the memory for executing the program instructions for performing the following functions: receiving a target message sent by a peer device; storing the target message in a buffer queue and retrieving the sequence number and acknowledgment number of all target messages in the buffer queue; comparing the acknowledgment number of the currently processed target message in the buffer queue with the next expected sequence number of the target message, and determining a processing strategy for the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board; and processing the target message according to the target message processing strategy to synchronize with the message processing status of the main control board.
[0014] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-described message synchronization method by running the computer program.
[0015] In this embodiment, the following methods are employed: receiving target packets sent by the peer device; storing the target packets in a cache queue and extracting the sequence number and acknowledgment number of all target packets in the cache queue; comparing the acknowledgment number of the currently processed target packet in the cache queue with the next expected sequence number of the target packet; determining the processing strategy for the target packet based on the comparison result, wherein the next expected sequence number of the target packet is the same as the next expected sequence number of the target packet in the primary control board; and processing the target packet according to the processing strategy to synchronize with the message processing status of the primary control board. By simultaneously receiving target packets sent by the peer device with the primary control board, comparing the currently processed target packet with the next expected processed packet, and adjusting the message processing strategy based on the comparison result, the goal of not passing through the primary control board during message synchronization is achieved. This reduces the interaction between the primary and backup control boards during synchronization, improves synchronization efficiency, and solves the technical problem of low virtual machine migration efficiency in related technologies. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0017] Figure 1 This is a hardware structure block diagram of a computer terminal for implementing a message synchronization method according to an embodiment of this application;
[0018] Figure 2 This is a flowchart of a message synchronization method according to this application;
[0019] Figure 3 This is a flowchart illustrating a message synchronization method in related technologies;
[0020] Figure 4 This is a flowchart illustrating another message synchronization method in related technologies;
[0021] Figure 5 This is a schematic diagram of the structure of a message synchronization system according to an embodiment of this application;
[0022] Figure 6 This is a schematic flowchart of a synchronization method for receiving messages according to an embodiment of this application;
[0023] Figure 7 This is a schematic flowchart of a synchronization method for sending messages according to an embodiment of this application;
[0024] Figure 8This is a schematic flowchart of a method for switching between a primary control board and a backup control board according to an embodiment of this application;
[0025] Figure 9 This is a schematic diagram of a message synchronization device according to an embodiment of this application. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] The message synchronization method embodiments provided in this application can be executed on mobile terminals, computer terminals, or similar computing devices. Figure 1 A hardware block diagram of a computer terminal for implementing a message synchronization method is shown. Figure 1 As shown, the computer terminal 10 may include one or more processors (shown as 102a, 102b, ..., 102n in the figure) (the processor may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0029] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be implemented wholly or partially as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be wholly or partially integrated into any other element in the computer terminal 10. As involved in the embodiments of this application, the data processing circuits serve as processor control (e.g., selection of a variable resistor termination path connected to an interface).
[0030] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the message synchronization method in this embodiment. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the aforementioned message synchronization method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0031] The transmission module 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission module 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0032] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10.
[0033] It should be noted here that, in some optional embodiments, the above... Figure 1 The computer device shown may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that... Figure 1This is only one instance of a specific particular instance, and is intended to illustrate the types of components that may exist in the aforementioned computer devices.
[0034] In the above operating environment, this application provides an embodiment of a message synchronization method. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than that shown here.
[0035] Figure 2 This is a flowchart of a message synchronization method according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:
[0036] Step S202: Receive the target message sent by the peer device;
[0037] Step S204: Store the target message in the buffer queue and extract the sequence number and acknowledgment number of all target messages in the buffer queue;
[0038] It should be noted that the sequence number of the target message is used to identify the order of data transmitted within the target message. It indicates a unique sequence number assigned to each byte by the sender when transmitting data. The sequence number is randomly selected by the sender during connection establishment and then increments with each data transmission. The receiver uses the acknowledgment number to determine the order of received data and to acknowledge receipt.
[0039] The acknowledgment number of the target message refers to the sequence number of the next byte that the data receiver expects to receive. In other words, the sender assigns a sequence number to each data packet when sending data, and the receiver sends an acknowledgment packet to the sender after receiving the data packet. This acknowledgment packet contains the sequence number of the next byte that the receiver expects to receive.
[0040] It should be noted that what is extracted here is the five-tuple of the target packet. The source address / destination address of the target packet is used to find the corresponding session, and the sequence number / acknowledgment number is used for repair processing.
[0041] Step S206: Compare the acknowledgment number of the target packet currently being processed in the buffer queue with the next expected sequence number of the target packet, and determine the processing strategy for the target packet based on the comparison result. The next expected sequence number of the target packet is the same as the next expected sequence number of the target packet in the main control board.
[0042] Step S208: Process the target message according to the target message processing strategy to synchronize with the message processing status of the main control board.
[0043] It is understandable that the main body responsible for implementing the above message synchronization method is the backup control board.
[0044] Figure 3 and Figure 4 The diagrams illustrate the message synchronization process in the two related technologies, as follows: Figure 3 As shown, the peer device sends TCP packets to the primary control board, which receives the TCP packets and copies them to the backup control board. The backup control board processes the TCP packets and sends the processing result back to the primary control board. The primary control board then processes the TCP packets it received. Due to the scheduling timing of the primary and backup processes, the synchronous processing performance is poor and cannot adapt to high-traffic scenarios. Figure 4 As shown, the peer device sends TCP packets to the primary control board, which receives the TCP packets. After the primary control board processes the received TCP packets, it synchronizes the TCP packets to the backup control board and receives the processing results from the backup control board. The TCP connection is frequently updated, and the synchronization processing performance is poor, making it unsuitable for high-traffic scenarios.
[0045] The message synchronization method in steps S202 to S208 involves receiving target messages sent by the peer device; storing the target messages in a buffer queue and extracting the sequence number and acknowledgment number of all target messages in the buffer queue; comparing the acknowledgment number of the currently processed target message in the buffer queue with the next expected sequence number of the target message; determining the processing strategy for the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the primary control board; and processing the target message according to the processing strategy to synchronize with the message processing status of the primary control board. By simultaneously receiving target messages sent by the peer device with the primary control board, comparing the currently processed target message with the next expected message, and adjusting the message processing strategy based on the comparison result, the goal of eliminating the primary control board during message synchronization is achieved. This reduces the interaction between the primary and backup control boards during synchronization, improves synchronization efficiency, and solves the technical problem of low virtual machine migration efficiency in related technologies. The following is a detailed explanation.
[0046] In step S206 of the above message synchronization method, determining the processing strategy for the target message based on the comparison result includes the following steps: if the comparison result indicates that the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message, the processing strategy is determined to be to process the next expected target message normally; if the comparison result indicates that the acknowledgment number of the currently processed target message is less than the next expected sequence number of the target message, the processing strategy is determined to construct a new message for processing until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message; if the comparison result indicates that the acknowledgment number of the currently processed target message is greater than the sequence number of the next expected message, the adjustment strategy is determined to stop processing the next expected message until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message.
[0047] The new message is created in the following way: a first message is constructed based on the target message being processed; the payload field of the next message to be processed corresponding to the target message being processed is found in the cache queue, and the payload field in the first message is replaced with the payload field of the next message to be processed to obtain a new message.
[0048] One option is to directly copy the target message being processed to obtain the first message. Another option is to construct the first message according to the information of the target message being processed, and then add the payload field to the first message to obtain a new message.
[0049] It should be noted that the payload field can be the payload of the message to be processed, such as application data.
[0050] Before receiving the target message sent by the peer device, the backup control board receives the primary control board configuration information and message processing status of the primary control board sent by the primary control board; based on the primary control board configuration information and message processing status, it adjusts the target configuration information and target message processing status to synchronize with the primary control board configuration information and message processing status.
[0051] In one alternative approach, the target message is a message belonging to the target protocol (TCP protocol).
[0052] Figure 5 A message synchronization system applicable to the message synchronization method proposed in the embodiments of this application is shown, such as... Figure 5 As shown, the bypass module runs on the backup control board, filters out TCP packets, and other packets still go through the kernel protocol stack (second protocol stack). This allows TCP packets to be sent directly to user-space applications for flexible processing.
[0053] The auto-repair module (repair module) runs on the backup control board. It parses the received TCP packets and records the TCP parameters of each TCP packet, such as the five-tuple, sequence number, acknowledgment number, and TCP payload. When a new TCP packet is received, it compares the packets to determine whether the backup control board's TCP status is ahead or behind the primary control board, and then determines the corresponding processing strategy.
[0054] Based on the above message synchronization system Figure 6 A flowchart for receiving messages is shown, such as Figure 6 As shown,
[0055] The primary and backup control board protocol stacks synchronize configuration information and message processing status through their respective protocol modules. The peer device simultaneously sends TCP packets to both the primary and backup control boards. The primary control board processes the received packets according to the normal procedure (receiving TCP packets, sending them to the first protocol stack, then to the first protocol module, resetting the timeout timer, encapsulating and processing them, and then sending the TCP packets to the peer device). Upon receiving a TCP packet, the backup control board uses an avoidance module to parse the TCP packet and stores the parsed TCP packet in a buffer queue. It uses a repair module to record the TCP packet's 5-tuple, sequence number, and acknowledgment number, and compares the sequence number and acknowledgment number with the same 5-tuple to obtain the comparison result. If the current processing... If the acknowledgment number of the target packet is equal to the next expected sequence number of the target packet, the processing strategy is to process the next expected target packet normally. If the comparison result indicates that the acknowledgment number of the currently processed target packet is less than the next expected sequence number of the target packet, the processing strategy is to construct a new packet for processing until the acknowledgment number of the currently processed target packet is equal to the next expected sequence number of the target packet. If the comparison result indicates that the acknowledgment number of the currently processed target packet is greater than the sequence number of the next expected packet, the adjustment strategy is to stop processing the next expected packet until the acknowledgment number of the currently processed target packet is equal to the next expected sequence number of the target packet, and send the currently processed TCP packet to the second protocol module for processing.
[0056] Understandably, there is a master-slave synchronization process before the master and slave can run simultaneously. This process is mainly used to synchronize the data after the motherboard has stabilized for the first time. Subsequent synchronizations will only be incremental, and a full synchronization will only be performed if there is a significant data update to the motherboard.
[0057] Figure 7 A flowchart for sending a message is shown, such as Figure 7As shown, before sending a message, the protocol stacks of the primary control board and the backup control board synchronize configuration information and message processing status through their respective protocol modules. In the primary control board, the first protocol module encapsulates the TCP message, starts a timer, and sends the TCP message to the first protocol stack, which then sends it to the peer device via the interface. In the backup control board, the second protocol module encapsulates the TCP message and sends it to the second protocol stack. The second protocol stack processes the message and sends it to the avoidance module. After parsing, the message is stored in a buffer queue. The repair module records the TCP message's 5-tuple, sequence number, and acknowledgment number, and compares identical sequence numbers and acknowledgment numbers. If the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message, then... The initial processing strategy is to process the next expected target packet normally. If the comparison result indicates that the acknowledgment number of the currently processed target packet is less than the next expected sequence number of the target packet, the processing strategy is to construct a new packet for processing until the acknowledgment number of the currently processed target packet equals the next expected sequence number of the target packet. If the comparison result indicates that the acknowledgment number of the currently processed target packet is greater than the next expected sequence number of the target packet, the adjustment strategy is to stop processing the next expected packet until the acknowledgment number of the currently processed target packet equals the next expected sequence number of the target packet. The currently processed TCP packet is then sent to the second protocol stack for processing to update the TCP configuration and state, and to keep the TCP packets of the primary control board and the backup control board synchronized.
[0058] Figure 8 A schematic diagram illustrating the switching process between the primary and backup control boards is shown, such as... Figure 8 As shown, the user terminal triggers a primary / standby switchover command, sending switchover commands to both the primary and standby control boards. Upon receiving the switchover command, the primary control board synchronizes its configuration information and message processing status with the standby control board. The primary control board executes the primary-to-standby demotion process, switching the hardware to standby mode, stopping the first protocol module, and starting the avoidance module and the repair module. The standby control board executes the standby-to-primary promotion process, switching the hardware to primary mode. The second protocol module operates normally, continuing automatic repair and handling asynchronous messages during the switchover process. After the timer expires, the avoidance module and the repair module are stopped.
[0059] It is understandable that the message synchronization method provided in this application supports real-time synchronization and batch backup between primary and backup, with fully asynchronous processing between primary and backup. Primary and backup will not wait or be blocked, and the TCP connection status is automatically repaired without manual intervention, ensuring the stability and reliability of business and system before and after the switchover. There is no need to distinguish between server and client, and no need to extend protocols or add simulation modules. Primary and backup boards reduce unnecessary interactions, and the asynchronous processing of primary and backup boards effectively improves performance. Primary and backup boards do not need to support virtualization, reducing equipment requirements and significantly reducing development costs.
[0060] Figure 9 This is a message synchronization device according to an embodiment of this application, such as... Figure 4 As shown, the device includes:
[0061] Receiver module 90 is used to receive target messages sent by the peer device;
[0062] Extraction module 92 is used to store target packets into a buffer queue and extract the sequence number and acknowledgment number of all target packets in the buffer queue;
[0063] The comparison module 94 is used to compare the acknowledgment number of the target message currently being processed in the buffer queue with the next expected sequence number of the target message, and determine the processing strategy of the target message based on the comparison result. The next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board.
[0064] The processing module 96 is used to process the target message according to the target message processing strategy, so as to synchronize with the message processing status of the main control board.
[0065] The comparison module 94 of the above-mentioned message synchronization device includes: a comparison submodule, used to determine the processing strategy as normal processing of the next expected target message when the comparison result indicates that the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message; to determine the processing strategy as constructing a new message for processing when the comparison result indicates that the acknowledgment number of the currently processed target message is less than the next expected sequence number of the target message, until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message; and to determine the adjustment strategy as stopping processing the next expected message when the comparison result indicates that the acknowledgment number of the currently processed target message is greater than the next expected sequence number of the target message, until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message.
[0066] The comparison submodule includes: a construction unit, used to construct a first message based on the target message being processed; to find the payload field of the next message to be processed corresponding to the target message being processed in the cache queue, and to replace the payload field in the first message with the payload field of the next message to be processed to obtain a new message;
[0067] The receiving module 90 includes: a synchronization submodule, used to receive the main control board configuration information and the message processing status of the main control board sent by the main control board; and to adjust the target configuration information and the target message processing status according to the main control board configuration information and the message processing status of the main control board, so that the target configuration information and the target message processing status are synchronized with the main control board configuration information and the message processing status of the main control board.
[0068] The comparison submodule mentioned above also includes: a filtering unit, which receives multiple messages sent by the peer device and identifies the message belonging to the target protocol among the multiple messages as the target message;
[0069] The above-mentioned message synchronization device also includes: a switching module, used to receive switching instructions, receive primary control board configuration information and message processing status of the primary control board sent by the primary control board; after completing synchronization with the primary control board according to the primary control board configuration information and message processing status of the primary control board, the execution mode is switched from standby control board mode to primary control board mode.
[0070] The aforementioned message synchronization device further includes: a sending module, used to store target messages in a buffer queue and extract the sequence number and acknowledgment number of all target messages in the buffer queue; compare the acknowledgment number of the currently sent target message in the buffer queue with the sequence number of the next expected target message, and determine the sending strategy of the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board; and send the target message according to the sending strategy of the target message to synchronize with the message sending status of the main control board.
[0071] It should be noted that, Figure 9 The message synchronization device shown is used to perform Figure 2 The above describes a message synchronization method. Therefore, the relevant explanations and descriptions in the message synchronization method also apply to this message synchronization device, and will not be repeated here.
[0072] This application embodiment also provides an electronic device, including: a memory for storing program instructions; and a processor connected to the memory for executing the program instructions for the following functions: receiving a target message sent by a peer device; storing the target message in a buffer queue and extracting the sequence number and acknowledgment number of all target messages in the buffer queue; comparing the acknowledgment number of the currently processed target message in the buffer queue with the next expected sequence number of the target message, and determining a processing strategy for the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board; and processing the target message according to the target message processing strategy to synchronize with the message processing status of the main control board.
[0073] It should be noted that the aforementioned electronic equipment is used to perform Figure 2 The message synchronization method shown above is also applicable to this electronic device, and will not be repeated here.
[0074] This application embodiment also provides a non-volatile storage medium, which includes a stored computer program. The device containing the non-volatile storage medium executes the following message synchronization method by running the computer program: receiving a target message sent by a peer device; storing the target message in a buffer queue and extracting the sequence number and acknowledgment number of all target messages in the buffer queue; comparing the acknowledgment number of the currently processed target message in the buffer queue with the next expected sequence number of the target message, determining a processing strategy for the target message based on the comparison result, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board; and processing the target message according to the target message processing strategy to synchronize with the message processing state of the main control board.
[0075] It should be noted that the aforementioned non-volatile storage media is used for execution. Figure 2 The message synchronization method shown above is also applicable to this non-volatile storage medium, and will not be repeated here.
[0076] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0077] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0078] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.
[0079] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0080] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0081] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0082] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A message synchronization method, characterized in that, include: Receive target messages sent by the peer device; The target message is stored in a cache queue, and the sequence number and acknowledgment number of all target messages in the cache queue are extracted. The acknowledgment number of the target packet currently being processed in the cache queue is compared with the next expected sequence number of the target packet. The processing strategy for the target packet is determined based on the comparison result. The next expected sequence number of the target packet is the same as the next expected sequence number of the target packet in the main control board. The target message is processed according to the target message processing strategy to synchronize with the message processing status of the main control board.
2. The method according to claim 1, characterized in that, The step of determining the processing strategy for the target message based on the comparison results includes: If the comparison result indicates that the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message, then the processing strategy is determined to be to process the next expected target message normally. If the comparison result indicates that the acknowledgment number of the currently processed target message is less than the next expected sequence number of the target message, the processing strategy is determined to construct a new message for processing until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message. If the comparison result indicates that the acknowledgment number of the currently processed target message is greater than the sequence number of the next expected message, the processing strategy is determined to stop processing the next expected message until the acknowledgment number of the currently processed target message is equal to the next expected sequence number of the target message.
3. The method according to claim 2, characterized in that, The new message is constructed in the following ways: Construct a first message based on the target message being processed; The payload field of the next pending message corresponding to the target message being processed is retrieved from the cache queue, and the payload field in the first message is replaced with the payload field of the next pending message to obtain the new message.
4. The method according to claim 1, characterized in that, The method further includes the following steps before receiving the target message sent by the peer device: Receive the primary control board configuration information and message processing status of the primary control board sent by the primary control board; Based on the primary control board configuration information and the primary control board's message processing status, adjust the target configuration information and the target message processing status to synchronize them with the primary control board configuration information and the primary control board's message processing status.
5. The method according to claim 2, characterized in that, The target message received from the peer device includes: Receive multiple messages sent by the peer device; The message belonging to the target protocol among the multiple messages is identified as the target message.
6. The method according to claim 1, characterized in that, The method further includes: Receive switching instructions, receive primary control board configuration information and message processing status of the primary control board sent by the primary control board; After synchronizing with the primary control board based on the primary control board configuration information and the primary control board's message processing status, the execution mode is switched from the backup control board mode to the primary control board mode.
7. The method according to claim 1, characterized in that, When sending the target message to the peer device, the method further includes: The target message is stored in a cache queue, and the sequence number and acknowledgment number of all target messages in the cache queue are extracted. The acknowledgment number of the target message currently being sent in the buffer queue is compared with the sequence number of the next expected target message to be sent. The sending strategy of the target message is determined based on the comparison result. The next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board. The target message is sent according to the target message sending strategy, so as to synchronize with the message sending status of the main control board.
8. A message synchronization device, characterized in that, include: The receiving module is used to receive target messages sent by the peer device; The extraction module is used to store the target message in a cache queue and extract the sequence number and acknowledgment number of all target messages in the cache queue. The comparison module is used to compare the acknowledgment number of the target packet currently being processed in the cache queue with the next expected sequence number of the target packet, and determine the processing strategy of the target packet based on the comparison result, wherein the next expected sequence number of the target packet is the same as the next expected sequence number of the target packet in the main control board. The processing module is used to process the target message according to the processing strategy of the target message, so as to synchronize with the message processing status of the main control board.
9. An electronic device, characterized in that, include: Memory, used to store program instructions; A processor, connected to the memory, is configured to execute program instructions for receiving target messages sent by a peer device; The target message is stored in a buffer queue, and the sequence number and acknowledgment number of all target messages in the buffer queue are extracted. The acknowledgment number of the target message currently being processed in the buffer queue is compared with the next expected sequence number of the target message. Based on the comparison result, the processing strategy for the target message is determined, wherein the next expected sequence number of the target message is the same as the next expected sequence number of the target message in the main control board. The target message is processed according to the processing strategy to synchronize with the message processing status of the main control board.
10. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the message synchronization method according to any one of claims 1 to 7 by running the computer program.
Citation Information
Patent Citations
Backup method and equipment for TCP connection
CN102035687A
TCP hot backup method and device
CN109194576A
