Self-adaptive adjustment method and system for UDP (User Datagram Protocol) socket buffer area and medium

By dynamically adjusting the buffer size during UDP socket buffer transmission, the problem of the inability to adjust the buffer size according to the network environment and packet loss rate changes in the prior art is solved, and memory resource utilization and transmission stability are improved.

CN120017731APending Publication Date: 2025-05-16KYLIN CORP

Patent Information

Application Number
CN202510145745.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-10
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

In the prior art, UDP-based data transmission method cannot dynamically adjust the socket buffer size according to real-time changes in the network environment and packet loss rate, resulting in waste of system resource memory and reduced transmission performance.

Method used

By setting the initial buffer size and adjustment rules before network transmission, and sampling packet loss rate and network traffic regularly during transmission, the size of the UDP socket buffer is dynamically adjusted according to the set thresholds and rules to take into account the low packet loss rate and high memory resource utilization.

Benefits of technology

It realizes dynamic adjustment of buffer size according to changes in the network environment, improves the system memory resource utilization rate and network transmission stability, and avoids resource waste and performance degradation caused by static configuration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120017731A_ABST
    Figure CN120017731A_ABST
Patent Text Reader

Abstract

The invention discloses a UDP (User Datagram Protocol) socket buffer area self-adaptive adjustment method and system and a medium. The method comprises the following steps: setting an initial UDP socket buffer area size, a buffer area size adjustment rule and a packet loss rate threshold value before network transmission; when network transmission is carried out, the packet loss rate is sampled regularly, the average value of the packet loss rate of each evaluation window period is calculated, and the average value of the packet loss rate of each evaluation window period is compared with a packet loss rate threshold value. And matching the comparison result with a buffer area size adjustment rule, and dynamically adjusting the size of the UDP socket buffer area according to the matching result corresponding to each evaluation window period in sequence so as to give consideration to low packet loss rate and high memory resource utilization rate. The invention aims to solve the problems that the existing UDP-based data transmission method cannot change the size of the UDP socket buffer area according to the real-time change of the network environment and the packet loss rate, so that the system resource memory waste and the transmission performance reduction are easily caused, and the system memory resource utilization rate and the network transmission stability can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of network communication, and in particular to a method, system and medium for adaptively adjusting a UDP socket buffer. Background Art

[0002] In current network communications, UDP (User Datagram Protocol) is widely used in delay-sensitive fields such as real-time communications, online games, and streaming media transmission due to its low latency characteristics. However, the UDP protocol is prone to packet loss due to the lack of transmission reliability guarantee. In the prior art, packet loss is usually reduced by means such as static configuration of buffer size, application layer retransmission, or bandwidth limitation. Statically configured buffer size may cause waste of memory resources due to fixed buffer size, or cause transmission performance degradation due to insufficient buffer; application layer retransmission increases latency and is difficult to adapt to application scenarios with high real-time requirements; bandwidth limitation means lack adaptability and cannot dynamically respond to real-time changes in the network environment. If the above technology is adapted to changes through manual intervention, not only will the operation be frequent and cumbersome, but it will also be difficult to meet the needs of real-time adjustment.

[0003] For example, a Chinese patent application with publication number: CN112929455A discloses a data transmission method, device, equipment and readable storage medium based on UDP, the method comprising: receiving data packets sent in parallel by a UDP data sender; wherein the data packets carry a sequence number inserted by the UDP data sender for the data packets; buffering the received data packets; determining whether the sent data packets are lost during the sending process; and when the data packets are lost, sending a retransmission request to the UDP data sender. Although this method can reduce the number of redundant data packets retransmitted by the sender and improve the transmission efficiency while reducing the packet loss rate, it cannot adaptively change the size of the buffer according to the real-time changes in the network environment. When the network load is low and the buffer is set to be large, it is easy to cause a waste of system memory resources. When the network load is high and the buffer is set to be small, it is easy to cause a decrease in transmission performance. Summary of the invention

[0004] Technical problem to be solved by the present invention: In view of the above-mentioned problems in the prior art, a UDP socket buffer adaptive adjustment method, system and medium are provided. The present invention aims to solve the problem that the existing UDP-based data transmission method cannot change the UDP socket buffer size according to the real-time changes of the network environment and the packet loss rate, which easily causes waste of system resource memory and reduced transmission performance. The present invention can improve the utilization rate of system memory resources and the stability of network transmission.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: A method for adaptively adjusting a UDP socket buffer comprises the following steps: performing initialization settings before network transmission, wherein the initialization settings include setting an initial UDP socket buffer size, setting a buffer size adjustment rule and setting a packet loss rate threshold; during network transmission, regularly sampling the packet loss rate and calculating the average packet loss rate of each evaluation window period, comparing the average packet loss rate of each evaluation window period with the packet loss rate threshold, matching the comparison result with the buffer size adjustment rule and dynamically adjusting the size of the UDP socket buffer according to the matching result corresponding to each evaluation window period in turn to take into account both low packet loss rate and high memory resource utilization.

[0006] Optionally, the network traffic is sampled while sampling the packet loss rate, and the buffer size adjustment rules include: if the average value of the sampled packet loss rate within the evaluation window period is greater than the packet loss rate threshold initially set by the system, then the size of the current UDP socket buffer is increased or maintained according to the system load conditions; if the average value of the sampled packet loss rate within the evaluation window period is less than the packet loss rate threshold initially set by the system and the average value of the packet loss rate is 0, and the size of the current UDP socket buffer is greater than the minimum value of the UDP socket buffer, then the size of the current UDP socket buffer is reduced or maintained according to the network traffic conditions; if the average value of the sampled packet loss rate within the evaluation window period is less than the packet loss rate threshold initially set by the system and the average value of the packet loss rate is not 0, then the current UDP socket buffer size is maintained unchanged.

[0007] Optionally, increasing or maintaining the size of the current UDP socket buffer according to the system load conditions includes: if the system load is lower than a set system load threshold, the system is determined to be in a low load state, and the current UDP socket buffer is increased; if the system load is above the set system load threshold, the system is determined to be in a high load state, and the current UDP socket buffer size is maintained.

[0008] Optionally, before increasing the current UDP socket buffer, the method further includes: calculating the size of the increased UDP socket buffer, and if the size of the increased UDP socket buffer is less than or equal to a preset maximum buffer value, increasing the current UDP socket buffer.

[0009] Optionally, reducing or maintaining the size of the current UDP socket buffer according to the network traffic conditions during the corresponding evaluation window period includes: if the maximum network traffic during the evaluation window period is less than a preset network traffic threshold, reducing the current UDP socket buffer; otherwise, performing a network fluctuation assessment and reducing or maintaining the size of the current UDP socket buffer according to the network fluctuation assessment results.

[0010] Optionally, performing network fluctuation assessment includes the following steps: calculating the average value of the sampled network traffic within the assessment window period; if the average value of the sampled network traffic is within a preset average network traffic assessment interval, calculating the coefficient of variation of the sampled network traffic during the assessment window period; if the coefficient of variation is lower than a preset fluctuation tolerance threshold, reducing the current UDP socket buffer; if the coefficient of variation is above the preset fluctuation tolerance threshold, maintaining the size of the current UDP socket buffer; if the average value of the sampled network traffic is lower than the lower limit of the average network traffic assessment interval, reducing the current UDP socket buffer; if the average value of the sampled network traffic is higher than the upper limit of the average network traffic assessment interval, maintaining the size of the current UDP socket buffer.

[0011] Optionally, the initialization setting also includes setting an adjustment factor, and the adjustment factor includes an increase adjustment factor and a decrease adjustment factor. When the size of the UDP socket buffer is dynamically adjusted according to the matching result corresponding to each evaluation window period, if the current UDP socket buffer needs to be increased, the size of the current UDP socket buffer is multiplied by (1+increase factor) to obtain the size of the new UDP socket buffer; if the current UDP socket buffer needs to be reduced, the size of the current UDP socket buffer is multiplied by (1-decrease factor) to obtain the size of the new UDP socket buffer.

[0012] In addition, the present invention also provides a UDP adaptive socket buffer adjustment system, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the UDP socket buffer adaptive adjustment method.

[0013] In addition, the present invention also provides a computer-readable storage medium, in which a computer program or instruction is stored. The computer program or instruction is programmed or configured to execute the UDP socket buffer adaptive adjustment method through a processor.

[0014] In addition, the present invention also provides a computer program product, including a computer program or an instruction, wherein the computer program or the instruction is programmed or configured to execute the UDP socket buffer adaptive adjustment method through a processor.

[0015] Compared with the prior art, the present invention mainly has the following advantages: The UDP socket buffer adaptive adjustment method disclosed by the present invention sets a buffer size adjustment rule for the system before network transmission. When network transmission is performed, the system regularly samples the packet loss rate and network traffic, and can adaptively and dynamically adjust the size of the current UDP socket buffer according to the buffer size adjustment rule to take into account both low packet loss rate and high memory resource utilization, which is conducive to solving the problems of memory resource waste caused by too large a static configuration buffer and transmission performance degradation caused by insufficient buffer setting, and improves the system memory resource utilization and network transmission stability during network transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 This is a flowchart of initialization settings of the method according to an embodiment of the present invention.

[0017] Figure 2 This is a flow chart of adjusting the UDP socket buffer size according to the method of an embodiment of the present invention.

[0018] Figure 3 The flowchart of an embodiment of the present invention is to reduce or maintain the current UDP socket buffer according to the network traffic situation. DETAILED DESCRIPTION

[0019] The technical solution of the present invention will be further described in detail below in conjunction with the accompanying drawings.

[0020] The UDP socket buffer adaptive adjustment method of this embodiment includes the following steps: performing initialization settings before network transmission, wherein the initialization settings include setting the initial UDP socket buffer size, setting the buffer size adjustment rules, and setting the packet loss rate threshold (such as Figure 1 When performing network transmission, the packet loss rate and network traffic are sampled regularly and the average packet loss rate of each evaluation window period is calculated. The average packet loss rate of each evaluation window period is compared with the packet loss rate threshold. The comparison result is matched with the buffer size adjustment rule and the size of the UDP socket buffer is dynamically adjusted according to the matching result corresponding to each evaluation window period in order to balance low packet loss rate and high memory resource utilization (such as Figure 2 as shown).

[0021] In the UDP socket buffer adaptive adjustment method implemented in this invention, the system sets the buffer size adjustment rules before network transmission. When performing network transmission, the system regularly samples the packet loss rate and network traffic, and can adaptively and dynamically adjust the size of the current UDP socket buffer according to the buffer size adjustment rules to take into account both low packet loss rate and high memory resource utilization. This is conducive to solving the problems of memory resource waste caused by too large a statically configured buffer and reduced transmission performance caused by insufficient buffer settings, and improves the system memory resource utilization and network transmission stability during network transmission.

[0022] In this embodiment, the initialization setting also includes setting an adjustment factor, and the adjustment factor includes an increase adjustment factor and a decrease adjustment factor. The increase adjustment factor is a coefficient greater than 0. When the current UDP socket buffer needs to be increased, the size of the current UDP socket buffer is multiplied by (1+increase factor) to obtain the size of the new UDP socket buffer; the decrease adjustment factor is a coefficient greater than 0 and less than 1. When the current UDP socket buffer needs to be reduced, the size of the current UDP socket buffer is multiplied by (1-decrease factor) to obtain the size of the new UDP socket buffer. The adjustment factor is set according to the specific usage scenario. For real-time communication scenarios (conference voice calls, etc.), it is sensitive to delays and needs to maintain a smaller buffer to reduce delays. The adjustment factor should not be set too large; streaming media scenarios (such as live video) can tolerate short delays, and a relatively aggressive adjustment factor preset can be made; data collection scenarios (such as sensor data collection) can be preset more aggressively. In actual use, multiple sets of adjustment factors can be set in the system. When performing network transmission, the system uses the matching adjustment factor for adjusting the size of the UDP socket buffer after identifying the usage scenario.

[0023] like Figure 2 As shown, as an optional implementation method, the buffer size adjustment rule includes the following strategy: a buffer adjustment evaluation is performed once every set time (for example, 10s), the set time is an evaluation window period, and the average value of the sampled packet loss rate within the evaluation window period is calculated. If the average value of the sampled packet loss rate within the evaluation window period is greater than the packet loss rate threshold initially set by the system, the size of the current UDP socket buffer is increased or maintained according to the system load situation; if the average value of the sampled packet loss rate within the evaluation window period is less than the packet loss rate threshold initially set by the system and the average value of the packet loss rate is 0, and the size of the current UDP socket buffer is greater than the minimum value of the UDP socket buffer, the size of the current UDP socket buffer is reduced or maintained according to the network traffic situation; if the average value of the sampled packet loss rate within the evaluation window period is less than the packet loss rate threshold initially set by the system and the average value of the packet loss rate is not 0, and in other cases, the current UDP socket buffer size is maintained unchanged.

[0024] like Figure 2As shown, as an optional implementation, increasing or maintaining the size of the current UDP socket buffer according to the system load includes: if the system load is lower than the set system load threshold, it is determined that the system is in a low load state, and the current UDP socket buffer is increased; if the system load is above the set system load threshold, it is determined that the system is in a high load state, and the current UDP socket buffer is maintained. The specific system load threshold is 90%, and of course in other embodiments it can also be set to other values ​​according to actual needs, which is conducive to preventing the UDP socket buffer from over-consuming system resources and causing performance degradation.

[0025] As an optional implementation method, in this embodiment, the buffer size adjustment rules also include: the size of the UDP socket buffer is adjusted to a maximum of 90% of the system available memory, which is further beneficial to prevent the UDP socket buffer from excessively consuming system resources and causing performance degradation. Of course, in other embodiments, the size can also be adjusted to a maximum of the system available memory as needed.

[0026] Correspondingly, before increasing the current UDP socket buffer, the following steps are also included: if the current UDP socket buffer is greater than or equal to a preset buffer maximum value, i.e., 90% of the system available memory, the size of the current UDP socket buffer is maintained; otherwise, the size of the current UDP socket buffer is multiplied by (1+increase factor) to calculate the size of the increased UDP socket buffer; if the size of the increased UDP socket buffer is less than or equal to the preset buffer maximum value, the current UDP socket buffer is increased according to the difference between the size of the increased UDP socket buffer and the size of the current UDP socket buffer; if the size of the current UDP socket buffer is less than the preset buffer maximum value, and the size of the increased UDP socket buffer is greater than the preset buffer maximum value, the current UDP socket buffer is increased to the preset buffer maximum value.

[0027] like Figure 2 As shown, as an optional implementation method, reducing or maintaining the size of the current UDP socket buffer according to the network traffic situation includes: if the maximum value of the network traffic of each sample during the evaluation window period is less than the preset network traffic threshold, that is, the network traffic of each sample during the evaluation window period is less than the preset network traffic threshold, then reducing the current UDP socket buffer, otherwise it is necessary to perform a network fluctuation assessment first, and reduce or maintain the size of the current UDP socket buffer according to the network fluctuation assessment result.

[0028] like Figure 3As shown, as an optional implementation method, the network fluctuation assessment includes the following steps: calculating the average value of the sampled network traffic within the evaluation window period, if the average value of the sampled network traffic is within the preset average network traffic assessment interval, then calculating the coefficient of variation of the sampled network traffic during the evaluation window period, if the coefficient of variation is lower than the preset fluctuation tolerance threshold (the network traffic fluctuation is small), then reducing the current UDP socket buffer, if the coefficient of variation is above the preset fluctuation tolerance threshold (the network traffic fluctuation is large), then maintaining the size of the current UDP socket buffer, which is beneficial to avoid data overflow of the UDP socket buffer due to instantaneous high traffic, and can effectively reduce the transmission performance degradation caused by premature reduction of the UDP socket buffer due to network fluctuations; if the average value of the sampled network traffic is lower than the lower limit of the average network traffic assessment interval, then reducing the current UDP socket buffer; if the average value of the sampled network traffic is higher than the upper limit of the average network traffic assessment interval, then maintaining the size of the current UDP socket buffer, specifically, coefficient of variation = (standard deviation of the sampled network traffic / average value of the sampled network traffic).

[0029] In this embodiment, before reducing the current UDP socket buffer, the following steps are also included: if the current UDP socket buffer is less than or equal to a preset buffer minimum value, the size of the current UDP socket buffer is maintained; otherwise, the size of the current UDP socket buffer is multiplied by (1-reduction factor) to calculate the size of the reduced UDP socket buffer; if the size of the reduced UDP socket buffer is greater than or equal to a preset buffer maximum value, the current UDP socket buffer is increased according to the difference between the size of the current UDP socket buffer and the size of the reduced UDP socket buffer; if the size of the current UDP socket buffer is greater than the preset buffer minimum value, and the size of the reduced UDP socket buffer is less than the preset buffer minimum value, the current UDP socket buffer is reduced to the preset buffer minimum value.

[0030] In addition, this embodiment also provides a UDP socket buffer adaptive adjustment system, including a microprocessor and a memory connected to each other, and the microprocessor is programmed or configured to execute the UDP socket buffer adaptive adjustment method.

[0031] In addition, this embodiment further provides a computer-readable storage medium, in which a computer program or instruction is stored. The computer program or instruction is programmed or configured to execute a UDP socket buffer adaptive adjustment method through a processor.

[0032] In addition, this embodiment also provides a computer program product, including a computer program or instructions, which are programmed or configured to execute the UDP socket buffer adaptive adjustment method through a processor.

[0033] Those skilled in the art should understand that the technical solutions provided by the embodiments of the present application may be in the form of methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0034] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A UDP socket buffer adaptive adjustment method, characterized in that: The method comprises the following steps: performing initialization settings before network transmission, wherein the initialization settings include setting an initial UDP socket buffer size, setting a buffer size adjustment rule, and setting a packet loss rate threshold; during network transmission, regularly sampling the packet loss rate and calculating the average packet loss rate of each evaluation window period, comparing the average packet loss rate of each evaluation window period with the packet loss rate threshold, matching the comparison result with the buffer size adjustment rule, and dynamically adjusting the size of the UDP socket buffer according to the matching result corresponding to each evaluation window period in turn to take into account both low packet loss rate and high memory resource utilization.

2. The UDP socket buffer adaptive adjustment method according to claim 1, characterized in that: While sampling the packet loss rate, the network traffic is also sampled, and the buffer size adjustment rules include: if the average value of the sampled packet loss rate within the evaluation window period is greater than the packet loss rate threshold initially set by the system, then the size of the current UDP socket buffer is increased or maintained according to the system load situation; if the average value of the sampled packet loss rate within the evaluation window period is less than the packet loss rate threshold initially set by the system and the average value of the packet loss rate is 0, and the size of the current UDP socket buffer is greater than the minimum value of the UDP socket buffer, then the size of the current UDP socket buffer is reduced or maintained according to the network traffic situation within the corresponding evaluation window period; if the average value of the sampled packet loss rate within the evaluation window period is less than the packet loss rate threshold initially set by the system and the average value of the packet loss rate is not 0, then the current UDP socket buffer size is maintained unchanged.

3. The UDP socket buffer adaptive adjustment method according to claim 2, characterized in that: Increasing or maintaining the size of the current UDP socket buffer according to the system load conditions includes: if the system load is lower than the set system load threshold, the system is determined to be in a low load state, and the current UDP socket buffer is increased; if the system load is above the set system load threshold, the system is determined to be in a high load state, and the current UDP socket buffer size is maintained.

4. The UDP socket buffer adaptive adjustment method according to claim 3, characterized in that: Before increasing the current UDP socket buffer, the method further includes: calculating the size of the increased UDP socket buffer, and if the size of the increased UDP socket buffer is less than or equal to the preset maximum buffer value, increasing the current UDP socket buffer.

5. The UDP socket buffer adaptive adjustment method according to claim 2, characterized in that: Reducing or maintaining the size of the current UDP socket buffer according to the network traffic conditions during the corresponding evaluation window period includes: if the maximum network traffic during the evaluation window period is less than a preset network traffic threshold, reducing the current UDP socket buffer; otherwise, performing a network fluctuation assessment and reducing or maintaining the size of the current UDP socket buffer according to the network fluctuation assessment results.

6. The UDP socket buffer adaptive adjustment method according to claim 5, characterized in that: The network fluctuation assessment includes the following steps: calculating the average value of the sampled network traffic within the assessment window period; if the average value of the sampled network traffic is within the preset average network traffic assessment interval, calculating the coefficient of variation of the sampled network traffic during the assessment window period; if the coefficient of variation is lower than the preset fluctuation tolerance threshold, reducing the current UDP socket buffer; if the coefficient of variation is above the preset fluctuation tolerance threshold, maintaining the size of the current UDP socket buffer; if the average value of the sampled network traffic is lower than the lower limit of the average network traffic assessment interval, reducing the current UDP socket buffer; if the average value of the sampled network traffic is higher than the upper limit of the average network traffic assessment interval, maintaining the size of the current UDP socket buffer.

7. The UDP socket buffer adaptive adjustment method according to any one of claims 1 to 6, characterized in that: The initialization setting also includes setting an adjustment factor, and the adjustment factor includes an increase adjustment factor and a decrease adjustment factor. When the size of the UDP socket buffer is dynamically adjusted according to the matching results corresponding to each evaluation window period, if the current UDP socket buffer needs to be increased, the size of the current UDP socket buffer is multiplied by (1+increase factor) to obtain the size of the new UDP socket buffer; if the current UDP socket buffer needs to be reduced, the size of the current UDP socket buffer is multiplied by (1-decrease factor) to obtain the size of the new UDP socket buffer.

8. A UDP socket buffer adaptive adjustment system, comprising a microprocessor and a memory connected to each other, characterized in that: The microprocessor is programmed or configured to execute the UDP socket buffer adaptive adjustment method described in any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program or instruction stored therein, characterized in that: The computer program or instruction is programmed or configured to execute the UDP socket buffer adaptive adjustment method described in any one of claims 1 to 7 through a processor.

10. A computer program product comprising a computer program or instructions, characterized in that The computer program or instruction is programmed or configured to execute the UDP socket buffer adaptive adjustment method described in any one of claims 1 to 7 through a processor.

Citation Information

Patent Citations

  • UDP-based data transmission method and device, equipment and readable storage medium

    CN112929455A

Cited By

  • UDP (User Datagram Protocol) multi-network type initialization method adaptive to multiple environments

    CN121442023A

  • Data transmission method, device and system, electronic equipment and storage medium

    CN121462675A