Flow control method, device, electronic device and storage medium
By using the token bucket mechanism on the network egress device and dynamically adjusting the limit value and priority coefficient, the problem of low performance and high cost of the existing QoS software solution on the network egress device is solved, and high performance is achieved. Flow control and fair allocation of bandwidth resources.
Patent Information
- Application Number
- CN202111270970.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-10-29
AI Technical Summary
Existing QoS software solutions have low performance on network egress equipment and are costly, difficult to use on dedicated network egress equipment, and cannot effectively alleviate the problem of unfair allocation of bandwidth resources.
The token bucket mechanism is used to implement traffic control on network egress devices. By dynamically adjusting the limit value and priority coefficient of nodes, refined differential services of traffic are achieved, and there is no need to cache traffic data in the memory, reducing memory pressure.
It achieves high-performance traffic control on network egress devices, reduces memory pressure, alleviates unfair allocation of bandwidth resources, and improves user-perceived traffic forwarding service experience.
Smart Images

Figure CN113973342B
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communications, and in particular to a flow control method, device, electronic device and storage medium. Background Art
[0002] The purpose of QoS (Quality of Service) is to provide users with better traffic forwarding services through traffic control under limited bandwidth resources.
[0003] Currently, mainstream QoS solutions are divided into hardware solutions and software solutions.
[0004] Hardware solutions include QoS-specific FPGAs (Field-Programmable Gate Arrays) or QoS coprocessors integrated into network processors, such as ezchip network processors. Hardware solutions provide good service performance, but the cost is too high for equipment manufacturers.
[0005] The representative of software solutions is the QoS module provided by DPDK (Date plane development kit). Through code optimization, the performance of DPDK's QoS module can be comparable to that of hardware solutions. However, DPDK's QoS module has strict deployment requirements. A Core (processor core) must be allocated separately for the QoS module, which is equivalent to using a Core of a general-purpose CPU (Central Processing Unit / Processor) to complete the functions of an FPGA or QoS coprocessor. Compared with hardware solutions, DPDK's solution is lower in cost, but for some scenarios that require flexible deployment and do not have high QoS requirements, DPDK's solution still has too many restrictions.
[0006] In addition to the software solution of DPDK's QoS module, some QoS-related algorithms provided in the Linux kernel can also be used to implement it, such as the HTB (Hierarchical Token Bucket) queuing mechanism. However, the HTB queuing mechanism needs to cache traffic data in memory, which puts a lot of pressure on the memory, resulting in low algorithm performance and cannot be used on dedicated network egress devices. Summary of the invention
[0007] The purpose of the embodiments of the present application is to provide a traffic control method, apparatus, electronic device and storage medium, so as to provide a QoS software solution that can be used on a network egress device.
[0008] The present application provides a flow control method, which is applied to a network egress device, including:
[0009] Determine a target node corresponding to the current traffic to be forwarded; the target node is a node mapped in the network egress device by a device sending the current traffic to be forwarded;
[0010] Determine whether the current traffic to be forwarded meets preset forwarding conditions in the target node and each upper node of the target node;
[0011] If the current traffic to be forwarded satisfies the preset forwarding conditions in the target node and each upper node of the target node, the current traffic to be forwarded is forwarded; otherwise, the current traffic to be forwarded is discarded; wherein:
[0012] The forwarding conditions of the target node and each upper-level node except the highest-level node include: within the node, the current remaining number of guaranteed tokens does not meet the demand for forwarding the current traffic to be forwarded, the current remaining number of restricted tokens meets the demand for forwarding the current traffic to be forwarded, and the number of restricted tokens currently used by the node in this cycle is less than the limit value corresponding to the node; wherein the limit value corresponding to the node is greater than or equal to the total number of guaranteed tokens of the node, and less than or equal to the total number of restricted tokens of the node.
[0013] In the above implementation process, the flow restriction of each node in the network egress device is realized by using a token bucket, thereby achieving the effect of controlling the flow, and the process does not require queuing of flow, does not require caching of flow data in memory, and has little pressure on memory, so it has high algorithm performance, can be used on network egress devices, and realizes flow control, providing flow forwarding services for users. In addition, the scheme of the present application sets the limit value corresponding to each node except the highest-level node, so that when the number of limit tokens used in the cycle reaches the limit value, the current flow to be forwarded is discarded, and no longer competes for the limit token of the upper node, thereby realizing the early flow restriction of the lower-level node, preventing individual lower-level nodes from occupying too many resources of the upper-level nodes, alleviating the unfair allocation of bandwidth resources, and ensuring the user-perceived flow forwarding service experience.
[0014] Furthermore, the method also includes: if the restriction token of the node's parent node in the previous cycle has been used up, then reducing the restriction value of the node; if the restriction token of the node's parent node in the previous cycle has not been used up, then increasing the restriction value of the node.
[0015] In the above implementation process, the restriction value of the subordinate node is dynamically adjusted by the restriction token usage of the superior node in the previous cycle. When the restriction token of the superior node in the previous cycle is used up, it means that the token of the superior node is tight. By reducing the restriction value of the subordinate node, the flow restriction of the subordinate node can be carried out in advance, thereby further preventing individual subordinate nodes from occupying too many resources of the superior node and alleviating the unfair allocation of bandwidth resources. On the contrary, when the restriction token of the superior node in the previous cycle is not used up, it means that the token of the superior node is available, and the corresponding bandwidth usage of the superior node is not tight, so the restriction value of the subordinate node can be increased, which makes the timing of submitting flow restriction to the subordinate node delayed, so that the resources of the superior node can be more fully utilized.
[0016] Furthermore, after determining the target node corresponding to the current traffic to be forwarded, the method also includes: determining the traffic priority of the current traffic to be forwarded; determining a priority coefficient based on the traffic priority; the higher the traffic priority, the smaller the priority coefficient, and the priority coefficient is greater than 0 and less than 1; multiplying the set standard limit value by the priority coefficient to obtain the limit value of the target node.
[0017] In the above implementation process, the limit value is dynamically adjusted according to the traffic priority of the current traffic to be forwarded, so that the higher the traffic priority of the traffic to be forwarded, the smaller the limit value corresponding to the traffic to be forwarded, so that the traffic to be forwarded with a higher traffic priority can have more opportunities to obtain the restriction token, that is, the traffic to be forwarded with a higher traffic priority can have a greater forwarding opportunity, thereby realizing more refined differentiated services for different traffic.
[0018] Furthermore, the forwarding conditions of the target node and each upper-level node except the highest-level node also include: within the node, the current remaining guaranteed token number meets the requirements for forwarding the current traffic to be forwarded, and the current traffic to be forwarded has a first mark; the first mark indicates that the remaining guaranteed token number of the previous node of the node meets the requirements for forwarding the current traffic to be forwarded; wherein, the target node assumes that the current traffic to be forwarded has the first mark.
[0019] Furthermore, the forwarding condition of the highest-level node includes: within the node, the current remaining guaranteed token quantity does not meet the requirement of forwarding the current traffic to be forwarded, and the current remaining restricted token quantity meets the requirement of forwarding the current traffic to be forwarded.
[0020] Furthermore, within the same cycle: the total number of guaranteed tokens of the upper node is greater than or equal to the sum of the total number of guaranteed tokens of all subordinate nodes of the upper node; the total number of restricted tokens of the upper node is greater than or equal to the total number of restricted tokens of any subordinate node of the upper node.
[0021] In the above implementation process, by setting the total number of guaranteed tokens of the upper node to be greater than or equal to the sum of the total number of guaranteed tokens of all subordinate nodes of the upper node, and the total number of restricted tokens of the upper node to be greater than or equal to the total number of restricted tokens of any subordinate node of the upper node, it can be ensured that the traffic forwarded using the guaranteed tokens can be forwarded normally, and the traffic forwarded by limiting the total number of tokens can fully compete.
[0022] Furthermore, the method also includes: after monitoring that the number of restricted tokens currently used by any node in this cycle is greater than a preset packet loss threshold, randomly discarding the received traffic to be forwarded corresponding to the node; wherein the packet loss threshold is greater than the total number of guaranteed tokens of the node and less than the limit value of the node.
[0023] In the above implementation process, by adopting the packet loss threshold to limit, the forwarding traffic can be randomly discarded in advance, and the packet loss can trigger the end-to-end flow control mechanism, so that the sender of the traffic actively reduces the sending window and reduces the sending traffic, thereby achieving the purpose of controlling the traffic in advance.
[0024] The embodiment of the present application also provides a flow control device, which is arranged on a network egress device, and includes: a determination module and a processing module;
[0025] The determination module is used to determine the target node corresponding to the current traffic to be forwarded; the target node is the node mapped in the network egress device by the device sending the current traffic to be forwarded;
[0026] The processing module is used to determine whether the current traffic to be forwarded meets the preset forwarding conditions in the target node and each upper node of the target node;
[0027] If the current traffic to be forwarded satisfies the preset forwarding conditions in the target node and each upper node of the target node, the current traffic to be forwarded is forwarded; otherwise, the current traffic to be forwarded is discarded; wherein:
[0028] The forwarding conditions of the target node and each upper-level node except the highest-level node include: within the node, the current remaining number of guaranteed tokens does not meet the demand for forwarding the current traffic to be forwarded, the current remaining number of restricted tokens meets the demand for forwarding the current traffic to be forwarded, and the number of restricted tokens currently used by the node in this cycle is less than the limit value corresponding to the node; wherein the limit value corresponding to the node is greater than or equal to the total number of guaranteed tokens of the node, and less than or equal to the total number of restricted tokens of the node.
[0029] An embodiment of the present application also provides an electronic device, including a processor, a memory and a communication bus; the communication bus is used to realize connection and communication between the processor and the memory; the processor is used to execute one or more programs stored in the memory to implement any of the above-mentioned flow control methods.
[0030] An embodiment of the present application also provides a readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement any of the above-mentioned flow control methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 A flow chart of a flow control method provided in an embodiment of the present application;
[0033] Figure 2 An exemplary node relationship diagram provided for an embodiment of the present application;
[0034] Figure 3 Another exemplary node relationship diagram provided for an embodiment of the present application;
[0035] Figure 4 A schematic diagram of the structure of a flow control device provided in an embodiment of the present application;
[0036] Figure 5 A schematic diagram of the structure of a network egress device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0038] Embodiment 1:
[0039] In order to implement a lightweight QoS software solution on a network egress device, an embodiment of the present application provides a flow control method applied to a network egress device. Figure 1 As shown, Figure 1 The flow chart of the flow control method provided in the embodiment of the present application includes:
[0040] S101: Determine the target node corresponding to the current traffic to be forwarded.
[0041] It should be noted that the network egress device refers to a device installed at the network egress location and used to determine whether the traffic in the network is to be sent out.
[0042] In the embodiment of the present application, the network architecture is maintained in the form of nodes on the network egress device.
[0043] For example, see Figure 2 As shown, Figure 2 This is a node relationship diagram exemplified in the embodiment of the present application. The nodes at each level are formed in a tree structure. The lowest level node in the diagram may correspond to a specific traffic sending entity in the network, and the upper level node represents the group described by each lower level node.
[0044] For example, suppose in actual application, device 1 and device 2 belong to a project group A. Suppose device 1 and device 2 are Figure 2 In the example, the corresponding nodes are nodes 1 and 2, then project group A corresponds to Figure 2 Node 9 in.
[0045] Assume that in actual application, project group A and project group B belong to project department C. Assume that project group B Figure 2 In the corresponding node 10, then project C corresponds to Figure 2 Node 13 in .
[0046] Assume that in actual application, project department C and project department D belong to company E. Assume that project department D Figure 2 The corresponding node is 14, then company E corresponds to Figure 2 Node 15 in.
[0047] In the above example, Figure 2 The system of company E is shown. Node 15 represents company E. The bandwidth of node 15 is the bandwidth of the entire company. The guaranteed token quantity and limited token quantity of node 15 are the total guaranteed token quantity and limited token quantity of all devices in the entire company. The lowest level nodes 1 to 8 correspond to each physical device.
[0048] It should be understood that for each branch in the node relationship diagram, the length of each branch may be different according to different actual division situations of each branch in the actual application process.
[0049] In the embodiment of the present application, the target node is the node mapped in the network egress device by the device sending the current traffic to be forwarded.
[0050] For example, in the above example, assuming that the device sending the current traffic to be forwarded is device 1, then the target node is node 1. In the embodiment of the present application, the device identification information corresponding to each node, such as the source IP address of the device, etc., can be pre-recorded, so that the target node can be determined accordingly.
[0051] S102: Determine whether the current traffic to be forwarded meets the preset forwarding conditions in the target node and each upper node of the target node. If the current traffic to be forwarded meets the preset forwarding conditions in the target node and each upper node of the target node, go to step S103; otherwise, go to step S104.
[0052] In the embodiment of the present application, the forwarding conditions for the target node and each upper-level node except the highest-level node (hereinafter referred to as the first forwarding condition for ease of description) may include:
[0053] In the node, the current remaining guaranteed token number does not meet the demand for forwarding the current traffic to be forwarded, the current remaining limit token number meets the demand for forwarding the current traffic to be forwarded, and the number of limit tokens currently used by the node in this cycle is less than the limit value corresponding to the node.
[0054] In an embodiment of the present application, the first forwarding condition may also include: within the node, the current remaining guaranteed token quantity meets the requirement of forwarding the current traffic to be forwarded, and the current traffic to be forwarded has a first mark.
[0055] In the embodiment of the present application, the target node assumes that the current traffic to be forwarded has a first tag, and the first tag indicates that the remaining guaranteed token quantity of the previous node of the node meets the requirement of forwarding the current traffic to be forwarded.
[0056] It should be noted that, in the embodiment of the present application, each node has two token buckets, namely, a guaranteed token bucket and a restricted token bucket. The tokens in the guaranteed token bucket are set according to the guaranteed bandwidth corresponding to the node, to ensure the minimum bandwidth size that the node can use; and the restricted token bucket is set according to the restricted bandwidth corresponding to the node, to limit the maximum bandwidth that the node can use.
[0057] When in use, for traffic with a first mark (e.g., marked as green), outbound control is performed through the guarantee token in the guarantee token bucket, while for traffic with a second mark (e.g., marked as yellow), outbound control is performed through the restriction token in the restriction token bucket.
[0058] In the embodiment of the present application, it can be assumed that when the traffic to be forwarded is received, the traffic to be forwarded has the first tag, so as to first determine whether the current remaining guaranteed token quantity in the node meets the requirement of forwarding the current traffic to be forwarded.
[0059] If the conditions are met, the traffic to be forwarded continues to carry the first tag, and the upper-layer node continues to make the judgment.
[0060] If not, continue to determine whether the current remaining limit token quantity in the node meets the requirement of forwarding the current traffic to be forwarded.
[0061] If the number of remaining limit tokens does not meet the needs of forwarding the current traffic to be forwarded, it means that the tokens in the node are insufficient to forward the traffic to be forwarded. At this time, there are two processing methods in the embodiment of the present application:
[0062] One is: the traffic to be forwarded can be directly discarded, so that the upper node does not continue to make judgments.
[0063] The second method is to change the mark of the traffic to be forwarded to the third mark (for example, red mark), and then perform mark identification when judging the upper node. When it is determined to be the third mark, the mark is not changed directly, and the judgment of the next higher node is continued until the highest node is reached. At this time, no substantive judgment is performed in the whole process, and the final mark is still the third mark, so the traffic to be forwarded is discarded.
[0064] If the number of remaining restriction tokens meets the requirement of forwarding the current traffic to be forwarded, it means that although the guarantee token in the node cannot support forwarding the traffic to be forwarded, the restriction token is sufficient to support it, and further judgment can be made in the upper-level node.
[0065] In the embodiment of the present application, in order to ensure that the target node can use the guarantee token to forward the current traffic to be forwarded, each upper node can also judge whether it is passed. The total number of guarantee tokens of the upper node can be set to be greater than or equal to the sum of the total number of guarantee tokens of all lower nodes of the upper node. For example, Figure 2 The total number of guaranteed tokens of the middle and upper node 13 is 100, so the sum of the total number of guaranteed tokens of its lower nodes 9 and 10 must not exceed 100.
[0066] In addition, in order to allow each subordinate node to fully compete, in the embodiment of the present application, the total number of restriction tokens of the upper node should be greater than or equal to the total number of restriction tokens of any subordinate node of the upper node.
[0067] It should be noted that for the same node, since the number of tokens in the guaranteed token bucket is set according to the guaranteed bandwidth corresponding to the node, and the number of tokens in the limited token bucket is set according to the limited bandwidth corresponding to the node, the total number of limited tokens should be greater than the total number of guaranteed tokens.
[0068] It should be understood that simply setting a guaranteed token bucket and a restricted token bucket to perform flow control may result in unfair resource allocation and waste of resources.
[0069] like Figure 3 As shown, assuming that the flow control (hereinafter referred to as flow control) of the upper node A is set to 10M to 20M (the minimum guaranteed bandwidth is 10M and the maximum restricted bandwidth is 20M), the flow control settings of the lower nodes are all 2M-20M.
[0070] At this time, if the traffic that node B needs to forward in this cycle far exceeds 20M, then when the token in the restricted token bucket is updated, it will be immediately preempted by node B. Nodes C, D, and E cannot use the maximum restricted bandwidth fairly, resulting in unfair resource allocation.
[0071] If the traffic that the lower-level nodes need to forward in this cycle exceeds 20M, then these lower-level nodes will use up their tokens in a short time after the token is updated, and messages cannot pass through in the subsequent time periods of this cycle, resulting in a poor user experience. In addition, in the second half of the token update cycle, the tokens of node A are exhausted, but all lower-level nodes are still trying to apply for tokens, which also leads to a waste of resources.
[0072] In the embodiment of the present application, by setting a corresponding limit value in each node except the highest-level node, when judging the forwarding condition, in addition to judging whether the current remaining guaranteed token number (i.e., the remaining token number in the guaranteed token bucket of the node) in the node meets the requirements for forwarding the current traffic to be forwarded, or judging whether the current remaining limited token number (i.e., the remaining token number in the limited token bucket of the node) meets the requirements for forwarding the current traffic to be forwarded, it is further judged whether the number of limited tokens currently used by the node in this cycle is less than the limit value corresponding to the node. If the number of limited tokens currently used by the node in this cycle is greater than or equal to the limit value corresponding to the node, the current traffic to be forwarded can be discarded, or the mark can be updated to the third mark.
[0073] It should be understood that if the number of remaining restriction tokens meets the demand for forwarding the current traffic to be forwarded, but the number of restriction tokens currently used by the node in this cycle is greater than or equal to the restriction value corresponding to the node, then it means that although there is no traffic congestion on the node, traffic congestion may have occurred at the node's parent node. In the embodiment of the present application, the traffic of the subordinate node is limited in advance by setting the restriction value, preventing individual subordinate nodes from occupying too many resources of the parent node, alleviating the unfair allocation of bandwidth resources, and ensuring the user-perceived traffic forwarding service experience.
[0074] It should be noted that in the embodiment of the present application, the limit value corresponding to each node should be greater than or equal to the total number of guaranteed tokens of the node (that is, the capacity of the guaranteed token bucket of the node), and less than or equal to the total number of restricted tokens of the node (that is, the capacity of the restricted token bucket of the node).
[0075] It should also be noted that in order to make the limit value of each node better achieve the regulation effect, in an embodiment of the present application, the limit value of each node in this cycle can also be dynamically adjusted according to the usage of the limit token of the parent node of each node in the previous cycle.
[0076] Exemplarily, if the restriction token of the node's parent node in the previous cycle has been used up, the restriction value of the node is reduced; if the restriction token of the node's parent node in the previous cycle has not been used up, the restriction value of the node is increased.
[0077] It should be understood that when the restriction token of the upper node in the previous cycle is used up, it means that the token of the upper node is tight. By reducing the restriction value of the lower node, the flow restriction of the lower node can be carried out in advance, thereby further preventing individual lower nodes from occupying too many resources of the upper node and alleviating the unfair allocation of bandwidth resources. On the contrary, when the restriction token of the upper node in the previous cycle is not used up, it means that the upper node token is available, and the bandwidth usage corresponding to the upper node is not tight, so the restriction value of the lower node can be increased, so that the timing of submitting flow restriction to the lower node is delayed, so that the resources of the upper node can be more fully utilized.
[0078] It should be noted that, for a token bucket, the number of tokens therein is replenished periodically. The period described in the embodiments of the present application refers to the replenishment period of the token bucket, or in some documents, is also referred to as the usage period of the tokens in the token bucket.
[0079] It should be noted that, in actual application, there are usually two ways to control tokens in a token bucket.
[0080] The first is: as long as the tokens in the token bucket are not 0 or negative, tokens can be allocated to the traffic to be forwarded. When the tokens are insufficient, the number of tokens in the token bucket is recorded as a negative value, and the number of tokens represented by the negative value is deducted when the tokens are replenished in the next cycle.
[0081] At this time, judging whether the current number of remaining guaranteed tokens meets the demand for forwarding the current traffic to be forwarded, and judging whether the current number of remaining restricted tokens meets the demand for forwarding the current traffic to be forwarded, can be by judging whether the current number of remaining guaranteed tokens and the current number of remaining restricted tokens are less than or equal to 0.
[0082] The determination of whether the restriction tokens have been used up may be performed by determining whether the number of restriction tokens is less than or equal to 0.
[0083] The second is that tokens can be allocated to the traffic to be forwarded only when the number of tokens in the token bucket is greater than or equal to the number of tokens required to forward the traffic to be forwarded.
[0084] At this time, it is necessary to determine whether the current number of remaining guaranteed tokens meets the needs of forwarding the current traffic to be forwarded, and whether the current number of remaining limited tokens meets the needs of forwarding the current traffic to be forwarded. It can be determined whether the current number of remaining guaranteed tokens and the current number of remaining limited tokens are greater than or equal to the number of tokens required to forward the current traffic to be forwarded.
[0085] The determination of whether the restriction token has been used up may be: determining whether the number of remaining restriction tokens is greater than or equal to the number of tokens required to forward the traffic to be forwarded during the last determination process at the end of the previous cycle. If greater, it is determined that it has not been used up; if less, it is determined that it has been used up.
[0086] Alternatively, determining whether the restriction token has been used up may also be: determining whether the number of remaining restriction tokens in the restriction token bucket is less than or equal to a set threshold value (the threshold value is a constant greater than or equal to 0, which can be set by engineers according to actual needs) at the end of the previous cycle. If so, it is determined that the restriction token has been used up. Otherwise, it is determined that the restriction token has not been used up.
[0087] It should also be noted that in actual application, different traffic often has different priorities. To this end, in the embodiment of the present application, after determining the target node corresponding to the current traffic to be forwarded, the traffic priority of the current traffic to be forwarded can also be determined, and then the priority coefficient is determined based on the traffic priority, and then the set standard limit value is multiplied by the priority coefficient to obtain the limit value of the target node.
[0088] In the embodiment of the present application, the higher the traffic priority, the smaller the priority coefficient, and the priority coefficient is greater than 0 and less than 1.
[0089] In the embodiment of the present application, the traffic priority can be characterized according to the DSCP (Differentiated Services Code Point) field in the message of the current traffic to be forwarded or the prior field in 80211.p. Then, the priority coefficient is determined based on the value of the DSCP field in the message or the prior field in 80211.p.
[0090] Exemplarily, priority coefficient values corresponding to values of different DSCP fields or prior fields may be recorded in advance, so that the priority coefficient of the current traffic to be forwarded may be obtained by table lookup.
[0091] In addition, for each upper-level node, the above method can also be used to calculate the limit value of the current flow to be forwarded, so as to achieve more refined differentiated services for different flows.
[0092] It should be understood that in actual application, different nodes may also have different priorities. To this end, in the embodiment of the present application, each upper node may also first determine the priority of its own lower nodes (such as Figure 2 The node priority of node 1 is the subordinate node of node 9, and node 9 is the subordinate node of node 13), the priority coefficient is determined, and then the set standard limit value is multiplied by the priority coefficient to obtain the limit value currently used for judgment by the node, thereby realizing more refined differentiated services for different nodes.
[0093] It should be understood that the above two solutions can be used in combination. That is, before making a judgment, each upper node can first calculate a priority coefficient based on the traffic priority of the current traffic to be forwarded and the node priority of the lower node that reports the current traffic to be forwarded, and then multiply the set standard limit value by the priority coefficient to obtain the limit value currently used for judgment by the node, thereby realizing differentiated services for different traffic and different nodes.
[0094] It is worth noting that in each implementation of calculating the limit value based on the priority coefficient, the standard limit value in this cycle can be dynamically updated according to the limit token usage of the node's parent node in the previous cycle. The update method can be found in the above description and will not be repeated here.
[0095] It should be noted that in the embodiment of the present application, the limit value does not need to be set in the highest-level node. To this end, the forwarding condition of the highest-level node (hereinafter referred to as the second forwarding condition) may include: within the node, the current remaining guaranteed token number does not meet the requirement of forwarding the current traffic to be forwarded, and the current remaining limit token number meets the requirement of forwarding the current traffic to be forwarded.
[0096] In addition, the second forwarding condition may also include: within the node, the current remaining guaranteed token quantity meets the requirement of forwarding the current traffic to be forwarded, and the current traffic to be forwarded has the first mark.
[0097] S103: Forward the current traffic to be forwarded.
[0098] It should be noted that, when forwarding the current traffic to be forwarded, it is necessary to deduct the number of tokens required for forwarding the current traffic to be forwarded from each node that has performed forwarding condition judgment.
[0099] If the current traffic to be forwarded is forwarded with the first mark, then the guaranteed token quantity of each node is deducted. If the current traffic to be forwarded is forwarded with the second mark, then the limited token quantity of each node is deducted.
[0100] S104: discard the current traffic to be forwarded.
[0101] It should be noted that in a feasible implementation of the embodiment of the present application, in the network egress device, a packet loss threshold can also be set for each node, and it is monitored whether the number of restriction tokens currently used by each node is greater than or equal to the packet loss threshold.
[0102] After monitoring that the number of restricted tokens currently used by any node in this cycle is greater than the preset packet loss threshold, the corresponding traffic to be forwarded received by the node can be randomly discarded, thereby triggering the end-to-end flow control mechanism, so that the sender of the traffic actively reduces the sending window and reduces the sending traffic, thereby achieving the purpose of controlling the traffic in advance.
[0103] It should be understood that if the above feasible implementation method is adopted, after receiving the current traffic to be forwarded, before judging whether the forwarding condition is met at each node, the above packet loss threshold can be judged first, and then random packet loss can be performed. In each node, if the current traffic to be forwarded is not discarded, further judgment on whether the forwarding condition is met is performed. If the current traffic to be forwarded is randomly discarded, the process can be terminated directly.
[0104] In the embodiment of the present application, the packet loss threshold of a node should be greater than the total number of guaranteed tokens of the node and less than the limit value of the node. Exemplarily, 80% of the limit value of the node can be taken as the packet loss threshold.
[0105] The flow control method provided in the embodiment of the present application uses a token bucket to implement flow restrictions for each node in the network egress device, thereby achieving a flow control effect, and the process does not require flow queuing, does not require flow data to be cached in the memory, and has little pressure on the memory, thereby having a high algorithm performance, and can be used on the network egress device, and realizes flow control, providing flow forwarding services for users. In addition, the scheme of the present application sets a limit value corresponding to each node except the highest-level node, so that when the number of limit tokens used in a cycle reaches the limit value, the current flow to be forwarded is discarded, and no longer competes for the limit token of the upper-level node, thereby realizing early flow restriction for the lower-level node, preventing individual lower-level nodes from occupying too many resources of the upper-level node, alleviating the unfair allocation of bandwidth resources, and ensuring the user-perceived flow forwarding service experience.
[0106] Embodiment 2:
[0107] This embodiment, based on the first embodiment, takes a specific flow control process as an example to further illustrate the present application.
[0108] Assume that the node relationship diagram in the network egress device is as follows Figure 3 shown.
[0109] In the figure, the total number of guaranteed tokens of node A is greater than or equal to the sum of the total number of guaranteed tokens of node B, node C, node D, and node E. The total number of restricted tokens of node A is equal to the total number of restricted tokens of node B, node C, node D, and node E.
[0110] Assume that node B receives a flow to be forwarded.
[0111] S1, determine whether the remaining guaranteed token number of node B is less than or equal to 0. If not, forward the traffic to be forwarded, and deduct the guaranteed token numbers in node B and node A (the deduction value is the number of tokens required to send the traffic to be forwarded). If yes, continue to execute subsequent steps.
[0112] S2: Determine the priority coefficient θ according to the DSCP field in the message of the traffic to be forwarded.
[0113] S3, multiplying the priority coefficient θ and the standard limit value to obtain the limit value of the node B for the traffic to be forwarded.
[0114] The standard limit value is determined based on the usage of the limit token of node A in the previous cycle. If the limit token of node A is fully used in the previous cycle, the standard limit value in this cycle is reduced by one based on the standard limit value in the previous cycle. If the limit token of node A is not fully used in the previous cycle, the standard limit value in this cycle is increased by one based on the standard limit value in the previous cycle.
[0115] S4, determine whether the number of limit tokens used by node B in this cycle is greater than 80% of the limit value. If not, execute the subsequent steps. If yes, randomly determine whether the traffic to be forwarded is discarded. If it is determined to be discarded, end the process. If it is determined not to be discarded, execute the subsequent steps.
[0116] S5, determining whether the number of limit tokens used by node B in this cycle is greater than the limit value, and determining whether the number of remaining limit tokens of node B is less than or equal to 0.
[0117] If the number of limit tokens used by node B in this period is greater than the limit value, or the number of remaining limit tokens of node B is less than or equal to 0, the message to be forwarded is discarded.
[0118] If the number of limit tokens used by node B in this cycle is less than or equal to the limit value, and the number of remaining limit tokens of node B is greater than 0, the traffic to be forwarded is marked as yellow and the subsequent steps are continued.
[0119] S6, determine whether the number of remaining limit tokens of node A is less than or equal to 0. If so, discard the message to be forwarded. If not, forward the traffic to be forwarded, and deduct the number of limit tokens in node B and node A (the deduction value is the number of tokens required to send the traffic to be forwarded).
[0120] Through the above scheme, a lightweight QoS software solution is implemented in the network egress device, and the process does not require traffic queuing, and does not require traffic data to be cached in the memory, which puts little pressure on the memory, thereby having higher algorithm performance. In addition, traffic distribution is dynamically adjustable based on the congestion status of the upper-level node, preventing individual lower-level nodes from occupying too many resources of the upper-level nodes, alleviating the unfair allocation of bandwidth resources, and ensuring the traffic forwarding service experience perceived by users.
[0121] Embodiment three:
[0122] Based on the same inventive concept, the embodiment of the present application also provides a flow control device 400 disposed in a network egress device. Figure 4 As shown, Figure 4 Shows the use of Figure 1 The flow control device of the method shown. It should be understood that the specific functions of the device 400 can be referred to the description above, and the detailed description is appropriately omitted here to avoid repetition. The device 400 includes at least one software function module that can be stored in a memory in the form of software or firmware or fixed in the operating system of the device 400. Specifically:
[0123] See also Figure 4 As shown, the apparatus 400 includes: a determination module 401 and a processing module 402. Among them:
[0124] The determination module 401 is used to determine the target node corresponding to the current traffic to be forwarded; the target node is the node mapped in the network egress device by the device sending the current traffic to be forwarded;
[0125] The processing module 402 is used to determine whether the current traffic to be forwarded meets the preset forwarding conditions in the target node and each upper node of the target node; if the current traffic to be forwarded meets the preset forwarding conditions in the target node and each upper node of the target node, forward the current traffic to be forwarded; otherwise, discard the current traffic to be forwarded; wherein:
[0126] The forwarding conditions of the target node and each upper-level node except the highest-level node include: within the node, the current remaining number of guaranteed tokens does not meet the demand for forwarding the current traffic to be forwarded, the current remaining number of restricted tokens meets the demand for forwarding the current traffic to be forwarded, and the number of restricted tokens currently used by the node in this cycle is less than the limit value corresponding to the node; wherein the limit value corresponding to the node is greater than or equal to the total number of guaranteed tokens of the node, and less than or equal to the total number of restricted tokens of the node.
[0127] In a feasible implementation of an embodiment of the present application, the processing module 402 is also used to reduce the restriction value of the node if the restriction token of the node's parent node in the previous cycle has been used up; if the restriction token of the node's parent node in the previous cycle has not been used up, increase the restriction value of the node.
[0128] In a feasible implementation of the embodiment of the present application, the determination module 401 is also used to determine the traffic priority of the current traffic to be forwarded after determining the target node corresponding to the current traffic to be forwarded; the processing module 402 is also used to determine the priority coefficient based on the traffic priority; the set standard limit value is multiplied by the priority coefficient to obtain the limit value of the target node. The higher the traffic priority, the smaller the priority coefficient, and the priority coefficient is greater than 0 and less than 1.
[0129] In a feasible implementation of the embodiment of the present application, the forwarding conditions of the target node and each upper-level node except the highest-level node also include: within the node, the current remaining guaranteed token number meets the requirements for forwarding the current traffic to be forwarded, and the current traffic to be forwarded has a first mark; the first mark indicates that the remaining guaranteed token number of the previous node of the node meets the requirements for forwarding the current traffic to be forwarded; wherein, the target node assumes that the current traffic to be forwarded has the first mark.
[0130] In a feasible implementation of an embodiment of the present application, the forwarding condition of the highest-level node includes: within the node, the current number of remaining guaranteed tokens does not meet the requirements for forwarding the current traffic to be forwarded, and the current number of remaining restricted tokens meets the requirements for forwarding the current traffic to be forwarded.
[0131] In a feasible implementation of the embodiment of the present application, within the same cycle: the total number of guaranteed tokens of the upper node is greater than or equal to the sum of the total number of guaranteed tokens of all subordinate nodes of the upper node; the total number of restricted tokens of the upper node is greater than or equal to the total number of restricted tokens of any subordinate node of the upper node.
[0132] In an embodiment of the present application, the processing module 402 is also used to randomly discard the received traffic to be forwarded corresponding to any node after monitoring that the number of restricted tokens currently used by any node in this cycle is greater than a preset packet loss threshold; wherein the packet loss threshold is greater than the total number of guaranteed tokens of the node and less than the limit value of the node.
[0133] It should be understood that, for the sake of brevity, some of the contents described in the first embodiment will not be repeated in this embodiment.
[0134] Embodiment 4:
[0135] This embodiment provides a network egress device. Figure 5 As shown, it includes a processor 501, a memory 502, an internal communication bus 503 and an external communication module 504. Among them:
[0136] The internal communication bus 503 is used to realize the connection and communication between the processor 501 , the memory 502 and the external communication module 504 .
[0137] The external communication module 504 is used to receive and forward traffic.
[0138] The processor 501 is used to execute one or more programs stored in the memory 502 to implement the flow control method in the above-mentioned embodiment 1 and / or embodiment 2.
[0139] Understandably, Figure 5 The structure shown is for illustration only. The network egress device may also include Figure 5 More or fewer components as shown, or with Figure 5 Different configurations shown.
[0140] This embodiment also provides a computer-readable storage medium, such as a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash disk, an SD (Secure Digital Memory Card) card, an MMC (Multimedia Card) card, etc., in which one or more programs for implementing the above steps are stored, and the one or more programs can be executed by one or more processors to implement the flow control method in the above embodiment 1 and / or embodiment 2. No further details are given here.
[0141] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0142] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0143] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0144] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0145] As used herein, a plurality refers to two or more than two.
[0146] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A flow control method, characterized in that: Applied to network egress devices, including: Determine a target node corresponding to the current traffic to be forwarded; the target node is a node mapped in the network egress device by a device sending the current traffic to be forwarded; Determine whether the current traffic to be forwarded meets preset forwarding conditions in the target node and each upper node of the target node; If the current traffic to be forwarded satisfies the preset forwarding conditions in the target node and each upper node of the target node, the current traffic to be forwarded is forwarded; otherwise, the current traffic to be forwarded is discarded; wherein: The forwarding conditions of the target node and each upper-level node except the highest-level node include: within the node, the current remaining guaranteed token number does not meet the demand for forwarding the current traffic to be forwarded, the current remaining restricted token number meets the demand for forwarding the current traffic to be forwarded, and the number of restricted tokens currently used by the node in this cycle is less than the limit value corresponding to the node; wherein the limit value corresponding to the node is greater than or equal to the total number of guaranteed tokens of the node, and less than or equal to the total number of restricted tokens of the node; Among them: the number of guaranteed tokens in each node is set according to the guaranteed bandwidth corresponding to the node, which is used to ensure the minimum bandwidth that can be used by the node. The number of limited tokens in each node is set according to the limited bandwidth corresponding to the node, which is used to limit the maximum bandwidth that the node can use.
2. The flow control method according to claim 1, characterized in that: The method further comprises: If the node's parent node has used up all the limit tokens in the previous cycle, the node's limit value will be reduced; If the node's parent node has not used up all the limit tokens in the previous cycle, the node's limit value will be increased.
3. The flow control method according to claim 1, characterized in that: After determining the target node corresponding to the current traffic to be forwarded, the method further includes: Determining the traffic priority of the current traffic to be forwarded; Determine a priority coefficient based on the traffic priority; the higher the traffic priority, the smaller the priority coefficient, and the priority coefficient is greater than 0 and less than 1; The set standard limit value is multiplied by the priority coefficient to obtain the limit value of the target node.
4. The flow control method according to claim 1, characterized in that: The forwarding conditions of the target node and each upper-level node except the highest-level node also include: Within the node, the current remaining guaranteed token quantity meets the requirement for forwarding the current traffic to be forwarded, and the current traffic to be forwarded has a first tag; the first tag indicates that the remaining guaranteed token quantity at the previous node of the node meets the requirement for forwarding the current traffic to be forwarded; wherein, the target node assumes that the current traffic to be forwarded has the first tag.
5. The flow control method according to claim 1, characterized in that: The forwarding conditions of the highest-level node include: In the node, the current remaining guaranteed token quantity does not meet the requirement of forwarding the current traffic to be forwarded, and the current remaining restricted token quantity meets the requirement of forwarding the current traffic to be forwarded.
6. The flow control method according to claim 1, characterized in that: In the same cycle: The total number of guaranteed tokens of the upper node is greater than or equal to the sum of the total number of guaranteed tokens of all subordinate nodes of the upper node; The total number of restriction tokens of the upper node is greater than or equal to the total number of restriction tokens of any lower node of the upper node.
7. The flow control method according to any one of claims 1 to 6, characterized in that: The method further comprises: After monitoring that the number of restricted tokens currently used by any node in this cycle is greater than the preset packet loss threshold, the to-be-forwarded traffic corresponding to the received node is randomly discarded; The packet loss threshold is greater than the total number of guaranteed tokens of the node and less than the limit value of the node.
8. A flow control device, characterized in that: It is arranged on the network egress device and includes: a determination module and a processing module; The determination module is used to determine the target node corresponding to the current traffic to be forwarded; the target node is the node mapped in the network egress device by the device sending the current traffic to be forwarded; The processing module is used to determine whether the current traffic to be forwarded meets the preset forwarding conditions in the target node and each upper node of the target node; if the current traffic to be forwarded meets the preset forwarding conditions in the target node and each upper node of the target node, forward the current traffic to be forwarded; otherwise, discard the current traffic to be forwarded; wherein: The forwarding conditions of the target node and each upper-level node except the highest-level node include: within the node, the current remaining guaranteed token number does not meet the demand for forwarding the current traffic to be forwarded, the current remaining restricted token number meets the demand for forwarding the current traffic to be forwarded, and the number of restricted tokens currently used by the node in this cycle is less than the limit value corresponding to the node; wherein the limit value corresponding to the node is greater than or equal to the total number of guaranteed tokens of the node, and less than or equal to the total number of restricted tokens of the node; Among them: the number of guaranteed tokens in each node is set according to the guaranteed bandwidth corresponding to the node, which is used to ensure the minimum bandwidth that can be used by the node. The number of limited tokens in each node is set according to the limited bandwidth corresponding to the node, which is used to limit the maximum bandwidth that the node can use.
9. A network egress device, characterized in that: include: Processor, memory, internal communication bus, and external communication module; The internal communication bus is used to realize the connection and communication between the processor, the memory and the external communication module; The external communication module is used to receive and forward traffic; The processor is used to execute the program stored in the memory to implement the flow control method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the flow control method according to any one of claims 1 to 7.
