Data writing method and device, equipment, storage medium and program product
By dynamically adjusting the data writing strategy by receiving AckNack messages, the problems of high data packet loss rate and data overlay loss caused by dynamic changes in the network environment in the DDS system are solved, thereby achieving resource optimization and improved transmission efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZEBRED NETWORK TECH CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-28
AI Technical Summary
Existing DDS systems suffer from high data packet loss rates in resource-constrained embedded environments, leading to increased CPU resource and time costs. Furthermore, dynamic changes in the network environment can cause data overlay and loss, reducing transmission efficiency.
By receiving AckNack messages, the upper limit of the number of unacknowledged data that a data writer can accommodate can be dynamically adjusted, blocking or allowing data to be written to the historical cache, thus avoiding excessive data writing during periods of high packet loss or network congestion.
It reduces the risk of data packet loss, optimizes memory resource usage, improves transmission efficiency and stability, and solves the problem of resource waste under traditional fixed strategies.
Smart Images

Figure CN121940104A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of distributed communication technology, and in particular to a data writing method, apparatus, device, storage medium, and program product. Background Technology
[0002] In scenarios such as autonomous driving where communication reliability is extremely critical, the DDS protocol is widely used to achieve efficient data transmission between devices. For example, in autonomous driving systems, vehicles need to receive sensor data, environmental perception information, and control commands in real time via the DDS protocol; any data loss or delay could lead to safety hazards.
[0003] However, existing DDS systems have the following problems in resource-constrained embedded environments (such as automotive computing units and industrial controllers): On the one hand, under traditional Quality of Service (QoS) configurations, data writers need to maintain communication reliability through heartbeat packets and AckNack messages. However, to avoid or mitigate end-to-end packet loss, sufficient historical cache space and transport layer cache space are often required. However, such additional configuration will consume a lot of memory resources. On the other hand, dynamic changes in the network environment can lead to data overwriting and loss. For example, in a shared memory channel, data that has not been read in time may be overwritten by new data, causing serious packet loss. In addition, packet loss not only triggers additional data retransmission, causing a significant increase in CPU resources and time costs, but also increases the interaction frequency of Heartbeat and AckNack, thereby reducing the overall transmission efficiency.
[0004] Therefore, there is an urgent need for a dynamically adjustable data writing solution. Summary of the Invention
[0005] This application provides a data writing method, apparatus, device, storage medium, and program product to prevent unread data from being overwritten by new data, thus avoiding packet loss.
[0006] In a first aspect, embodiments of this application provide a data writing method, comprising: applied to a data writer, the data writer being configured with an upper limit on the allowed amount of unconfirmed data, including:
[0007] Receive AckNack messages, which are used to indicate data acknowledgment messages and / or data unacknowledged messages;
[0008] Based on the AckNack message, determine the current number of unacknowledged data for the data writer;
[0009] When the data writer receives the data to be written, it determines whether the current number of unconfirmed data has reached the upper limit of the allowed number of unconfirmed data.
[0010] If the current number of unconfirmed data reaches the upper limit of the allowed number of unconfirmed data, the writing of the data to be written will be blocked and written to the historical cache; where the historical cache refers to the area used by the data writer to temporarily store the data to be sent.
[0011] If the current number of unconfirmed data has not reached the upper limit of the allowed number of unconfirmed data, then the data to be written is allowed to be written to the historical cache.
[0012] In one possible implementation, the method further includes:
[0013] Determine the parameters corresponding to the historical cache. These parameters include the upper limit on the number of unacknowledged data entries allowed and the corresponding update period.
[0014] An update coroutine is created based on the upper limit of the number of unconfirmed data that can be accommodated and the update cycle; the update coroutine is used to update the upper limit of the number of unconfirmed data that can be accommodated in response to the update cycle.
[0015] In one possible implementation, before determining whether the current number of unacknowledged data entries has reached the upper limit of the allowed number of unacknowledged data entries when the data writer receives the data to be sent, the method further includes:
[0016] Determine whether the current time of receiving the AckNack message is the update time corresponding to the update cycle;
[0017] If the current time of receiving the AckNack message is the update time corresponding to the update cycle, then the current time is determined to be the update time corresponding to the upper limit of the number of unacknowledged data that can be accommodated, and the update goroutine is executed;
[0018] Collect all AckNack messages between the update time and the previous update time; based on the all AckNack messages, update the upper limit of the number of unacknowledged data that can be accommodated.
[0019] In one possible implementation, the upper limit on the allowed number of unacknowledged data messages is updated based on the full AckNack message, including:
[0020] Determine if there are any unacknowledged data messages in the full AckNack message list;
[0021] If there are unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is greater than the minimum number of unacknowledged data messages.
[0022] If the upper limit of the allowed number of unconfirmed data is greater than the minimum number of unconfirmed data, the upper limit of the allowed number of unconfirmed data will be updated according to the preset shrinking step size.
[0023] In one possible implementation, the method further includes:
[0024] If there are no unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is less than the maximum number of unacknowledged data messages.
[0025] If the upper limit of the number of unconfirmed data that can be accommodated is less than the maximum number of unconfirmed data, then the upper limit of the number of unconfirmed data that can be accommodated will be updated according to the preset expansion step size.
[0026] In one possible implementation, based on the AckNack message, the current number of unacknowledged data items corresponding to the data writer is determined, including:
[0027] Determine whether the AckNack message contains an unacknowledged data message. If the AckNack message contains an unacknowledged data message;
[0028] Based on the unconfirmed data messages, determine the number of unconfirmed data; and use this number of unconfirmed data as the current number of unconfirmed data for the data writer.
[0029] If the AckNack message does not contain any unacknowledged data messages, then the current number of unacknowledged data messages for the data writer is determined to be zero.
[0030] Secondly, embodiments of this application provide a data writing device, comprising: an application for a data writer, the data writer being configured with an upper limit on the amount of unconfirmed data that can be accommodated, including:
[0031] The receiving module is used to receive AckNack messages, which are used to indicate data acknowledgment messages and / or data unacknowledgment messages;
[0032] The processing module is used to determine the current number of unacknowledged data for the data writer based on the AckNack message;
[0033] The processing module is used to determine whether the current number of unconfirmed data has reached the upper limit of the allowed number of unconfirmed data when the data writer receives the data to be written.
[0034] The write module is used to block writing the data to be written to the history cache if the current number of unacknowledged data reaches the upper limit of the allowed number of unacknowledged data; the history cache refers to the area used by the data writer to temporarily store the data to be sent.
[0035] The write module is also used to allow data to be written to the historical cache if the current number of unconfirmed data has not reached the upper limit of the number of unconfirmed data that can be accommodated.
[0036] In one possible implementation, the processing module is further configured to:
[0037] Determine the parameters corresponding to the historical cache. These parameters include the upper limit on the number of unacknowledged data entries allowed and the corresponding update period.
[0038] An update coroutine is created based on the upper limit of the number of unconfirmed data that can be accommodated and the update cycle; the update coroutine is used to update the upper limit of the number of unconfirmed data that can be accommodated in response to the update cycle.
[0039] In one possible implementation, the processing module is further configured to:
[0040] Determine whether the current time of receiving the AckNack message is the update time corresponding to the update cycle;
[0041] If the current time of receiving the AckNack message is the update time corresponding to the update cycle, then the current time is determined to be the update time corresponding to the upper limit of the number of unacknowledged data that can be accommodated, and the update goroutine is executed;
[0042] Collect all AckNack messages between the update time and the previous update time; based on the all AckNack messages, update the upper limit of the number of unacknowledged data that can be accommodated.
[0043] In one possible implementation, the processing module is further configured to:
[0044] Determine if there are any unacknowledged data messages in the full AckNack message list;
[0045] If there are unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is greater than the minimum number of unacknowledged data messages.
[0046] If the upper limit of the allowed number of unconfirmed data is greater than the minimum number of unconfirmed data, the upper limit of the allowed number of unconfirmed data will be updated according to the preset shrinking step size.
[0047] In one possible implementation, the processing module is further configured to:
[0048] If there are no unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is less than the maximum number of unacknowledged data messages.
[0049] If the upper limit of the number of unconfirmed data that can be accommodated is less than the maximum number of unconfirmed data, then the upper limit of the number of unconfirmed data that can be accommodated will be updated according to the preset expansion step size.
[0050] In one possible implementation, the processing module is further configured to:
[0051] Determine whether the AckNack message contains an unacknowledged data message. If the AckNack message contains an unacknowledged data message;
[0052] Based on the unconfirmed data messages, determine the number of unconfirmed data; and use this number of unconfirmed data as the current number of unconfirmed data for the data writer.
[0053] If the AckNack message does not contain any unacknowledged data messages, then the current number of unacknowledged data messages for the data writer is determined to be zero.
[0054] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0055] The memory stores instructions that the computer executes;
[0056] The processor executes computer execution instructions stored in memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0057] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.
[0058] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.
[0059] The data writing method, apparatus, device, storage medium, and program product provided in this application determine the current number of unacknowledged data items for the data writer based on receiving an AckNack message. Then, when the data writer receives data to be written, it first determines whether the current number of unacknowledged data items reaches the upper limit of the allowed number of unacknowledged data items. If the current number of unacknowledged data items reaches the upper limit, writing the data to be written is blocked; if the current number of unacknowledged data items does not reach the upper limit, writing the data to be written is allowed. This application dynamically adjusts the write operation for the data writer by receiving an AckNack message and the upper limit of the allowed number of unacknowledged data items, avoiding excessive writing of data to the historical cache during periods of high packet loss or network congestion, thereby reducing the risk of packet loss. Attached Figure Description
[0060] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0061] Figure 1 A flowchart illustrating a data writing method provided in this application. Figure 1 ;
[0062] Figure 2 A flowchart illustrating a data writing method provided in this application. Figure 2 ;
[0063] Figure 3 A schematic diagram of a data writing device provided in this application;
[0064] Figure 4 This is a schematic diagram of the structure of an electronic device provided in this application.
[0065] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation
[0066] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0067] In scenarios such as autonomous driving where communication reliability is extremely critical, the DDS protocol is widely used to achieve efficient data transmission between devices. For example, in autonomous driving systems, vehicles need to receive sensor data, environmental perception information, and control commands in real time via the DDS protocol; any data loss or delay could lead to safety hazards.
[0068] However, existing DDS systems have the following problems in resource-constrained embedded environments (such as automotive computing units and industrial controllers): On the one hand, under traditional Quality of Service (QoS) configurations, data writers need to maintain communication reliability through heartbeat packets and AckNack messages. However, to avoid or mitigate end-to-end packet loss, sufficient historical cache space and transport layer cache space are often required. However, such additional configuration will consume a lot of memory resources. On the other hand, dynamic changes in the network environment can lead to data overwriting and loss. For example, in a shared memory channel, data that has not been read in time may be overwritten by new data, causing serious packet loss. In addition, packet loss not only triggers additional data retransmission, causing a significant increase in CPU resources and time costs, but also increases the interaction frequency of Heartbeat and AckNack, thereby reducing the overall transmission efficiency.
[0069] Therefore, there is an urgent need for a dynamically adjustable data writing solution.
[0070] The data writing method, apparatus, device, storage medium, and program product provided in this application determine the current number of unacknowledged data entries for the data writer based on the received AckNack message. Then, when the data writer receives data to be written, it first determines whether the current number of unacknowledged data entries reaches the upper limit of the allowed number of unacknowledged data entries. If the current number of unacknowledged data entries reaches the upper limit, writing the data to be written is blocked; if the current number of unacknowledged data entries does not reach the upper limit, writing the data to be written is allowed. This application dynamically adjusts the write operation for the data writer by receiving AckNack messages and the upper limit of the allowed number of unacknowledged data entries, avoiding excessive writing of data to the historical cache during periods of high packet loss or network congestion, thereby reducing the risk of packet loss.
[0071] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0072] Figure 1A flowchart illustrating a data writing method provided in this application. Figure 1 ,like Figure 1 As shown, this application describes a data writing method for a data writer, which is configured with an upper limit on the amount of unconfirmed data it can hold. The method includes:
[0073] S101. Receive an AckNack message, which is used to indicate a data acknowledgment message and / or a data unacknowledgment message;
[0074] The AckNack message is used to notify the data writer and data reader of successfully received data, as well as whether any data has been missed and needs to be resent. Specifically, the AckNack message contains a sequence number set, which indicates the sequence number of the missing data for the data reader, so that the data writer can identify the data that needs to be resent to ensure the reliability of data transmission. If the sequence number set is empty, it means that the data reader has received all the sent data.
[0075] Data acknowledgment information refers to data that has been received, while data unacknowledged information refers to data that has not been received. For example, if the SequenceNumberSet in a received AckNack message is "base = 1, bitmap = 01010", where 1 indicates data not received and 0 indicates data received, and "base" refers to the starting sequence number of the bits in the bitmap, then we can determine that bits 0, 2, and 4 of the bitmap are 0, and bits 1 and 3 are 1. That is, data corresponding to sequence numbers 2 and 4 were not received, while data corresponding to sequence numbers 1, 3, and 5 were received. Therefore, based on this SequenceNumberSet, we can determine that "data 2 corresponding to sequence number 2 and data 4 corresponding to sequence number 4 were not received," and "data 1 corresponding to sequence number 1, data 3 corresponding to sequence number 3, and data 5 corresponding to sequence number 5 were received." Thus, the data acknowledgment information is "data 1, data 3, and data 5 have been acknowledged," and the data unacknowledged information is "data 2 and data 4 were not received."
[0076] S102. Based on the AckNack message, determine the current number of unacknowledged data for the data writer.
[0077] Based on the above, for example, if there are 2 unacknowledged data entries in an AckNack message, namely data 2 and data 4, then the current number of unacknowledged data entries corresponding to the data writer is 2.
[0078] In one possible implementation, the number of unacknowledged data items for the data writer is determined based on the AckNack message, as follows:
[0079] Determine whether the AckNack message contains an unacknowledged data message. If the AckNack message contains an unacknowledged data message;
[0080] Based on the unconfirmed data messages, determine the number of unconfirmed data; and use this number of unconfirmed data as the current number of unconfirmed data for the data writer.
[0081] If the AckNack message does not contain any unacknowledged data messages, then the current number of unacknowledged data messages for the data writer is determined to be zero.
[0082] Specifically, for example, based on the received AckNack message, first determine whether the AckNack message includes unacknowledged data messages; if the received AckNack message includes unacknowledged data messages, then determine the number of unacknowledged data messages in the AckNack message; for example, if the AckNack message contains data acknowledgment information as "Data 1, Data 2, Data 3, ..., Data 15 have been acknowledged as received", and data unacknowledged information as "Data 16, Data 17, ..., Data 35 have not been received", then the number of unacknowledged data messages can be determined to be 25. Therefore, the current number of unacknowledged data messages corresponding to the data writer = the number of unacknowledged data messages corresponding to the AckNack message = 25 messages.
[0083] Similarly, if the AckNack message is: "Data 1, Data 2, Data 3, Data 4, ..., Data 35 have been confirmed received", excluding unacknowledged data, then the number of unacknowledged data can be determined to be 0; therefore, the current number of unacknowledged data corresponding to the data writer is zero.
[0084] This step determines the current number of unacknowledged data by the data writer based on the received AckNack messages, so as to accurately count the number of unacknowledged data and avoid omissions or errors in recording unacknowledged data.
[0085] S103. When the data writer receives the data to be written, determine whether the current number of unconfirmed data has reached the upper limit of the number of unconfirmed data that can be accommodated.
[0086] To prevent unread data from being overwritten by new data in a shared memory channel, causing severe packet loss, an upper limit (current_allowed_nack_sample_num_max) is set to control the amount of data written by the data writer, thus preventing unreceived data from being overwritten by new data and resulting in data loss.
[0087] For example, the maximum number of unconfirmed data entries allowed is 30. When writing new data "Data A", the data writer first determines whether the current number of unconfirmed data entries has reached the maximum number of unconfirmed data entries allowed. Based on the above, the current number of unconfirmed data entries is 25. Therefore, the current number of unconfirmed data entries is 25, which does not reach the maximum number of unconfirmed data entries allowed, which is 30.
[0088] In one possible implementation, the method further includes:
[0089] Determine the parameters corresponding to the historical cache. These parameters include the upper limit on the number of unacknowledged data entries allowed and the corresponding update period.
[0090] An update coroutine is created based on the upper limit of the number of unconfirmed data that can be accommodated and the update cycle; the update coroutine is used to update the upper limit of the number of unconfirmed data that can be accommodated in response to the update cycle.
[0091] To address the shortcomings of existing solutions, which lack a proactive transmission frequency adjustment mechanism based on network state prediction and thus cannot automatically optimize data transmission rates under varying network quality, leading to increased packet loss rates under high load and insufficient throughput during idle periods, this paper proposes an update coroutine that dynamically adjusts `current_allowed_nack_sample_num_max` based on AckNack message feedback. This enables proactive prediction and response to network conditions. Furthermore, the periodic scheduling characteristics of the coroutine ensure the real-time performance and stability of the `current_allowed_nack_sample_num_max` adjustment.
[0092] Specifically, an update coroutine is created based on the upper limit of the number of unacknowledged data allowed (current_allowed_nack_sample_num_max) and the corresponding update period (update_period). For example, update_period is set to "update current_allowed_nack_sample_num_max every 500 milliseconds".
[0093] In one possible implementation, Figure 2 A flowchart illustrating a data writing method provided in this application. Figure 2 ,like Figure 2 As shown, before determining whether the current number of unacknowledged data has reached the upper limit of the allowed number of unacknowledged data when the data writer receives data to be sent, the following steps are also included:
[0094] S201. Determine whether the current time of receiving the AckNack message is the update time corresponding to the update cycle;
[0095] S202. If the current time of receiving the AckNack message is the update time corresponding to the update cycle, then determine that the current time is the update time corresponding to the upper limit of the number of unacknowledged data that can be accommodated, and execute the update goroutine.
[0096] S203. Collect all AckNack messages between the update time and the previous update time; based on the all AckNack messages, update the upper limit of the number of unacknowledged data that can be accommodated.
[0097] Specifically, after receiving the AckNack message and before the data writer receives the data to be sent, it first determines whether the current time of receiving the AckNack message is the update time corresponding to update_period. If it is determined that the current time of receiving the AckNack message is the update time corresponding to update_period, then the upper limit of the number of unacknowledged data that can be accommodated is updated first, and then it is determined whether the current number of unacknowledged data has reached the upper limit of the number of unacknowledged data that can be accommodated.
[0098] For example, if `update_period` is set to "update the upper limit of the allowed number of unacknowledged data every 500 milliseconds," such as 60,000 milliseconds per minute, then the upper limit of the allowed number of unacknowledged data will be updated 120 times within one minute. The update times would be as follows: 14:20:05.500. If the current time of receiving the AckNack message is 14:20:05.500, it can be determined that the current time of receiving the AckNack message is the update time corresponding to `update_period`. Therefore, all AckNack messages received between the two update times of 14:20:05.000 and 14:20:05.500 are retrieved. For example, the AckNack messages received between 14:20:05.000 and 14:20:05.500 include: "AckNack message 1, AckNack message 2, AckNack message 3; based on the received AckNack message 1, AckNack message 2, and AckNack message 3, update the upper limit of the number of unacknowledged data that can be accommodated; and feed back the updated upper limit of the number of unacknowledged data that can be accommodated to the data writer."
[0099] Before the data writer receives the data to be sent, it determines whether the current time is an update time. This is to avoid the situation where the upper limit of the allowed number of unacknowledged data is not updated before the update time is reached, which would lead to inaccurate results in determining whether the current number of unacknowledged data has reached the upper limit of the allowed number of unacknowledged data.
[0100] In one possible implementation, the upper limit on the number of unacknowledged data that can be accommodated is updated based on the full AckNack message, as follows:
[0101] Determine if there are any unacknowledged data messages in the full AckNack message list;
[0102] If there are unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is greater than the minimum number of unacknowledged data messages.
[0103] If the upper limit of the allowed number of unconfirmed data is greater than the minimum number of unconfirmed data, the upper limit of the allowed number of unconfirmed data will be updated according to the preset shrinking step size.
[0104] The minimum number of unacknowledged data (min_allowed_nack_sample_num) and the shrinking step size are set according to requirements. For example, the minimum number of unacknowledged data can be set to "20" and the shrinking step size can be set to 10.
[0105] Based on the above, determine whether there are any unacknowledged data messages in the full set of AckNack messages; if the determination shows that there are unacknowledged data messages in AckNack message 2 among AckNack message 1, AckNack message 2, and AckNack message 3, then it is determined that there are unacknowledged data messages in the full set of AckNack messages; and then reduce and update the upper limit of the number of unacknowledged data messages that can be accommodated.
[0106] Specifically, by comparing the upper limit of the allowed number of unconfirmed data items "30" with the minimum number of unconfirmed data items "20", we can see that the upper limit of the allowed number of unconfirmed data items is greater than the minimum number of unconfirmed data items. Therefore, the upper limit of the allowed number of unconfirmed data items is updated according to the preset reduction step size "10", so the updated upper limit of the allowed number of unconfirmed data items = 30 - 10 = 20.
[0107] In one possible implementation, the method further includes:
[0108] If there are no unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is less than the maximum number of unacknowledged data messages.
[0109] If the upper limit of the number of unconfirmed data that can be accommodated is less than the maximum number of unconfirmed data, then the upper limit of the number of unconfirmed data that can be accommodated will be updated according to the preset expansion step size.
[0110] The maximum number of unacknowledged data (max_allowed_nack_sample_num) and the step size are set according to requirements. For example, the maximum number of unacknowledged data can be set to "100" and the step size to 10.
[0111] Similarly, if AckNack messages 1, 2, and 3 do not contain any unacknowledged data messages, then it is determined that there are no unacknowledged data messages in the entire set of AckNack messages; the upper limit of the allowed number of unacknowledged data messages is then expanded and updated. Specifically, comparing the upper limit of the allowed number of unacknowledged data messages "30" with the maximum number of unacknowledged data messages "100", we find that the upper limit of the allowed number of unacknowledged data messages is less than the maximum number of unacknowledged data messages. Therefore, the upper limit of the allowed number of unacknowledged data messages is updated by a preset expansion step of "10 messages", resulting in an updated upper limit of the allowed number of unacknowledged data messages = 30 + 10 = 40 messages.
[0112] In summary, by dynamically adjusting the upper limit of the amount of unconfirmed data that can be accommodated, the problem of resource waste or insufficient caching in traditional fixed-depth strategies is solved, thus balancing memory usage and data reliability and ensuring stable operation in resource-constrained environments.
[0113] S104. If the current number of unconfirmed data reaches the upper limit of the allowed number of unconfirmed data, then the writing of the data to be written will be blocked and written to the historical cache; where the historical cache refers to the area used by the data writer to temporarily store the data to be sent.
[0114] For example, if the current number of unacknowledged data items is 30, it can be determined that the upper limit of the allowed number of unacknowledged data items has been reached. Therefore, the writing of the data to be written will be blocked and written to the historical cache. Wait to receive a new AckNack message to re-determine the current number of unacknowledged data items. If the current number of unacknowledged data items is re-determined to be less than 30, the writing of the data to be written to the historical cache can continue.
[0115] S105. If the current number of unconfirmed data does not reach the upper limit of the allowed number of unconfirmed data, then the data to be written is allowed to be written to the historical cache.
[0116] Based on the foregoing, it can be determined that the current number of unconfirmed data entries is 25, which is less than the maximum allowed number of unconfirmed data entries of 30. Therefore, it is permissible to write the data to be written to the historical cache.
[0117] This application provides a data writing method based on receiving an AckNack message to determine the current number of unacknowledged data entries for the data writer. Then, when the data writer receives data to be written, it first determines whether the current number of unacknowledged data entries reaches the upper limit of the allowed number of unacknowledged data entries. If the current number of unacknowledged data entries reaches the upper limit, writing the data to be written is blocked; if the current number of unacknowledged data entries does not reach the upper limit, writing the data to be written is allowed. This application dynamically adjusts the write operation for the data writer by receiving the AckNack message and the upper limit of the allowed number of unacknowledged data entries, avoiding excessive writing of data to the historical cache during periods of high packet loss or network congestion, thereby reducing the risk of packet loss.
[0118] Figure 3 A schematic diagram of a data writing device provided in this application is shown below. Figure 3 As shown, this embodiment provides a data writing device 300, which is configured to accommodate an upper limit on the amount of unacknowledged data a data writer can hold. The device includes:
[0119] The receiving module 301 is used to receive AckNack messages, which are used to indicate data acknowledgment messages and / or data unacknowledgment messages;
[0120] Processing module 302 is used to determine the number of currently unacknowledged data corresponding to the data writer based on the AckNack message;
[0121] Processing module 302 is used to determine whether the current number of unconfirmed data has reached the upper limit of the number of unconfirmed data that can be accommodated when the data writer receives the data to be written.
[0122] The writing module 303 is used to block the writing of the data to be written to the historical cache if the current number of unacknowledged data reaches the upper limit of the number of unacknowledged data that can be accommodated; where the historical cache refers to the area used by the data writer to temporarily store the data to be sent.
[0123] The writing module 303 is also used to allow the data to be written to the historical cache if the current number of unconfirmed data has not reached the upper limit of the number of unconfirmed data that can be accommodated.
[0124] In one possible implementation, the processing module 302 is further configured to:
[0125] Determine the parameters corresponding to the historical cache. These parameters include the upper limit on the number of unacknowledged data entries allowed and the corresponding update period.
[0126] An update coroutine is created based on the upper limit of the number of unconfirmed data that can be accommodated and the update cycle; the update coroutine is used to update the upper limit of the number of unconfirmed data that can be accommodated in response to the update cycle.
[0127] In one possible implementation, the processing module 302 is further configured to:
[0128] Determine whether the current time of receiving the AckNack message is the update time corresponding to the update cycle;
[0129] If the current time of receiving the AckNack message is the update time corresponding to the update cycle, then the current time is determined to be the update time corresponding to the upper limit of the number of unacknowledged data that can be accommodated, and the update goroutine is executed;
[0130] Collect all AckNack messages between the update time and the previous update time; based on the all AckNack messages, update the upper limit of the number of unacknowledged data that can be accommodated.
[0131] In one possible implementation, the processing module 302 is further configured to:
[0132] Determine if there are any unacknowledged data messages in the full AckNack message list;
[0133] If there are unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is greater than the minimum number of unacknowledged data messages.
[0134] If the upper limit of the allowed number of unconfirmed data is greater than the minimum number of unconfirmed data, the upper limit of the allowed number of unconfirmed data will be updated according to the preset shrinking step size.
[0135] In one possible implementation, the processing module 302 is further configured to:
[0136] If there are no unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data messages that can be accommodated is less than the maximum number of unacknowledged data messages.
[0137] If the upper limit of the number of unconfirmed data that can be accommodated is less than the maximum number of unconfirmed data, then the upper limit of the number of unconfirmed data that can be accommodated will be updated according to the preset expansion step size.
[0138] In one possible implementation, the processing module 302 is further configured to:
[0139] Determine whether the AckNack message contains an unacknowledged data message. If the AckNack message contains an unacknowledged data message;
[0140] Based on the unconfirmed data messages, determine the number of unconfirmed data; and use this number of unconfirmed data as the current number of unconfirmed data for the data writer.
[0141] If the AckNack message does not contain any unacknowledged data messages, then the current number of unacknowledged data messages for the data writer is determined to be zero.
[0142] The data writing device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0143] Figure 4 This is a schematic diagram of the structure of an electronic device provided in this application. Figure 4 As shown, the electronic device 40 provided in this embodiment includes at least one processor 401 and a memory 402. Optionally, the device 40 further includes a communication component 403. The processor 401, memory 402, and communication component 403 are connected via a bus 404.
[0144] In a specific implementation, at least one processor 401 executes computer execution instructions stored in memory 402, causing at least one processor 401 to perform the above-described method.
[0145] The specific implementation process of processor 401 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0146] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0147] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0148] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0149] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0150] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0151] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0152] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0153] The division of units is merely a logical functional division; 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 coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0154] 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 network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0155] In addition, the functional units in the various embodiments of the present invention 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.
[0156] If a function 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 invention, or the part that contributes to the prior art, or a 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 invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0157] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0158] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A data writing method, characterized in that, Applied to a data writer configured with an upper limit on the amount of unacknowledged data that can be accommodated, the method includes: Receive an AckNack message, which is used to indicate a data acknowledgment message and / or a data unacknowledgment message; Based on the AckNack message, determine the current number of unacknowledged data for the data writer; When the data writer receives the data to be written, it determines whether the current number of unconfirmed data has reached the upper limit of the allowed number of unconfirmed data. If the number of currently unconfirmed data reaches the upper limit of the allowed number of unconfirmed data, then the writing of the data to be written to the historical cache will be blocked; wherein, the historical cache refers to the area used by the data writer to temporarily store the data to be sent; If the current number of unconfirmed data does not reach the upper limit of the allowed number of unconfirmed data, then the data to be written is allowed to be written to the historical cache.
2. The method according to claim 1, characterized in that, The method further includes: The parameters corresponding to the historical cache are determined, including the upper limit on the number of unconfirmed data that can be accommodated and the update period corresponding to the upper limit on the number of unconfirmed data that can be accommodated. An update coroutine is created based on the upper limit of the allowed number of unconfirmed data and the update cycle; wherein the update coroutine is used to update the upper limit of the allowed number of unconfirmed data in response to the update cycle.
3. The method according to claim 1, characterized in that, Before determining whether the current number of unacknowledged data reaches the upper limit of the allowed number of unacknowledged data when the data writer receives the data to be sent, the method further includes: Determine whether the current time of receiving the AckNack message is the update time corresponding to the update cycle; If the current time of receiving the AckNack message is the update time corresponding to the update cycle, then the current time is determined to be the update time corresponding to the upper limit of the number of unacknowledged data that can be accommodated, and the update coroutine is executed; Collect all AckNack messages between the update time and the previous update time; based on the all AckNack messages, update the upper limit of the number of unacknowledged data that can be accommodated.
4. The method according to claim 3, characterized in that, The step of updating the upper limit of the allowed number of unacknowledged data based on the full AckNack message includes: Determine whether there are any unacknowledged data messages in the full AckNack message list; If there are unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data that can be accommodated is greater than the minimum number of unacknowledged data; If the upper limit of the allowed number of unconfirmed data is greater than the minimum number of unconfirmed data, then the upper limit of the allowed number of unconfirmed data is updated according to a preset shrinking step size.
5. The method according to claim 4, characterized in that, The method further includes: If there are no unacknowledged data messages in the full AckNack message, then determine whether the upper limit of the number of unacknowledged data that can be accommodated is less than the maximum number of unacknowledged data; If the upper limit of the allowed number of unconfirmed data is less than the maximum number of unconfirmed data, then the upper limit of the allowed number of unconfirmed data is updated according to a preset expansion step size.
6. The method according to claim 1, characterized in that, The step of determining the current number of unacknowledged data items corresponding to the data writer based on the AckNack message includes: Determine whether the AckNack message includes an unacknowledged data message; if the AckNack message includes an unacknowledged data message. Based on the unconfirmed data message, the number of unconfirmed data items is determined; this number is then used as the current number of unconfirmed data items corresponding to the data writer. If the AckNack message does not include unacknowledged data messages, then the current number of unacknowledged data messages corresponding to the data writer is determined to be zero.
7. A data writing device, characterized in that, Applied to data writers, the data writers are configured with an upper limit on the amount of unacknowledged data they can accommodate, including: A receiving module is configured to receive an AckNack message, which is used to indicate a data acknowledgment message and / or a data unacknowledgment message; The processing module is used to determine the current number of unacknowledged data corresponding to the data writer based on the AckNack message; The processing module is used to determine whether the current number of unconfirmed data reaches the upper limit of the allowed number of unconfirmed data when the data writer receives the data to be written. The writing module is configured to block the writing of the data to be written to the historical cache if the number of unconfirmed data currently being written reaches the upper limit of the allowed number of unconfirmed data; wherein, the historical cache refers to the area used by the data writer to temporarily store the data to be sent; The writing module is further configured to allow the data to be written to the historical cache if the number of currently unconfirmed data does not reach the upper limit of the allowed number of unconfirmed data.
8. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-6.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-6.