Method, device, electronic device and computer-readable storage medium for receiving data packets

By dynamically adjusting the packet reception configuration, the problem of excessive CPU load in high-traffic scenarios is solved, the packet reception efficiency is improved and the CPU load is balanced, and the packet loss rate is reduced.

CN120128624BActive Publication Date: 2025-09-09SHENZHEN TCL NEW-TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510616727.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-09-09
Estimated Expiration
2045-05-14

AI Technical Summary

Technical Problem

In high-traffic scenarios, existing technologies suffer from low efficiency in packet reception and distribution, excessive central processing unit (CPU) load, and insufficient dynamics, resulting in high packet loss rates.

Method used

By obtaining packet reception status parameters in real time, the packet reception configuration can be dynamically adjusted, including expanding or shrinking the packet reception queue, adjusting the weight of the packet reception queue and the CPU binding relationship, optimizing the network traffic rate and polling budget, and merging packet processing.

Benefits of technology

It reduces the packet loss rate during traffic bursts, improves the efficiency of data packet reception, achieves CPU load balancing, and improves system performance and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120128624B_ABST
    Figure CN120128624B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a method, apparatus, electronic device, and computer-readable storage medium for receiving data packets, relating to the field of computer network technology. The method includes: obtaining data packet reception status parameters in real time; dynamically adjusting the data packet reception configuration based on the data packet reception status parameters; and receiving and processing the data packet according to the adjusted data packet reception configuration. In this manner, this solution can dynamically adjust the data packet reception configuration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer network technology, and specifically to a method, device, electronic device, and computer-readable storage medium for receiving a data packet. Background Art

[0002] With the rapid growth of network traffic, the efficiency of packet reception and distribution faces severe challenges. Related technologies have introduced various optimization mechanisms, including the New Network API (NAPI), Receive Side Scaling (RSS), and Receive Packet Steering (RPS). However, these optimization mechanisms lack dynamicity in high-traffic scenarios, potentially overloading some central processing units (CPUs). Summary of the Invention

[0003] Embodiments of the present application provide a method, apparatus, electronic device, and computer-readable storage medium for receiving a data packet, which can dynamically adjust the data packet receiving configuration.

[0004] In a first aspect, an embodiment of the present application provides a method for receiving a data packet, comprising:

[0005] Get data packet receiving status parameters in real time;

[0006] Dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter;

[0007] The data packet is received and processed according to the adjusted data packet receiving configuration.

[0008] In one embodiment, the data packet receiving state parameter includes: the number of data packets to be processed in the data packet receiving queue and the total number of data packets in the data packet receiving queue;

[0009] The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes:

[0010] Determine the ratio of the number of the data packets to be processed to the total number of the data packets as the retention rate of the data packet receiving queue;

[0011] Get the queue expansion threshold and queue contraction threshold;

[0012] When the retention rate of the data packet receiving queue is greater than the queue expansion threshold, expanding the data packet receiving queue;

[0013] When the retention rate of the data packet receiving queue is less than the queue shrinkage threshold, the data packet receiving queue is shrunk.

[0014] In one embodiment, the data packet receiving state parameters include: the total number of data packet receiving queues, five-tuple information of the target data packet, and the real-time load of each of the plurality of data packet receiving queues;

[0015] The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes:

[0016] Calculating a hash value of the target data packet according to the five-tuple information of the target data packet;

[0017] Obtaining weights of the plurality of packet receiving queues;

[0018] adjusting the weights of the plurality of data packet receiving queues according to the respective real-time loads of the plurality of data packet receiving queues to obtain adjusted weights;

[0019] The target data packet receiving queue for receiving the target data packet is adjusted according to the hash value of the target data packet and the adjusted weights of the plurality of data packet receiving queues.

[0020] In one embodiment, the data packet reception status parameters include: real-time statistics of soft interrupts;

[0021] The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes:

[0022] Determining the real-time load of each of the multiple CPUs based on the real-time statistical data of the soft interrupt;

[0023] The binding relationship between the data packet receiving queue and the multiple CPUs is modified according to the real-time loads of the multiple CPUs.

[0024] In one embodiment, the data packet reception state parameters include: current network traffic rate;

[0025] The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes:

[0026] Get the network traffic rate threshold;

[0027] When the current network traffic rate is greater than the network traffic rate threshold, increasing the polling budget;

[0028] When the current network traffic rate is less than the network traffic rate threshold, the polling budget is reduced.

[0029] In one embodiment, dynamically adjusting the data packet reception configuration according to the data packet reception state parameter includes:

[0030] Get packet processing delay;

[0031] Obtaining a delay threshold corresponding to the data packet processing delay;

[0032] When the data packet processing delay is not greater than the delay threshold, the polling budget is dynamically adjusted.

[0033] In one embodiment, the method further comprises:

[0034] Get the packet merging threshold;

[0035] Merging the received multiple data packets according to the data packet merging threshold to obtain a merged data packet;

[0036] The combined data packet is delivered.

[0037] In a second aspect, an embodiment of the present application provides a device for receiving a data packet, including:

[0038] Acquisition module, used to obtain data packet receiving status parameters in real time;

[0039] An adjustment module, configured to dynamically adjust a data packet receiving configuration according to the data packet receiving state parameter;

[0040] The receiving module is used to receive and process the data packet according to the adjusted data packet receiving configuration.

[0041] In one embodiment, the data packet receiving state parameter includes: the number of data packets to be processed in the data packet receiving queue and the total number of data packets in the data packet receiving queue; the adjustment module includes:

[0042] a retention rate determining unit, configured to determine a ratio of the number of the data packets to be processed to the total number of the data packets as the retention rate of the data packet receiving queue;

[0043] A queue threshold acquisition unit is used to obtain a queue expansion threshold and a queue contraction threshold;

[0044] an expansion unit, configured to expand the capacity of the data packet receiving queue when the retention rate of the data packet receiving queue is greater than the queue expansion threshold;

[0045] The shrinking unit is configured to shrink the data packet receiving queue when the retention rate of the data packet receiving queue is less than the queue shrinking threshold.

[0046] In one embodiment, the data packet receiving state parameters include: the total number of data packet receiving queues, the five-tuple information of the target data packet, and the real-time load of each of the plurality of data packet receiving queues; the adjustment module includes:

[0047] A hash value calculation unit, configured to calculate a hash value of the target data packet according to the five-tuple information of the target data packet;

[0048] a weight obtaining unit, configured to obtain a weight of each of the plurality of data packet receiving queues;

[0049] a weight adjustment unit, configured to adjust the weights of the plurality of data packet receiving queues according to the respective real-time loads of the plurality of data packet receiving queues to obtain adjusted weights;

[0050] The receiving queue adjusting unit is configured to adjust the target data packet receiving queue for receiving the target data packet according to the hash value of the target data packet and the adjusted weights of the plurality of data packet receiving queues.

[0051] In one embodiment, the data packet reception status parameter includes: real-time statistics of soft interrupts; and the adjustment module includes:

[0052] A real-time load determination unit, configured to determine the real-time load of each of the plurality of CPUs based on the real-time statistical data of the soft interrupt;

[0053] The relationship modification unit is used to modify the binding relationship between the data packet receiving queue and the multiple CPUs according to the real-time load of each of the multiple CPUs.

[0054] In one embodiment, the data packet receiving state parameter includes: a current network traffic rate; and the adjustment module includes:

[0055] A rate threshold acquisition unit, used to acquire a network traffic rate threshold;

[0056] a budget increasing unit, configured to increase the polling budget when the current network traffic rate is greater than the network traffic rate threshold;

[0057] The budget reduction unit is configured to reduce the polling budget when the current network traffic rate is less than the network traffic rate threshold.

[0058] In one embodiment, the adjustment module includes:

[0059] A delay acquisition unit, used to acquire data packet processing delay;

[0060] a delay threshold obtaining unit, configured to obtain a delay threshold corresponding to the data packet processing delay;

[0061] A budget adjustment unit is configured to dynamically adjust the polling budget when the data packet processing delay is not greater than the delay threshold.

[0062] In one embodiment, the apparatus further comprises:

[0063] A merging threshold acquisition module is used to obtain a data packet merging threshold;

[0064] a data packet merging module, configured to merge the received multiple data packets according to the data packet merging threshold to obtain a merged data packet;

[0065] The delivery module is used to deliver the merged data packet.

[0066] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps in the above-mentioned method for receiving data packets are implemented.

[0067] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned method for receiving a data packet are implemented.

[0068] In a fifth aspect, embodiments of the present application further provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations described in the embodiments of the present application.

[0069] The embodiments of the present application have the following beneficial effects: the packet reception configuration can be dynamically adjusted based on real-time acquired packet reception status parameters, thereby receiving and processing packets according to the adjusted packet reception configuration. In this way, dynamic adjustment of the packet reception configuration can address different scenarios, reduce packet loss during traffic bursts, improve packet reception efficiency, and achieve CPU load balancing. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] In order to more clearly illustrate the technical solutions in this application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0071] Figure 1 This is a schematic diagram of the steps of a method for receiving a data packet provided in one embodiment of the present application;

[0072] Figure 2 This is a schematic diagram of the steps of another method for receiving a data packet provided in one embodiment of the present application;

[0073] Figure 3 1 is a schematic structural diagram of a device for receiving data packets provided in one embodiment of the present application;

[0074] Figure 4 It is a structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0075] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.

[0076] In one embodiment, Figure 1 A method for receiving a data packet is provided. Although the steps are shown in a logical order in the diagram, in some cases, the steps shown or described may be performed in a different order than that shown in the figure. Specifically, the method for receiving a data packet can be applied to a data packet receiving terminal, where the data packet receiving terminal may include, but is not limited to, one or more of a smartphone, a tablet computer, a laptop computer, a desktop computer, and an in-vehicle computer.

[0077] It should be noted that the order of description of the following embodiments does not limit the priority order of the embodiments.

[0078] according to Figure 1 The method for receiving a data packet shown in FIG. 1 includes at least steps S110 to S130, which are described in detail as follows:

[0079] In step S110, data packet receiving state parameters are acquired in real time.

[0080] The data packet receiving status parameters refer to parameters related to receiving data packets.

[0081] The packet reception status parameters may include, but are not limited to, one or more of: the number of packets to be processed in the packet reception queue, the total number of packets in the packet reception queue, the total number of packet reception queues, the five-tuple information of the target packet, the real-time load of the packet reception queue, the real-time statistics of the soft interrupt, and the current network traffic rate.

[0082] In step S120, the data packet receiving configuration is dynamically adjusted according to the data packet receiving state parameters.

[0083] The packet reception configuration is a configuration related to receiving packets and may include, but is not limited to, one or more of the following: the number of packet reception queues, the weight of the packet reception queues, the binding relationship between the packet reception queues and the CPU, and the polling budget.

[0084] Based on the data packet reception status parameters of multiple dimensions, the data packet reception status can be determined from multiple dimensions. Based on the data packet reception status of multiple dimensions, it can be determined whether the data packet reception configuration of each dimension needs to be adjusted.

[0085] Optionally, the retention rate of the data packet receive queue can be determined based on the number of data packets to be processed in the data packet receive queue and the total number of data packets in the data packet receive queue, thereby determining whether to expand or shrink the data packet receive queue based on the retention rate of the data packet receive queue.

[0086] Optionally, the weight of the data packet receiving queue may be adjusted according to the real-time load of the data packet receiving queue, and then the data packet receiving queue corresponding to the data packet may be determined according to the adjusted weight of the data packet receiving queue.

[0087] In step S130 , the data packet is received and processed according to the adjusted data packet receiving configuration.

[0088] After the data packet receiving configuration is adjusted in real time, the data packet can be received and processed according to the data packet receiving configuration adjusted in real time.

[0089] By adopting the technical solutions of the embodiments of this application, the packet reception configuration can be dynamically adjusted based on the real-time acquired packet reception status parameters, thereby receiving and processing packets according to the adjusted packet reception configuration. In this way, dynamic adjustment of the packet reception configuration can cope with different scenarios, reduce packet loss rates during traffic bursts, improve packet reception efficiency, and achieve CPU load balancing.

[0090] Based on the above technical solution, as an embodiment, the data packet receiving state parameter includes: the number of data packets to be processed in the data packet receiving queue and the total number of data packets in the data packet receiving queue.

[0091] Dynamically adjusting the packet receiving configuration based on the packet receiving state parameters may include: determining the ratio of the number of packets to be processed to the total number of packets as the retention rate of the packet receiving queue; obtaining a queue expansion threshold and a queue contraction threshold; expanding the packet receiving queue when the retention rate of the packet receiving queue is greater than the queue expansion threshold; and contracting the packet receiving queue when the retention rate of the packet receiving queue is less than the queue contraction threshold.

[0092] The packet receive queue temporarily stores received packets. During the data reception process, packets may arrive quickly, but the processing program may not be able to process them immediately. The packet receive queue temporarily stores received packets to prevent them from being lost, allowing subsequent processing programs to retrieve them from the queue. The packet receive queue can be a ring buffer queue.

[0093] The data packets to be processed in the data packet receiving queue are data packets that have been received in the data packet receiving queue and are waiting to be processed by the processing program. The total number of data packets in the data packet receiving queue is the total number of various data packets in the data packet.

[0094] Optionally, the ratio of the number of data packets to be processed in the data packet receiving queue to the total number of data packets in the data packet receiving queue may be determined as the retention rate of the data packet receiving queue.

[0095] Optionally, you can also periodically check the packet loss statistics of the data packet receive queue in / proc / net / dev (such as rx_queue_X_drops and rx_fifo_errors) and determine the retention rate of the data packet receive queue based on the packet loss statistics. The packet loss rate of the data packet receive queue can be determined based on the packet loss statistics of the data packet receive queue. The retention rate of the data packet receive queue is proportional to the packet loss rate of the data packet receive queue.

[0096] A preset queue expansion threshold and queue contraction threshold can be obtained, where the queue expansion threshold is greater than the queue contraction threshold. When the retention rate of the packet receive queue is greater than the queue expansion threshold, the packet receive queue is triggered to expand. Optionally, the expansion capacity can be a fixed value. Optionally, the expansion capacity can be determined based on the difference between the retention rate and the queue expansion threshold, with the expansion capacity being proportional to the difference.

[0097] When the retention rate of a packet receive queue is less than a queue shrinkage threshold, the packet receive queue is triggered to shrink. Optionally, the shrinkage capacity can be a fixed value. Optionally, the shrinkage capacity can be determined based on the difference between the queue shrinkage threshold and the retention rate, with the shrinkage capacity being proportional to the difference.

[0098] By adopting the technical solution of the embodiment of the present application, the retention rate of the data packet receiving queue can be obtained in real time, and the capacity of the data packet receiving queue can be adjusted in real time according to the retention rate of the data packet receiving queue to ensure that the capacity of the data packet receiving queue is within an appropriate range, avoiding the capacity of the data packet receiving queue being too large and occupying a large amount of storage space, and avoiding the capacity of the data packet receiving queue being too small and causing newly arrived data packets to be discarded.

[0099] Based on the above technical solution, as an embodiment, the data packet receiving state parameters include: the total number of data packet receiving queues, the five-tuple information of the target data packet and the real-time load of each of the multiple data packet receiving queues.

[0100] Dynamically adjusting the packet receiving configuration according to the packet receiving state parameters may include: calculating the hash value of the target packet according to the five-tuple information of the target packet; obtaining the weights of multiple packet receiving queues; adjusting the weights of the multiple packet receiving queues according to their respective real-time loads to obtain adjusted weights; and adjusting the target packet receiving queue that receives the target packet according to the hash value of the target packet and the adjusted weights of the multiple packet receiving queues.

[0101] The target data packet can be any data packet to be stored in the queue. The five-tuple information of the data packet is the key information used to identify and distinguish different network connections or data packet flows, including the source Internet Protocol (IP) address, destination IP address, source port number, destination port number, and transport layer protocol. The source IP address refers to the IP address of the device or network node that sends the data packet; the destination IP address is the IP address of the target device or network node to which the data packet is to be sent; the source port number is used to identify the port used by the application or process sending the data packet on the source device; the destination port number specifies the port used by the application or process on the target device to which the data packet is to be sent; the transport layer protocol refers to the transport layer protocol used by the data packet, such as the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP).

[0102] A preset hash function may be obtained, and the five-tuple information of the target data packet may be hashed using the hash function to obtain a hash value of the target data packet. The hash value of the target data packet may be obtained by hashing one or more pieces of information in the five-tuple information of the target data packet.

[0103] In related technologies, the remainder of dividing a packet's hash value by the total number of packet receive queues is directly used to statically determine the queue to which the packet belongs. For example, multiple packet receive queues can be pre-numbered. If there are four packet receive queues, the four packet receive queues can be numbered 0, 1, 2, and 3, respectively. If the remainder of dividing a packet's hash value by the total number of packet receive queues is 2, the packet can be stored in packet receive queue numbered 2.

[0104] In one embodiment of the present application, a weight is set for each data packet receiving queue, and the weight can be dynamically adjusted according to the real-time load of the data packet receiving queue. When determining the data packet receiving queue to which the target data packet belongs, the hash value of the target data packet and the weight of the data packet receiving queue can be comprehensively considered to balance the load of the data packet receiving queue.

[0105] In one embodiment, the target data packet receiving queue for receiving the target data packet may be determined according to a remainder obtained by dividing a hash value of the target data packet by the total number of data packet receiving queues and the weight of the data packet receiving queue.

[0106] For example, the two packet receive queues numbered 0 and 1 both have weights of 0.5 before adjustment. Because their weights are equal, if the remainder of a packet's hash value divided by the total number of packet receive queues is 0, the packet can be stored in packet receive queue 0; if the remainder is 1, the packet can be stored in packet receive queue 1. If it is found that the load of packet receive queue 0 is higher and the load of packet receive queue 1 is lower, the weight of packet receive queue 0 can be adjusted to 0.6 and the weight of packet receive queue 1 can be adjusted to 0.4. According to the modified weights, 20% of the packets with a remainder of 1 (i.e., 0.6-0.4) will be allocated to packet receive queue 0.

[0107] In another embodiment, the target data packet receiving queue that receives the target data packet may be determined directly based on the hash value of the target data packet and the weight of the data packet receiving queue.

[0108] For example, the weights of the four packet receive queues were all 0.25 before adjustment, and the adjusted weights are 0.1, 0.15, 0.35, and 0.4. The quintuple information of the target packet is hashed to obtain a hash value within a larger range, and then the packet receive queues are assigned based on the new weights. Assuming the hash value range is 0-99, based on the adjusted weights, packets with hash values ​​in the range of 0-9 can be assigned to packet receive queue 0; packets with hash values ​​in the range of 10-24 can be assigned to packet receive queue 1; packets with hash values ​​in the range of 25-59 can be assigned to packet receive queue 2; and packets with hash values ​​in the range of 60-99 can be assigned to packet receive queue 3.

[0109] In one embodiment, the real-time load of a packet receive queue can be determined based on the ratio of the number of packets in the packet receive queue to the capacity of the packet receive queue. The weight of the packet receive queue can be dynamically adjusted based on the real-time load of the packet receive queue. The load and weight of the packet receive queue are inversely proportional: the greater the real-time load of the packet receive queue, the lower the weight of the packet receive queue; the smaller the real-time load of the packet receive queue, the higher the weight of the packet receive queue.

[0110] Optionally, you can dynamically adjust the weight of the packet receive queue using the ethtool-X command. The ethtool-X command is a subcommand of the ethtool tool in the Linux system and is mainly used to configure the packet receive queue of the network device.

[0111] By adopting the technical solution of the embodiment of the present application, the target data packet receiving queue is determined statically based on the remainder, and is changed to be determined based on the hash value and dynamic weight of the target data packet. Because the weight of the data packet receiving queue is adjusted in real time according to the real-time load of the data packet receiving queue, the data packet can be guided to flow to the data packet receiving queue with lower load, thereby achieving load balancing of the data packet receiving queue.

[0112] In one embodiment of the above technical solution, the packet reception status parameters include real-time statistics of soft interrupts. Dynamically adjusting the packet reception configuration based on the packet reception status parameters may include determining the real-time load of each of the multiple central processing units (CPUs) based on the real-time statistics of the soft interrupts; and modifying the binding relationships between the packet reception queues and the multiple CPUs based on the real-time loads of the multiple CPUs.

[0113] The RPS mechanism can distribute data packets to different CPU cores for processing. By reasonably distributing data packets to different CPU cores for processing, it reduces competition between CPUs and cache failures, improves the processing speed of network data packets and the overall network performance of the system, especially when processing highly concurrent network connections and a large number of network data packets, it can significantly improve the system's throughput and response speed.

[0114] In the RPS mechanism of the related art, after receiving a data packet, the CPU to which the data packet receiving queue is statically bound processes the data packet according to the static binding relationship between the data packet receiving queue and the CPU.

[0115] In one embodiment of the present application, the real-time load of each of the multiple CPUs can be determined based on the real-time statistical data of the soft interrupt. According to the real-time load of the CPU, the binding relationship between the data packet receiving queue and the CPU can be dynamically modified so that the data packet can be processed by the CPU with low load.

[0116] Real-time softirq statistics can be obtained by monitoring the distribution of network receive (NET_RX) softirqs in / proc / softirqs. These statistics can include the number of packets pending for each CPU and the rate at which each CPU processes packets. Alternatively, the CPU load can be determined based on the number of packets pending and the rate at which each CPU processes packets. Alternatively, real-time CPU load can be obtained directly using command-line tools.

[0117] By modifying the binding relationship between multiple packet receive queues and multiple CPUs, you can make the number of packet receive queues bound to the CPU smaller when the CPU load is higher, and make the number of packet receive queues bound to the CPU larger when the CPU load is lower. <device> / queues / rx-X / rps_cpus file to modify the binding relationship between the packet receive queue where the packet is located and the CPU.

[0118] When a data packet is received, the binding relationship between the data packet receiving queue and the CPU can be dynamically modified so that the data packet is allocated to the CPU with the lowest real-time load.

[0119] By adopting the technical solution of the embodiment of the present application, the distribution path of data packets can be dynamically adjusted through the real-time load of the CPU to achieve CPU load balancing, give full play to the advantages of multi-core processors, accelerate data processing and computing speed, avoid single-core bottlenecks, improve system performance, increase system stability, and improve resource utilization.

[0120] In one embodiment of the above technical solution, the packet reception state parameter includes a current network traffic rate. Dynamically adjusting the packet reception configuration based on the packet reception state parameter may include obtaining a network traffic rate threshold; increasing the polling budget when the current network traffic rate exceeds the network traffic rate threshold; and decreasing the polling budget when the current network traffic rate is less than the network traffic rate threshold.

[0121] NAPI is a technology used in the Linux networking subsystem to improve the efficiency of network packet reception. It uses a combination of interrupts and polling. When a new packet arrives, the kernel is first notified via an interrupt. After responding to the interrupt, the kernel then polls the device's receive queue for batches of packets until all packets in the queue are processed or the preset polling budget is reached. The kernel then re-enables interrupts and waits for the next packet to arrive.

[0122] The polling budget of the NAPI mechanism in the related art is fixed. In one embodiment of the present application, whether to modify the polling budget can be determined based on the relationship between the current network traffic rate and the network traffic rate threshold.

[0123] You can obtain the current network traffic rate through command-line tools, network monitoring software, or built-in system functions. You can also obtain preset network traffic rate thresholds, which can be set based on actual needs.

[0124] When the current network traffic rate exceeds the network traffic rate threshold, the polling budget is increased; when the current network traffic rate is less than the network traffic rate threshold, the polling budget is decreased. Optionally, the amount of polling budget increase or decrease can be determined based on the difference between the current network traffic rate and the network traffic rate threshold, with the amount of polling budget increase or decrease proportional to the difference. Alternatively, the polling budget can be dynamically adjusted using the sysctl -w net.core.netdev_budget command.

[0125] The polling budget can be the number of packets that can be processed in batches by the NAPI mechanism's polling function (poll function). Calling the NAPI mechanism's poll function extracts and processes packets in batches from the packet receiving queue.

[0126] You can set a budget threshold. When the increased polling budget exceeds the budget threshold, the polling budget is adjusted to the budget threshold to control the polling budget growth limit.

[0127] By adopting the technical solution of the embodiment of the present application, the receiving efficiency in high-traffic scenarios can be optimized by dynamically adjusting the polling budget of NAPI; appropriately increasing the polling budget in high-traffic scenarios can reduce the soft interrupt triggering frequency and improve throughput; appropriately reducing the polling budget in low-traffic scenarios can reduce CPU occupancy.

[0128] Based on the above technical solution, as an embodiment, dynamically adjusting the packet reception configuration according to the packet reception state parameters may include: obtaining the packet processing delay; obtaining the delay threshold corresponding to the packet processing delay; and dynamically adjusting the polling budget when the packet processing delay is not greater than the delay threshold.

[0129] Adjusting NAPI's polling budget may increase scheduling latency under high traffic conditions. Therefore, the polling budget can be dynamically adjusted only when the packet processing latency is no greater than a latency threshold. The latency threshold can be set based on actual needs.

[0130] Packet processing latency is the time interval from when a packet enters a network device (such as a router, switch, or server) to when the device completes processing and forwards or transmits it. Alternatively, you can use network testing tools or network monitoring software to obtain packet processing latency.

[0131] By adopting the technical solution of the embodiment of the present application, the adjustment frequency of the polling budget can be dynamically adjusted by monitoring the data processing delay, thereby avoiding the impact of the scheduling delay caused by the dynamic adjustment of the polling budget on the reception and processing of data packets.

[0132] Based on the above technical solution, as an embodiment, Figure 2 As shown, the method for receiving a data packet may further include steps S210 to S230.

[0133] In step S210, a data packet merging threshold is obtained.

[0134] In step S220, the received multiple data packets are merged according to the data packet merging threshold to obtain a merged data packet.

[0135] In step S230, the merged data packet is delivered.

[0136] Generic Receive Offload (GRO) can be used to merge packets, reducing the number of packets processed by the upper-layer network stack. The packet merging threshold can be set based on actual needs. During packet delivery, multiple packets can be merged, with the number of packets merged at each time not exceeding the packet merging threshold.

[0137] Optionally, you can call the napi_gro_receive function to merge multiple packets into a large packet, improving the processing efficiency of the network stack. After the merger is completed, the merged packet is delivered to the upper IP layer through the netif_receive_skb function.

[0138] By adopting the technical solution of the embodiment of the present application and merging data packets before delivery, transmission efficiency can be improved, network congestion can be reduced, resource usage can be reduced, and data reliability can be enhanced.

[0139] During the initialization phase, the network card is configured to support RSS and NAPI mechanisms, and the dynamic path allocation module and dynamic queue monitoring module are enabled. The dynamic path allocation module determines the packet receive queue for receiving packets and determines the binding between the packet receive queue and the CPU. The dynamic queue monitoring module expands and contracts the packet receive queue. Use the ethtool -G command to configure the initial size and maximum capacity of the packet receive queue.

[0140] During real-time monitoring, the dynamic queue monitoring module reads data from / proc / net / dev and / proc / softirqs to analyze queue retention rates and softirq distribution. The dynamic path allocation module adjusts RSS and RPS configurations based on traffic characteristics (real-time load of the packet receive queue and current network traffic rate) and CPU load.

[0141] In the soft interrupt processing stage, when the network card receives data, a soft interrupt is triggered; the poll function of NAPI is called to extract data packets in batches from the data packet receive queue; and the napi_gro_receive function is used to merge data packets to reduce the processing burden of the network stack.

[0142] During the dynamic optimization phase, the number of queues, queue weights, and NAPI budget are dynamically adjusted based on real-time monitoring results. After the adjustment is complete, the network card configuration is reloaded to make the dynamic adjustment policy effective.

[0143] The data packet receiving method proposed in one embodiment of the present application can be applied to data center load balancing. In high-traffic environments, the data packet receiving method uses dynamic path allocation and queue optimization, making it suitable for data center multi-path traffic management and high-throughput scenarios.

[0144] The data packet receiving method proposed in one embodiment of the present application can also be applied to edge computing environments. For data transmission optimization between edge nodes, dynamic queue adjustment can effectively cope with burst traffic.

[0145] The data packet receiving method proposed in one embodiment of this application can also be applied to cloud computing network optimization. This data packet receiving method can serve as the basis for internal network scheduling within cloud service providers, improving network performance between virtual machines and containers through dynamic path selection and load balancing.

[0146] The data packet receiving method proposed in one embodiment of the present application can also be applied to industrial Internet of Things scenarios. In industrial equipment that supports Ethernet communication, the data packet receiving method can be used to optimize high-concurrency data transmission and reduce network latency.

[0147] In 5G base stations, the dynamic monitoring mechanism of the packet receiving queue and 5G network slicing can be combined to optimize multi-path transmission between base stations.

[0148] In the in-vehicle network of autonomous vehicles, network path allocation and queues can be dynamically adjusted in combination with the low latency requirements of sensor data.

[0149] In a distributed storage system, the efficiency of large data transmission can be improved by optimizing NAPI budget and queue allocation.

[0150] Optionally, the data packet receiving method proposed in one embodiment of the present application can also be combined with a machine learning algorithm to predict the network traffic rate, adjust the queue configuration in advance and modify the polling budget based on the predicted network traffic rate, so as to further reduce the packet loss rate during traffic bursts.

[0151] Optionally, the data packet receiving method proposed in an embodiment of the present application can also be combined with hardware RPS and software path selection mechanisms on a NIC that supports hardware acceleration to further optimize path allocation and CPU utilization.

[0152] Optionally, in scenarios where traffic latency is a concern, the packet receiving method proposed in one embodiment of the present application can also include a packet priority-based path allocation and queue management algorithm. The priority of each packet can be determined, and packets of different priorities can be assigned to different packet receiving queues.

[0153] The data packet receiving method proposed in one embodiment of the present application can simultaneously adjust one or more data packet receiving configurations. The multiple data packet receiving configuration adjustment methods can cooperate with each other and work together to improve data packet receiving performance.

[0154] In one embodiment, the expansion / contraction of the packet receive queue can be coordinated with the dynamic adjustment in the RSS mechanism and / or RPS mechanism to achieve optimized load balancing. Specifically, dynamically expanding / contracting the packet receive queue based on the traffic load can avoid queue overflow or resource waste. The RSS mechanism can distribute data packets to multiple packet receive queues through hardware hashing, and effectively divert traffic in combination with the expansion / contraction of the packet receive queue. The RPS mechanism further optimizes CPU load balancing at the software level, dynamically selecting the least busy CPU to process data packets.

[0155] Expanding or shrinking the packet receive queue works in conjunction with dynamic adjustments in the RSS and / or RPS mechanisms, offering the advantage of consistent dynamics. Both expansion or shrinking of the packet receive queue and dynamic adjustments in the RSS and / or RPS mechanisms rely on real-time monitoring (such as queue retention rate and CPU load) and dynamically adjust the configuration based on feedback.

[0156] Expanding / contracting the packet receive queue works synergistically with the dynamic adjustments in the RSS and / or RPS mechanisms in terms of resources. When the packet receive queue is expanded, RSS can effectively utilize the newly added packet receive queue. When the packet receive queue is contracted, RPS reallocates processing tasks to avoid performance degradation.

[0157] The expansion / contraction of packet receiving queues and dynamic adjustments in the RSS mechanism and / or RPS mechanism can form a load balancing chain: through the coordination of the RSS mechanism to the queue adjustment and then to the RPS mechanism, multi-level load balancing can be built from hardware to queues to CPUs.

[0158] In one embodiment, adjusting NAPI's polling budget in conjunction with packet coalescing can reduce CPU overhead. Increasing the polling budget allows the CPU to process more packets simultaneously, reducing context switches; lowering the polling budget prevents CPU overload. Coalescing packets at the Data Plane Development Kit (DPDK) or NIC level can reduce the number of interrupts the CPU must handle.

[0159] Adjusting NAPI's polling budget in conjunction with packet merging can optimize CPU load. Packet merging reduces interrupt frequency, which, together with polling budget adjustment, reduces CPU interrupt processing overhead.

[0160] Adjusting the NAPI polling budget and packet merging is dynamically matched. In high-traffic scenarios, packet merging and high NAPI budget work together to maximize CPU processing efficiency.

[0161] Adjusting NAPI's polling budget and packet merging can achieve hardware collaboration. The merging capabilities of the network card or DPDK complement NAPI's software optimization to form a low-overhead processing link.

[0162] In one embodiment, the overall coordination of expanding and / or shrinking the packet receiving queue, dynamic adjustment in the RSS mechanism and / or RPS mechanism, and adjusting the NAPI polling budget and packet merging can achieve optimization of the entire process of packet reception and processing. Specifically, the RSS mechanism can achieve hardware offload, distribute packets to multiple queues through hashing, reduce the pressure on a single queue, and lay the foundation for subsequent optimization; the dynamic expansion / contraction of the packet receiving queue can dynamically adjust the number of queues based on the RSS traffic distribution to ensure maximum resource utilization efficiency; the RPS mechanism can achieve CPU balancing, dynamically assigning queue tasks to the most idle CPU at the software level to avoid single-core overload; adjusting the NAPI polling budget and packet merging can reduce overhead, improve CPU processing efficiency, reduce interrupts and context switching, and improve overall throughput.

[0163] In one embodiment, in high-traffic burst scenarios, the RSS mechanism can distribute traffic to multiple queues and dynamically expand queue capacity; the RPS mechanism can select idle CPUs for processing; increasing the NAPI budget and merging data packets can reduce CPU overhead.

[0164] In one embodiment, in a low-traffic scenario, the queue can be shrunk to save resources and the polling budget can be reduced to avoid CPU idleness and waste.

[0165] To facilitate better implementation of the data packet receiving method of the present application, the present application also provides a data packet receiving device based on the above-mentioned data packet receiving method. The meanings of the terms herein are the same as those in the above-mentioned data packet receiving method, and specific implementation details can be referred to the description in the method embodiment.

[0166] See also Figure 3 , Figure 3 : is a structural diagram of a data packet receiving device provided in an embodiment of the present application, the data packet receiving device includes:

[0167] Acquisition module 301, used to obtain data packet reception status parameters in real time;

[0168] An adjustment module 302, configured to dynamically adjust a data packet receiving configuration according to the data packet receiving state parameter;

[0169] The receiving module 303 is configured to receive and process data packets according to the adjusted data packet receiving configuration.

[0170] In one embodiment, the data packet receiving state parameter includes: the number of data packets to be processed in the data packet receiving queue and the total number of data packets in the data packet receiving queue; the adjustment module 302 includes:

[0171] a retention rate determining unit, configured to determine a ratio of the number of the data packets to be processed to the total number of the data packets as the retention rate of the data packet receiving queue;

[0172] A queue threshold acquisition unit is used to obtain a queue expansion threshold and a queue contraction threshold;

[0173] an expansion unit, configured to expand the capacity of the data packet receiving queue when the retention rate of the data packet receiving queue is greater than the queue expansion threshold;

[0174] The shrinking unit is configured to shrink the data packet receiving queue when the retention rate of the data packet receiving queue is less than the queue shrinking threshold.

[0175] In one embodiment, the packet receiving state parameters include: the total number of packet receiving queues, the five-tuple information of the target packet, and the real-time load of each of the plurality of packet receiving queues; the adjustment module 302 includes:

[0176] A hash value calculation unit, configured to calculate a hash value of the target data packet according to the five-tuple information of the target data packet;

[0177] a weight obtaining unit, configured to obtain a weight of each of the plurality of data packet receiving queues;

[0178] a weight adjustment unit, configured to adjust the weights of the plurality of data packet receiving queues according to the respective real-time loads of the plurality of data packet receiving queues to obtain adjusted weights;

[0179] The receiving queue adjusting unit is configured to adjust the target data packet receiving queue for receiving the target data packet according to the hash value of the target data packet and the adjusted weights of the plurality of data packet receiving queues.

[0180] In one embodiment, the data packet reception status parameter includes: real-time statistics of soft interrupts; the adjustment module 302 includes:

[0181] A real-time load determination unit, configured to determine the real-time load of each of the plurality of central processing units (CPUs) based on the real-time statistical data of the soft interrupt;

[0182] The relationship modification unit is used to modify the binding relationship between the data packet receiving queue and the multiple CPUs according to the real-time load of each of the multiple CPUs.

[0183] In one embodiment, the data packet receiving state parameter includes: a current network traffic rate; the adjustment module 302 includes:

[0184] A rate threshold acquisition unit, used to acquire a network traffic rate threshold;

[0185] a budget increasing unit, configured to increase the polling budget when the current network traffic rate is greater than the network traffic rate threshold;

[0186] The budget reduction unit is configured to reduce the polling budget when the current network traffic rate is less than the network traffic rate threshold.

[0187] In one embodiment, the adjustment module 302 includes:

[0188] A delay acquisition unit, used to acquire data packet processing delay;

[0189] a delay threshold obtaining unit, configured to obtain a delay threshold corresponding to the data packet processing delay;

[0190] A budget adjustment unit is configured to dynamically adjust the polling budget when the data packet processing delay is not greater than the delay threshold.

[0191] In one embodiment, the apparatus further comprises:

[0192] A merging threshold acquisition module is used to obtain a data packet merging threshold;

[0193] a data packet merging module, configured to merge the received multiple data packets according to the data packet merging threshold to obtain a merged data packet;

[0194] The delivery module is used to deliver the merged data packet.

[0195] By adopting the technical solutions of the embodiments of this application, the packet reception configuration can be dynamically adjusted based on the real-time acquired packet reception status parameters, thereby receiving and processing packets according to the adjusted packet reception configuration. In this way, dynamic adjustment of the packet reception configuration can cope with different scenarios, reduce packet loss rates during traffic bursts, improve packet reception efficiency, and achieve CPU load balancing.

[0196] The specific definition of the data packet receiving device can be found in the definition of the data packet receiving method above and will not be repeated here. The various modules in the above-mentioned data packet receiving device can be implemented in whole or in part through software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each of the above modules.

[0197] In addition, the present application also provides an electronic device, such as Figure 4 As shown, it shows a schematic diagram of the structure of the electronic device involved in this application, specifically:

[0198] The electronic device may include one or more processing core processors 401 and one or more computer readable storage media memories 402 and other components. It will be understood by those skilled in the art that Figure 4 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently.

[0199] Processor 401 is the control center of the electronic device, connecting the various parts of the entire electronic device using various interfaces and lines. By running or executing software programs and / or modules stored in memory 402 and accessing data stored in memory 402, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, processor 401 may include one or more processing cores; preferably, processor 401 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 401.

[0200] Memory 402 can be used to store software programs and modules. Processor 401 executes various functional applications and data processing by running the software programs and modules stored in memory 402. Memory 402 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as sound playback or image playback); the data storage area may store data generated based on the use of the electronic device. Memory 402 may also include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory 402 may also include a memory controller to provide processor 401 with access to memory 402.

[0201] In one embodiment, the electronic device further includes a power supply 403 for supplying power to various components. Preferably, the power supply 403 can be logically connected to the processor 401 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 403 can also include any of one or more DC or AC power supplies, a recharging system, a power supply device debugging circuit, a power converter or inverter, a power status indicator, and other components.

[0202] In one embodiment, the electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0203] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to one or more application processes into the memory 402 according to the following instructions, and the processor 401 runs the application stored in the memory 402, thereby implementing the steps of any of the data packet receiving methods provided in the embodiments of the present application.

[0204] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0205] In one embodiment, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method described in any embodiment of the present application is implemented.

[0206] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in any embodiment of the present application is implemented.

[0207] In some embodiments, a computer program product is also proposed, including a computer program or instructions, which implements the method described in any embodiment of the present application when executed by a processor.

[0208] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0209] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0210] To this end, the present application provides a computer-readable storage medium having a computer program stored thereon. The computer program can be loaded by a processor to execute the steps in any one of the data packet receiving methods provided in the present application.

[0211] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0212] The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0213] Since the instructions stored in the computer-readable storage medium can execute the steps in any method for receiving a data packet provided in the present application, the beneficial effects that can be achieved by any method for receiving a data packet provided in the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0214] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0215] The above is a detailed introduction to a data packet receiving method, device, electronic device and computer-readable storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.< / device>

Claims

1. A method for receiving a data packet, characterized in that: include: Get data packet receiving status parameters in real time; Dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter; receiving and processing the data packet according to the adjusted data packet receiving configuration; The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes: Determining the retention rate of the packet receive queue as the ratio of the number of packets to be processed in the packet receive queue to the total number of packets in the packet receive queue; determining whether to expand or shrink the packet receive queue based on the retention rate of the packet receive queue; the expanded capacity is proportional to the difference between the retention rate and a queue expansion threshold; the shrunk capacity is proportional to the difference between the queue shrinkage threshold and the retention rate; The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes: Predicting network traffic rates based on machine learning algorithms, adjusting queue configurations and modifying polling budgets in advance based on the predicted network traffic rates; dynamically adjusting polling budgets when packet processing delay is no greater than a delay threshold; the packet processing delay is the time interval from when a packet enters a network device to when the network device completes processing and forwards or transmits the packet; The method further includes: after expanding the data packet receiving queue, utilizing the newly added data packet receiving queue based on the receiving end extended RSS mechanism; when shrinking the data packet receiving queue, reallocating processing tasks based on the received data packet guided RPS mechanism; and adjusting the polling budget in conjunction with data packet merging to reduce CPU overhead.

2. The method according to claim 1, characterized in that The data packet receiving state parameters include: the number of data packets to be processed in the data packet receiving queue and the total number of data packets in the data packet receiving queue; The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes: Determining the ratio of the number of the data packets to be processed to the total number of the data packets as the retention rate of the data packet receiving queue; Get the queue expansion threshold and queue contraction threshold; When the retention rate of the data packet receiving queue is greater than the queue expansion threshold, expanding the data packet receiving queue; When the retention rate of the data packet receiving queue is less than the queue shrinking threshold, the data packet receiving queue is shrunk.

3. The method according to claim 1, characterized in that The data packet receiving state parameters include: the total number of data packet receiving queues, the five-tuple information of the target data packet and the real-time load of each of the plurality of data packet receiving queues; The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes: Calculating a hash value of the target data packet according to the five-tuple information of the target data packet; Obtaining weights of the plurality of packet receiving queues; adjusting the weights of the plurality of data packet receiving queues according to the respective real-time loads of the plurality of data packet receiving queues to obtain adjusted weights; The target data packet receiving queue for receiving the target data packet is adjusted according to the hash value of the target data packet and the adjusted weights of the plurality of data packet receiving queues.

4. The method according to claim 1, wherein The data packet receiving status parameters include: real-time statistics of soft interrupts; The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes: Determining the real-time load of each of the plurality of central processing units (CPUs) based on the real-time statistical data of the soft interrupt; The binding relationship between the data packet receiving queue and the multiple CPUs is modified according to the real-time loads of the multiple CPUs.

5. The method according to claim 1, wherein The data packet receiving state parameters include: current network traffic rate; The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes: Get the network traffic rate threshold; When the current network traffic rate is greater than the network traffic rate threshold, increasing the polling budget; When the current network traffic rate is less than the network traffic rate threshold, the polling budget is reduced.

6. The method according to claim 5, characterized in that The dynamically adjusting the data packet receiving configuration according to the data packet receiving state parameter includes: Get packet processing delay; Obtaining a delay threshold corresponding to the data packet processing delay; When the data packet processing delay is not greater than the delay threshold, the polling budget is dynamically adjusted.

7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Get the packet merging threshold; Merging the received multiple data packets according to the data packet merging threshold to obtain a merged data packet; The combined data packet is delivered.

8. A device for receiving a data packet, characterized in that: include: Acquisition module, used to obtain data packet receiving status parameters in real time; An adjustment module, configured to dynamically adjust a data packet receiving configuration according to the data packet receiving state parameter; A receiving module, configured to receive and process data packets according to the adjusted data packet receiving configuration; The adjustment module is specifically configured to: determine the retention rate of the packet receiving queue as the ratio of the number of packets to be processed in the packet receiving queue to the total number of packets in the packet receiving queue; determine whether to expand or shrink the packet receiving queue based on the retention rate of the packet receiving queue; the expanded capacity is proportional to the difference between the retention rate and the queue expansion threshold; the shrunk capacity is proportional to the difference between the queue shrinkage threshold and the retention rate; The adjustment module is specifically configured to: predict the network traffic rate based on a machine learning algorithm, adjust the queue configuration and modify the polling budget in advance based on the predicted network traffic rate; dynamically adjust the polling budget when the packet processing delay is no greater than a delay threshold; the packet processing delay is the time interval from when the packet enters the network device to when the network device completes processing of the packet and forwards or transmits the packet; The device is used to utilize the newly added data packet receiving queue based on the receiving end extended RSS mechanism after expanding the data packet receiving queue; reallocate processing tasks based on the received data packet guided RPS mechanism when shrinking the data packet receiving queue; and adjust the polling budget and data packet merging in coordination to reduce CPU overhead.

9. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the method for receiving a data packet according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the method for receiving a data packet according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Network data reception processing method and apparatus

    CN106375239A

  • Load balancing method, server, data center network system and electronic equipment

    CN115509748A

  • Message sending method and device, server and storage medium

    CN117692401A

  • Data acquisition method and device based on multi-order queue and electronic equipment

    CN119544741A