A flow control system and method based on buffer zone
By introducing a buffer-based flow control system between Qemu and Kvm, the problem of uneven busyness and idleness caused by large or small message volumes in the existing technology is solved, load balancing and communication fluency are achieved, communication blocking is avoided, and communication is improved. Improved message processing speed.
Patent Information
- Application Number
- CN202211164472.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-09-23
AI Technical Summary
The existing flow control mechanism between Qemu and Kvm can easily lead to uneven busyness and idleness when the message volume is large or the message volume is small, causing congestion or idle waste. In extreme cases, it may cause the device and driver to be unable to communicate.
A buffer-based flow control system is adopted to achieve message splitting and synchronization through a message processing device, a window update device, a message receiving device and a message sending device, ensuring the effective use of the buffer and avoiding communication congestion.
It effectively avoids communication congestion caused by peaks and valleys, improves load balancing, enhances message processing speed and communication fluency, and is suitable for flow control in extreme scenarios.
Smart Images

Figure CN115567459B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of communication scenarios between Qemu and Kvm, and specifically provides a flow control system and method based on a buffer. Background Art
[0002] For most enterprise organizations, regardless of their size, they are now dealing with a hybrid IT environment that includes virtual and physical servers. Hybrid environments complicate almost every aspect of server management. It reduces administrator productivity, increases the cost of management tools, and the knowledge of management tools among administrators is too fragmented, and may lead to a significant reduction in application availability and data integrity. Deploying virtualization enables physical servers to host multiple virtual servers. It provides the ability to easily migrate virtual servers between different physical servers to balance the demand for resources. Physical servers running virtualization software are often able to maintain operation at more than 80% of their rated capacity. Consolidating business applications onto a single physical server, each with its own independent operating environment, can significantly reduce the number of physical servers in an enterprise data center, further reducing capital expenditures. The implementation of virtualization mostly relies on the Qemu+Kvm architecture, and the communication technology for implementing devices and drivers is mostly based on vring communication.
[0003] The flow control between Qemu+Kvm is mainly based on a simple judgment (the position where the current Kvm end message processing is completed - the position where the Qemu end message processing is completed < the number of messages processed by the current Kvm end this time). If the condition is met, it means that the Qemu device end processing speed is fast enough, and the Kvm end will continue to send; if it is not met, it means that the device processing speed is relatively slow, and the message sending is suspended until this condition is met. Under such judgment conditions, if the message volume is large in a certain period of time, or no message is generated in a certain period of time, the existing implementation mechanism is very likely to cause uneven busy and idle in such a situation, causing congestion when the message volume is large, and idle waste when there is no message; or due to extremely large messages, the judgment condition cannot be met, which leads to the disadvantage that the device end and the driver end cannot communicate. Some other existing modifications based on vring only modify the internal communication messages of vring, reduce the delay of message transmission or reduce the number of copies to improve efficiency, and basically do not involve any flow control, and cannot avoid the above-described disadvantages.
[0004] It should be noted that Qemu is a set of simulated processor software written by Fabrice Bella and distributed under the GPL license. It is widely used on the GNU / Linux platform. Kvm is an open source virtualization technology built into Linux that can transform Linux into a virtual machine monitor, enabling the host to run multiple isolated virtual environments. Thread is the smallest unit that the operating system can perform computational scheduling. It is contained in the process and is the actual operating unit in the process. A thread refers to a single sequential control flow in a process, and each thread executes different tasks in parallel. Vring is part of the heap space. A certain amount of storage space is reserved in the heap space, which is used to buffer input or output data. This reserved space is called a buffer. IT refers to the general term for Internet information technology; the driver end is simulated by Kvm, and the driver end in this article refers to the Kvm end; the device end is simulated by Qemu, and the device end in this article refers to the Qemu end. Summary of the invention
[0005] In view of the drawbacks that if the amount of messages is large within a certain period of time, or no messages are generated within a certain period of time, the existing implementation mechanism is very likely to cause uneven busyness and idleness in such a situation, resulting in congestion when the amount of messages is large, and idleness is wasted when there are no messages; or the judgment condition cannot be met due to extremely large messages, thereby causing the device end and the driver end to be unable to communicate. The present invention provides a flow control system and method based on vring.
[0006] In a first aspect, the technical solution of the present invention provides a flow control system based on a buffer, including a buffer, a device end simulated by Qemu, and a driver end simulated by Kvm;
[0007] The buffer is a cache device shared by the device side and the driver side for storing messages stored by the device side and the driver side;
[0008] The device end and the driver end are respectively provided with a message processing device, a window updating device, a message receiving device, and a message sending device;
[0009] A message processing device, used to perform service processing on the received message to trigger the window updating device at the same end, split the message when it is necessary to split the message, fill the message split offset and split flag into the message header, and fill the message that meets the sending conditions into the buffer device through the sending device, and send the message notification to the other end through the sending device;
[0010] A receiving device, configured to obtain the message in the cache device after receiving the message notification, and transmit the obtained message to the message processing device at the same end;
[0011] The window updating device is used to update the remaining windows according to the received window synchronization message; or, calculate the size of the remaining windows and update the calculation result to the message header, and send the window synchronization message to the opposite end through the sending device at the same end.
[0012] Furthermore, the message processing device at the driver end is used to process the message to obtain the message length when there is a message to be processed, trigger the window update device at the driver end when it is determined that the remaining space in the cache device is greater than the message length, split the message when it is determined that the remaining space in the cache device is not greater than the message length, and trigger the window update device at the driver end when it is determined that the message that satisfies the sendable condition after the splitting is obtained, fill the cache device with the message that satisfies the sendable condition after the splitting, and send the message notification to the device end through the sending device at the driver end.
[0013] Furthermore, the receiving device at the device end is a multi-threaded device. After receiving the message notification sent by the sending device at the driver end, the receiving device at the device end uses the main thread to obtain the message in the buffer device and transmits the obtained message to the message processing device at the device end.
[0014] Furthermore, the message processing device on the device side is used to determine whether the message is a window synchronization message after receiving the message. If so, trigger the window update device on the device side. If not, further determine that the message is a message to be sent, and trigger the window update device on the device side when it is determined that the remaining windows meet the sending conditions. When the remaining windows do not meet the sending conditions, the message is split. When it is determined that the message that meets the conditions for sending is obtained after the split, the window update device on the device side is triggered, and the message that meets the conditions for sending is filled into the cache device, and the message notification is sent to the driver side through the sending device on the device side.
[0015] Furthermore, after receiving the message notification sent by the sending device at the device end, the receiving device at the driver end triggers the message processing device at the driver end.
[0016] Furthermore, the message processing device at the driver end is also used to determine whether the message notification received by the receiving device at the driver end is a window synchronization message. If so, the window update device at the driver end is triggered. If not, the message is processed and the window update device is triggered.
[0017] Furthermore, the window updating device at the driver end is used to deduct the size of the message to be sent from the remaining window when the remaining space is greater than the message length, or when a message that satisfies the sendable length is obtained after splitting, and to update the deducted window size to the window field in the message header, and to send a window synchronization message notification to the receiving device at the device end via the sending device at the driver end; it is also used to update the remaining windows according to the received window synchronization message, and return the update to the message processing device at the driver end after the update is completed; it is also used for the message notification received by the receiving device at the driver end is not a window synchronization message, and after the message processing device at the driver end processes the message, it recalculates the remaining windows and updates the calculation result to the window field in the message header, and to send a window synchronization message notification to the receiving device at the device end via the sending device at the driver end.
[0018] Furthermore, the window updating device on the device side is used to update the remaining windows according to the received window synchronization message, and return the message to the receiving device on the device side after the update is completed; it is also used to deduct the size of the message to be sent from the remaining window when the remaining space is greater than the message length, or when a message that satisfies the sendable requirement is obtained after splitting, and update the deducted window size to the window field in the message header, and send the window synchronization message notification to the receiving device on the driver side via the sending device on the device side.
[0019] The workflow of the system provided by the present invention is as follows:
[0020] 1) When the Kvm end has a message to be processed, it enters the message processing device of the Kvm end to perform the next message processing. When there is no message to be processed, the Kvm end needs to wait for the generation of the message.
[0021] 2) Get the length of the message to be processed and proceed to the next step.
[0022] 3) Determine whether the remaining space in the buffer (ie, the storage device) is sufficient to send the message. If there is not enough space, split the message and execute step 4); if there is enough space, directly proceed to step 5).
[0023] 4) The split messages that meet the send window are sent to step 5), and the split messages that do not meet the send window are returned to step 1) for processing.
[0024] 5) Enter the window update device on the Kvm side, deduct the message size to be sent this time from the remaining window, and update the calculation result to the window field in the message header, send the window synchronization message notification through the sending device on the Kvm side, and proceed to the next step.
[0025] 6) Fill the message into the buffer and proceed to the next step.
[0026] 7) Enter the sending device on the Kvm side to send a message notification to the Qemu side and proceed to the next step.
[0027] 8) Enter the receiving device of the Qemu end. After receiving the message, the Qemu end uses the main receiving thread to continuously obtain the messages in the buffer vring, and distributes the messages according to the load balancing strategy, and proceeds to the next step.
[0028] 9) Enter the message processing device on the Qemu side, judge the received message, if it is a synchronization message, enter the window update device on the Qemu side to update the remaining windows, and directly return to step 8) after window synchronization. If it is not a window synchronization message, proceed to the next step.
[0029] 10) The message processing device entering the Qemu end performs corresponding business processing on the received message and proceeds to the next step.
[0030] 11) Determine whether it is necessary to send a message to the Kvm end. If not, return to step 8) to enter the message receiving device of the Qemu end; if necessary, proceed to the next step.
[0031] 12) Get the length of the message to be sent and determine whether the remaining window is sufficient. If not, the message processing device on the Qemu side needs to be used to split the message. The message that meets the remaining window enters step 13) for processing, and the message that does not meet the window enters step 11) and waits for remaining space to be processed.
[0032] 13) After the window update device on the Qemu side recalculates the window and sends a window synchronization message notification (the window update device in step 15 will process it), the message is filled into the buffer and the next step is performed.
[0033] 14) Enter the sending device on the Qemu side, send the message notification to the Kvm side, and proceed to the next step.
[0034] 15) Enter the receiving device on the Kvm side to receive the notification message, then enter the message processing device on the Kvm side to determine whether it is a window synchronization message. If it is a synchronization message, enter the window updating device on the Kvm side to update the window and then enter step 1) for processing; if not, perform message processing and enter the next step.
[0035] 16) After the message processing device on the Kvm side completes the processing, first, the window updating device is entered to perform window updating and the window synchronization message is sent to the Qemu side for processing via the sending device on the Kvm side; secondly, the processing is re-entered into step 1).
[0036] In a second aspect, the technical solution of the present invention further provides a flow control method based on a buffer, comprising the following steps:
[0037] When the driver has a message to be processed, the driver processes the message to obtain the message length, determines whether the remaining space in the buffer is greater than the message length, and if so, triggers a window update; if not, the message is split, and when it is determined that a message that satisfies the sendable condition is obtained after the split, the window update is triggered, the message that satisfies the sendable condition after the split is filled into the buffer, and a message notification is sent to the device;
[0038] After receiving the message notification, the device side obtains the message in the buffer; determines whether the message is a window synchronization message, if so, triggers the window update, if not, determines whether the message is a message to be sent, determines whether the remaining windows meet the sending conditions, if so, triggers the window update, if not, splits the message, and determines that the message that meets the conditions for sending is obtained after the split, triggers the window update, fills the split message that meets the conditions for sending into the buffer, and sends the message notification to the driver side;
[0039] After receiving the message notification, the driver determines whether the message notification is a window synchronization message. If so, it triggers the window update. If not, it processes the message, triggers the window update, and sends the message notification to the device.
[0040] Furthermore, the steps of triggering window update include:
[0041] When the remaining space is greater than the message length, or when a message that can be sent is obtained after splitting, the size of the message to be sent is deducted from the remaining window, and the deducted window size is updated to the window field in the message header, and a message notification is sent to the device end or the driver end; or,
[0042] Update the remaining windows according to the received window synchronization message; or,
[0043] The message notification received by the driver is not a window synchronization message. After processing the message, the driver recalculates the remaining windows and updates the calculation results to the window field in the message header, and sends a window synchronization message notification to the device.
[0044] It can be seen from the above technical scheme that the present invention has the following advantages: it can avoid the communication blockage between the driver and the device caused by the frequent occurrence of peaks and valleys in extreme scenarios; at the same time, it can avoid the occurrence of blockage scenarios in extremely large message conditions, making the load more balanced; at the same time, the Qemu-side multi-threading mechanism of this scheme can greatly improve the message processing speed of the Qemu side, making message communication smoother.
[0045] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect.
[0046] It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 is a schematic block diagram of a system according to an embodiment of the present invention.
[0049] Figure 2 It is a message format diagram of an embodiment of the present invention.
[0050] Figure 3 is a schematic flow chart of a method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0052] like Figure 1 As shown, the technical solution of the present invention provides a flow control system based on a buffer, including a buffer, a device end simulated by Qemu, and a driver end simulated by Kvm; here, the device end may also be referred to as a Qemu end, and the driver end may also be referred to as a Kvm end;
[0053] The buffer is a cache device shared by the device side and the driver side for storing messages stored by the device side and the driver side;
[0054] The device end and the driver end are respectively provided with a message processing device, a window updating device, a message receiving device, and a message sending device;
[0055] A message processing device, used to perform service processing on the received message to trigger the window updating device at the same end, split the message when it is necessary to split the message, fill the message split offset and split flag into the message header, and fill the message that meets the sending conditions into the buffer device through the sending device, and send the message notification to the other end through the sending device;
[0056] A receiving device, configured to obtain the message in the cache device after receiving the message notification, and transmit the obtained message to the message processing device at the same end;
[0057] The window updating device is used to update the remaining windows according to the received window synchronization message; or, calculate the size of the remaining windows and update the calculation result to the message header, and send the window synchronization message to the other end through the sending device at the same end. The format of the message is as follows: Figure 2 shown.
[0058] The message processing device on the Qemu side is mainly responsible for processing specific services on the device side, and the message processing device on the Kvm side is mainly responsible for the services on the driver side; the window update device is mainly responsible for maintaining the size of the remaining window; the receiving device is mainly responsible for obtaining messages from the cache device; the sending device on the Qemu side is mainly responsible for storing device-side messages in the cache device, and the sending device on the Kvm side is mainly responsible for storing driver-side messages in the buffer device; the cache device is mainly responsible for storing messages between the Qemu side and the Kvm side.
[0059] The vring-based flow control system is composed of multiple device modules including message processing device, window update device, receiving device, sending device, and cache device. It supports multi-threaded processing on the Qemu side, supports the splitting of large messages, supports a more accurate window control mechanism, and uses the window mechanism to better achieve flow control.
[0060] In some embodiments, the message processing device at the driver end is used to process the message to obtain the message length when there is a message to be processed, and to trigger the window update device at the driver end when it is determined that the remaining space in the cache device is greater than the message length, and to split the message when it is determined that the remaining space in the cache device is not greater than the message length, and to trigger the window update device at the driver end when it is determined that the message that satisfies the sendable condition after the split is obtained, and to fill the message that satisfies the sendable condition after the split into the cache device, and to send a message notification to the device end through the sending device at the driver end. The message processing device at the driver end is also used to determine whether the message notification received by the receiving device at the driver end is a window synchronization message, and if so, to trigger the window update device at the driver end, and if not, to process the message and trigger the window update device.
[0061] That is to say, the message processing device at the driver end is responsible for receiving messages from the receiving device at the driver end and performing specific business processing and splitting the sent messages that need to be split; here, the principle of splitting is to comply with the sending window and message integrity. For example, messages have different types. If the incoming message type meets the remaining window, the message that meets the window type in this message will be split separately and sent, and other types of messages will be regarded as the split parts that do not meet the window; if the incoming message type does not meet the remaining window, the message that does not meet the remaining window type will be directly split, and the splitting process will fill the filled message with the split mark and split offset.
[0062] In some embodiments, the receiving device on the device side is a multi-threaded device. After receiving the message notification sent by the sending device on the driver side, the receiving device on the device side uses the main thread to obtain the message in the buffer device and transmits the obtained message to the message processing device on the device side.
[0063] In some embodiments, a message processing device on the device side is used to determine whether the message is a window synchronization message after receiving the message. If so, the window update device on the device side is triggered. If not, when further determining that the message is a message to be sent, the window update device on the device side is triggered when it is determined that the remaining windows meet the sending conditions. When the remaining windows do not meet the sending conditions, the message is split. When it is determined that the message that meets the conditions for sending is obtained after the split, the window update device on the device side is triggered, and the message that meets the conditions for sending is filled into the cache device, and the message notification is sent to the driver side through the sending device on the device side.
[0064] The message processing device at the device end receives the message from the receiving device at the device end and performs specific business processing and splits the sent messages that need to be split. When splitting, the principle of splitting is to comply with the sending window and message integrity. For example, messages have different types. If the incoming message type meets the remaining window, the message that meets the window type in this message will be split separately and sent, and other types of messages will be regarded as the split parts that do not meet the window; if the incoming message type does not meet the remaining window, the message that does not meet the remaining window type will be directly split, and the splitting process will fill the filled message with a split mark and a split offset.
[0065] After receiving the message notification sent by the sending device at the device end, the receiving device at the driver end triggers the message processing device at the driver end.
[0066] In some embodiments, the window updating device at the driver end is used to deduct the size of the message to be sent from the remaining window when the remaining space is greater than the message length, or when a message that can be sent is obtained after splitting, and to update the deducted window size to the window field in the message header, and to send a window synchronization message notification to the receiving device at the device end via the sending device at the driver end; it is also used to update the remaining windows according to the received window synchronization message, and return to the message processing device at the driver end after the update is completed; it is also used for the message notification received by the receiving device at the driver end is not a window synchronization message, and after the message processing device at the driver end processes the message, it recalculates the remaining windows and updates the calculation result to the window field in the message header, and sends the window synchronization message notification to the receiving device at the device end via the sending device at the driver end.
[0067] The window updating device at the device end is used to update the remaining windows according to the received window synchronization message, and return to the receiving device at the device end after the update is completed; it is also used to deduct the size of the message to be sent from the remaining window when the remaining space is greater than the message length, or when a message that satisfies the sendable length is obtained after splitting, and the deducted window size is updated to the window field in the message header, and the window synchronization message notification is sent to the receiving device at the driver end via the sending device at the device end.
[0068] That is to say, the functions of the window update device on the Qemu side and the Kvm side are the same. They have two triggering ways: one is to receive the message of updating the window from the receiving device on the Qemu side or the Kvm side to synchronize the remaining window size; the other is to recalculate the remaining window due to the message filling on the Qemu side or the Kvm side.
[0069] The cache device is responsible for opening up memory that can be accessed by both Qemu and Kvm. It can be a circular or non-circular cache area and must be physically continuous pages. It maintains the location where Qemu stores messages, the location where Qemu releases, the location where Kvm stores, the location where Kvm releases, and the messages stored by Qemu and Kvm.
[0070] The embodiment of the present invention further provides a flow control method based on a buffer zone, comprising the following steps:
[0071] When the driver has a message to be processed, the driver processes the message to obtain the message length, determines whether the remaining space in the buffer is greater than the message length, and if so, triggers a window update; if not, the message is split, and when it is determined that a message that satisfies the sendable condition is obtained after the split, the window update is triggered, the message that satisfies the sendable condition after the split is filled into the buffer, and a message notification is sent to the device;
[0072] After receiving the message notification, the device side obtains the message in the buffer; determines whether the message is a window synchronization message, if so, triggers the window update, if not, determines whether the message is a message to be sent, determines whether the remaining windows meet the sending conditions, if so, triggers the window update, if not, splits the message, and determines that the message that meets the conditions for sending is obtained after the split, triggers the window update, fills the split message that meets the conditions for sending into the buffer, and sends the message notification to the driver side;
[0073] After receiving the message notification, the driver determines whether the message notification is a window synchronization message. If so, it triggers the window update. If not, it processes the message, triggers the window update, and sends the message notification to the device.
[0074] It should be noted that the steps to trigger window update include:
[0075] When the remaining space is greater than the message length, or when a message that can be sent is obtained after splitting, the size of the message to be sent is deducted from the remaining window, and the deducted window size is updated to the window field in the message header, and a message notification is sent to the device end or the driver end; or,
[0076] Update the remaining windows according to the received window synchronization message; or,
[0077] The message notification received by the driver is not a window synchronization message. After processing the message, the driver recalculates the remaining windows and updates the calculation results to the window field in the message header, and sends a window synchronization message notification to the device.
[0078] like Figure 3 As shown, the specific steps are as follows;
[0079] The workflow of the system provided by the present invention is as follows:
[0080] 1) When the Kvm end has a message to be processed, it enters the message processing device of the Kvm end to perform the next message processing. When there is no message to be processed, the Kvm end needs to wait for the generation of the message.
[0081] 2) Get the length of the message to be processed and proceed to the next step.
[0082] 3) Determine whether the remaining space in the buffer (ie, the storage device) is sufficient to send the message. If there is not enough space, split the message and execute step 4); if there is enough space, directly proceed to step 5).
[0083] 4) The split messages that meet the send window are sent to step 5), and the split messages that do not meet the send window are returned to step 1) for processing.
[0084] 5) Enter the window update device on the Kvm side, deduct the message size to be sent this time from the remaining window, and update the calculation result to the window field in the message header, send the window synchronization message notification through the sending device on the Kvm side, and proceed to the next step.
[0085] 6) Fill the message into the buffer and proceed to the next step.
[0086] 7) Enter the sending device on the Kvm side to send a message notification to the Qemu side and proceed to the next step.
[0087] 8) Enter the receiving device of the Qemu end. After receiving the message, the Qemu end uses the main receiving thread to continuously obtain the messages in the buffer vring, and distributes the messages according to the load balancing strategy, and proceeds to the next step.
[0088] 9) Enter the message processing device on the Qemu side, judge the received message, if it is a synchronization message, enter the window update device on the Qemu side to update the remaining windows, and directly return to step 8) after window synchronization. If it is not a window synchronization message, proceed to the next step.
[0089] 10) The message processing device entering the Qemu end performs corresponding business processing on the received message and proceeds to the next step.
[0090] 11) Determine whether it is necessary to send a message to the Kvm end. If not, return to step 8) to enter the message receiving device of the Qemu end; if necessary, proceed to the next step.
[0091] 12) Get the length of the message to be sent and determine whether the remaining window is sufficient. If not, the message processing device on the Qemu side needs to be used to split the message. The message that meets the remaining window enters step 13) for processing, and the message that does not meet the window enters step 11) and waits for remaining space to be processed.
[0092] 13) After the window update device on the Qemu side recalculates the window and sends a window synchronization message notification (the window update device in step 15 will process it), the message is filled into the buffer and the next step is performed.
[0093] 14) Enter the sending device on the Qemu side, send the message notification to the Kvm side, and proceed to the next step.
[0094] 15) Enter the receiving device on the Kvm side to receive the notification message, then enter the message processing device on the Kvm side to determine whether it is a window synchronization message. If it is a synchronization message, enter the window updating device on the Kvm side to update the window and then enter step 1) for processing; if not, perform message processing and enter the next step.
[0095] 16) After the message processing device on the Kvm side completes the processing, first, the window updating device is entered to perform window updating and the window synchronization message is sent to the Qemu side for processing via the sending device on the Kvm side; secondly, the processing is re-entered into step 1).
[0096] Although the present invention has been described in detail by referring to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person of ordinary skill in the art may easily think of changes or substitutions within the technical scope disclosed by the present invention, and these shall be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A flow control system based on a buffer zone, characterized in that: Including the buffer, the device side simulated by Qemu, and the driver side simulated by Kvm; The buffer is a cache device shared by the device side and the driver side for storing messages stored by the device side and the driver side; The device end and the driver end are respectively provided with a message processing device, a window updating device, a message receiving device, and a message sending device; A message processing device, used to perform service processing on the received message to trigger the window updating device at the same end, split the message when it is necessary to split the message, fill the message split offset and split flag into the message header, and fill the message that meets the sending condition into the cache device through the sending device, and send a message notification to the other end through the sending device; a receiving device, used to obtain the message in the cache device after receiving the message notification, and transmit the obtained message to the message processing device at the same end; A window updating device, used to update the remaining windows according to the received window synchronization message; or, to calculate the size of the remaining windows and update the calculation result to the message header, and to send the window synchronization message to the opposite end through the sending device at the same end; The message processing device at the driver end is used to process the message to obtain the message length when there is a message to be processed, trigger the window updating device at the driver end when it is determined that the remaining space in the cache device is greater than the message length, split the message when it is determined that the remaining space in the cache device is not greater than the message length, and trigger the window updating device at the driver end when it is determined that the message that satisfies the sendability after the splitting is obtained, fill the message that satisfies the sendability after the splitting into the cache device, and send the message notification to the device end through the sending device at the driver end; The message processing device at the device end is used to determine whether the message is a window synchronization message after receiving the message. If so, the window update device at the device end is triggered. If not, when further determining that the message is a message to be sent, the window update device at the device end is triggered when it is determined that the remaining windows meet the sending conditions. When the remaining windows do not meet the sending conditions, the message is split. When it is determined that the splitting results in a message that meets the requirements for sending, the window update device at the device end is triggered, and the splitting results in a message that meets the requirements for sending into the cache device, and the message notification is sent to the driver end through the sending device at the device end. The window updating device at the driver end is used to deduct the size of the message to be sent from the remaining window when the remaining space is greater than the message length, or when a message that can be sent is obtained after splitting, and to update the deducted window size to the window field in the message header, and to send a window synchronization message notification to the receiving device at the device end through the sending device at the driver end; It is also used to update the remaining windows according to the received window synchronization message, and return the message to the message processing device at the driver end after the update is completed; it is also used when the message notification received by the receiving device at the driver end is not a window synchronization message. After the message processing device at the driver end processes the message, it recalculates the remaining windows and updates the calculation results to the window field in the message header, and sends the window synchronization message notification to the receiving device at the device end via the sending device at the driver end.
2. The flow control system based on buffer zone according to claim 1, characterized in that: The receiving device at the device end is a multi-threaded device. After receiving the message notification sent by the sending device at the driver end, the receiving device at the device end uses the main thread to obtain the message in the buffer device and transmits the obtained message to the message processing device at the device end.
3. The flow control system based on buffer zone according to claim 2, characterized in that: After receiving the message notification sent by the sending device at the device end, the receiving device at the driver end triggers the message processing device at the driver end.
4. The flow control system based on buffer zone according to claim 3, characterized in that: The message processing device at the driver end is also used to determine whether the message notification received by the receiving device at the driver end is a window synchronization message. If so, the window update device at the driver end is triggered. If not, the message is processed and the window update device is triggered.
5. The flow control system based on buffer zone according to claim 4, characterized in that: The window updating device at the device end is used to update the remaining windows according to the received window synchronization message, and return to the receiving device at the device end after the update is completed; it is also used to deduct the size of the message to be sent from the remaining window when the remaining space is greater than the message length, or when a message that satisfies the sendable length is obtained after splitting, and the deducted window size is updated to the window field in the message header, and the window synchronization message notification is sent to the receiving device at the driver end via the sending device at the device end.
6. A flow control method based on a buffer, characterized in that: The steps include: When the driver has a message to be processed, the driver processes the message to obtain the message length, determines whether the remaining space in the buffer is greater than the message length, and if so, triggers a window update; if not, the message is split, and when it is determined that a message that satisfies the sendable condition is obtained after the split, the window update is triggered, the message that satisfies the sendable condition after the split is filled into the buffer, and a message notification is sent to the device; After receiving the message notification, the device side obtains the message in the buffer; determines whether the message is a window synchronization message, if so, triggers the window update, if not, determines whether the message is a message to be sent, determines whether the remaining windows meet the sending conditions, if so, triggers the window update, if not, splits the message, and determines that the message that meets the conditions for sending is obtained after the split, triggers the window update, fills the split message that meets the conditions for sending into the buffer, and sends the message notification to the driver side; After receiving the message notification, the driver determines whether the message notification is a window synchronization message. If so, it triggers the window update. If not, it processes the message, triggers the window update, and sends the message notification to the device. The steps to trigger a window update include: When the remaining space is greater than the message length, or when a message that can be sent is obtained after splitting, the size of the message to be sent is deducted from the remaining window, and the deducted window size is updated to the window field in the message header, and a message notification is sent to the device end or the driver end; or, Update the remaining windows according to the received window synchronization message; or, The message notification received by the driver is not a window synchronization message. After processing the message, the driver recalculates the remaining windows and updates the calculation results to the window field in the message header, and sends a window synchronization message notification to the device.
