Network resource allocation method and device

By determining the mapping relationship between the application and the transmission port and performing the cyclic execution of bandwidth adjustment policies, the problem of applications preempting network bandwidth in the Linux operating system is solved, and network resource allocation and management at the application level is realized, ensuring the timeliness of transmission of important data.

CN119697134AInactive Publication Date: 2025-03-25KYLIN CORP
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510199122.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-24
Publication Date
2025-03-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In Linux operating systems, applications preempt network bandwidth, resulting in the inability to transmit urgent and important data in time, and the existing technology cannot realize application-level network resource allocation and management.

Method used

By determining the mapping relationship between the application and the transmission port, the transmission port corresponding to the application with the same priority is filtered into the transmission queue of the same priority, and the bandwidth adjustment strategy is cyclically executed to dynamically allocate network resources to ensure that the transmission queue with higher priority enjoys sufficient network resources.

Benefits of technology

It realizes classification of applications and unified management of network resources according to priority, ensuring the timeliness of transmission of important data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697134A_ABST
    Figure CN119697134A_ABST
Patent Text Reader

Abstract

The invention relates to a network resource allocation method and device, and the method comprises the steps: determining a mapping relation between an application program and a transmission port when the application program initiates networking for any application program; according to the mapping relation, the transmission ports corresponding to the application programs belonging to the same priority are filtered into a transmission queue corresponding to the same priority for data transmission; the method comprises the following steps: S1301, acquiring current transmission rates of all transmission queues; s1302, taking the transmission queues with the corresponding priorities being not the lowest priorities as object queues, and executing bandwidth adjustment strategies on the object queues according to the sequence of the corresponding priorities from high to low and the relationship between the bandwidth threshold values of the object queues and the current transmission rates; and S1303, after the bandwidth adjustment strategy is executed on all the object queues, exiting the current cycle, jumping to the step S1301 again, and executing the next cycle. By adopting the method, the dynamic distribution of network resources can be realized, and the transmission timeliness of important data is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer networks, and in particular to a method and device for allocating network resources. Background Art

[0002] In the Linux operating system, many applications implement data transmission through the network. Although this data transmission method is helpful for real-time data update and distributed processing tasks, it also has the problem of applications occupying network bandwidth, resulting in the failure of timely transmission of urgent and important data.

[0003] The TC (L3 Packets Traffic Control) implemented in the current Linux kernel is all speed-limited in the dimension of the network quintuple (which includes the port). TC can set the rate value of the port. However, the characteristic of Linux applications is that an application can contain many processes, and each process can also use multiple network ports for network communication. The network protocol layer in Linux cannot know which ports belong to the same process and the same application. Therefore, the current Linux network protocol stack cannot implement network control in the application dimension.

[0004] In addition, the port corresponding to an application changes dynamically and the instantaneous rate of each port also changes, so it is difficult to achieve that the total rate of all ports is below a limited value by setting the rate of each port in advance, and it is even more impossible to establish a network resource allocation mechanism.

[0005] In the prior art, data filtering is often used to retain urgent and important data. However, this method does not establish a network resource allocation mechanism, but instead uses a data elimination mechanism to ensure the transmission of part of the data, which not only leads to the loss of task data, but also increases the difficulty of classifying the importance of data when facing more and more task data, and is prone to the problem of importance classification errors. Therefore, how to establish an effective network resource allocation mechanism is an important direction to ensure the timeliness of data transmission. Summary of the invention

[0006] Based on this, it is necessary to provide a method and device for allocating network resources to address the above technical issues, so as to ensure the timeliness of transmission of important data.

[0007] In a first aspect, the present invention provides a method for allocating network resources, comprising: S110, for any application, when the application initiates networking, determining a mapping relationship between the application and the transmission port; S120, according to the mapping relationship, filtering the transmission ports corresponding to the applications of the same priority into the transmission queues corresponding to the same priority for data transmission; S130, looping through the following steps: S1301, obtaining the current transmission rates of all transmission queues; S1302, taking the transmission queues whose corresponding priorities are not the lowest priorities as the object queues, and executing the bandwidth adjustment strategy for each object queue in descending order of the corresponding priorities according to the relationship between the bandwidth threshold of each object queue and the current transmission rate; S1303, after the bandwidth adjustment strategy is executed for all object queues, the current loop is exited and the process jumps to step S1301 again to execute the next loop.

[0008] In one of the embodiments, a bandwidth adjustment strategy is executed on each object queue based on the relationship between the bandwidth threshold and the current transmission rate of each object queue, including: S210, if the difference between the bandwidth threshold of the current object queue and its current transmission rate is greater than or equal to a first preset threshold, the first adjustment strategy is executed on the current object queue; S220, if the difference between the bandwidth threshold of the current object queue and the current transmission rate is less than a second preset threshold, the second adjustment strategy is executed on the current object queue; wherein the first preset threshold is greater than the second preset threshold.

[0009] In one embodiment, the execution logic of the first adjustment strategy is to loop through the following steps: S2101, selecting a transmission queue with the highest priority from other transmission queues that meet the first transfer condition as a receiving queue; reducing the bandwidth threshold of the current object queue by a preset adjustment value, and at the same time, increasing the bandwidth threshold of the receiving queue by a preset adjustment value; S2102, determining whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is greater than or equal to the second preset threshold and less than the first preset threshold; if so, terminating the execution logic of the current first adjustment strategy; if not, executing step S2101; The first transfer condition is to meet any of the following sub-conditions: The first sub-condition: the transmission queue has the lowest priority; Second sub-condition: the difference between the bandwidth threshold of the transmission queue and its transmission rate is less than a second preset threshold.

[0010] In one embodiment, the execution logic of the second adjustment strategy is to loop through the following steps: S2201, judging whether there is a transmission queue that meets the second transfer condition among other transmission queues whose corresponding priorities are lower than the current object queue in order of corresponding priorities from low to high; If so, the judgment is terminated, the bandwidth threshold of the transmission queue that meets the second transfer condition is reduced by the preset adjustment value, and at the same time, the bandwidth threshold of the current object queue is increased by the preset adjustment value; If it does not exist, then the execution logic of the current second adjustment strategy ends; S2202, determining whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is greater than or equal to the second preset threshold and less than the first preset threshold; if so, terminating the execution logic of the current second adjustment strategy; if not, executing step S2201; The second transfer condition is that the difference between the bandwidth threshold of the transmission queue and the preset minimum bandwidth value is greater than or equal to the preset adjustment value.

[0011] In one embodiment, for any application, when the application initiates networking, determining a mapping relationship between the application and the transmission port includes: Get the mapping relationship between all application processes and transmission ports; Get the mapping relationship between applications and application processes; The mapping relationship between the application program and the transmission port is determined according to the mapping relationship between the application program and the transmission port, and the mapping relationship between the application program and the application program.

[0012] In one of the embodiments, for any application, when the application initiates networking, the priority of the application is obtained; Traverse the existing transmission queues; if there is no transmission queue corresponding to the priority, initialize the transmission queue corresponding to the priority.

[0013] In one of the embodiments, initializing a transmission queue corresponding to a priority level includes: Get the initialization coefficient corresponding to the priority; The product of the initialization coefficient and the total bandwidth threshold is used as the bandwidth threshold of the transmission queue corresponding to the priority.

[0014] In one of the embodiments, for any existing transmission queue, if all applications in the transmission queue have exited network communication, it is confirmed that there is no network communication in the transmission queue; Transfer the bandwidth threshold of the transmission queue without network communication to the transmission queue with the lowest corresponding priority among other transmission queues; Releases the transmit queue that has no network traffic.

[0015] In one of the embodiments, for any application, if there is no mapping relationship between the transmission port and the application, it is determined that the application has exited the network communication.

[0016] In a second aspect, the present invention further provides a network resource allocation device, comprising: A determination module, used for determining a mapping relationship between an application and a transmission port for any application when the application initiates networking; A filtering module is used to filter the transmission ports corresponding to the applications of the same priority level into the transmission queues corresponding to the same priority level for data transmission according to the mapping relationship; The execution module is used to loop through the following steps: S1301, obtaining the current transmission rates of all transmission queues; S1302, taking the transmission queues whose corresponding priorities are not the lowest priorities as the object queues, and executing the bandwidth adjustment strategy for each object queue in descending order of the corresponding priorities according to the relationship between the bandwidth threshold of each object queue and the current transmission rate; S1303, after the bandwidth adjustment strategy is executed for all object queues, the current loop is exited and the process jumps to step S1301 again to execute the next loop.

[0017] The above-mentioned network resource allocation method and device, when any application initiates networking, determines the mapping relationship between the application and the transmission port, so that all the transmission ports of the same application can form a resource allocation subject, which is conducive to the allocation of network resources at the application level. Then, according to the mapping relationship between the application and the transmission port, the transmission ports corresponding to the applications of the same priority are filtered into the transmission queue corresponding to the same priority for data transmission, so that the applications are classified according to the priority, and the network resources occupied by the applications of the same priority are uniformly managed. The following steps are executed cyclically: S1301, the current transmission rate of all transmission queues is obtained; S1302, the transmission queue with the corresponding priority not being the lowest priority is taken as the object queue, and the bandwidth adjustment strategy is executed for each object queue according to the relationship between the bandwidth threshold of each object queue and the current transmission rate in the order from high to low corresponding priority; S1303, after the bandwidth adjustment strategy is executed for all object queues, the current loop is exited, and step S1301 is jumped again to execute the next loop. Network resources can be dynamically allocated to transmission queues corresponding to different priorities as needed, so that the transmission queue corresponding to the higher priority enjoys sufficient network resources, and the transmission timeliness of important data is guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for use in the embodiments of the present invention or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 A schematic diagram of the principle of a step of filtering a transmission port in an embodiment; Figure 2 The figure is a flowchart of a method for allocating network resources in one embodiment. DETAILED DESCRIPTION

[0020] The technical scheme in the embodiment of the present invention is described clearly and completely below in conjunction with the accompanying drawings in the embodiment of the present invention. In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.

[0021] In an optional embodiment, a method for allocating network resources is provided. In this embodiment, the method includes the following steps: S110, for any application, when the application initiates networking, determining a mapping relationship between the application and the transmission port.

[0022] Among them, the application initiating networking can be understood as the application establishing a connection with the network for data transmission and interaction. When the application is running, it will correspond to at least one process, which is responsible for executing the specific tasks of the application. When the process communicates with the outside world through the network, it will send and receive data through a specific transmission port. Because in the Linux operating system, the network protocol layer cannot grasp the mapping relationship between the transmission port and the application, it is also impossible to uniformly manage the network resources required by the application.

[0023] In an optional embodiment, the mapping relationship between all application processes and transmission ports can be obtained; the mapping relationship between the application program and the application process can be obtained; and the mapping relationship between the application program and the transmission port can be determined based on the mapping relationship between the application process and the transmission port, and the mapping relationship between the application program and the application process.

[0024] Optionally, the Kprobe kernel probe mechanism can be used to obtain the relationship data between the process and the transmission port in real time, and the process-port data can be transferred from the kernel layer to the application-port relationship data maintenance module of the user layer through the Netlink mechanism to determine the mapping relationship between the process and the transmission port.

[0025] Furthermore, in the application-port relationship data maintenance module of all applications, the relationship data between applications and processes can be obtained through the Linux application management mechanism dpkg to determine the mapping relationship between applications and processes. Combined with the determined mapping relationship between processes and transmission ports, the mapping relationship between applications and transmission ports can be further determined.

[0026] S120, according to the mapping relationship, filtering the transmission ports corresponding to the applications of the same priority into the transmission queues corresponding to the same priority for data transmission.

[0027] Optionally, different priorities can be set for different applications based on their importance. Furthermore, the TC-HTB queue rules (qdisc) mechanism of TC (Traffic Control) can be used to establish a class as the overall network transmission queue for applications of the same priority; the transmission ports corresponding to applications of the same level are filtered into the corresponding transmission queues through the TC filter to implement data transmission, so that all network data of applications of the same priority are transmitted in the same transmission queue. For a transmission queue, the bandwidth threshold allocated to it is equal to the network resource allocation value of all applications of the priority.

[0028] For example, Figure 1 As shown in the figure, it is assumed that there are application 1, application 2, application 3 and application 4. The mapping relationship between application and process is: Application 1 corresponds to process 1, process 2, and process 3; Application 2 corresponds to process 4 and process 5; Application 3 corresponds to process 6; Application 4 corresponds to process 7.

[0029] The corresponding relationship between the process and the transmission port is: Process 1 corresponds to port 443 and port 8080; Process 2 corresponds to port 8022; Process 3 corresponds to port 22; Process 4 corresponds to port 6060; Process 5 corresponds to port 20; Process 6 corresponds to port 9090; Process 7 corresponds to port 9091.

[0030] The priority ranking of each application is: application 1>application 2=application 3>application 4; In descending order of corresponding priorities, the order of transmission queues is as follows: queue 1 > queue 2 > queue 3; The filtering process for each transmission port is as follows: Filter ports 443, 8080, 8022, and 22 to queue 1; Filter ports 6060, 20, and 9090 to queue 2; Filter port 9091 to queue 3; Queue 1, queue 2, and queue 3 transmit data through NIC (Network Interface Card).

[0031] S130, looping through the following steps: S1301: Obtain the current transmission rate of all transmission queues; S1302: Taking the transmission queues with corresponding priorities other than the lowest priority as the object queues, and executing the bandwidth adjustment strategy for each object queue in descending order of the corresponding priorities according to the relationship between the bandwidth threshold of each object queue and the current transmission rate; S1303: After the bandwidth adjustment strategy is executed for all object queues, the current loop is exited and the process jumps to step S1301 again to execute the next loop.

[0032] Among them, the monitoring of the current transmission rate of all transmission queues is real-time, and the interval between two acquisitions of the current transmission rate of all transmission queues can be regarded as an adjustment cycle. It can be understood that since the unit of the transmission rate is generally M / s, the interval between two acquisitions of the current transmission rate of all transmission queues can be 1s, that is, the execution period of each adjustment cycle can be 1s. The object queue can be understood as the transmission queue that needs to determine whether to execute the bandwidth adjustment strategy during the adjustment cycle.

[0033] Optionally, executing a bandwidth adjustment strategy for each object queue can be understood as a strategy for adjusting the bandwidth threshold of each object queue. The bandwidth threshold can be understood as the upper limit of the transmission rate of the current transmission queue. According to the relationship between the bandwidth threshold of each object queue and the current transmission rate, the network resource state of each object queue can be determined. The network resource state may include: a network resource idle state, a network resource sufficient state, and a network resource insufficient state. Among them, the network resource idle state can be understood as a state in which the bandwidth threshold of the object queue far exceeds the current transmission rate; the network resource sufficient state can be understood as a state in which the bandwidth threshold of the object queue and its current transmission rate are adapted; the network resource insufficient state can be understood as a state in which the bandwidth threshold of the object queue is close to being equal to the current transmission rate.

[0034] Exemplarily, for any object queue, the method for determining its network resource status is as follows: If the difference between the bandwidth threshold of the object queue and its current transmission rate is greater than or equal to the first preset threshold, it is determined that the object queue is in a network resource idle state; If the difference between the bandwidth threshold of the object queue and the current transmission rate is less than the first preset threshold and greater than or equal to the second preset threshold, it is determined that the object queue is in a state of sufficient network resources; If the difference between the bandwidth threshold of the object queue and the current transmission rate is smaller than the second preset threshold, it is determined that the object queue is in a state of network resource shortage.

[0035] The first preset threshold value should be greater than the second preset threshold value. The first preset threshold value and the second preset threshold value can be set by technicians according to needs or experience, or determined through a large number of experiments, and this application does not impose any restrictions on this. For example, the first preset threshold value can be set to 0.2M / s, and the second preset threshold value can be set to 0.1M / s.

[0036] It is understandable that if the object queue is in a network resource idle state, the network resources cannot be effectively utilized; if the object queue is in a network resource sufficient state, it is neither lacking in network resources nor wasting network resources; if the object queue is in a network resource insufficient state, the network resources are at risk of not being able to meet the data transmission requirements. Therefore, it is necessary to adjust the bandwidth threshold of the object queue in the network resource idle state and the network resource insufficient state, but it is not necessary to adjust the bandwidth threshold of the object queue in the network resource sufficient state.

[0037] To illustrate the above scheme, assume that a first priority, a second priority, and a third priority are set from high to low; the first priority corresponds to the first transmission queue, the second priority corresponds to the second transmission queue, and the third priority corresponds to the third transmission queue.

[0038] The execution process of step S130 is: S1301, obtaining current transmission rates of the first transmission queue, the second transmission queue, and the third transmission queue; S1302: Because the third transmission queue has the lowest corresponding priority, the first transmission queue and the second transmission queue are used as object queues; First, determine whether the first transmission queue is in a network resource idle state or a network resource shortage state; if so, execute a bandwidth adjustment strategy for the first transmission queue to make the first transmission queue in a network resource sufficient state; After executing the bandwidth adjustment strategy on the first transmission queue, determining whether the second transmission queue is in a network resource idle state or a network resource insufficient state; if so, executing the bandwidth adjustment strategy on the second transmission queue so that the second transmission queue is in a network resource sufficient state; S1303: The bandwidth adjustment strategy has been executed for all object queues, the current loop is exited, and the process jumps to step S1301 again to execute the next loop.

[0039] In this embodiment, when any application initiates networking, the mapping relationship between the application and the transmission port is determined, so that all the transmission ports of the same application can form a resource allocation subject, which is conducive to the allocation of network resources at the application level. Then, according to the mapping relationship between the application and the transmission port, the transmission ports corresponding to the applications of the same priority are filtered into the transmission queues corresponding to the same priority for data transmission, so that the applications are classified according to the priority, and the network resources occupied by the applications of the same priority are uniformly managed. The following steps are executed in a loop: S1301, the current transmission rate of all transmission queues is obtained; S1302, the transmission queues with the corresponding priority not being the lowest priority are taken as the object queues, and the bandwidth adjustment strategy is executed for each object queue in the order from high to low according to the relationship between the bandwidth threshold of each object queue and the current transmission rate; S1303, after the bandwidth adjustment strategy is executed for all object queues, the current loop is exited, and step S1301 is jumped again to execute the next loop. Network resources can be dynamically allocated to transmission queues corresponding to different priorities as needed, so that the transmission queues corresponding to higher priorities enjoy sufficient network resources, and the transmission timeliness of important data is guaranteed.

[0040] Based on the technical solutions of the above embodiments, the present application also provides an optional embodiment. In this optional embodiment, the steps of executing the bandwidth adjustment strategy are refined, including: S210: If the difference between the bandwidth threshold of the current object queue and the current transmission rate thereof is greater than or equal to a first preset threshold, a first adjustment strategy is executed on the current object queue.

[0041] In an optional embodiment, the execution logic of the first adjustment strategy is to execute the following steps in a loop: S2101: Selecting a queue with the highest priority from other transmission queues that meet the first transfer condition as a receiving queue; reducing a bandwidth threshold of a current object queue by a preset adjustment value, and increasing a bandwidth threshold of a receiving queue by a preset adjustment value.

[0042] S2102: Determine whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is less than a first preset threshold and greater than or equal to a second preset threshold: If yes, then the execution logic of the current first adjustment strategy ends; If not, continue to execute step S2101.

[0043] The preset adjustment value may be set by a technician according to needs or experience, or determined through a large number of experiments, and this application does not impose any limitation on this. For example, the preset unit adjustment value may be set to 0.1 M / s.

[0044] The first transfer condition can be understood as a condition that other transmission queues can obtain the idle network resources of the current transmission queue. Optionally, the first transfer condition can be any of the following sub-conditions: The first sub-condition: the transmission queue has the lowest priority; Second sub-condition: the difference between the bandwidth threshold of the transmission queue and its transmission rate is less than a second preset threshold.

[0045] According to the above two sub-conditions, the transmission queue with the lowest priority can receive idle network resources without restriction; except for the transmission queue with the lowest priority, the other transmission queues can only receive idle network resources when they are in a state of lack of network resources. However, since the receiving queue selects the queue with the highest priority from other transmission queues that meet the first transfer condition, the transmission queue with a higher priority will get the idle network resources first.

[0046] In order to explain the above situation more intuitively, assume that the first priority, the second priority and the third priority are set from high to low; the first priority corresponds to the first transmission queue, the second priority corresponds to the second transmission queue, and the third priority corresponds to the third transmission queue. If the current transmission rate of the first transmission queue is 2M / s and the bandwidth threshold is 2.3M / s, it is determined that the first transmission queue is in a network resource idle state, and the first adjustment strategy needs to be executed for the first transmission queue. The specific execution process is: First, determine whether the second transmission queue meets the first transfer condition; if the current transmission rate of the second transmission queue is 1M / s and the bandwidth threshold is 1M / s, then determine that the second transmission queue meets the first transfer condition, reduce the bandwidth threshold of the first transmission queue by 0.1M / s (assuming the preset adjustment value is 0.1M / s), and increase the bandwidth threshold of the second transmission queue by 0.1M / s; After the first adjustment, the current transmission rate of the first transmission queue is still 2M / s, and the bandwidth threshold is 2.2M / s, so it is determined that the first transmission queue is still in a resource idle state; Re-determine whether the second transmission queue meets the first transfer condition; at this time, the current transmission rate of the second transmission queue is 1M / s, and the bandwidth threshold is 1.1M / s, which no longer meets the first transfer condition; sequentially determining whether the third transmission queue satisfies the first transfer condition; since the third transmission queue is the queue with the lowest corresponding priority, the third transmission queue satisfies the first transfer condition; The bandwidth threshold of the first transmission queue is further reduced by 0.1M / s, and the bandwidth threshold of the third transmission queue is increased by 0.1M / s; After the second adjustment, the current transmission rate of the first transmission queue is still 2M / s, and the bandwidth threshold is 2.1M / s. It is determined that the first transmission queue is in a state of sufficient resources and there is no need to adjust the bandwidth threshold of the first transmission queue, so the current loop is exited.

[0047] S220: If the difference between the bandwidth threshold of the current object queue and the current transmission rate is less than the second preset threshold, execute the second adjustment strategy for the current object queue.

[0048] In an optional embodiment, the execution logic of the second adjustment strategy is to loop through the following steps: S2201: In order of corresponding priorities from low to high, determine whether there is a transmission queue that meets the second transfer condition among other transmission queues whose corresponding priorities are lower than the current object queue: If so, the bandwidth threshold of the transmission queue that meets the second transfer condition is reduced by a preset adjustment value, and at the same time, the bandwidth threshold of the current object queue is increased by a preset adjustment value; If it does not exist, the execution logic of the current second adjustment strategy ends.

[0049] S2202: Determine whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is greater than or equal to the second preset threshold and less than the first preset threshold: If yes, then the execution logic of the current second adjustment strategy ends; If not, continue to execute step S2201.

[0050] The second transfer condition can be understood as the condition that other transmission queues can transfer network resources to the current object queue. Since the judgment is based on the order of corresponding priorities from low to high, the object queue that lacks network resources will first plunder network resources from other transmission queues with lower priorities.

[0051] Optionally, the second transfer condition may be: a difference between a bandwidth threshold of the transmission queue and a preset minimum bandwidth value is greater than or equal to a preset adjustment value.

[0052] The preset minimum bandwidth value may be set by technicians according to needs or experience, or determined through a large number of experiments, and this application does not impose any limitation on this. For example, the preset minimum bandwidth value may be set to 0.1 M / s.

[0053] In order to explain the above situation more intuitively, assume that the first priority, the second priority and the third priority are set from high to low; the first priority corresponds to the first transmission queue, the second priority corresponds to the second transmission queue, and the third priority corresponds to the third transmission queue. If the current transmission rate of the first transmission queue is 2.2M / s and the bandwidth threshold is 2.2M / s, it is determined that the first transmission queue is in a state of lack of network resources, and the second adjustment strategy needs to be executed for the first transmission queue. The specific execution process is: First, determine whether the third transmission queue meets the first transfer condition; if the current transmission rate of the third transmission queue is 0.1M / s and the bandwidth threshold is 0.1M / s, then determine that the third transmission queue does not meet the second transfer condition; Continue to determine whether the second transmission queue meets the second transfer condition; if the current transmission rate of the second transmission queue is 1.1M / s and the bandwidth threshold is 1.2M / s, determine that the second transmission queue meets the second transfer condition; Reduce the bandwidth threshold of the second transmission queue by 0.1M / s (assuming the preset adjustment value is 0.1M / s), and increase the bandwidth threshold of the first transmission queue by 0.1M / s; After the first adjustment, the current transmission rate of the first transmission queue is 2.2M / s, and the bandwidth threshold is 2.3M / s. It is determined that the first transmission queue is in a state of sufficient resources and there is no need to adjust the bandwidth threshold of the first transmission queue, so the current loop is exited.

[0054] In addition, for the above example, another possible execution process is given as follows: First, determine whether the third transmission queue meets the first transfer condition; if the current transmission rate of the third transmission queue is 0.1M / s and the bandwidth threshold is 0.1M / s, then determine that the third transmission queue does not meet the second transfer condition; Continue to determine whether the second transmission queue meets the second transfer condition; if the current transmission rate of the second transmission queue is 0.1M / s and the bandwidth threshold is 0.1M / s, it is determined that the second transmission queue also does not meet the second transfer condition; Since there is no transmission queue that meets the second transfer condition, the current loop is directly exited.

[0055] In this embodiment, if the current object queue is in a state of idle network resources, the idle network resources of the current object queue can be transferred to other transmission queues by executing the first adjustment strategy on the current object queue, thereby avoiding waste of network resources; if the current object queue is in a state of insufficient network resources, the second adjustment strategy can be executed on the current object queue to supplement the network resources to the current object queue, thereby ensuring the timeliness of data transmission of the current object queue.

[0056] In an optional embodiment, data is shown in Table 1, and the total bandwidth threshold TS is 10M / s, wherein the bandwidth threshold of class 1 is 5M / s, the bandwidth threshold of class 2 is 3M / s, and the bandwidth threshold of class 3 is 2M / s.

[0057] Table 1

[0058] When the bandwidth threshold of the transmission queue is insufficient, the bandwidth value can only be requested from the lower priority queue, that is, the second adjustment strategy is implemented: If, in the current adjustment cycle, the current transmission rate of class1 rises to its bandwidth threshold of 5M / s, it means that the bandwidth threshold of class1 does not meet its transmission needs, and the bandwidth is first seized from class3 with the lowest priority, and 0.1M / s of bandwidth resources are seized each time. If, in the next adjustment cycle, the current transmission rate of class1 increases to 5.1M / s, which is still equal to its bandwidth threshold, bandwidth resources are continuously seized from low-priority queues. Until the current transmission rate of class1 in a certain adjustment cycle is the same as that in the previous adjustment cycle, for example, the current transmission rate of class1 stops increasing after reaching 5.9M / s, the queue threshold of class1 is 6M / s, and the queue bandwidth threshold of class3 is reduced to 1M / s.

[0059] If the current transmission rate of class1 keeps increasing, and class3 has dropped to the minimum bandwidth threshold of 0.1M / s and is still insufficient to meet the needs of class1, bandwidth will be taken from class2, which has the second lowest priority. If the rate of class1 stops increasing after reaching 7.9M / s, the bandwidth threshold of class1 will be 8M / s, the bandwidth threshold of class3 will be reduced to the preset minimum bandwidth value of 0.1M / s, and the queue threshold of class2 will be reduced to 1.9M / s.

[0060] When the high-priority queue does not need too much bandwidth, the bandwidth threshold of the low-priority transmission queue can be greater than that of the high-priority transmission queue, provided that the corresponding requirements of the high-priority queue are met. That is, the first adjustment strategy is implemented: If the current transmission rate of class1 stops increasing after reaching 2.9M / s, the bandwidth threshold of class1 is 3M / s. At this time, if the current transmission rate of class2 is 1.9M / s, its bandwidth threshold is 2M / s, and the bandwidth threshold of class3 is 5M / s.

[0061] If the current transmission rate of class2 increases from 1.9M / s to 6.9M / s, the bandwidth threshold of class2 increases to 6.9M / s, while the bandwidth threshold of class3 is the preset minimum bandwidth value of 0.1M / s, and the threshold of class1 remains at 3M / s. That is, the bandwidth threshold of the low-priority queue class2 is greater than the bandwidth threshold of the high-priority queue class1. Moreover, when the current transmission rate of class2 is equal to the bandwidth threshold of 6.9M / s, although class2 still has the need to seize bandwidth resources, class3 has reached the preset minimum bandwidth value of 0.1M / s and class2 has a lower priority than class1, so class2 can no longer seize bandwidth from other queues.

[0062] Based on the technical solutions of the above embodiments, the present application also provides an optional embodiment, in which a step of initializing a transmission queue is added, including: S310, for any application, when the application initiates networking, obtain the priority of the application.

[0063] S320, traverse the existing transmission queues; if there is no transmission queue corresponding to the priority, initialize the transmission queue corresponding to the priority.

[0064] In an optional embodiment, an initialization coefficient corresponding to the priority may be obtained; and the product of the initialization coefficient and the total bandwidth threshold is used as the bandwidth threshold of the transmission queue corresponding to the priority.

[0065] Among them, the initialization coefficient can be understood as the proportion of the total network speed of the network card corresponding to the priority. For example, if the total network speed of the network card is 10M / s, and the initialization coefficient corresponding to the priority is 0.5, then when initializing the transmission queue, its bandwidth threshold is set to 5M / s. It can be understood that the higher the priority, the larger the corresponding initialization coefficient. The sum of the bandwidth thresholds of all transmission queues is equal to the total network speed of the network card.

[0066] In this embodiment, the transmission queue corresponding to the priority is initialized according to the priority of the application. This can avoid the transmission queue itself from occupying computer resources and can also uniformly allocate network resources to applications with the same priority.

[0067] Based on the technical solutions of the above embodiments, the present application also provides an optional embodiment, in which a step of releasing the transmission queue is added, including: S410, for any existing transmission queue, if all applications in the transmission queue have exited network communication, confirming that there is no network communication in the transmission queue.

[0068] Optionally, for any application, if there is no mapping relationship between the transmission port and the application, it is determined that the application has exited network communication.

[0069] S420: Transfer the bandwidth threshold of the transmission queue without network communication to the transmission queue with the lowest corresponding priority among other transmission queues.

[0070] Exemplarily, assume that the first priority, the second priority, and the third priority are set from high to low; the first priority corresponds to the first transmission queue, the second priority corresponds to the second transmission queue, and the third priority corresponds to the third transmission queue. The bandwidth threshold of the second transmission queue is 1.5M / s, and the bandwidth threshold of the third transmission queue is 1M / s. If it is determined that there is no network communication in the third transmission queue (it can also be understood that the current transmission rate of the third transmission queue is 0), the bandwidth threshold of the third transmission queue is transferred to the second transmission queue, so that the bandwidth threshold of the second transmission queue is 2.5M / s.

[0071] S430, releasing the transmission queue without network communication.

[0072] It is understandable that, since the transmission queue itself is also a form of data, when there is no data transmission in the transmission queue, the transmission queue needs to be released. Exemplarily, if it is determined that all processes of the application have no ports in use according to the relationship data (establishment / release) returned by the process-port relationship monitoring module in the Kprobe kernel probe, then it is considered that the application has exited network communication. If all applications corresponding to a certain priority level exit network communication, it means that the transmission queue has no network communication. Then, after the bandwidth threshold of the transmission queue is transferred, the transmission queue is released.

[0073] In this embodiment, the bandwidth threshold of the transmission queue without network communication is transferred to other transmission queues, and then the transmission queue is released, thereby reducing the storage space occupied by the transmission queue.

[0074] Based on the technical solutions of the above embodiments, the present application also provides an optional embodiment, such as Figure 2 As shown, in this optional embodiment, the method for allocating network resources includes: S510, obtaining application-process relationship data through the Linux application management mechanism dpkg, and sending the application-process relationship data to the application-port relationship data maintenance module to determine the mapping relationship between the application and the process.

[0075] S520, through the Kprobe kernel probe mechanism, real-time acquisition of process-transmission port relationship data (corresponding to Figure 2The function corresponding to the "process-port relationship monitoring" module in the kernel layer) passes the process-port relationship data from the kernel layer to the application-port relationship data maintenance module in the user layer to determine the mapping relationship between the process and the transmission port.

[0076] S530, the application-port relationship data maintenance module determines the application-port relationship data according to the application-process relationship data and the process-port relationship data, and sends the application-port relationship data to the network resource allocation module of the application priority.

[0077] S540: The application priority maintenance module obtains the application priority tag value, and sends the application priority tag value to the priority network resource allocation module.

[0078] S550, the NIC sends the total network card flow rate to the priority network resource allocation module; the sum of the bandwidth thresholds of the transmission queues corresponding to all priorities is equal to the total network card flow rate of the NIC.

[0079] S560, the priority network resource allocation module adjusts the bandwidth threshold of each transmission queue in real time according to the total flow rate of the network card and the relationship between the current transmission rate of each transmission queue and the bandwidth threshold.

[0080] S570, each transmission queue performs network communication with the outside through the NIC.

[0081] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0082] Based on the same inventive concept, an embodiment of the present invention further provides a network resource allocation device for implementing the network resource allocation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more network resource allocation devices provided below can refer to the limitations of the method above, and will not be repeated here.

[0083] In an exemplary embodiment, a network resource allocation device is provided, comprising: a determination module, a filtering module and an adjustment module, wherein: The determination module is used to determine the mapping relationship between the application and the transmission port for any application when the application initiates networking.

[0084] The filtering module is used to filter the transmission ports corresponding to the applications with the same priority level into the transmission queues corresponding to the same priority level for data transmission according to the mapping relationship.

[0085] The execution module is used to loop through the following steps: S1301, obtaining the current transmission rates of all transmission queues; S1302, taking the transmission queues whose corresponding priorities are not the lowest priorities as the object queues, and executing the bandwidth adjustment strategy for each object queue in descending order of the corresponding priorities according to the relationship between the bandwidth threshold of each object queue and the current transmission rate; S1303, after the bandwidth adjustment strategy is executed for all object queues, the current loop is exited and the process jumps to step S1301 again to execute the next loop.

[0086] In one embodiment, the adjustment module includes: a first execution unit, used to execute a first adjustment strategy on the current object queue if the difference between the bandwidth threshold of the current object queue and its current transmission rate is greater than or equal to a first preset threshold; a second execution unit, used to execute a second adjustment strategy on the current object queue if the difference between the bandwidth threshold of the current object queue and its current transmission rate is less than a second preset threshold.

[0087] In one embodiment, the first execution unit includes: a first execution sub-unit, used to execute S2101: select the transmission queue with the highest priority from other transmission queues that meet the first transfer condition as the receiving queue; reduce the bandwidth threshold of the current object queue by a preset adjustment value, and at the same time, increase the bandwidth threshold of the receiving queue by a preset adjustment value; a first judgment sub-unit, used to judge whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is greater than or equal to a second preset threshold and less than the first preset threshold; if so, end the execution logic of the current first adjustment strategy; if not, execute step S2101.

[0088] In one embodiment, the second execution unit includes: a second execution sub-unit, used to execute S2201: in order from low to high corresponding priorities, determine whether there is a transmission queue that meets the second transfer condition in other transmission queues with corresponding priorities lower than the current object queue; if so, terminate this determination, reduce the bandwidth threshold of the transmission queue that meets the second transfer condition by a preset adjustment value, and at the same time, increase the bandwidth threshold of the current object queue by a preset adjustment value; if not, terminate the execution logic of the current second adjustment strategy; a second judgment sub-unit, used to determine whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is greater than or equal to the second preset threshold and less than the first preset threshold; if so, terminate the execution logic of the current second adjustment strategy; if not, execute step S2201.

[0089] In one embodiment, the determination module includes: a first acquisition unit, used to obtain the mapping relationship between all application processes and transmission ports; a second acquisition unit, used to obtain the mapping relationship between the application program and the application process; a first determination unit, used to determine the mapping relationship between the application program and the transmission port based on the mapping relationship between the application process and the transmission port, and the mapping relationship between the application program and the application process.

[0090] In one of the embodiments, the determination module also includes: a third acquisition unit, used to obtain the priority of any application when the application initiates networking; a first initial unit, used to traverse the existing transmission queues; if there is no transmission queue corresponding to the priority, initialize the transmission queue corresponding to the priority.

[0091] In one of the embodiments, the first initialization unit includes: a first acquisition subunit, used to obtain an initialization coefficient corresponding to the priority; and a first allocation subunit, used to use the product of the initialization coefficient and the total bandwidth threshold as the bandwidth threshold of the transmission queue corresponding to the priority.

[0092] In one embodiment, the filtering module is further used to: for any existing transmission queue, if all applications in the transmission queue have exited network communication, confirm that there is no network communication in the transmission queue; transfer the bandwidth threshold of the transmission queue without network communication to the transmission queue with the lowest priority among other transmission queues; release the transmission queue without network communication. Wherein, for any application, if there is no mapping relationship between the transmission port and the application, it is determined that the application has exited network communication.

[0093] Each module in the above device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0094] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of the present invention.

[0095] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.

Claims

1. A method for allocating network resources, characterized in that: The method comprises: S110, for any application, when the application initiates networking, determining a mapping relationship between the application and a transmission port; S120, according to the mapping relationship, filtering the transmission ports corresponding to the applications of the same priority into the transmission queues corresponding to the same priority for data transmission; S130, looping through the following steps: S1301, obtaining the current transmission rates of all transmission queues; S1302, taking the transmission queues whose corresponding priorities are not the lowest priorities as the object queues, and executing the bandwidth adjustment strategy for each object queue in descending order of the corresponding priorities according to the relationship between the bandwidth threshold of each object queue and the current transmission rate; S1303, after the bandwidth adjustment strategy is executed for all object queues, the current loop is exited and the process jumps to step S1301 again to execute the next loop.

2. The method according to claim 1, characterized in that The executing of the bandwidth adjustment strategy for each object queue according to the relationship between the bandwidth threshold of each object queue and the current transmission rate includes: S210, if the difference between the bandwidth threshold of the current object queue and its current transmission rate is greater than or equal to the first preset threshold, executing the first adjustment strategy for the current object queue; S220, if the difference between the bandwidth threshold of the current object queue and the current transmission rate is less than the second preset threshold, executing the second adjustment strategy for the current object queue; Among them, the first preset threshold is greater than the second preset threshold.

3. The method according to claim 2, characterized in that The execution logic of the first adjustment strategy is to execute the following steps in a loop: S2101, selecting a transmission queue with the highest priority from other transmission queues that meet the first transfer condition as a receiving queue; reducing the bandwidth threshold of the current object queue by a preset adjustment value, and at the same time, increasing the bandwidth threshold of the receiving queue by a preset adjustment value; S2102, determining whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is greater than or equal to the second preset threshold and less than the first preset threshold; if so, terminating the execution logic of the current first adjustment strategy; if not, executing step S2101; The first transfer condition is to satisfy any of the following sub-conditions: The first sub-condition: the transmission queue has the lowest priority; Second sub-condition: the difference between the bandwidth threshold of the transmission queue and its transmission rate is less than a second preset threshold.

4. The method according to claim 2, characterized in that: The execution logic of the second adjustment strategy is to loop through the following steps: S2201, judging whether there is a transmission queue that meets the second transfer condition among other transmission queues whose corresponding priorities are lower than the current object queue in order of corresponding priorities from low to high; If so, the judgment is terminated, the bandwidth threshold of the transmission queue that meets the second transfer condition is reduced by the preset adjustment value, and at the same time, the bandwidth threshold of the current object queue is increased by the preset adjustment value; If it does not exist, then the execution logic of the current second adjustment strategy ends; S2202, determining whether the difference between the bandwidth threshold of the current object queue and the current transmission rate is greater than or equal to the second preset threshold and less than the first preset threshold; if so, terminating the execution logic of the current second adjustment strategy; If not, execute step S2201; The second transfer condition is that the difference between the bandwidth threshold of the transmission queue and the preset minimum bandwidth value is greater than or equal to the preset adjustment value.

5. The method according to claim 1, characterized in that For any application, when the application initiates networking, determining the mapping relationship between the application and the transmission port includes: Get the mapping relationship between all application processes and transmission ports; Obtaining a mapping relationship between the application program and the application process; The mapping relationship between the application program and the transmission port is determined according to the mapping relationship between the application process and the transmission port, and the mapping relationship between the application program and the application process.

6. The method according to claim 1, characterized in that Also includes: For any application, when the application initiates networking, obtain the priority of the application; Traverse the existing transmission queue; If there is no transmission queue corresponding to the priority level, the transmission queue corresponding to the priority level is initialized.

7. The method according to claim 6, characterized in that Initializing the transmission queue corresponding to the priority level includes: Obtaining an initialization coefficient corresponding to the priority; The product of the initialization coefficient and the total bandwidth threshold is used as the bandwidth threshold of the transmission queue corresponding to the priority.

8. The method according to claim 1, characterized in that Also includes: For any existing transmission queue, if all applications in the transmission queue have exited network communication, confirming that there is no network communication in the transmission queue; Transferring the bandwidth threshold of the transmission queue without network communication to the transmission queue with the lowest corresponding priority among other transmission queues; The transmission queue without network communication is released.

9. The method according to claim 8, characterized in that For any application, if there is no mapping relationship between the transmission port and the application, it is determined that the application has exited the network communication.

10. A network resource allocation device, characterized in that: The device comprises: A determination module, used for determining, for any application, a mapping relationship between the application and a transmission port when the application initiates networking; A filtering module, used for filtering the transmission ports corresponding to the applications of the same priority level into the transmission queues corresponding to the same priority level for data transmission according to the mapping relationship; The execution module is used to loop through the following steps: S1301, obtaining the current transmission rates of all transmission queues; S1302, taking the transmission queues whose corresponding priorities are not the lowest priorities as the object queues, and executing the bandwidth adjustment strategy for each object queue in descending order of the corresponding priorities according to the relationship between the bandwidth threshold of each object queue and the current transmission rate; S1303, after the bandwidth adjustment strategy is executed for all object queues, the current loop is exited and the process jumps to step S1301 again to execute the next loop.

Citation Information

Patent Citations

  • Bandwidth setting method, device and system

    CN106453143A

  • Industrial Internet-of-Things for adaptively adjusting time slot window and bandwidth sharing based on TSN

    CN112003791A

  • Service flow scheduling method, device and system

    CN114679792A

  • Bandwidth resource allocation method applied to civil aviation communication system

    CN115087035A