A method and system for traffic shaping based on counting period optimization

CN122933547APending Publication Date: 2026-10-16BEIJING YUNMAI XINLIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611195751.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-07
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

这一偏差在连续运行中不断累积,在最小粒度下整形误差较大,远不能满足千分之一以内的精度要求

Benefits of technology

[0033] 1. Significantly improved shaping accuracy

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122933547A_ABST
    Figure CN122933547A_ABST
Patent Text Reader

Abstract

The present application relates to the field of traffic shaping, and particularly relates to a traffic shaping method and system based on counting period optimization. The method starts from the scheduling period of a reference value to generate candidate counting period values in an incremental manner; for each candidate value, the relative error between the theoretical token quantity and the actual token quantity is calculated as a shaping error, the actual token quantity being the theoretical token quantity divided by the authorized value and then rounded down again multiplied by the authorized value; it is judged whether the ratio of the candidate counting period value to the main frequency is equal to the negative integer power of two, if so, the operation of multiplying the candidate counting period value and dividing the main frequency is replaced by a right shift operation of the corresponding number of bits; the candidate value that meets the conditions of the shaping error being not greater than a preset accuracy threshold and the number of multipliers being one at the same time is determined as the optimal counting period; and the token adding is performed by one multiplier according to the optimal counting period. The present application reduces the number of multipliers while ensuring the shaping accuracy, and reduces the chip timing convergence pressure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of flow shaping, and in particular to a flow shaping method and system based on counting cycle optimization. Background Technology

[0002] Traffic shaping is used to limit outflow and bursts from a network, ensuring packets are sent at a more uniform rate. It is typically implemented using a token bucket algorithm. The system adds tokens to the token bucket at a fixed period according to a configured shaping rate, and consumes the corresponding number of tokens from the bucket whenever a data packet needs to be sent.

[0003] In the actual hardware implementation of network chips, traffic shaping involves the collaborative work of multiple hardware modules. Taking PPS (Packets Per Second) mode as an example, the shaping requirement ranges from a minimum granularity of 1 PPS to a maximum of 400 Mbps, with a dynamic range of 4 × 10⁻⁶. 8 This places extremely high demands on the precision of token addition.

[0004] In existing technologies, token addition calculations typically involve a Data Path Module (DPM) and an Integer Configuration Management Module. The DPM module only supports integer operations; therefore, the token value (a parameter defining how many data packets a token represents) must be rounded up to an integer. For example, at a 1.2GHz clock frequency and a 32-cycle counting period, the theoretical number of packets to be processed per scheduling cycle is 10.667, which rounds up to 11.

[0005] However, existing technologies have the following problems:

[0006] First, the limitations of integer arithmetic lead to insufficient precision. Since the DPM module only supports integer arithmetic, the authorized value can only be rounded down. With a counting cycle of 32 cycles, the theoretical authorized value is 10.667. After rounding up to 11, a deviation is introduced in each scheduling cycle. This deviation accumulates continuously during operation, resulting in a large shaping error at the smallest granularity, far from meeting the precision requirement of less than one-thousandth.

[0007] Second, the cascaded operation of two multipliers leads to difficulties in timing convergence. During the token addition calculation, three variables—"configured shaping rate," "authorization value," and "counting cycle"—need to be multiplied, involving the cascaded operation of two multipliers (first calculating the rate × authorization value, then multiplying by the counting cycle). Multipliers are heavy-duty circuit units in chip design, exhibiting significant path delays. At high-speed clocks (e.g., 1.2GHz), the path delay created by the cascaded operation of two multipliers can easily exceed the clock cycle constraint, becoming a critical path and severely increasing the pressure on timing convergence.

[0008] Therefore, optimizing the counting cycle to reduce the number of multipliers and lower timing pressure while ensuring shaping accuracy is a technical problem that urgently needs to be solved. Summary of the Invention

[0009] To address one of the aforementioned technical problems, the present invention adopts the following technical solution:

[0010] According to one aspect of the present invention, a flow shaping method based on counting period optimization is provided, comprising the following steps:

[0011] Starting from the baseline value, candidate counting cycle values ​​are generated sequentially and incrementally. For each candidate counting cycle value... Perform the following steps respectively and steps The integer error corresponding to the candidate counting period value N and the number of multipliers required to perform token addition calculation under the candidate counting period value N are obtained; the baseline value is the scheduling period.

[0012] Step A: Calculate the shaping error , The following conditions must be met:

[0013] ;

[0014] ;

[0015] ;

[0016] in, This is the actual number of tokens that can be added; This is the theoretical number of tokens that should be added; For the configured shaping rate, For licensing value, Main frequency, To round down;

[0017] Step B: Determine whether adding the execution token can reduce the number of multipliers.

[0018] when When determining that the operation of multiplying by the candidate counting cycle value N and dividing by the main frequency F can be replaced by a right shift operation of M bits, the required number of multipliers is one;

[0019] The candidate counting period value N that simultaneously satisfies both the first and second conditions is determined as the optimal counting period; where the first condition is... The condition is that the number of multipliers is one and the value is less than or equal to the preset precision threshold.

[0020] According to the optimal counting cycle, a multiplier is used to perform token addition calculation and add tokens to the token bucket.

[0021] According to a second aspect of the present invention, a flow shaping system based on counting period optimization is provided, comprising:

[0022] The candidate counting cycle value generation module is used to generate candidate counting cycle values ​​sequentially, starting from a baseline value. For each candidate counting cycle value... Perform the following steps respectively and steps The integer error corresponding to the candidate counting period value N and the number of multipliers required to perform token addition calculation under the candidate counting period value N are obtained; the baseline value is the scheduling period.

[0023] Step A: Calculate the shaping error , The following conditions must be met:

[0024] ;

[0025] ;

[0026] ;

[0027] in, For the configured shaping rate, For licensing value, Main frequency, To round down;

[0028] Step B: Determine whether adding the execution token can reduce the number of multipliers.

[0029] when When determining that the operation of multiplying by the candidate counting cycle value N and dividing by the main frequency F can be replaced by a right shift operation of M bits, the required number of multipliers is one;

[0030] The target counting cycle value generation module is used to determine the candidate counting cycle value N that simultaneously satisfies the first condition and the second condition as the optimal counting cycle; wherein the first condition is... The condition is that the number of multipliers is one and the value is less than or equal to the preset precision threshold.

[0031] The token addition module is used to perform token addition calculations using a multiplier according to the optimal counting period and add tokens to the token bucket.

[0032] This invention has at least one of the following beneficial effects:

[0033] 1. Significantly improved shaping accuracy

[0034] in accordance with It can be seen that when the candidate counting cycle value The theoretical number of tokens added each time as the number increases. It increases accordingly. Because... It is Converted into licensing value Integer multiples of, i.e. , and The absolute value of the difference between them does not exceed one authorized value. Therefore, relative error Follow The value increases and then monotonically decreases. Based on this principle, this invention, by sequentially increasing the candidate counting period value from the beginning of the scheduling period, uses a shaping error less than or equal to a preset precision threshold as one of the conditions for selecting the optimal counting period, effectively reducing the relative error caused by rounding the authorized value. With main frequency The scheduling cycle is 32 beats, and the authorized value is... Taking the configuration as an example, the optimal counting period is obtained through enumeration and filtering. Shaping error can be reduced The accuracy is controlled to within one-thousandth, which is far superior to the accuracy level of existing technologies.

[0035] 2. Reduces the number of multipliers, lowers timing convergence pressure, and simplifies hardware implementation.

[0036] In the process of selecting the optimal counting period, this invention selects candidate counting period values. With main frequency ratio Is it equal to As one of the filtering criteria. When At that time, multiply by the candidate counting period value Divide by the clock speed The operation is mathematically equivalent to multiplying by In binary hardware implementations, multiplying by Equivalent to right shift This operation, which requires only one shifter and does not involve multiplication, can be completed using only one bit shifter. Therefore, the operation that originally required two multipliers cascaded together can now be performed using only one bit shifter. The calculation of "" can be converted into a multiplier (for...). Add a shifter (for right shift) This invention employs a hardware architecture that utilizes two multipliers in series. Compared to existing dual-multiplier cascaded schemes, this invention avoids the critical path delay problem caused by the cascaded multipliers, significantly reducing the pressure on chip timing convergence. Furthermore, the entire scheme can be implemented simply by adding a counting cycle configuration register and a shifter to the existing hardware architecture, resulting in minimal impact on chip area and power consumption, and demonstrating good feasibility and universality. Attached Figure Description

[0037] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 A flowchart of a flow shaping method based on counting cycle optimization provided in an embodiment of the present invention.

[0039] Figure 2 A flowchart illustrating a traffic shaping method based on asynchronous dual-authorization value provided in an embodiment of the present invention. Detailed Implementation

[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0041] As a possible first embodiment of the present invention, such as Figure 1 As shown, this embodiment provides a flow shaping method based on counting period optimization, including the following steps:

[0042] Step 101: Starting from the baseline value, generate candidate counting cycle values ​​sequentially by incrementing the value. For each candidate counting cycle value... Perform the following steps respectively and steps The candidate counting cycle value is obtained. The corresponding shaping error and the candidate counting period value The number of multipliers required for computation is added by the execution token. The baseline value is the scheduling period.

[0043] Step 101 generates candidate counting cycle values ​​by sequentially incrementing from the baseline value, specifically including:

[0044] Starting from the base value, the candidate count cycle value is incremented one by one in a step of one clock cycle.

[0045] The scheduling cycle is 32 clock cycles.

[0046] The scheduling cycle (32 clock cycles) is the minimum number of clock cycles for the chip to perform scheduling operations, and it is also the minimum time unit for hardware pipeline processing. The time interval for any token addition operation cannot be less than this value. Therefore, the scheduling cycle is used as the base value for enumeration.

[0047] Enumerating in increments of one clock cycle ensures that no candidate cycle value is overlooked, thus accurately finding the optimal solution that simultaneously satisfies accuracy and hardware simplification requirements. The upper limit of the enumeration does not need to be pre-set; it stops once a value satisfying the conditions is found. This guarantees that the obtained counting cycle value is the smallest value that satisfies the conditions, thereby avoiding other problems caused by excessively large counting cycles.

[0048] By systematically enumerating candidate counting cycle values, a foundation is laid for subsequent screening of counting cycles that can simultaneously meet the two conditions of "high precision" and "single multiplier".

[0049] Step A: Calculate the shaping error Error, which satisfies the following condition:

[0050]

[0051] in, For the configured shaping rate, For licensing value, Main frequency, This is for rounding down.

[0052] Licensing value The following conditions must be met:

[0053]

[0054] in, To achieve the maximum shaping rate, For the scheduling period, Main frequency, This is for rounding up.

[0055] In the data path module, all calculations are integer operations and decimals are not supported; therefore, the licensing value is limited. The number of tokens must be rounded to the nearest integer. If the actual calculated theoretical number of tokens is not... When the value is an integer multiple of the integer, only the decimal part can be discarded (i.e., rounded down to the nearest integer). (integer multiples of), thus causing a deviation in the number of tokens. It is the theoretical number of tokens that should be added; it is a continuous value. This is the actual number of tokens that can be added; it must be... The absolute value of the difference between the two is an integer multiple of the total. This is the relative error, which reflects the degree to which the rounding operation affects the accuracy of the rounding operation.

[0056] Licensing value The maximum shaping rate, scheduling cycle, and clock frequency jointly determine the throughput: at the maximum shaping rate, the number of packets to be processed in each scheduling cycle is rounded up. The resulting integer value ensures that the throughput is not insufficient due to rounding at the maximum rate, while also ensuring... The value of has a fixed physical meaning, which facilitates uniform calculation at different rates.

[0057] This step enables a quantitative evaluation of any candidate counting period value. The impact on shaping accuracy provides a comparable quantitative indicator for subsequent screening of counting cycles that meet accuracy requirements.

[0058] Step B: Determine whether adding the execution token can reduce the number of multipliers.

[0059] when At that time, determine the multiplication by the candidate counting period value. Divide by the clock speed The operation can be replaced by a right shift. For bit shifting operations, only one multiplier is required.

[0060] when At that time, determine the multiplication by the candidate counting period value. Divide by the clock speed The operation still requires a multiplier, and two multipliers are needed.

[0061] In the token addition calculation, the complete formula is: If you calculate directly using this formula, you need to first... Multiply by, then multiply by and divide by This involves the cascading of two multipliers.

[0062] However, in digital logic, dividing by (Frequency) and multiplied by (Counting period) can be combined into multiplication. .when Multiplying by this value is equivalent to shifting to the right. Bitwise shifting operations can be implemented in hardware with just wiring, without consuming multiplier resources, and the latency is much lower than that of a multiplier. When this condition is not met, a second multiplier must be used to complete the multiplication and division operations.

[0063] The purpose of step B is to filter out candidate counting cycle values ​​that can reduce the number of multipliers from two to one, thereby simplifying the hardware implementation as much as possible while meeting accuracy requirements. This criterion allows us to filter out special values ​​"related to powers of 2" from the numerous enumerated candidate values, enabling the hardware design to use an architecture of one multiplier and one shifter, avoiding the critical path delay problem caused by cascading two multipliers.

[0064] Step 102: Select candidate counting cycle values ​​that simultaneously satisfy the first and second conditions. The optimal counting period is determined by the following conditions: the first condition is that Error is less than or equal to the preset precision threshold, and the second condition is that the number of multipliers is one.

[0065] Specifically, the preset accuracy threshold can be one-thousandth.

[0066] Step A provides the error quantification metric, and step B provides the result of determining the number of multipliers. However, these two conditions are separate: one value may meet the accuracy requirements but require two multipliers (due to timing pressure), while the other value may only require one multiplier but fail to meet the accuracy requirements. Only by simultaneously satisfying both conditions can we ensure both shaping accuracy and optimize hardware implementation.

[0067] The preset accuracy threshold is one-thousandth, which is sufficient to meet the needs of most traffic shaping applications. However, this accuracy value is not fixed; those skilled in the art can adjust the threshold adaptively according to specific usage scenarios and accuracy requirements.

[0068] The second condition of having only one multiplier is that the architecture of a single multiplier plus a shifter can completely avoid the critical path delay problem caused by the cascading of two multipliers, while two multipliers cannot achieve this optimization goal.

[0069] By filtering under two conditions, a unique optimal counting cycle value can be obtained, which ensures that the shaping error is within an acceptable range and achieves the simplification of the hardware architecture.

[0070] As an example, in the clock speed The scheduling cycle is 32 clock cycles, and the authorized value is... Under the given conditions, the optimal counting period can be obtained through the above enumeration and screening. ,and Based on this, we can further solve for... .

[0071] The detailed derivation process is as follows:

[0072] The first step is to determine the value of the license. .

[0073] At maximum shaping rate Mega PPS, main frequency Scheduling cycle During the shooting, 11.

[0074] The second step is to enumerate candidate counting cycle values.

[0075] from Initially, the step size is increased gradually by 1 beat, for each... Calculate separately:

[0076] (1) Accuracy condition verification:

[0077] Calculate the error. Verify the minimum reshaping rate. PPS and maximum shaping rate At megaPPS, are the error rates all below one in a thousand?

[0078] (2) Verification of the number of multipliers: Verification Is it equal to .

[0079] When enumeration reaches hour, ,and The closest to that value, i.e. ,satisfy The conditions. At the same time, At that point, the error had dropped to below one-thousandth, meeting the preset accuracy threshold. Therefore... It was determined to be the optimal counting period.

[0080] The above example illustrates that, under actual hardware configuration (1.2GHz clock speed, 32-cycle scheduling period) and shaping requirements (1PPS to 400 Mbps), the enumeration filtering method of this invention can achieve the desired results when enumerating to... At that time, both conditions are satisfied simultaneously, therefore It is determined to be the optimal counting period, at this time .

[0081] Step 103: According to the optimal counting cycle, use a multiplier to perform token addition calculation and add tokens to the token bucket.

[0082] Step 103 specifically includes:

[0083] Configure the shaping rate With the value of licensing Multiply them to get the first product.

[0084] Shift the first product to the right The system retrieves the number of tokens to be added and adds that number of tokens to the token bucket.

[0085] When the optimal counting period satisfy At that time, the complete token addition calculation It can be rewritten as .because and The product is done in the first multiplier, multiplied by In binary arithmetic, this is equivalent to a right shift. Therefore, the entire calculation process requires only one multiplication ( ). ) and one shift (right shift) It can be completed in one step (1), without the need for a second multiplier.

[0086] By replacing multiplication operations with shift operations, the critical path delay problem caused by cascading two multipliers is avoided, significantly reducing the pressure on chip timing convergence. Furthermore, the shifter only requires wiring in hardware implementation, without introducing additional latency and area overhead, making the overall hardware architecture simpler and more efficient.

[0087] Example 1 improves shaping accuracy by enumerating and selecting the optimal counting period, while utilizing... The characteristic of this method reduces the number of multipliers from two to one, effectively alleviating the timing convergence pressure caused by cascading two multipliers. However, this scheme has an inherent limitation: when the optimal counting period... When the time is much greater than the scheduling cycle (32 cycles) (e.g.) The number of tokens that need to be added each time increases significantly. The token bucket cannot obtain new tokens during a long counting period. Once it does obtain new tokens, they flood in all at once, causing a traffic burst. This contradicts the original intention of traffic shaping to "smooth traffic".

[0088] Therefore, based on Example 1, Example 2 fundamentally solves the above problems by introducing an asynchronous dual-authorization value mechanism. The core idea of ​​Example 2 is to maintain two different authorization values ​​on the token management side and the data path side respectively: the token management side uses a fractional authorization value. Perform high-precision addition, using integer authorization values ​​on the data path side. Consumption management is implemented, and the two are accurately converted through a mapping relationship, thereby achieving zero-error shaping while maintaining high-frequency addition (short counting cycle) and completely eliminating sudden traffic.

[0089] like Figure 2As shown, as a second possible embodiment of the present invention, a traffic shaping method based on asynchronous dual-authorization value is provided, including the following steps:

[0090] Step 201: Determine the decimal width based on the minimum integer granularity; the decimal width is used to store the fractional part of the token.

[0091] Step 201 specifically includes:

[0092] Step 201.1: Obtain the minimum shaping granularity .

[0093] Step 201.2: According to Calculate the theoretical number of tokens to be added per scheduling cycle at the minimum integer granularity. For the scheduling period, Main frequency.

[0094] Step 201.3: Convert the theoretical token quantity into authorized value units to obtain... .

[0095] Step 201.4: Under the minimum shaping granularity, when using a bit width of When storing binary decimals, the storage precision is 1. .

[0096] Step 201.5: [The following is a list of steps / conditions] The smallest The value is determined as the decimal places width.

[0097] Based on the above, the decimal width can specifically be 29 bits.

[0098] At the smallest integer granularity (e.g., 1 PPS), the number of tokens to be added in each scheduling cycle is extremely small. If the decimal width is insufficient, this tiny amount cannot be accurately represented and can only be rounded to 0 or an approximate value. This results in tokens never being added at the smallest granularity, or the amount added deviating from the theoretical value, causing the integer function to fail.

[0099] By determining the fractional bit width based on the smallest integer granularity, this fractional bit width can accurately represent the amount of tokens added at the smallest granularity, thereby ensuring storage accuracy across the entire rate range.

[0100] As an example, in the clock speed Scheduling cycle Shot, maximum shaping rate Under a typical configuration of megaPPS:

[0101] Step 201.1: Minimum Shaping Granularity PPS;

[0102] Step 201.2: Calculate the Token (a packet);

[0103] Step 201.3: Convert the theoretical token quantity into authorized value units. The conversion method is to divide by the authorized value, here rounded up to the nearest integer at the maximum rate. Based on the conversion, we obtain the Token. (Each authorized unit of value);

[0104] Step 201.4: When using a bit width of When storing binary decimals, the storage precision is 1. ;

[0105] Step 201.5: Verify each Does the value satisfy? .

[0106] The following table gives the various Validation results of the value:

[0107] Table 1

[0108]

[0109] As shown in Table 1, when When storage precision is insufficient, The requirement for precise representation is first met at this time, therefore the minimum value that satisfies the condition is... The value is 29, meaning the decimal width is 29 bits.

[0110] Step 202: Under the precision constraint of decimal places, and with the goal of zero shaping error, deduce the first authorized value used by the token management side in reverse. .

[0111] Step 202 specifically includes:

[0112] Step 202.1: Under the precision constraint of decimal place width, establish the error equation Error, which satisfies the following conditions.

[0113]

[0114]

[0115]

[0116] in, For the configured shaping rate, For the scheduling period, Main frequency, To round down;

[0117] Step 202.2: Let Error Solving under the precision constraint of decimal place width .

[0118] As an example, in the clock speed Scheduling cycle Clock cycles, maximum shaping rate Under the condition of megaPPS, the value of the second license According to the formula Calculated Further reverse derivation as described above yields the value of the first authorization. .

[0119] Secondary Authorization Value The following conditions must be met:

[0120]

[0121] in, To achieve the maximum shaping rate, For the scheduling period, Main frequency, For rounding up; maximum shaping rate As mentioned above The values ​​are the same.

[0122] It should be noted that the second authorized value in this embodiment Compared with the authorized value in Example 1 Although the calculation formulas are the same, they play different roles in this invention: in Example 1 It is the sole authorized value, used for token addition calculations within a single value system; while in this embodiment... It is the second authorization value in the asynchronous dual authorization value system, which is related to the first authorization value on the data path side. When used together, the two constitute the asynchronous dual-licensing value feature of this invention.

[0123] The existing approach is to first determine the licensing value (rounded to an integer), then calculate the resulting error, and finally try to reduce the error. The present invention takes the opposite approach: it first sets "zero error" as the target constraint, and then works backward to determine the required licensing value to achieve this goal. Under the constraint of a given decimal place width precision, This is the theoretical number of tokens that should be added. This is the actual number of tokens that can be added (it must be) (integer multiples of). Let Error That is, requirements This means It must be exactly The value is an integer multiple of the given value. Solving this equation under the constraint of decimal place width precision yields the authorized value that satisfies the zero-error condition.

[0124] Since this value is derived by working backward from the decimal place width precision, and the decimal place width itself is determined based on the minimum integer granularity, this value can ensure that token addition does not produce rounding errors even at the minimum integer granularity, thus fundamentally solving the problem of accumulated errors introduced by rounding fixed authorization values ​​in existing technologies.

[0125] The specific process of reverse derivation is as follows:

[0126] In Error Under the constraints, requirements ,Right now:

[0127] The condition for the above formula to be true is It is an integer, that is It must be Integer multiples of. For any configured integer shaping rate. MegaPPS , .

[0128] Given the precision constraint of 29 bits for the fractional part, a solution needs to be found across the entire data rate range. This makes all All Integer multiples of. Through the... Solving for all possible values ​​from 1 to 400M yields a unique result. .

[0129] Specific verification:

[0130] when During PPS, After dividing by 14.31, it is approximately This value has a precision of 29 bits (minimum precision). The following can be precisely represented, that is It is an integer.

[0131] when At 1 megaPPS, Dividing by 14.31 yields approximately 0.745, which can also be accurately represented with 29-bit precision.

[0132] For any value between 1 and 400 megabytes The calculation results are similar for all of them. Therefore, it can be seen that... It can achieve full-rate range at 29-bit precision. All Multiples of an integer, thus implementing Error. .

[0133] Step 203: On the data path side, use the second authorization value. Manage token consumption. It is an integer.

[0134] Based on the above, the scheduling cycle is specifically 32 clock cycles.

[0135] The hardware architecture of the data path module is fixed, supporting only integer operations and unable to perform high-precision decimal operations. Forcing the DPM module to support decimal operations would significantly increase hardware complexity and path latency.

[0136] Therefore, this invention retains an integer license value on the data path side. (e.g., 11) This ensures full compatibility with existing hardware, requiring no modifications to the data path module. Simultaneously, the scheduling cycle remains at 32 clock cycles, enabling frequent token addition operations with only a small number of tokens added each time, thus completely avoiding the problem of large token backlogs caused by increased counting cycles.

[0137] By using integer authorization values ​​on the data path side This allows the present invention to be fully compatible with existing data path module integer arithmetic hardware without any hardware modification, significantly reducing implementation costs.

[0138] Step 204: Establish and The mapping relationship between them.

[0139] Step 204 specifically includes:

[0140] Step 204.1: According to and Calculate the ratio satisfy

[0141] Step 204.2: [The text appears to be incomplete and contains several grammatical errors. A more accurate translation would require the full context.] It is stored in the configuration register as a fixed-point number; the decimal width of the fixed-point number is the decimal width.

[0142] Because the token management side uses Add (decimals), used on the data path side. Consumption management is based on (integers), and these are two independent value systems. When a data packet is sent, the data path consumes [amount / cost]. indivual If a unit has tokens, how many should the token management side deduct? Unit tokens? This requires a conversion relationship.

[0143] because and All are known fixed values, and their ratio It is a fixed constant, By pre-storing the fixed-point numbers in the configuration register, conversions can be performed quickly each time they are consumed. The decimal width of the fixed-point numbers remains consistent with the aforementioned decimal width to ensure no loss of conversion accuracy.

[0144] This was achieved by pre-storing the ratio. and The precise conversion between them ensures that the consumption on the data path side is accurately reflected in the token balance on the token management side, ensuring consistent measurement of additions and consumptions.

[0145] Step 205: According to the scheduling cycle, use Add a token to the token bucket and store the fractional part of the token with a fractional bit width.

[0146] A scheduling cycle (e.g., 32 clock cycles) is the smallest unit of time for hardware to perform scheduling operations. It is used according to the scheduling cycle. Adding tokens means that tokens are added frequently, with a small number of tokens added each time, thus avoiding the problem of a large influx of tokens at once after they have been accumulating in the bucket for a long time.

[0147] Meanwhile, since the number of tokens added each time may not be an integer (especially when the configured integer rate is low), the resulting decimal part must be stored and accumulated into the next addition; otherwise, accumulated errors will occur due to rounding. Storing the decimal part of the tokens with the bit width determined in step 201 ensures that the decimal part of each addition is accurately recorded and accumulated. By maintaining a high frequency of token additions during the scheduling cycle, the problem of traffic bursts is fundamentally eliminated, achieving true traffic smoothing. Simultaneously, the lossless storage of the decimal part guarantees the accuracy of the token bucket balance during long-term operation.

[0148] Step 206: When the data path side consumes a token, according to the mapping relationship, the token consumed by the data path side... quantity The conversion to token management requires the following: The quantity.

[0149] Step 206 specifically includes:

[0150] Quantity used With the configuration register stored Multiply them to get the product;

[0151] Shifting the product right by the number of decimal places gives the amount of data required by the token management side. The quantity.

[0152] Each time a data packet is sent, the data path side consumes a certain amount of resources. Tokens. To keep the token balance on the token management side synchronized with the consumption on the data path side, the consumed tokens must be... Quantity converted to corresponding The quantity is deducted from the token management side.

[0153] The conversion method is as follows:

[0154] Consumed quantity Multiply by the ratio ,because Stored in fixed-point format. Its decimal places are [number]. Therefore, the product is shifted to the right. The corresponding bit can be obtained. Quantity. This entire operation is completed on the token management side; the data path side only needs to report the consumption. quantity There's no need to worry about the conversion process.

[0155] Through mapping calculations, it is ensured that the token balance on the token management side is always precisely synchronized with actual consumption, with both additions and consumptions made in accordance with the mapping relationship. To standardize the units of measurement and avoid systematic deviations in the token bucket balance caused by inconsistent units of measurement, the long-term consistency between the token bucket balance and the theoretical value is guaranteed.

[0156] In summary, Implementation Example 2 maintains fractional authorization values ​​on both the token management side and the data path side through an "asynchronous dual authorization value" mechanism. And integer authorized value Both sides operate independently and are not dependent on each other, which constitutes the core characteristic of asynchronous dual authorization. This is achieved through determining the decimal width and reverse derivation. By combining a series of methods such as establishing mapping relationships, high-frequency addition, and accurate conversion, Example 2 simultaneously achieves several beneficial effects, including zero-error lossless storage of the decimal part of the shaped fraction, and a balance between hardware compatibility and high precision.

[0157] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0158] Furthermore, the accompanying drawings are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention and are not intended to be limiting. It is readily understood that the processes shown in the above drawings do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0159] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0160] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A flow shaping method based on counting cycle optimization, characterized in that, Includes the following steps: Starting from the baseline value, candidate counting cycle values ​​are generated sequentially and incrementally. For each candidate counting cycle value... Perform the following steps respectively and steps The shaping error corresponding to the candidate counting period value N and the candidate counting period value are obtained. The number of multipliers required for computation is increased by adding the execution token; The baseline value is the scheduling period; Step A: Calculate the shaping error , The following conditions must be met: ; ; ; in, This is the actual number of tokens that can be added; This is the theoretical number of tokens that should be added; For the configured shaping rate, For licensing value, Main frequency, To round down; Step B: Determine whether adding the execution token can reduce the number of multipliers. when When it is determined that the operation of multiplying by the candidate counting period value N and dividing by the main frequency F can be replaced by a right shift operation of M bits, the required number of multipliers is one; The candidate counting period value N that simultaneously satisfies the first condition and the second condition is determined as the optimal counting period; wherein the first condition is... The second condition is that the number of multipliers is one, and the value is less than or equal to a preset precision threshold. According to the optimal counting period, a multiplier is used to perform token addition calculation and add tokens to the token bucket.

2. The method according to claim 1, characterized in that, The step of generating candidate counting cycle values ​​sequentially, starting from the baseline value, includes: Starting from the reference value, the candidate counting cycle value is incremented one by one in a clock cycle.

3. The method according to claim 1, characterized in that, Step B further includes: when At that time, determine the multiplication by the candidate counting period value. Divide by the clock speed The operation still requires a multiplier, and two multipliers are needed.

4. The method according to claim 1, characterized in that, The step of performing token addition calculations using a multiplier according to the optimal counting period includes: The configured shaping rate With the aforementioned authorized value Multiply them to get the first product; Shift the first product right by M bits to obtain the number of tokens to be added; Add the number of tokens to be added to the token bucket.

5. The method according to claim 1, characterized in that, The preset accuracy threshold is one in a thousand.

6. The method according to claim 1, characterized in that, At the main frequency The scheduling period is 32 clock cycles, and the authorized value... Under the condition that the optimal counting period is ,and .

7. The method according to claim 6, characterized in that, 。 8. The method according to claim 1, characterized in that, The scheduling cycle is 32 clock cycles.

9. The method according to claim 1, characterized in that, The authorized value The following conditions must be met: ; in, To achieve the maximum shaping rate, The scheduling period is... Main frequency, This is for rounding up.

10. A flow shaping system based on counting cycle optimization, characterized in that, include: The candidate counting cycle value generation module is used to generate candidate counting cycle values ​​sequentially, starting from a baseline value. For each candidate counting cycle value... Perform the following steps respectively and steps The shaping error corresponding to the candidate counting period value N and the number of multipliers required to perform token addition calculation under the candidate counting period value N are obtained. The baseline value is the scheduling period; Step A: Calculate the shaping error , The following conditions must be met: ; ; ; in, This is the actual number of tokens that can be added; This is the theoretical number of tokens that should be added; For the configured shaping rate, For licensing value, Main frequency, To round down; Step B: Determine whether adding the execution token can reduce the number of multipliers. when When it is determined that the operation of multiplying by the candidate counting period value N and dividing by the main frequency F can be replaced by a right shift operation of M bits, the required number of multipliers is one; The target counting cycle value generation module is used to determine the candidate counting cycle value N that simultaneously satisfies the first condition and the second condition as the optimal counting cycle; wherein the first condition is... The second condition is that the number of multipliers is one, and the value is less than or equal to a preset precision threshold. The token addition module is used to perform token addition calculations using a multiplier according to the optimal counting period and add tokens to the token bucket.