Token bucket processing method and device

By dynamically adjusting the bucket depth of the token bucket, based on the comparison results of the current traffic rate and preconfigured bandwidth, the traffic shock and resource waste caused by the fixed bucket depth are solved, and more effective bandwidth utilization and network stability are achieved.

CN119996324APending Publication Date: 2025-05-13NEW H3C TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510138593.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-07
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The existing token bucket bucket depth is a fixed value, which may cause intermittent shocks in burst traffic or waste resources when bandwidth is insufficient.

Method used

By obtaining the first rate of the network device passing the traffic in Nth second and comparing it with the preconfigured second rate, the bucket depth of the token bucket at N+1 second is dynamically adjusted according to the comparison results, so that the current passing traffic rate gradually coincides with the preconfigured bandwidth.

Benefits of technology

It reduces the impact on the network, effectively utilizes bandwidth resources, and avoids intermittent traffic shocks and resource waste caused by fixed bucket depths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119996324A_ABST
    Figure CN119996324A_ABST
Patent Text Reader

Abstract

The invention provides a token bucket processing method and device, the method is applied to network equipment, and the method comprises the following steps: obtaining a first rate of traffic passing of the network equipment in the Nth second; identifying a magnitude relationship between the first rate and a pre-configured second rate; and adjusting the bucket depth of the token bucket configured in the network equipment in the (N + 1) th second according to the identification result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a token bucket processing method and device. Background Art

[0002] For network services, factors that affect the quality of service (QoS) include transmission bandwidth, transmission delay, data packet loss rate, etc. In the network, the quality of service can be improved by ensuring the transmission bandwidth, reducing the transmission delay, reducing the data packet loss rate and delay jitter, etc.

[0003] However, network resources are always limited. When ensuring the service quality of a certain type of business, the service quality of other businesses may be damaged. Therefore, network administrators need to plan and allocate network resources reasonably according to the characteristics of various businesses, so that network resources can be used efficiently.

[0004] In order to make better use of limited network resources and better serve more users, the user traffic must be limited. Traffic policing, traffic shaping and speed limiting can all achieve the function of limiting the traffic rate, and to achieve this function, the traffic passing through the network device must be measured. Token buckets are usually used to measure traffic.

[0005] When evaluating traffic specifications using a token bucket, the number of tokens in the token bucket is based on whether it is sufficient to forward messages. If there are enough tokens in the token bucket to forward messages, the traffic is said to comply with or meet the specifications; otherwise, the traffic is said to be noncompliant or exceeded.

[0006] In one example, the interface of the network device is configured with a speed limit of 10M (bps) and a token bucket depth of 625000 (byte). In the intermittent uniform flow scenario (taking 6 seconds of flow as an example, the flow in the last 5 seconds of the 1st, 2nd, 3rd, 4th, 5th, and 6th seconds is 10M, and if calculated in ms, it is also uniform), the maximum flow that can pass in the first second is 15M. The calculation process is: 10000000+625000*8=15000000 (bps)=15M (bps).

[0007] In another example, the interface of the network device is configured with a speed limit of 10M (bps) and a token bucket depth of 625000 (byte). In a scenario where the flow rate is uneven (taking 1 second of flow as an example, the flow rate is 10M per second, and if calculated in ms, it is uneven, reaching 10M within 100ms and 0M within 900ms), the maximum flow rate that can pass is 1.5M. Calculation method: 1000000+6250*8=1050000 (bps)=1.05M (bps)

[0008] In the above examples, the use of token buckets to measure traffic also exposes the following problems: the depth of the token bucket is a fixed value. If the bucket depth is too large, the burst traffic will increase, which will bring intermittent impacts; if the bucket depth is too small, the bandwidth resources cannot be fully occupied, which will lead to resource waste. Summary of the invention

[0009] In view of this, the present application provides a token bucket processing method and device to solve the problem that when the bucket depth of the existing token bucket is a fixed value, intermittent traffic impact or resource waste may be caused.

[0010] In a first aspect, the present application provides a token bucket processing method, the method being applied to a network device, the method comprising:

[0011] Obtaining a first rate at which traffic passes through the network device within the Nth second;

[0012] Identify a magnitude relationship between the first rate and a preconfigured second rate;

[0013] According to the identification result, the bucket depth of the token bucket configured in the network device at the N+1th second is adjusted.

[0014] In a second aspect, the present application provides a token bucket processing device, the device is applied to a network device, and the device includes:

[0015] An acquiring unit, configured to acquire a first rate at which traffic passes through the network device within the Nth second;

[0016] an identification unit, configured to identify a magnitude relationship between the first rate and a preconfigured second rate;

[0017] The adjusting unit is used to adjust the bucket depth of the token bucket configured in the network device at the N+1th second according to the identification result.

[0018] In a third aspect, the present application provides a network device, including a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to execute the method provided in the first aspect of the present application.

[0019] Therefore, by applying the token bucket processing method and device provided in the present application, the network device obtains the first rate of traffic passing through the network device in the Nth second; the network device identifies the relationship between the first rate and the preconfigured second rate; based on the identification result, the network device adjusts the bucket depth of the token bucket configured in the network device at the N+1th second.

[0020] In this way, the token bucket depth is adaptively adjusted based on the current rate of traffic passing through, so that the current rate of traffic passing through gradually matches the pre-configured bandwidth, reducing the impact on the network and effectively utilizing bandwidth resources. At the same time, it also solves the problem of intermittent traffic impact or resource waste when the existing token bucket depth is a fixed value. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flowchart of a token bucket processing method provided in an embodiment of the present application;

[0022] Figure 2 A schematic diagram of adjusting the bucket depth of a token bucket provided in an embodiment of the present application;

[0023] Figure 3 A structural diagram of a token bucket processing device provided in an embodiment of the present application;

[0024] Figure 4 The network device hardware structure provided in the embodiment of the present application. DETAILED DESCRIPTION

[0025] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0026] The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in this article refers to and includes any or all possible combinations of one or more corresponding listed items.

[0027] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0028] The token bucket processing method provided in the embodiment of the present application is described in detail below. Figure 1 , Figure 1The flowchart of the token bucket processing method provided by the embodiment of the present application. The method is applied to a network device, and a token bucket has been configured in the network device. The token bucket processing method provided by the embodiment of the present application may include the following steps.

[0029] Step 110, obtaining a first rate at which traffic passes through the network device in the Nth second;

[0030] Specifically, multiple network devices have been set up in the network, and each network device is used to forward service messages of multiple service flows to achieve corresponding service functions.

[0031] The following uses a network device as an example for explanation.

[0032] The network device obtains the first rate of traffic passing through the network device in the Nth second, where N is an integer greater than or equal to 0. N may also be a decimal, for example, 0.1, 0.2, 0.3, etc. The value of N may be determined according to actual conditions.

[0033] Optionally, the specific process of the network device obtaining the first rate of traffic passing through itself in the Nth second is:

[0034] The network device obtains a first message statistic value within the N-1th second and a second message statistic value within the Nth second; the network device calculates a message quantity difference between the first message statistic value and the second message statistic value, and calculates a time difference between the Nth second and the N-1th second; the network device uses the quotient of the message quantity difference and the time difference as a first rate.

[0035] Step 120: Identify the magnitude relationship between the first rate and a preconfigured second rate;

[0036] Specifically, according to the description of step 110, after the network device obtains the first rate at which traffic passes through itself in the Nth second, it obtains the second rate preconfigured locally.

[0037] The network device identifies the magnitude relationship between the first rate and the second rate, that is, the network device identifies whether the first rate is greater than, equal to, or less than the second rate.

[0038] Step 130: According to the identification result, the bucket depth of the token bucket configured in the network device at the N+1th second is adjusted.

[0039] Specifically, according to the description of step 120, after the network device identifies the size relationship between the first rate and the second rate, the network device adjusts the bucket depth of the token bucket configured in itself at the N+1th second according to the identification result.

[0040] Optionally, in an embodiment of the present application, in one implementation, the specific process of the network device adjusting the bucket depth of the token bucket configured in itself at the N+1 second according to the identification result is:

[0041] If the first rate is greater than the second rate, then at the N+1th second, the network device adjusts the maximum bucket depth of the token bucket to the first value, and the minimum bucket depth of the token bucket is the same as the minimum bucket depth of the token bucket at the Nth second; wherein the first value is half of the sum of the maximum bucket depth and the minimum bucket depth of the token bucket at the Nth second.

[0042] Optionally, in an embodiment of the present application, in another implementation manner, the specific process of the network device adjusting the bucket depth of the token bucket configured in itself at the N+1th second according to the identification result is:

[0043] If the first rate is less than the second rate, then at the N+1th second, the network device adjusts the minimum bucket depth of the token bucket to the second value, and the maximum bucket depth of the token bucket is the same as the maximum bucket depth of the token bucket at the Nth second;

[0044] The second value is half of the sum of the maximum bucket depth and the minimum bucket depth of the token bucket at the Nth second.

[0045] Optionally, in an embodiment of the present application, in another implementation manner, the specific process of the network device adjusting the bucket depth of the token bucket configured in itself at the N+1th second according to the identification result is:

[0046] If the first rate is equal to the second rate, then at the N+1th second, the network device does not adjust the bucket depth of the token bucket.

[0047] It should be noted that the network device repeatedly performs the process of adjusting the bucket depth of the token bucket so that the first rate gradually approaches the second rate. When the first rate is within a preset tolerance, the network device stops adjusting the bucket depth of the token bucket.

[0048] For example, the tolerance can be specifically that the difference between the first rate and the second rate is within plus or minus 1%. The tolerance can also be configured by the user, for example, if it is configured to be 10%, when the second rate is 10M and the first rate is greater than 9M or less than 11M, the network device stops adjusting the token bucket depth.

[0049] Therefore, by applying the token bucket processing device provided in the present application, the network device obtains the first rate at which traffic passes through the network device in the Nth second; the network device identifies the relationship between the first rate and the preconfigured second rate; based on the identification result, the network device adjusts the bucket depth of the token bucket configured in the network device in the N+1th second.

[0050] In this way, by adaptively adjusting the depth of the token bucket using the current rate of traffic passing through, the current rate of traffic passing through is gradually made consistent with the pre-configured bandwidth, reducing the impact on the network and effectively utilizing bandwidth resources. At the same time, it also solves the problem of possible intermittent traffic impact or resource waste when the depth of the existing token bucket is a fixed value.

[0051] The following details the processing method of the token bucket provided by the embodiments of the present application. Refer to Figure 2 , Figure 2 which is a schematic diagram of the depth adjustment of the token bucket provided by the embodiments of the present application.

[0052] Administrators pre-configure the maximum token bucket depth (Max), minimum token bucket depth (Min), default token bucket depth (Default), and the average rate (CIR) for allowing the transmission or forwarding of packets in the network device.

[0053] Among them, the maximum token bucket depth, minimum token bucket depth, and default token bucket depth satisfy the relationship of Min < Default < Max; the forwarding rate can also be referred to as the rate of putting tokens into the token bucket, and the forwarding rate can be configured according to the bandwidth purchased by the user from the operator. For example, when the purchased bandwidth is 10M, the rate is 10M; when the purchased bandwidth is 100M, the rate is 100M.

[0054] Administrators also pre-configure the real-time token bucket depth (RealTimeCbs) in the network device. In the initial stage, the real-time token bucket depth (RealTimeCbs) is the default token bucket depth (Default), the maximum value of the next token bucket depth (NextMax) is the maximum token bucket depth (Max), and the minimum value of the next token bucket depth is the minimum token bucket depth (Min).

[0055] During the process of calculating the token bucket depth for the next second, the network device obtains the current actual rate of traffic passing through (Rate), and compares this rate with the preset average rate. According to the comparison result, the maximum token bucket depth of the previous second, and the minimum token bucket depth of the previous second, calculate the maximum value of the token bucket depth for the next second and the minimum value of the next-hop token bucket depth.

[0056] For example, initially, RealTimeCbs = Default, NextMax = Max, NextMin = Min;

[0057] If Rate(n), that is, the actual rate of traffic passing through in the Nth second = CIR, then RealTimeCbs(n + 1) = RealTimeCbs(n) remains unchanged, and the network device does not adjust the token bucket depth;

[0058] If Rate(n) > CIR, then NextMax(n + 1) = RealTimeCbs; NextMin(n + 1) = NextMin(n), that is, it remains unchanged; RealTimeCbs = (NextMax(n) + NextMin(n)) / 2;

[0059] If Rate(n) < Cir, then NextMax(n + 1) = NextMax(n), that is, it remains unchanged; NextMin(n + 1) = RealTimeCbs; RealTimeCbs = (NextMax(n) + NextMin(n)) / 2.

[0060] Execute the above repeatedly, so that the rate of the currently actual passing traffic gradually approaches the CIR. When the rate of the currently actual passing traffic is within the preset tolerance, the network device stops adjusting the depth of the token bucket. For example, the tolerance can be specifically that the difference between the rate of the currently actual passing traffic and the CIR is within plus or minus 1%. The tolerance can also be configured by the user. For example, when configured as 10%, and the CIR is 10M, when the rate of the currently actual passing traffic is greater than 9M or less than 11M, the network device stops adjusting the depth of the token bucket.

[0061] Based on the same inventive concept, the embodiments of the present application also provide a token bucket processing device corresponding to the token bucket processing method. Refer to Figure 3 , Figure 3 The token bucket processing device provided by the embodiments of the present application, the device is applied to a network device, and the device includes:

[0062] An obtaining unit 310, configured to obtain a first rate of the traffic passing through the network device in the Nth second;

[0063] An identifying unit 320, configured to identify the magnitude relationship between the first rate and a pre-configured second rate;

[0064] An adjusting unit 330, configured to adjust the depth of the token bucket configured in the network device at the (N + 1)th second according to the identification result.

[0065] Optionally, the adjusting unit 330 is specifically configured to, if the first rate is greater than the second rate, at the (N + 1)th second, adjust the maximum value of the depth of the token bucket to a first value, and the minimum value of the depth of the token bucket is the same as the minimum value of the depth of the token bucket at the Nth second;

[0066] The first value is half of the sum of the maximum value and the minimum value of the depth of the token bucket at the Nth second.

[0067] Optionally, the adjustment unit 330 is further specifically configured to, if the first rate is less than the second rate, adjust the minimum bucket depth of the token bucket to a second value at the N+1th second, and the maximum bucket depth of the token bucket is the same as the maximum bucket depth of the token bucket at the Nth second;

[0068] The second value is half of the sum of the maximum bucket depth and the minimum bucket depth of the token bucket at the Nth second.

[0069] Optionally, the adjusting unit 330 is further specifically configured to, if the first rate is equal to the second rate, not adjust the bucket depth of the token bucket at the N+1th second.

[0070] Optionally, the acquisition unit 310 is specifically used to acquire a first message statistical value within the N-1th second and a second message statistical value within the Nth second;

[0071] Calculate the message quantity difference between the first message statistical value and the second message statistical value, and calculate the time difference between the Nth second and the N-1th second;

[0072] The quotient of the message quantity difference and the time difference is used as the first rate.

[0073] Therefore, by applying the token bucket processing device provided in the present application, the network device obtains the first rate at which traffic passes through the network device in the Nth second; the network device identifies the relationship between the first rate and the preconfigured second rate; based on the identification result, the network device adjusts the bucket depth of the token bucket configured in the network device in the N+1th second.

[0074] In this way, the token bucket depth is adaptively adjusted based on the current rate of traffic passing through, so that the current rate of traffic passing through gradually matches the pre-configured bandwidth, reducing the impact on the network and effectively utilizing bandwidth resources. At the same time, it also solves the problem of intermittent traffic impact or resource waste when the existing token bucket depth is a fixed value.

[0075] Based on the same inventive concept, the embodiment of the present application also provides a network device, such as Figure 4 As shown, it includes a processor 410, a transceiver 420 and a machine-readable storage medium 430, the machine-readable storage medium 430 stores machine-executable instructions that can be executed by the processor 410, and the processor 410 is prompted by the machine-executable instructions to execute the token bucket processing method provided in the embodiment of the present application. Figure 3 The token bucket processing device shown in FIG. Figure 4 The network device hardware structure shown is implemented.

[0076] The computer-readable storage medium 430 may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. Optionally, the computer-readable storage medium 430 may also be at least one storage device located away from the processor 410.

[0077] The processor 410 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, or discrete hardware components.

[0078] In the embodiment of the present application, the processor 410 reads the machine executable instructions stored in the machine readable storage medium 430, and the machine executable instructions enable the processor 410 itself and the transceiver 420 to execute the token bucket processing method described in the aforementioned embodiment of the present application.

[0079] In addition, an embodiment of the present application provides a machine-readable storage medium 430, which stores machine-executable instructions. When called and executed by the processor 410, the machine-executable instructions prompt the processor 410 itself and the calling transceiver 420 to execute the token bucket processing method described in the aforementioned embodiment of the present application.

[0080] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0081] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying any creative work.

[0082] As for the token bucket processing device and machine-readable storage medium embodiments, since the method contents involved are basically similar to the aforementioned method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0083] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A token bucket processing method, characterized in that: The method is applied to a network device, and the method comprises: Obtaining a first rate at which traffic passes through the network device within the Nth second; Identify a magnitude relationship between the first rate and a preconfigured second rate; According to the identification result, the bucket depth of the token bucket configured in the network device at the N+1th second is adjusted.

2. The method according to claim 1, characterized in that The step of adjusting the bucket depth of the token bucket configured in the network device at the N+1th second according to the identification result specifically includes: If the first rate is greater than the second rate, then at the N+1th second, the maximum bucket depth of the token bucket is adjusted to the first value, and the minimum bucket depth of the token bucket is the same as the minimum bucket depth of the token bucket at the Nth second; The first value is half of the sum of the maximum bucket depth and the minimum bucket depth of the token bucket at the Nth second.

3. The method according to claim 1, characterized in that The step of adjusting the bucket depth of the token bucket configured in the network device at the N+1th second according to the identification result specifically includes: If the first rate is less than the second rate, then at the N+1th second, the minimum bucket depth of the token bucket is adjusted to the second value, and the maximum bucket depth of the token bucket is the same as the maximum bucket depth of the token bucket at the Nth second; The second value is half of the sum of the maximum bucket depth and the minimum bucket depth of the token bucket at the Nth second.

4. The method according to claim 1, characterized in that: The step of adjusting the bucket depth of the token bucket configured in the network device at the N+1th second according to the identification result specifically includes: If the first rate is equal to the second rate, then at the N+1th second, the bucket depth of the token bucket is not adjusted.

5. The method according to claim 1, characterized in that The obtaining of a first rate at which traffic passes through the network device within the Nth second specifically includes: Obtain the first message statistics within the N-1 second and the second message statistics within the N second; Calculate the message quantity difference between the first message statistical value and the second message statistical value, and calculate the time difference between the Nth second and the N-1th second; The quotient of the message quantity difference and the time difference is used as the first rate.

6. A token bucket processing device, characterized in that: The device is applied to a network device, and the device comprises: An acquiring unit, configured to acquire a first rate at which traffic passes through the network device within the Nth second; an identification unit, configured to identify a magnitude relationship between the first rate and a preconfigured second rate; The adjusting unit is used to adjust the bucket depth of the token bucket configured in the network device at the N+1th second according to the identification result.

7. The device according to claim 6, characterized in that The adjustment unit is specifically configured to, if the first rate is greater than the second rate, adjust the maximum bucket depth of the token bucket to a first value at the N+1th second, and the minimum bucket depth of the token bucket is the same as the minimum bucket depth of the token bucket at the Nth second; The first value is half of the sum of the maximum bucket depth and the minimum bucket depth of the token bucket at the Nth second.

8. The device according to claim 6, characterized in that The adjustment unit is further specifically configured to, if the first rate is less than the second rate, adjust the minimum bucket depth of the token bucket to a second value at the N+1th second, and the maximum bucket depth of the token bucket is the same as the maximum bucket depth of the token bucket at the Nth second; The second value is half of the sum of the maximum bucket depth and the minimum bucket depth of the token bucket at the Nth second.

9. The device according to claim 6, characterized in that The adjustment unit is further specifically configured to, if the first rate is equal to the second rate, not adjust the bucket depth of the token bucket at the N+1th second.

10. The device according to claim 6, characterized in that The acquisition unit is specifically used to acquire the first message statistical value within the N-1th second and the second message statistical value within the Nth second; Calculate the message quantity difference between the first message statistical value and the second message statistical value, and calculate the time difference between the Nth second and the N-1th second; The quotient of the message quantity difference and the time difference is used as the first rate.