Flow rate limiting method and device

By using the parallel execution of multiple token filling rules in the token bucket algorithm, the problem of precise traffic control in non-integer alignment scenarios is solved, ensuring the system service quality and traffic control accuracy.

CN120499115APending Publication Date: 2025-08-15T HEAD (CHENGDU) SEMICONDUCTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510450204.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-10
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing token bucket algorithm is difficult to achieve precise traffic control in non-integer alignment scenarios, while ensuring the service quality of the system, resulting in system performance degradation or loss of traffic control accuracy.

Method used

A variety of token fill rules are executed in parallel, including a first token fill rule and at least one second token fill rule, respectively, indicating to fill or reverse fill tokens at every base time interval and compensation time interval to update the target token bucket.

Benefits of technology

It realizes precise flow control in non-integer alignment scenarios, ensures the service quality of the system, and avoids system performance degradation and loss of flow control accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120499115A_ABST
    Figure CN120499115A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a flow rate limiting method and device. According to the embodiment of the invention, after a flow rate limiting instruction is received, a target token bucket of a target node is initialized according to the flow rate limiting instruction, a first token filling rule is obtained, and at least one second token filling rule corresponding to the target token bucket is determined; and updating the target token bucket according to the first token filling rule and the second token filling rule, and performing data packet transceiving control on the target node according to the target token bucket. Wherein the first token filling rule is used for indicating that tokens of a reference number are filled every reference time interval, and the second token filling rule is used for indicating that tokens of a compensation number are filled or reversely filled every compensation time interval. Therefore, the token buckets are updated by adopting a mode of executing multiple token filling rules in parallel, and the embodiment of the invention can realize accurate flow control in a non-integer alignment scene and guarantee the service quality of a system at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of flow control, and in particular to a flow rate limiting method and device. Background Art

[0002] Currently, the token bucket algorithm is commonly used to implement traffic speed limits on network nodes. To ensure that the actual data transmission rate of network nodes after speed limit is relatively smooth, the token bucket algorithm usually needs to subdivide the speed limit configuration value to obtain a fine-grained token filling period and the number of tokens filled per time. However, the current token bucket algorithm only performs well in integer alignment scenarios. Once faced with non-integer alignment scenarios, existing token bucket algorithms either set coarse-grained token filling periods and the number of tokens filled per time, or approximate the speed limit configuration value. Setting a coarse-grained token filling period and the number of tokens filled per time will lead to a decrease in the system's service quality, while approximating the speed limit configuration value will result in a loss of flow control accuracy. This makes it difficult for the current token bucket algorithm to achieve precise flow control in non-integer alignment scenarios while ensuring the system's service quality. Summary of the Invention

[0003] In view of this, embodiments of the present invention provide a method and apparatus for limiting traffic speed, so as to achieve precise control of traffic in non-integer alignment scenarios while ensuring the service quality of the system.

[0004] In a first aspect, an embodiment of the present invention provides a method for limiting flow rate, the method comprising:

[0005] Receive traffic rate limit instructions;

[0006] Initialize the target token bucket of the target node according to the traffic rate limit instruction;

[0007] Obtain a first token filling rule, where the first token filling rule is used to indicate filling a reference number of tokens at each reference time interval;

[0008] Determine at least one second token filling rule corresponding to the target token bucket, wherein the second token filling rule is used to indicate filling or reverse filling of a compensation amount of tokens at each compensation time interval;

[0009] Update the target token bucket according to the first token filling rule and the second token filling rule;

[0010] The target node is controlled to send and receive data packets according to the target token bucket.

[0011] In a second aspect, an embodiment of the present invention is to provide a flow rate limiting device, the device comprising:

[0012] An instruction receiving unit, used for receiving a flow rate limit instruction;

[0013] A token bucket initialization unit, configured to initialize a target token bucket of a target node according to the traffic rate limit instruction;

[0014] A first rule acquiring unit, configured to acquire a first token filling rule, wherein the first token filling rule is configured to indicate that a reference number of tokens are filled every reference time interval;

[0015] A second rule acquisition unit is used to determine at least one second token filling rule corresponding to the target token bucket, wherein the second token filling rule is used to indicate filling or reverse filling of a compensation amount of tokens at each compensation time interval;

[0016] a token bucket updating unit, configured to update the target token bucket according to the first token filling rule and the second token filling rule;

[0017] A control unit is used to control the sending and receiving of data packets to the target node according to the target token bucket.

[0018] In a third aspect, an embodiment of the present invention aims to provide a computer-readable storage medium storing computer program instructions, which implement the method described in the first aspect when executed by a processor.

[0019] In a fourth aspect, an embodiment of the present invention is directed to providing an electronic device, comprising:

[0020] a memory for storing one or more computer program instructions;

[0021] A processor, wherein the one or more computer program instructions are executed by the processor to implement the method as described in the first aspect.

[0022] In a fifth aspect, an embodiment of the present invention aims to provide a computer program product, which, when executed on a computer, enables the computer to execute the method as described in the first aspect.

[0023] After receiving a traffic rate limit instruction, an embodiment of the present invention will initialize the target token bucket of the target node according to the traffic rate limit instruction, obtain a first token filling rule, and determine at least one second token filling rule corresponding to the target token bucket, and then update the target token bucket according to the first token filling rule and the second token filling rule, and then control the sending and receiving of data packets of the target node according to the target token bucket. The first token filling rule is used to indicate that a reference number of tokens are filled at each reference time interval, and the second token filling rule is used to indicate that a compensation number of tokens are filled or reversely filled at each compensation time interval. Therefore, by updating the token bucket by executing multiple token filling rules in parallel, the embodiment of the present invention can achieve precise traffic control in non-integer alignment scenarios while ensuring the service quality of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0025] Figure 1 Flowchart of a flow rate limiting method according to an embodiment of the present invention;

[0026] Figure 2 Flowchart of a token bucket initialization method according to an embodiment of the present invention;

[0027] Figure 3 Flowchart of a token bucket updating method according to an embodiment of the present invention;

[0028] Figure 4 Flowchart of a data packet sending and receiving control method according to an embodiment of the present invention;

[0029] Figure 5 A schematic diagram of a token distribution process according to an embodiment of the present invention;

[0030] Figure 6 A schematic diagram of another token distribution process according to an embodiment of the present invention;

[0031] Figure 7 Schematic diagram of a flow rate limiting device according to an embodiment of the present invention;

[0032] Figure 8 FIG. 4 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0033] The present application is described below based on the following embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, certain specific details are described in detail. Those skilled in the art can fully understand the present application without the description of these details. To avoid obscuring the essence of the present application, well-known methods, processes, procedures, components, and circuits are not described in detail.

[0034] Furthermore, persons of ordinary skill in the art will appreciate that the figures provided herein are for illustration purposes only and are not necessarily drawn to scale.

[0035] Unless the context clearly requires otherwise, words like “include”, “comprising” and the like throughout this application should be interpreted as including rather than exclusive or exhaustive; that is, as meaning “including but not limited to”.

[0036] In the description of this application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.

[0037] Where the solutions described in this specification and in the examples involve the processing of personal information, such processing will be conducted with a legitimate basis (e.g., with the consent of the personal information subject or as necessary for the performance of a contract) and only within the prescribed or agreed scope. A user's refusal to process personal information other than that required for basic functions will not affect the user's use of these basic functions.

[0038] Currently, the token bucket algorithm is commonly used to implement traffic rate limiting on network nodes. Specifically, the token bucket algorithm uses tokens as the resource required to pass data packets, creates a virtual token bucket to store tokens, and periodically adds tokens to the bucket with a fixed token refill period and a fixed number of tokens to be filled at a time. Consequently, whenever a data packet arrives, the token bucket algorithm determines whether to allow the packet to pass based on whether the number of tokens currently stored in the token bucket is sufficient to meet the consumption, thereby achieving traffic rate limiting. To ensure a relatively smooth actual data transmission rate at the network node after rate limiting (i.e., to ensure that data packets are processed more evenly throughout the entire time period, reducing instantaneous peak loads), the token bucket algorithm typically requires subdividing the rate limit configuration value to achieve a fine-grained token refill period and number of tokens to be filled at a time. However, current token bucket algorithms only perform well when the packets are aligned with integers. When faced with non-integer alignment, existing token bucket algorithms either set a coarse-grained token refill period and number of tokens to be filled at a time, or approximate the rate limit configuration value. For example, when the rate limit is configured at 1 Mpps, the current token bucket algorithm can set the token fill period and the number of tokens filled per time to 1 μs and 1 token. However, when the rate limit is configured at 1.03 Mpps, the current token bucket algorithm either sets the token fill period and the number of tokens filled per time to 100 μs and 103 tokens, or approximates 1.03 Mpps to 1.02 Mpps or 1 Mpps. Setting coarse-grained token fill periods and the number of tokens filled per time can degrade system quality of service (for example, once tokens in the target token bucket are exhausted, it takes a long time for them to be replenished, resulting in packets not being processed promptly. For example, tokens in the target token bucket are often consumed by lower-priority packets that arrive first, preventing higher-priority packets from receiving the appropriate priority). Approximating the rate limit also results in a loss of flow control precision, making it difficult for the current token bucket algorithm to achieve precise flow control in non-integer alignment scenarios while maintaining system quality of service.

[0039] Based on this, an embodiment of the present invention provides a flow rate limiting method and apparatus to achieve precise flow control in non-integer alignment scenarios while ensuring the service quality of the system.

[0040] It is to be noted that, in an embodiment of the present invention, subdividing the speed limit configuration value may specifically refer to subdividing the speed limit configuration value (that is, the upper limit of the data transmission rate set by the user. It should be understood that the data transmission rate may refer to the amount of data transmitted within a corresponding time. Schematically, a data transmission rate of 100Mpps may be used to represent the transmission of 100 million standard unit data packets in 1 second) according to a token filling period of a first predetermined value (for example, 1ns, 2ns and / or 5ns, etc., which may be set according to actual needs), and obtaining the corresponding single token filling number, or refers to subdividing the set data transmission rate limit value according to a single token filling number of a second predetermined value (for example, 1 token, 2 tokens and / or 5 tokens, etc., which may be set according to actual needs. It should be understood that, in this embodiment of the invention, 1 token may be consumed to pass 1 standard unit data packet) and obtaining the corresponding token filling period. Relatively speaking, in an embodiment of the present invention, the integer alignment scenario may specifically refer to a scenario in which at least one set of token filling periods and single token filling quantities that are all integers can be obtained after subdivision, and the non-integer alignment scenario may specifically refer to a scenario in which a set of token filling periods and single token filling quantities that are all integers cannot be obtained after subdivision.

[0041] It is hoped that the traffic speed limiting method in the embodiment of the present invention can be applied to any scenario where there is a data transmission process and traffic speed limiting is required, such as enterprise internal networks, data centers, Internet service providers, content distribution networks, instant communications, online game service provision, cloud computing and virtualization environments, Internet of Things interactions, video streaming transmission and testing and development environments, etc. This application does not limit the application scenarios of the traffic speed limiting method.

[0042] Furthermore, in an embodiment of the present invention, the traffic speed limit object can be a single network node or a system composed of multiple network nodes. Specifically, when the traffic speed limit object is a single network node, the traffic speed limit method in an embodiment of the present invention can be used to limit and optimize the input traffic or output traffic of the single network node. When the traffic speed limit object is a system composed of multiple network nodes, the traffic speed limit method in an embodiment of the present invention can be used to limit and optimize the input traffic or output traffic of each network node in the system.

[0043] It should be understood that in the following description, for the convenience of explanation, a system in which the traffic rate limit object is composed of multiple network nodes will be mainly described in detail as an example.

[0044] It is to be noted that, in the embodiments of the present invention, a network node may refer to any physical device or application that can send, receive, or forward data. Network nodes can be further divided into physical nodes or logical nodes. Among them, a physical node may refer to a hardware device that actually exists and has a clear physical address in the network. Physical nodes may specifically include network-related devices (e.g., routers, firewalls, or switches) used to implement network communications and terminal devices (e.g., personal computers, servers, smartphones, smart wearable devices, tablets, IoT devices, or vehicle-mounted terminals) that participate in communications. A logical node may refer to a service or application logic that does not directly correspond to a specific physical device but is defined at the software level. A logical node can be run on a corresponding hardware device. A logical node may specifically include a virtual machine, a cloud service instance, or a microservice architecture container.

[0045] Figure 1 This is a flow chart of the flow rate limiting method according to an embodiment of the present invention. It is to be noted that the relevant steps in the flow rate limiting method can be executed by a specially designed flow rate limiting device (e.g., a flow shaper) and / or a flow rate limiting program. The flow rate limiting device can be implemented by a pure hardware structure or by a combination of software and hardware, and this application does not impose any restrictions on this. It should be understood that in order to be able to execute the flow rate limiting method according to an embodiment of the present invention, the flow rate limiting device can be set at the communication interface of the corresponding physical node. The flow rate limiting program can be deployed and run on the corresponding physical node, or deployed and run on the corresponding hardware device running the logical node. As Figure 1 As shown, the flow rate limiting method may specifically include the following steps:

[0046] Step S100: Receive a flow rate limit instruction.

[0047] Specifically, this embodiment may receive a traffic rate limiting instruction, wherein the traffic rate limiting instruction may be used to instruct to enable traffic rate limiting for a corresponding target node.

[0048] Optionally, as a triggering method for the flow rate limit instruction, each network node may have a corresponding flow rate limit activation condition, and the flow rate limit instruction may be automatically triggered after the flow rate limit activation condition is met. It should be understood that in this implementation method, the target node may specifically refer to the network node whose corresponding flow rate limit activation condition is met. Among them, the flow rate limit activation condition may be pre-set by relevant personnel. Schematically, the flow rate limit activation condition may specifically include judgment conditions such as whether the flow used by the current node reaches the flow threshold, whether there is a high-priority node currently using the flow and / or whether the current network environment is congested. The present application does not limit the content of the flow rate limit activation condition itself. Alternatively, as another triggering method for the flow rate limit instruction, the flow rate limit instruction may also be triggered based on user operation. It should be understood that in this implementation method, the target node may be a network node selected by the user. The present application does not limit the flow rate limit instruction method.

[0049] Optionally, the target node may be a physical node or a logical node, which is not limited in this application.

[0050] Step S200: Initialize the target token bucket of the target node according to the traffic rate limit instruction.

[0051] Specifically, after receiving the traffic rate limiting instruction, this embodiment may initialize the target token bucket of the target node according to the traffic rate limiting instruction.

[0052] Optionally, in this embodiment, initializing the target token bucket of the target node may specifically refer to setting relevant initial attributes of the target token bucket.

[0053] Figure 2 Flowchart of the token bucket initialization method of the embodiment of the present invention. It should be understood that by executing Figure 2 The token bucket initialization method shown in FIG. 1 can set the initial attributes of the target token bucket in this embodiment, thereby initializing the target token bucket, that is, implementing the above step S200. Figure 2 As shown, the token bucket initialization method may specifically include the following steps:

[0054] Step S210: Setting the maximum token capacity of the target token bucket according to the bucket capacity configuration value.

[0055] Specifically, the traffic rate limit instruction may include a bucket capacity configuration value. The bucket capacity configuration value may be used to represent a requirement for setting the maximum token capacity of the token bucket. In this embodiment, the maximum token capacity of the target token bucket may be set according to the bucket capacity configuration value in the traffic rate limit instruction.

[0056] Step S220: Setting the initial token quantity of the target token bucket according to the initial token configuration value.

[0057] Specifically, in addition to the bucket capacity configuration value, the traffic rate limit instruction may also include an initial token configuration value. The initial token configuration value may be used to indicate the requirement for setting the initial token quantity of the target token bucket. In this embodiment, the initial token quantity of the target token bucket may be set based on the initial token configuration value in the traffic rate limit instruction.

[0058] Step S300: Obtain a first token filling rule.

[0059] Specifically, after initializing the target token bucket of the target node, this embodiment can obtain a first token filling rule. The first token filling rule can be used to indicate that a reference number of tokens should be filled at a reference time interval. It should be noted that, compared to the prior art method of updating a token bucket using a single token filling rule, this embodiment updates the token bucket by executing multiple token filling rules in parallel. Here, the first token filling rule can be specifically understood as a pre-set basic token filling rule.

[0060] Optionally, as a method for setting a first token filling rule, to ensure full utilization of system processing performance, this embodiment may set the first token filling rule based on the upper limit of the data transmission rate that the system can handle. When setting the first token filling rule based on the upper limit of the data transmission rate that the system can handle, this embodiment may subdivide the upper limit of the data transmission rate in the same manner as subdividing the rate limit configuration value, thereby obtaining the first token filling rule. Specifically, assuming the upper limit of the data transmission rate that the system can handle is 100 Mpps, this embodiment may subdivide the set upper limit of the data transmission rate by the number of single token fills being a second predetermined value (here, the second predetermined value is 1 data packet), thereby obtaining a first token filling rule indicating that one token is filled every 10 ns. It should be understood that the specific values given above are for illustrative purposes only. In actual applications, the specific value of the second predetermined value may be set according to actual needs. Alternatively, this embodiment may also determine the first token filling rule by subdividing the set upper limit of the data transmission rate by the fill period being the first predetermined value.

[0061] Further optionally, when the data transmission rate upper limit cannot be subdivided to obtain a set of token filling periods and single token filling quantities that are all integers, this embodiment may first adjust the data transmission rate upper limit accordingly (i.e., adjust it to the closest data transmission rate value that can obtain at least one set of token filling periods and single token filling quantities that are all integers through subdivision), and then set the first token filling rule based on the adjusted value. For example, assuming that the data transmission rate upper limit that the system can handle is 103 Mpps, then this embodiment first adjusts 103 Mpps to 100 Mpps, and then sets the first token filling rule based on 100 Mpps.

[0062] It is to be noted that, since this embodiment uses a plurality of token filling rules to update the token bucket in parallel, the adaptive adjustment made by this embodiment when determining the first token filling rule will not cause the actual data transmission rate of the target node after current limiting to fail to meet the speed limit configuration value.

[0063] Optionally, as another method for setting the first token filling rule, this embodiment may also determine the average rate limit configuration value for each node and set the first token filling rule based on the average rate limit configuration value for each node in the system. When setting the first token filling rule based on the average rate limit configuration value, this embodiment may also subdivide the average rate limit configuration value in the same manner as subdividing the rate limit configuration value, thereby obtaining the first token filling rule. Specifically, assuming the average rate limit configuration value is 1 Mpps, this embodiment may subdivide the set average rate limit configuration value by a second predetermined value (here, the second predetermined value is 1 data packet) for a single token filling, thereby obtaining a first token filling rule indicating that 1 token is filled every 1 μs. It should be understood that the specific values given above are for illustrative purposes only. In actual applications, the specific values of the second predetermined value may be set according to actual needs. Alternatively, this embodiment may also determine the first token filling rule by subdividing the set data transmission rate limit value by a first predetermined value for a filling period.

[0064] Further, optionally, when the average speed limit configuration value cannot be subdivided to obtain a set of token fill periods and single token fill quantities that are all integers, this embodiment can also first adjust the average speed limit configuration value accordingly (i.e., adjust it to the closest data transmission rate value that can obtain at least one set of token fill periods and single token fill quantities that are all integers through subdivision), and then set the first token fill rule based on the adjusted value. For example, assuming the average speed limit configuration value is 1.03 Mpps, then this embodiment first adjusts 1.03 Mpps to 1 Mpps, and then sets the first token fill rule based on 1 Mpps.

[0065] Optionally, the first token filling rule determined in this embodiment can be a global token filling rule, that is, the first token filling rule can be simultaneously oriented to multiple network nodes in the system. For multiple network nodes in a unified system, this embodiment can obtain the same first token filling rule when controlling the sending and receiving of data packets for the multiple network nodes. Alternatively, the first token filling rule can also be set separately for each network node, and this application does not limit this. It should be understood that when the first token filling rule is a global token filling rule, the second token filling rule can be a local token filling rule determined separately for each network node.

[0066] Step S400: Determine at least one second token filling rule corresponding to the target token bucket.

[0067] Specifically, after obtaining the first token filling rule, this embodiment can determine at least one second token filling rule corresponding to the target token bucket. The second token filling rule can be used to indicate whether to fill or reverse fill a compensation number of tokens at each compensation time interval. It should be understood that in this embodiment, the at least one second token filling rule can be executed in parallel with the first token filling rule to ensure that the actual data transmission rate of the target node after flow limiting can meet the user's flow rate limit requirements for the target node.

[0068] Optionally, the traffic rate limit instruction may include a rate limit configuration value. The rate limit configuration value may be used to characterize the traffic rate limit requirement for the node. In step S400, this embodiment may determine at least one second token filling rule corresponding to the target token bucket based on the first token filling rule and the rate limit configuration value.

[0069] Further, optionally, as an implementation, when determining at least one second token filling rule corresponding to the target token bucket based on the first token filling rule and the rate limit configuration value, this embodiment may first determine a data transmission rate difference based on the first token filling rule and the rate limit configuration value (the data transmission rate difference can be considered as the data transmission rate value required to ensure that the actual data transmission rate of the target node after current limiting meets the rate limit configuration value). Furthermore, this embodiment may further refine the data transmission rate difference to determine at least one second token filling rule. It should be understood that the data transmission rate difference here can be either negative or positive. Specifically, taking the determination of a second token filling rule as an example, assuming that the current first token filling rule indicates that one token is filled every 10 ns and the rate limit configuration value is 1.03 Mpps, this embodiment may first determine that the data transmission rate difference is -99.97 Mpps. Furthermore, this embodiment may further refine the data transmission rate difference to obtain a second token filling rule that indicates that 9897 tokens are reversely filled every 100 μs. Assuming that the current first token filling rule indicates that one token is filled every 1 μs and the rate limit configuration value is 1.03 Mpps, this embodiment can first determine that the data transmission rate difference is 0.03 Mpps. Furthermore, this embodiment can further subdivide the data transmission rate difference to obtain a second token filling rule indicating that three tokens are filled every 100 μs.

[0070] It should be understood that in actual application, the number of second token filling rules determined can be set according to system requirements. Schematically, for a scenario in which the current first token filling rule is used to indicate that 1 token is filled every 10ns and the speed limit configuration value is 1.03Mpps, this embodiment can also determine four second token filling rules. In this case, the four second token filling rules can be used to indicate reverse filling of 9 tokens every 100ns, reverse filling of 9 tokens every 1μs, reverse filling of 9 tokens every 10μs, and reverse filling of 7 tokens every 100μs.

[0071] It should be understood that the specific settings of the second token filling rule given above are only for illustration. In actual application, on the basis of enabling the actual data transmission rate of the target node after flow limiting to meet the user's flow rate limit requirements for the target node, the specific settings of the second token filling rule can be determined by the device or program itself, or can be determined based on user instructions. No more examples will be given here.

[0072] Step S500: Update the target token bucket according to the first token filling rule and the second token filling rule.

[0073] Specifically, after obtaining a first token filling rule and determining at least one second token filling rule, this embodiment can begin updating the target token bucket according to the first token filling rule and the second token filling rule. It should be understood that during the process of updating the target token bucket according to the first token filling rule and the second token filling rule, the first token filling rule and each second token filling rule can be executed in parallel. That is, the execution of the first token filling rule and the second token filling rule do not interfere with each other.

[0074] Figure 3 Flowchart of the token bucket update method according to an embodiment of the present invention. Figure 3 As shown, the token bucket updating method may specifically include the following steps:

[0075] Step S510: Fill a reference number of tokens into the target token bucket at reference time intervals according to the first token filling rule.

[0076] Specifically, this embodiment can fill a reference number of tokens into the target token bucket at every reference time interval according to the first token filling rule.

[0077] Step S520: For each of the second token filling rules, fill or reverse fill the target token bucket with a compensation number of tokens at every compensation time interval according to the second token filling rule.

[0078] Specifically, while updating the target token bucket according to the first token filling rule, this embodiment can, for each second token filling rule, fill or reverse fill the target token bucket with a compensation number of tokens at each compensation interval according to the second token filling rule. It should be understood that reverse filling can specifically refer to deducting tokens from the target token bucket. It should be understood that this embodiment can implement the operation of updating the target token bucket according to multiple token filling rules by creating multiple timers that do not interfere with each other.

[0079] Optionally, in order to avoid generating excessive burst traffic and affecting the stability of the system, when filling tokens into the target token bucket according to the first token filling rule and the second token filling rule, if it is detected that the number of tokens in the target token bucket after filling is greater than the maximum token capacity of the target token bucket, this embodiment can also reset the number of tokens in the target token bucket to the maximum token capacity.

[0080] Optionally, in this embodiment, the number of tokens in the target token bucket can be deducted to a negative value by the second token filling rule. Specifically, to ensure that the data transmission rate of the target node after flow limiting can meet the user's flow rate limit requirements for the target node, when reverse filling tokens into the target token bucket according to the second token filling rule, if it is detected that the number of tokens in the target token bucket after reverse filling is less than zero, this embodiment can also record the number of tokens in the target token bucket as a corresponding negative value. For example, assuming the current number of tokens in the target token bucket is 1 and 9987 tokens need to be reverse filled, the number of tokens in the target token bucket after reverse filling can be recorded as -9986. It is to be noted that when the number of tokens in the target token bucket is a negative value, all subsequent tokens filled into the target token bucket will be used to offset the number of tokens in the target token bucket until the number of tokens in the target token bucket returns to zero or a positive value. For example, assuming the current number of tokens in the target token bucket is -9986 and 10 tokens need to be filled, the number of tokens in the target token bucket after filling can be recorded as -9976. Furthermore, when the number of tokens in the target token bucket is negative, the tokens subsequently backfilled into the target token bucket will continue to accumulate based on the negative value. For example, if the current number of tokens in the target token bucket is -1 and 9987 tokens need to be backfilled, the number of tokens in the target token bucket after backfilling can be recorded as -9988.

[0081] Step S600: Control the sending and receiving of data packets to the target node according to the target token bucket.

[0082] Specifically, after starting to update the target token bucket, this embodiment can control the sending and receiving of data packets for the target node according to the target token bucket.

[0083] Figure 4 FIG. 1 is a flow chart of a method for controlling the sending and receiving of data packets according to an embodiment of the present invention. Figure 4 The data packet receiving and sending control method described above can control the data packet receiving and sending of the target node according to the target token bucket, that is, implement the above step S600. Figure 4 As shown, the data packet sending and receiving control method may specifically include the following steps:

[0084] Step S610: Receive a data packet.

[0085] Specifically, this embodiment can receive a data packet. Optionally, when this embodiment is used to control the input traffic of a target node, the data packet here can specifically refer to a data packet to be received by the target node. When this embodiment is used to control the output traffic of a target node, the data packet here can specifically refer to a data packet to be sent by the target node.

[0086] Step S620: Determine the number of tokens to be consumed by the data packet and the number of usable tokens in the target token bucket.

[0087] Specifically, after receiving a data packet, this embodiment can determine the number of tokens to be consumed for the data packet and the number of available tokens in the target token bucket. The number of tokens consumed for passing data packets of different sizes varies. The number of tokens to be consumed can specifically be the number of tokens required to pass the current data packet. It should be noted that when determining the number of available tokens, if the number of tokens in the target token bucket is a negative value, this embodiment can directly determine the number of available tokens to be zero.

[0088] Step S630: Allow the data packet to pass or intercept the data packet according to the number of tokens to be consumed and the number of usable tokens.

[0089] Specifically, after determining the number of tokens to be consumed by a data packet and the number of available tokens in the target token bucket, this embodiment can allow the data packet to pass or intercept the data packet based on the number of tokens to be consumed and the number of available tokens. Optionally, intercepting the data packet can mean discarding the data packet or simulating network delay to temporarily hold the data packet, which is not limited in this application.

[0090] Optionally, when allowing or intercepting a data packet based on the number of tokens to be consumed and the number of available tokens, this embodiment may first detect whether the number of tokens to be consumed is less than or equal to the number of available tokens. Furthermore, if the detection result indicates that the number of tokens to be consumed is less than or equal to the number of available tokens, this embodiment allows the data packet to pass and deducts tokens equal to the number of tokens to be consumed from the target token bucket. If the detection result indicates that the number of tokens to be consumed is greater than the number of available tokens, this embodiment may intercept the data packet.

[0091] After receiving a traffic rate limit instruction, an embodiment of the present invention will initialize the target token bucket of the target node according to the traffic rate limit instruction, obtain a first token filling rule, and determine at least one second token filling rule corresponding to the target token bucket, and then update the target token bucket according to the first token filling rule and the second token filling rule, and then control the sending and receiving of data packets of the target node according to the target token bucket. The first token filling rule is used to indicate that a reference number of tokens are filled at each reference time interval, and the second token filling rule is used to indicate that a compensation number of tokens are filled or reversely filled at each compensation time interval. Therefore, by updating the token bucket by executing multiple token filling rules in parallel, the embodiment of the present invention can achieve precise traffic control in non-integer alignment scenarios while ensuring the service quality of the system.

[0092] Figure 5FIG1 is a schematic diagram of a token distribution process according to an embodiment of the present invention. It should be understood that Figure 5 The token distribution process in the example can correspond to a rate limit configuration value of 1.3Mpps, wherein the first token filling rule is used to indicate that 1 token is filled every 1μs, and the second token filling rule is used to indicate that 3 tokens are filled every 10μs, which is a traffic rate limit scenario. Figure 5 As described above, each small grid in the time progress bar 51 can be used to represent 1 μs. Under the instruction of the first token filling rule, this embodiment can fill 1 token into the token bucket every 1 μs. Under the instruction of the second token filling rule, this embodiment can fill 3 tokens into the token bucket every 10 μs. Therefore, by executing the first token filling rule and the second token filling rule in parallel, the embodiment of the present invention can achieve precise traffic control while ensuring the global traffic speed limit value meets the speed limit configuration value of 1.3 Mpps, while ensuring the service quality of the system.

[0093] Figure 6 FIG. 1 is a schematic diagram of another token distribution process according to an embodiment of the present invention. It should be understood that Figure 6 The token distribution process in the example can correspond to a rate limit configuration value of 0.85Mpps. The first token filling rule is used to indicate that 1 token is filled every 1μs, and the second token filling rule is used to indicate that 3 tokens are filled in reverse every 20μs. This is a traffic rate limit scenario. Figure 6 As described above, each small grid in the time progress bar 61 can be used to represent 1μs. Under the instruction of the first token filling rule, this embodiment can fill 1 token into the token bucket every 1μs. Under the instruction of the second token filling rule, this embodiment can reversely fill 3 tokens into the token bucket every 20μs. Therefore, by executing the first token filling rule and the second token filling rule in parallel, the embodiment of the present invention can achieve precise traffic control while ensuring that the global traffic speed limit value meets the speed limit configuration value of 0.85Mpps, while ensuring the service quality of the system.

[0094] Figure 7 Schematic diagram of a flow rate limiting device according to an embodiment of the present invention. Figure 7 As shown, the flow rate limiting device of the embodiment of the present invention includes an instruction receiving unit 71, a token bucket initialization unit 72, a first rule acquisition unit 73, a second rule acquisition unit 74, a token bucket update unit 77 and a control unit 77.

[0095] Specifically, the instruction receiving unit 71 is used to receive a flow rate limit instruction;

[0096] The token bucket initialization unit 72 is used to initialize the target token bucket of the target node according to the traffic rate limit instruction;

[0097] The first rule acquisition unit 73 is used to acquire a first token filling rule, where the first token filling rule is used to indicate that a reference number of tokens are filled every reference time interval;

[0098] The second rule acquisition unit 74 is used to determine at least one second token filling rule corresponding to the target token bucket, the second token filling rule being used to indicate filling or reverse filling of a compensation number of tokens at each compensation time interval;

[0099] The token bucket updating unit 77 is configured to update the target token bucket according to the first token filling rule and the second token filling rule;

[0100] The control unit 77 is configured to control the sending and receiving of data packets to the target node according to the target token bucket.

[0101] After receiving a traffic rate limit instruction, an embodiment of the present invention will initialize the target token bucket of the target node according to the traffic rate limit instruction, obtain a first token filling rule, and determine at least one second token filling rule corresponding to the target token bucket, and then update the target token bucket according to the first token filling rule and the second token filling rule, and then control the sending and receiving of data packets of the target node according to the target token bucket. The first token filling rule is used to indicate that a reference number of tokens are filled at each reference time interval, and the second token filling rule is used to indicate that a compensation number of tokens are filled or reversely filled at each compensation time interval. Therefore, by updating the token bucket by executing multiple token filling rules in parallel, the embodiment of the present invention can achieve precise traffic control in non-integer alignment scenarios while ensuring the service quality of the system.

[0102] Figure 8 Schematic diagram of an electronic device according to an embodiment of the present invention. In this embodiment, the electronic device may be the flow rate limiting device or the device that executes the flow rate limiting program in the above embodiment. Figure 8 As shown, the electronic device includes: at least one processor 81; a memory 82 connected to the at least one processor 81; and a communication component 83 connected to the scanning device, the communication component 83 receiving and sending data under the control of the processor 81; wherein the memory 82 stores instructions that can be executed by at least one processor 81, and the instructions are executed by at least one processor 81 to implement the above-mentioned traffic speed limiting method.

[0103] Specifically, the electronic device includes: one or more processors 81 and a memory 82, Figure 8 A processor 81 is taken as an example. The processor 81 and the memory 82 can be connected via a bus or other means. Figure 8In this example, a bus connection is used. Memory 82, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs, and modules. Processor 81 executes the non-volatile software programs, instructions, and modules stored in memory 82 to execute various functional applications and data processing of the device, thereby implementing the aforementioned traffic rate limiting method.

[0104] The memory 82 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store a list of options, etc. Furthermore, the memory 82 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 82 may optionally include a memory remotely located relative to the processor 81, and such remote memory may be connected to an external device via a network. Examples of the aforementioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0105] One or more modules are stored in the memory 82 and, when executed by one or more processors 81 , perform the traffic rate limiting method in any of the above method embodiments.

[0106] The above-mentioned product can execute the method provided in the embodiment of this application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of this application.

[0107] After receiving a traffic rate limit instruction, an embodiment of the present invention will initialize the target token bucket of the target node according to the traffic rate limit instruction, obtain a first token filling rule, and determine at least one second token filling rule corresponding to the target token bucket, and then update the target token bucket according to the first token filling rule and the second token filling rule, and then control the sending and receiving of data packets of the target node according to the target token bucket. The first token filling rule is used to indicate that a reference number of tokens are filled at each reference time interval, and the second token filling rule is used to indicate that a compensation number of tokens are filled or reversely filled at each compensation time interval. Therefore, by updating the token bucket by executing multiple token filling rules in parallel, the embodiment of the present invention can achieve precise traffic control in non-integer alignment scenarios while ensuring the service quality of the system.

[0108] Another embodiment of the present invention relates to a non-volatile storage medium for storing a computer-readable program, wherein the computer-readable program is used to enable a computer to execute part or all of the above method embodiments.

[0109] That is, those skilled in the art will understand that all or part of the steps in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a program, which is stored in a storage medium and includes a number of instructions for causing a device (which may be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., various media that can store program code.

[0110] The foregoing is merely a preferred embodiment of the present application and is not intended to limit the present application. Persons skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application are intended to be within the scope of protection of the present application.

Claims

1. A flow rate limiting method, characterized in that: The method comprises: Receive traffic rate limit instructions; Initialize the target token bucket of the target node according to the traffic rate limit instruction; Obtain a first token filling rule, where the first token filling rule is used to indicate filling a reference number of tokens at each reference time interval; Determine at least one second token filling rule corresponding to the target token bucket, wherein the second token filling rule is used to indicate filling or reverse filling of a compensation amount of tokens at each compensation time interval; Update the target token bucket according to the first token filling rule and the second token filling rule; The target node is controlled to send and receive data packets according to the target token bucket.

2. The method according to claim 1, characterized in that The traffic speed limit instruction includes a speed limit configuration value, and the speed limit configuration value is used to represent the traffic speed limit requirement for the node; Determining at least one second token filling rule corresponding to the target token bucket includes: At least one second token filling rule corresponding to the target token bucket is determined according to the first token filling rule and the rate limit configuration value.

3. The method according to claim 1, characterized in that The traffic rate limit instruction includes an initial token configuration value and a bucket capacity configuration value; Initializing the target token bucket of the target node according to the traffic rate limit instruction includes: Setting the maximum token capacity of the target token bucket according to the bucket capacity configuration value; The initial token quantity of the target token bucket is set according to the initial token configuration value.

4. The method according to claim 1, wherein Updating the target token bucket according to the first token filling rule and the second token filling rule includes: Filling a reference number of tokens into the target token bucket at reference time intervals according to the first token filling rule; For each of the second token filling rules, a compensation number of tokens is filled or reversed into the target token bucket at every compensation time interval according to the second token filling rule.

5. The method according to claim 4, characterized in that When filling tokens into the target token bucket, the method further includes: In response to detecting that the number of tokens in the target token bucket after filling is greater than the maximum token capacity of the target token bucket, the number of tokens in the target token bucket is reset to the maximum token capacity.

6. The method according to claim 4, characterized in that When reverse filling tokens into the target token bucket, the method further includes: In response to detecting that the number of tokens in the target token bucket is less than zero after reverse filling, the number of tokens in the target token bucket is recorded as a negative value.

7. The method according to claim 1, characterized in that The first token filling rule is set according to the upper limit of the data transmission rate of the system.

8. The method according to claim 1, characterized in that The first token filling rule is set according to the average speed limit configuration value of each node in the system.

9. The method according to claim 1, characterized in that The controlling of sending and receiving data packets to the target node according to the target token bucket includes: Receive data packets; Determine the number of tokens to be consumed by the data packet and the number of available tokens in the target token bucket, wherein the number of tokens to be consumed is the number of tokens required to pass the data packet; The data packet is allowed to pass or intercepted according to the number of tokens to be consumed and the number of available tokens.

10. The method according to claim 9, characterized in that The allowing the data packet to pass or intercepting the data packet according to the number of tokens to be consumed and the number of available tokens includes: In response to detecting that the number of tokens to be consumed is less than or equal to the number of usable tokens, allowing the data packet to pass, and deducting tokens of the number of tokens to be consumed from the target token bucket; In response to detecting that the number of tokens to be consumed is greater than the number of usable tokens, the data packet is intercepted.

11. A flow rate limiting device, characterized in that: The device comprises: An instruction receiving unit, used for receiving a flow rate limit instruction; A token bucket initialization unit, configured to initialize a target token bucket of a target node according to the traffic rate limit instruction; A first rule acquiring unit, configured to acquire a first token filling rule, wherein the first token filling rule is configured to indicate that a reference number of tokens are filled every reference time interval; A second rule acquisition unit is used to determine at least one second token filling rule corresponding to the target token bucket, wherein the second token filling rule is used to indicate filling or reverse filling of a compensation amount of tokens at each compensation time interval; a token bucket updating unit, configured to update the target token bucket according to the first token filling rule and the second token filling rule; A control unit is used to control the sending and receiving of data packets to the target node according to the target token bucket.

12. A computer-readable storage medium storing computer program instructions, characterized in that: The computer program instructions implement the method according to any one of claims 1 to 10 when executed by a processor.

13. An electronic device, characterized in that: The device comprises: a memory for storing one or more computer program instructions; A processor, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 10.

14. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 1 to 10.