Flow measurement method, device and equipment
By using reference color results in traffic measurement to determine the fast color results of the message and delaying the Meter operation, the problem of high access pressure brought by Meter operation to the storage media is solved, and more efficient bandwidth utilization is achieved.
Patent Information
- Application Number
- CN202510312644.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-06-17
AI Technical Summary
In the prior art, Meter operation brings greater access pressure to the storage medium, resulting in the bandwidth indicator of the storage medium becoming a bottleneck in chip design.
By determining the fast color result of each message in the same traffic group based on the reference color result of the current traffic group, and alternately performing write and read operations, the Meter operation of the token bucket is delayed, and the access frequency of storage media is reduced.
It effectively reduces the access bandwidth to storage media, reduces the pressure on storage media by Meter operations, and provides twice the access bandwidth of Meter operations under the same process, avoiding bandwidth indicators becoming a bottleneck in chip design.
Smart Images

Figure CN120166076A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of packet switching technology, and particularly relates to a traffic measurement method, device, and equipment. Background Art
[0002] Meter is an operation for measuring the rate of traffic, which is implemented through the token bucket technology. In existing traffic measurement schemes, a Meter operation is performed on each packet in a traffic group, and the color result of the packet is determined based on information such as the number of bytes of the packet and the number of tokens in the token bucket, so that subsequent modules can perform operations such as releasing, discarding, and caching the current packet according to the color result of the packet. Since each Meter operation requires RMW (Read-Modify-Write) on the storage medium (usually SRAM) storing the token bucket information, in the design of a large-bandwidth switching chip, the Meter operation will bring a large access pressure to the relevant storage medium, and even cause the bandwidth index of the relevant storage medium to become the bottleneck of the chip design. If more advanced process technologies are used to improve the performance of the relevant storage medium, huge chip fabrication costs and supply chain security risks will be incurred. Summary of the Invention
[0003] This application provides a traffic measurement method, device, and equipment, which can solve the technical problem in the prior art that the Meter operation brings a large access pressure to the relevant storage medium, resulting in the bandwidth index of the relevant storage medium becoming the bottleneck of the chip design.
[0004] In a first aspect, an embodiment of this application provides a traffic measurement method, and the traffic measurement method includes:
[0005] For each packet in the same traffic group, determine the quick color result of the current packet according to the reference color result of the current traffic group;
[0006] For each packet in the same traffic group, alternately perform a first operation and a second operation. The first operation includes: writing the quick color result and the number of bytes of the current packet into a first storage medium. The second operation includes: reading the quick color result and the number of bytes of the previous packet of the current traffic group from the first storage medium, and adding them together with the quick color result and the number of bytes of the current packet as a task of the current traffic group to a task queue;
[0007] Take out tasks from the task queue according to the first-in, first-out principle, update the token bucket information of the corresponding traffic group in the second storage medium according to the quick color result and the number of bytes carried by the tasks, and update the reference color result of the current traffic group according to the updated token bucket information.
[0008] Further, in one embodiment, after the step of determining the fast color result of the current message according to the reference color result of the current traffic group, the following steps are also included:
[0009] If the debit flag of the current traffic group is the first value, set the debit flag to the second value; otherwise, set the debit flag to the first value.
[0010] The step of alternately performing the first operation and the second operation includes:
[0011] If the debit flag of the current traffic group is the first value, perform the first operation; otherwise, perform the second operation.
[0012] Further, in one embodiment, when the color-sensitive mode is adopted, the step of determining the fast color result of the current message according to the reference color result of the current traffic group includes:
[0013] If both the reference color result of the current traffic group and the preset color result of the current message are green, the fast color result of the current message is green;
[0014] If the reference color result of the current traffic group is green and the preset color result of the current message is yellow, the fast color result of the current message is yellow;
[0015] If the reference color result of the current traffic group is yellow and the preset color result of the current message is green, the fast color result of the current message is yellow;
[0016] If the reference color result of the current traffic group or the preset color result of the current message is red, the fast color result of the current message is red.
[0017] Further, in one embodiment, when the color-blind mode is adopted, the step of determining the fast color result of the current message according to the reference color result of the current traffic group includes:
[0018] Take the reference color result of the current traffic group as the fast color result of the current message.
[0019] Further, in one embodiment, when the token bucket adopts a single-rate two-color model, the steps of updating the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and the number of bytes carried by the task, and updating the reference color result of the current traffic group according to the updated token bucket information include:
[0020] If the first fast color result is green, assign the first deduction value to the first number of bytes; if the first fast color result is red, assign the first deduction value to zero; wherein, the first fast color result and the first number of bytes are the fast color result and the number of bytes of one of the messages carried by the task;
[0021] If the second fast color result is green, add the second byte count to the first deduction value; if the second fast color result is red, the first deduction value remains unchanged; wherein, the second fast color result and the second byte count are the fast color result and the byte count of another message carried by the task.
[0022] Subtract the first deduction value from the token count of bucket C of the traffic group corresponding to the task in the second storage medium.
[0023] If the updated token count of bucket C is greater than or equal to the first threshold, update the reference color result of the current traffic group to green.
[0024] If the updated token count of bucket C is less than the first threshold, update the reference color result of the current traffic group to red.
[0025] Further, in one embodiment, when the token bucket adopts a single-rate three-color model, the steps of updating the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and the byte count carried by the task, and updating the reference color result of the current traffic group according to the updated token bucket information include:
[0026] If the first fast color result is green, assign the second deduction value to the first byte count and assign the third deduction value to zero; if the first fast color result is yellow, assign the second deduction value to zero and assign the third deduction value to the first byte count; if the first fast color result is red, assign the second deduction value and the third deduction value to zero; wherein, the first fast color result and the first byte count are the fast color result and the byte count of one of the messages carried by the task.
[0027] If the second fast color result is green, add the second byte count to the second deduction value and the third deduction value remains unchanged; if the second fast color result is yellow, the second deduction value remains unchanged and add the second byte count to the third deduction value; if the second fast color result is red, the second deduction value and the third deduction value remain unchanged; wherein, the second fast color result and the second byte count are the fast color result and the byte count of another message carried by the task.
[0028] Subtract the second deduction value from the token count of bucket C of the traffic group corresponding to the task in the second storage medium, and subtract the third deduction value from the token count of bucket E.
[0029] If the updated token count of bucket C is greater than or equal to the second threshold, update the reference color result of the current traffic group to green.
[0030] If the updated token count of bucket C is less than the second threshold and the token count of bucket E is greater than or equal to the third threshold, update the reference color result of the current traffic group to yellow.
[0031] If the number of tokens in bucket C after update is less than the second threshold and the number of tokens in bucket E is less than the third threshold, update the reference color result of the current traffic group to red.
[0032] Further, in an embodiment, when the token bucket adopts a two-rate three-color model, the steps of updating the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and the number of bytes carried by the task, and updating the reference color result of the current traffic group according to the updated token bucket information include:
[0033] If the first fast color result is green, assign the fourth deduction value and the fifth deduction value to the first number of bytes; if the first fast color result is yellow, assign the fourth deduction value to zero and the fifth deduction value to the first number of bytes; if the first fast color result is red, assign the fourth deduction value and the fifth deduction value to zero; wherein, the first fast color result and the first number of bytes are the fast color result and the number of bytes of one of the packets carried by the task.
[0034] If the second fast color result is green, add the second number of bytes to the fourth deduction value and the fifth deduction value; if the second fast color result is yellow, keep the fourth deduction value unchanged and add the second number of bytes to the fifth deduction value; if the second fast color result is red, keep the fourth deduction value and the fifth deduction value unchanged; wherein, the second fast color result and the second number of bytes are the fast color result and the number of bytes of the other packet carried by the task.
[0035] Subtract the fourth deduction value from the number of tokens in bucket C of the traffic group corresponding to the task in the second storage medium, and subtract the fifth deduction value from the number of tokens in bucket P.
[0036] If the number of tokens in bucket C after update is greater than or equal to the fourth threshold and the number of tokens in bucket P is greater than or equal to the fifth threshold, update the reference color result of the current traffic group to green.
[0037] If the number of tokens in bucket C after update is less than the fourth threshold and the number of tokens in bucket P is greater than or equal to the fifth threshold, update the reference color result of the current traffic group to yellow.
[0038] If the number of tokens in bucket P after update is less than the fifth threshold, update the reference color result of the current traffic group to red.
[0039] Further, in an embodiment, the initial reference color result is green.
[0040] In a second aspect, an embodiment of the present application further provides a traffic measurement device, and the traffic measurement device includes:
[0041] A quick response module, which is used to determine the quick color result of each message in the same traffic group according to the benchmark color result of the current traffic group;
[0042] A correction module, which is used to alternately perform a first operation and a second operation for each message in the same traffic group. The first operation includes: writing the quick color result and byte count of the current message into a first storage medium. The second operation includes: reading the quick color result and byte count of the previous message of the current traffic group from the first storage medium, and taking them together with the quick color result and byte count of the current message as a task of the current traffic group and adding it to a task queue;
[0043] A Meter counting module, which is used to take tasks from the task queue according to the principle of first in first out, update the token bucket information of the corresponding traffic group in a second storage medium according to the quick color result and byte count carried by the tasks, and update the benchmark color result of the current traffic group according to the updated token bucket information.
[0044] In a third aspect, an embodiment of the present application further provides a traffic measurement device, which includes a processor, a memory, and a traffic measurement program stored on the memory and executable by the processor. When the traffic measurement program is executed by the processor, the steps of the above traffic measurement method are implemented.
[0045] In the present application, for the same traffic group, the quick color result of each message is determined according to the benchmark color result, and the byte count of the message and the token bucket information do not need to be used. The token bucket information and the benchmark color result are updated according to the quick color results and byte counts of two adjacent messages. In this way, it is ensured that the number of tokens deducted from the token bucket is consistent with the actual way of processing messages, but the deduction operation is delayed a little. According to the level of the deducted token quantity, the way of how to process messages in the next period of time is determined in advance. Through the present application, only one Meter operation is performed for every two replied messages, the access bandwidth to the second storage medium is reduced to half of that of the relevant storage medium in the existing solution, and the accuracy of traffic measurement can be ensured. Under the condition of the same process technology, the access bandwidth for twice the Meter operation can be provided, avoiding the bandwidth index from becoming a bottleneck in chip design. Description of the Drawings
[0046] Figure 1 It is a schematic flowchart of a traffic measurement method in an embodiment of the present application;
[0047] Figure 2 It is a schematic flowchart of the update of the token bucket information and the benchmark color result when the token bucket adopts a single-rate two-color model;
[0048] Figure 3Schematic diagram of the update process of token bucket information and reference color results when the token bucket adopts the single-rate three-color model;
[0049] Figure 4 Schematic diagram of the update process of token bucket information and reference color results when the token bucket adopts the dual-rate three-color model;
[0050] Figure 5 Schematic diagram of the functional modules of the traffic measurement device in an embodiment of the present application;
[0051] Figure 6 Schematic diagram of the hardware structure of the traffic measurement device involved in the solution of the embodiment of the present application. Detailed implementation manners
[0052] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0053] To make the purpose, technical solution and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0054] In a first aspect, an embodiment of the present application provides a traffic measurement method.
[0055] Figure 1 The flowchart of the traffic measurement method in an embodiment of the present application is shown.
[0056] Refer to Figure 1 , in an embodiment, the traffic measurement method includes the following steps:
[0057] S1. For each packet in the same traffic group, determine the fast color result of the current packet according to the reference color result of the current traffic group.
[0058] In the prior art, the color result of a packet is determined according to information such as the number of bytes of the packet and the number of tokens in the token bucket. In this embodiment, the determination of the fast color result does not require the use of the number of bytes of the packet and the token bucket information, but uses the reference color result, without accessing the storage medium storing the token bucket information. The subsequent module processes the current packet according to the color result of the packet, for example, releases the green and yellow packets, and discards or caches the red packets.
[0059] It can be understood that since each traffic group uses its own token bucket to perform message statistics, the baseline color results of each traffic group are also independent of each other.
[0060] S2. For each message in the same traffic group, alternately perform a first operation and a second operation, wherein the first operation includes: writing the fast color result and the number of bytes of the current message into a first storage medium, and the second operation includes: reading the fast color result and the number of bytes of the previous message of the current traffic group from the first storage medium, and adding the fast color result and the number of bytes together with the fast color result and the number of bytes of the current message as a task of the current traffic group to the task queue.
[0061] Specifically, for every two adjacent messages of the same traffic group, the fast color result and byte count of the first message will be written to the first storage medium and read after the second message arrives. The fast color results and byte count of the two messages are added to the task queue as a task of the current traffic group.
[0062] The task queue uses FIFO.
[0063] S3. Take out the task from the task queue according to the first-in-first-out principle, update the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and number of bytes carried by the task, and update the baseline color result of the current traffic group according to the updated token bucket information.
[0064] Specifically, in step S1, the color result is returned to the message, but the Meter operation is not performed to update the token bucket information. In step S3, the Meter operation is performed on two messages as a group, so that the updated token bucket information is consistent with the token bucket information that should be there after the color result is returned to the second message. After the token bucket information is updated, the benchmark color result of the corresponding traffic group is updated according to the token bucket information.
[0065] For example, when the baseline color result is updated, the number of tokens is insufficient, the baseline color result is updated to red, and no messages of the traffic group are released before the next update of the baseline color result. The number of tokens will continue to accumulate. When the baseline color result is updated next time, the number of tokens is sufficient, the baseline color result is updated to green, and some or all messages of the traffic group (depending on whether the color-sensitive mode is turned on) are released before the next update of the baseline color result.
[0066] In the processing flow of the existing scheme, each time a message is responded to, at most one read operation and one write operation are required on the relevant storage medium storing the token bucket information (equivalent to the second storage medium of this embodiment), and the ratio of the number of read and write operations to the number of responses is approximately equal to 2, that is, the token bucket information is read for calculation, and the calculated new token bucket information is written.
[0067] In the processing flow of this embodiment, for every two messages replied, one read operation and one write operation need to be performed on the first storage medium, and at most one read operation and one write operation need to be performed on the second storage medium. The ratio of the number of read and write operations to the number of replied messages is approximately equal to 1. Therefore, in this embodiment, the access pressure on the relevant storage medium in the existing solution is evenly distributed to the first storage medium and the second storage medium, and the access bandwidth for the second storage medium is reduced to half of that of the relevant storage medium in the existing solution.
[0068] It should be noted that taking more than two messages as a group for one Meter operation can further reduce the access bandwidth for the second storage medium. However, in this embodiment, only two messages are taken as a group, and the reasons are as follows:
[0069] Taking four messages as a group as an example, for the second storage medium, according to the quick color results and byte counts of the four messages, the token bucket information of the corresponding traffic group in the second storage medium is updated. For every four messages replied, at most one read operation and one write operation need to be performed on the second storage medium. The ratio of the number of read and write operations to the number of replied messages is approximately equal to 1 / 2, and the access bandwidth is lower than that of the second storage medium in this embodiment.
[0070] However, for the first storage medium, one possible solution is that when processing the first message, directly write the corresponding quick color result and byte count, that is, perform one write operation. When processing the second and third messages, it is necessary to first read the previously written content, and then accumulate it with the quick color result and byte count to be written, and overwrite the read content with the accumulated result, that is, perform one read operation and one write operation. When processing the fourth message, directly read the previously written content, that is, perform one read operation. In this solution, for every four messages replied, three read operations and three write operations need to be performed on the first storage medium. The ratio of the number of read and write operations to the number of replied messages is approximately equal to 3 / 2, and the average access bandwidth is higher than that of the second storage medium in this embodiment. The access bandwidth will also surge when processing the second and third messages.
[0071] Another possible solution is that when processing the first, second, and third messages, write the corresponding quick color results and byte counts to different locations, that is, perform one write operation. When processing the fourth message, sequentially read the content written in the previous three times, that is, perform three read operations. In this solution, for every four messages replied, three read operations and three write operations also need to be performed on the first storage medium. The ratio of the number of read and write operations to the number of replied messages is approximately equal to 3 / 2, and the average access bandwidth is higher than that of the second storage medium in this embodiment. The access bandwidth will also surge when processing the fourth message.
[0072] It can be seen that when more than two packets are grouped together, the access bandwidth of the first storage medium is higher than that of the second storage medium in this embodiment, and the bandwidth index of the first storage medium will become a bottleneck in chip design. In addition, the ratio of the number of Meter operations to the number of packets decreases, which also leads to a decrease in the accuracy of traffic measurement.
[0073] Therefore, after comprehensive consideration and hardware testing, it is finally decided to set the solution to the form of grouping two packets in this embodiment, which can make full use of the access bandwidth provided by the first storage medium and the second storage medium.
[0074] Thus, in this embodiment, for the same traffic group, the quick color result of each packet is determined according to the reference color result, and the byte number of the packet and the token bucket information are not required. The token bucket information and the reference color result are updated according to the quick color results and byte numbers of two adjacent packets. In this way, it is ensured that the number of tokens deducted from the token bucket is consistent with the actual way of processing packets, except that the deduction operation is delayed a little. According to the level of the deducted token number, how to process packets in the next period of time is determined in advance. Through this embodiment, only one Meter operation is performed for every two packets answered, and the access bandwidth to the second storage medium is reduced to half of that of the relevant storage medium in the existing solution, and the accuracy of traffic measurement can be ensured. Under the condition of the same process technology, the access bandwidth for twice the Meter operation can be provided, avoiding the bandwidth index becoming a bottleneck in chip design.
[0075] Further, in one embodiment, after the step of determining the quick color result of the current packet according to the reference color result of the current traffic group, the following steps are also included:
[0076] If the debit flag of the current traffic group is the first value, set the debit flag to the second value; otherwise, set the debit flag to the first value.
[0077] The step of alternately performing the first operation and the second operation includes:
[0078] If the debit flag of the current traffic group is the first value, perform the first operation; otherwise, perform the second operation.
[0079] In this embodiment, by flipping and detecting the debit flag, it is determined whether to perform the first operation or the second operation, ensuring the orderly alternation of the first operation and the second operation.
[0080] Exemplarily, the debit flag is a boolean variable, the first value is 0, and the second value is 1.
[0081] Of course, in other embodiments, there are other ways to achieve alternation. For example, add a sequence number to the packet, perform the first operation on the packet with an odd sequence number, and perform the second operation on the packet with an even sequence number.
[0082] Further, in one embodiment, when the color-sensitive mode is adopted, the step of determining the fast color result of the current message according to the reference color result of the current traffic group includes:
[0083] If both the reference color result of the current traffic group and the preset color result of the current message are green, the fast color result of the current message is green;
[0084] If the reference color result of the current traffic group is green and the preset color result of the current message is yellow, the fast color result of the current message is yellow;
[0085] If the reference color result of the current traffic group is yellow and the preset color result of the current message is green, the fast color result of the current message is yellow;
[0086] If the reference color result of the current traffic group or the preset color result of the current message is red, the fast color result of the current message is red.
[0087] Specifically, the preset color result of the current message may be the color set during message assembly or the color result returned by the upstream traffic measurement device.
[0088] In the color-sensitive mode, it is necessary to comprehensively consider the reference color result of the current traffic group and the preset color result of the current message to determine the fast color result of the current message. The basic idea is consistent with the existing solution, that is, the priority of the color result returned to the message is not higher than the preset color result, and the priorities of red, yellow, and green increase in turn.
[0089] Further, in one embodiment, when the color-blind mode is adopted, the step of determining the fast color result of the current message according to the reference color result of the current traffic group includes:
[0090] Take the reference color result of the current traffic group as the fast color result of the current message.
[0091] In the color-blind mode, it is not necessary to refer to the preset color result of the current message, and directly return the reference color result of the current traffic group.
[0092] Further, in one embodiment, when the token bucket adopts the single-rate two-color model, the step of updating the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and the number of bytes carried by the task, and updating the reference color result of the current traffic group according to the updated token bucket information includes:
[0093] If the first fast color result is green, assign the first deduction value to the first number of bytes; if the first fast color result is red, assign the first deduction value to zero; where the first fast color result and the first number of bytes are the fast color result and the number of bytes of one of the packets carried by the task.
[0094] If the second fast color result is green, add the second number of bytes to the first deduction value; if the second fast color result is red, the first deduction value remains unchanged; where the second fast color result and the second number of bytes are the fast color result and the number of bytes of the other packet carried by the task.
[0095] Subtract the first deduction value from the number of tokens in the C bucket of the traffic group corresponding to the task in the second storage medium.
[0096] If the number of tokens in the C bucket after update is greater than or equal to the first threshold, update the reference color result of the current traffic group to green.
[0097] If the number of tokens in the C bucket after update is less than the first threshold, update the reference color result of the current traffic group to red.
[0098] In the prior art, the single-rate two-color model is also called the single-speed single-bucket model. The CIR (Committed Information Rate) represents the rate at which tokens are put into the C bucket, that is, the average rate at which the C bucket allows packets to be transmitted or forwarded. The CBS (Committed Burst Size) represents the capacity of the C bucket, that is, the committed burst traffic that the C bucket can pass through instantaneously. Tc represents the number of tokens in the C bucket. If Tc < CBS, then Tc increases, otherwise it does not increase. For the arriving packets, let B represent the size of the packet. In the color-blind mode, if B ≤ Tc, the packet is marked as green and Tc is reduced by B; if B > Tc, the packet is marked as red and Tc is not reduced.
[0099] Figure 2 Shows a schematic diagram of the update process of the token bucket information and the reference color result when the token bucket adopts the single-rate two-color model.
[0100] Refer to Figure 2 , Color1 represents the first fast color result, Byte1 represents the first number of bytes, Color2 represents the second fast color result, Byte2 represents the second number of bytes, State represents the reference color result, X1 represents the first deduction value, and Y1 represents the first threshold.
[0101] Optionally, Y1 = 0.
[0102] Specifically, the first quick color result and the first number of bytes are the quick color result and the number of bytes of the first message carried by the task, and the second quick color result and the second number of bytes are the quick color result and the number of bytes of the second message carried by the task. Alternatively, the first quick color result and the first number of bytes are the quick color result and the number of bytes of the second message carried by the task, and the second quick color result and the second number of bytes are the quick color result and the number of bytes of the first message carried by the task.
[0103] Further, in one embodiment, when the token bucket adopts a single-rate three-color model, the step of updating the token bucket information of the corresponding traffic group in the second storage medium according to the quick color result and the number of bytes carried by the task, and updating the reference color result of the current traffic group according to the updated token bucket information includes:
[0104] If the first quick color result is green, assign the second deduction value to the first number of bytes and assign the third deduction value to zero; if the first quick color result is yellow, assign the second deduction value to zero and assign the third deduction value to the first number of bytes; if the first quick color result is red, assign the second deduction value and the third deduction value to zero; wherein, the first quick color result and the first number of bytes are the quick color result and the number of bytes of one of the messages carried by the task;
[0105] If the second quick color result is green, add the second number of bytes to the second deduction value and keep the third deduction value unchanged; if the second quick color result is yellow, keep the second deduction value unchanged and add the second number of bytes to the third deduction value; if the second quick color result is red, keep the second deduction value and the third deduction value unchanged; wherein, the second quick color result and the second number of bytes are the quick color result and the number of bytes of the other message carried by the task;
[0106] Subtract the second deduction value from the token quantity of the C bucket and subtract the third deduction value from the token quantity of the E bucket of the traffic group corresponding to the task in the second storage medium;
[0107] If the token quantity of the C bucket after update is greater than or equal to the second threshold, update the reference color result of the current traffic group to green;
[0108] If the token quantity of the C bucket after update is less than the second threshold and the token quantity of the E bucket is greater than or equal to the third threshold, update the reference color result of the current traffic group to yellow;
[0109] If the token quantity of the C bucket after update is less than the second threshold and the token quantity of the E bucket is less than the third threshold, update the reference color result of the current traffic group to red.
[0110] In the prior art, the single-rate three-color model is also known as the single-speed two-bucket model. The CIR (Committed Information Rate) represents the rate at which tokens are put into bucket C, that is, the average rate at which bucket C allows packets to be transmitted or forwarded. The CBS (Committed Burst Size) represents the capacity of bucket C, that is, the committed burst traffic that bucket C can instantaneously pass through. The EBS (Excess Burst Size) represents the capacity of bucket E, that is, the excess burst traffic that bucket E can instantaneously pass through. Tc represents the number of tokens in bucket C, and Te represents the number of tokens in bucket E. If Tc < CBS, then Tc increases. If Tc = CBS and Te < EBS, then Te increases. If Tc = CBS and Te = EBS, then neither increases. For the arriving packets, let B represent the size of the packet. In the color-blind mode, if B ≤ Tc, the packet is marked green, and Tc is decreased by B. If Tc < B ≤ Te, the packet is marked yellow, Tc is not decreased, and Te is decreased by B. If B > Te, the packet is marked red, and neither Tc nor Te is decreased.
[0111] Figure 3 It is a schematic diagram of the update process of token bucket information and reference color results when the token bucket adopts the single-rate three-color model.
[0112] Refer to Figure 3 , Color1 represents the first fast color result, Byte1 represents the first number of bytes, Color2 represents the second fast color result, Byte2 represents the second number of bytes, State represents the reference color result, X2 represents the second deduction value, X3 represents the third deduction value, Y2 represents the second threshold, and Y3 represents the third threshold.
[0113] Optionally, Y2 = Y3 = 0.
[0114] Furthermore, in an embodiment, when the token bucket adopts the dual-rate three-color model, the step of updating the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and the number of bytes carried by the task, and updating the reference color result of the current traffic group according to the updated token bucket information includes:
[0115] If the first fast color result is green, then assign the fourth deduction value and the fifth deduction value to the first number of bytes; if the first fast color result is yellow, then assign the fourth deduction value to zero and the fifth deduction value to the first number of bytes; if the first fast color result is red, then assign the fourth deduction value and the fifth deduction value to zero; where the first fast color result and the first number of bytes are the fast color result and the number of bytes of one of the packets carried by the task;
[0116] If the second quick color result is green, add the fourth deduction value and the fifth deduction value to the second byte count; if the second quick color result is yellow, keep the fourth deduction value unchanged and add the fifth deduction value to the second byte count; if the second quick color result is red, keep the fourth deduction value and the fifth deduction value unchanged; where the second quick color result and the second byte count are the quick color result and the byte count of another message carried by the task.
[0117] Subtract the fourth deduction value from the token count of bucket C in the traffic group corresponding to the task in the second storage medium, and subtract the fifth deduction value from the token count of bucket P.
[0118] If the updated token count of bucket C is greater than or equal to the fourth threshold and the token count of bucket P is greater than or equal to the fifth threshold, update the reference color result of the current traffic group to green.
[0119] If the updated token count of bucket C is less than the fourth threshold and the token count of bucket P is greater than or equal to the fifth threshold, update the reference color result of the current traffic group to yellow.
[0120] If the updated token count of bucket P is less than the fifth threshold, update the reference color result of the current traffic group to red.
[0121] In the prior art, the two-rate three-color model is also known as the two-speed two-bucket model. PIR (Peak Information Rate) represents the rate at which tokens are put into bucket P, that is, the peak rate at which bucket P allows messages to be transmitted or forwarded. CIR (Committed Information Rate) represents the rate at which tokens are put into bucket C, that is, the average rate at which bucket C allows messages to be transmitted or forwarded. PIR is greater than CIR. PBS (Peak Burst Size) represents the capacity of bucket P, that is, the peak burst traffic that bucket P can pass through instantaneously. CBS (Committed Burst Size) represents the capacity of bucket C, that is, the committed burst traffic that bucket C can pass through instantaneously. Tp represents the token count in bucket P, and Tc represents the token count in bucket C. If Tp < PBS, then Tp increases, otherwise Tp does not increase. If Tc < CBS, then Tc increases, otherwise Tc does not increase. For the arriving message, let B represent the size of the message. In the color-blind mode, if B ≤ Tp and B ≤ Tc, the message is marked as green, and both Tp and Tc are reduced by B. If Tc < B ≤ Tp, the message is marked as yellow, Tc is not reduced, and Tp is reduced by B. If B > Tp, the message is marked as red, and neither Tc nor Tp is reduced.
[0122] Figure 4 It is a schematic diagram of the update process of the token bucket information and the reference color result when the token bucket adopts the two-rate three-color model.
[0123] Refer to Figure 4, Color1 represents the first fast color result, Byte1 represents the first number of bytes, Color2 represents the second fast color result, Byte2 represents the second number of bytes, State represents the reference color result, X4 represents the fourth deduction value, X5 represents the fifth deduction value, Y4 represents the fourth threshold, and Y5 represents the fifth threshold.
[0124] Optionally, Y4 = Y5 = 0.
[0125] Furthermore, in one embodiment, the initial reference color result is green.
[0126] In this embodiment, before updating the reference color result through the token bucket information, the default reference color result is green, and the packet is released.
[0127] In a second aspect, an embodiment of the present application further provides a traffic measurement device.
[0128] Figure 5 The schematic diagram of the functional modules of the traffic measurement device in an embodiment of the present application is shown.
[0129] Referring to Figure 5 , in one embodiment, the traffic measurement device includes:
[0130] A fast response module, configured to determine the fast color result of the current packet according to the reference color result of the current traffic group for each packet in the same traffic group;
[0131] A correction module, configured to alternately perform a first operation and a second operation for each packet in the same traffic group. The first operation includes: writing the fast color result and the number of bytes of the current packet into the first storage medium. The second operation includes: reading the fast color result and the number of bytes of the previous packet of the current traffic group from the first storage medium, and adding them together with the fast color result and the number of bytes of the current packet as a task of the current traffic group to the task queue;
[0132] A Meter counting module, configured to take out tasks from the task queue according to the first-in first-out principle, update the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and the number of bytes carried by the tasks, and update the reference color result of the current traffic group according to the updated token bucket information.
[0133] Figure 5 In eng / 2 rate to take out tasks for Meter operations, the fast response module returns fast color results to the packets at a rate of R eng , the packets initiate Meter requests at a rate of R lookup , R lookup ≤R eng .
[0134] Further, in one embodiment, after the fast response module determines the fast color result of the current message according to the reference color result of the current traffic group, if the debit flag of the current traffic group is the first value, the debit flag is set to the second value; otherwise, the debit flag is set to the first value.
[0135] The Mete counting module is used to perform a first operation if the debit flag of the current traffic group is the first value, and perform a second operation otherwise.
[0136] Further, in one embodiment, when the color-sensitive mode is adopted, the fast response module is used for:
[0137] If both the reference color result of the current traffic group and the preset color result of the current message are green, the fast color result of the current message is green;
[0138] If the reference color result of the current traffic group is green and the preset color result of the current message is yellow, the fast color result of the current message is yellow;
[0139] If the reference color result of the current traffic group is yellow and the preset color result of the current message is green, the fast color result of the current message is yellow;
[0140] If the reference color result of the current traffic group or the preset color result of the current message is red, the fast color result of the current message is red.
[0141] Further, in one embodiment, when the color-blind mode is adopted, the fast response module is used for:
[0142] Taking the reference color result of the current traffic group as the fast color result of the current message.
[0143] Further, in one embodiment, when the token bucket adopts the single-rate two-color model, the Meter calculation module is used for:
[0144] If the first fast color result is green, assign the first deduction value to the first number of bytes; if the first fast color result is red, assign the first deduction value to zero; wherein, the first fast color result and the first number of bytes are the fast color result and the number of bytes of one of the messages carried by the task;
[0145] If the second fast color result is green, add the second number of bytes to the first deduction value; if the second fast color result is red, the first deduction value remains unchanged; wherein, the second fast color result and the second number of bytes are the fast color result and the number of bytes of the other message carried by the task;
[0146] Subtract the first deduction value from the token quantity of the C bucket of the traffic group corresponding to the task in the second storage medium;
[0147] If the number of tokens in bucket C after update is greater than or equal to the first threshold, update the reference color result of the current traffic group to green;
[0148] If the number of tokens in bucket C after update is less than the first threshold, update the reference color result of the current traffic group to red.
[0149] Further, in one embodiment, when the token bucket adopts the single-rate three-color model, the Meter calculation module is used for:
[0150] If the first fast color result is green, assign the second deduction value to the first byte count and assign the third deduction value to zero; if the first fast color result is yellow, assign the second deduction value to zero and assign the third deduction value to the first byte count; if the first fast color result is red, assign both the second deduction value and the third deduction value to zero; where the first fast color result and the first byte count are the fast color result and byte count of one of the packets carried by the task;
[0151] If the second fast color result is green, add the second byte count to the second deduction value and keep the third deduction value unchanged; if the second fast color result is yellow, keep the second deduction value unchanged and add the second byte count to the third deduction value; if the second fast color result is red, keep both the second deduction value and the third deduction value unchanged; where the second fast color result and the second byte count are the fast color result and byte count of the other packet carried by the task;
[0152] Subtract the second deduction value from the number of tokens in bucket C of the traffic group corresponding to the task in the second storage medium, and subtract the third deduction value from the number of tokens in bucket E.
[0153] If the number of tokens in bucket C after update is greater than or equal to the second threshold, update the reference color result of the current traffic group to green;
[0154] If the number of tokens in bucket C after update is less than the second threshold and the number of tokens in bucket E is greater than or equal to the third threshold, update the reference color result of the current traffic group to yellow;
[0155] If the number of tokens in bucket C after update is less than the second threshold and the number of tokens in bucket E is less than the third threshold, update the reference color result of the current traffic group to red.
[0156] Further, in one embodiment, when the token bucket adopts the dual-rate three-color model, the Meter calculation module is used for:
[0157] If the first fast color result is green, assign the fourth deduction value and the fifth deduction value to the first number of bytes; if the first fast color result is yellow, assign the fourth deduction value to zero and the fifth deduction value to the first number of bytes; if the first fast color result is red, assign the fourth deduction value and the fifth deduction value to zero; wherein, the first fast color result and the first number of bytes are the fast color result and the number of bytes of one of the packets carried by the task.
[0158] If the second fast color result is green, add the fourth deduction value and the fifth deduction value to the second number of bytes; if the second fast color result is yellow, keep the fourth deduction value unchanged and add the fifth deduction value to the second number of bytes; if the second fast color result is red, keep the fourth deduction value and the fifth deduction value unchanged; wherein, the second fast color result and the second number of bytes are the fast color result and the number of bytes of the other packet carried by the task.
[0159] Subtract the fourth deduction value from the number of tokens in the C bucket of the traffic group corresponding to the task in the second storage medium, and subtract the fifth deduction value from the number of tokens in the P bucket.
[0160] If the number of tokens in the updated C bucket is greater than or equal to the fourth threshold and the number of tokens in the P bucket is greater than or equal to the fifth threshold, update the reference color result of the current traffic group to green.
[0161] If the number of tokens in the updated C bucket is less than the fourth threshold and the number of tokens in the P bucket is greater than or equal to the fifth threshold, update the reference color result of the current traffic group to yellow.
[0162] If the number of tokens in the updated P bucket is less than the fifth threshold, update the reference color result of the current traffic group to red.
[0163] Further, in one embodiment, the initial reference color result is green.
[0164] Wherein, the functions of each module in the above traffic measurement device correspond to the steps in the above traffic measurement method embodiment, and their functions and implementation processes will not be elaborated here one by one.
[0165] In a third aspect, an embodiment of the present application provides a traffic measurement device, and the traffic measurement device may be a switch.
[0166] Figure 6 The hardware structure diagram of the traffic measurement device involved in the embodiment of the present application is shown.
[0167] Refer to Figure 6 In the embodiment of the present application, the traffic measurement device may include a processor, a memory, a communication interface, and a communication bus.
[0168] Among them, the communication bus can be of any type and is used to interconnect the processor, the memory, and the communication interface.
[0169] The communication interface includes input / output (I / O) interfaces, physical interfaces, and logical interfaces, etc., which are used to interconnect the components inside the flow measurement device, as well as interfaces for interconnecting the flow measurement device with other devices. The physical interface can be an Ethernet interface, a fiber optic interface, an ATM interface, etc.
[0170] The memory includes a first storage medium and a second storage medium, and the first storage medium and the second storage medium can be SRAM.
[0171] The processor can be a general-purpose processor, and the general-purpose processor can call the flow measurement program stored in the memory and execute the flow measurement method provided by the embodiments of the present application. For example, the general-purpose processor can be a central processing unit (CPU). Among them, the method executed when the flow measurement program is called can refer to the various embodiments of the flow measurement method of the present application, which will not be elaborated here.
[0172] Those skilled in the art can understand that Figure 6 the hardware structure shown in does not constitute a limitation to the present application, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0173] Among them, the method implemented when the flow measurement program is executed can refer to the various embodiments of the flow measurement method of the present application, which will not be elaborated here.
[0174] It should be noted that the serial numbers of the above embodiments of the present application are only for description and do not represent the superiority or inferiority of the embodiments.
[0175] The terms "including" and "having" and any variations thereof in the specification, claims, and drawings of the present application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes unlisted steps or units, or optionally further includes other steps or units inherent to these processes, methods, products, or devices. The descriptions of terms such as "first", "second", and "third" are used to distinguish different objects, etc., and do not represent a sequential order, nor do they limit that "first", "second", and "third" are of different types.
[0176] In the description of the embodiments of the present application, words such as "exemplary", "for example" or "for illustration purposes" are used to indicate examples, illustrations or explanations. Any embodiment or design solution described as "exemplary", "for example" or "for illustration purposes" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary", "for example" or "for illustration purposes" is intended to present relevant concepts in a specific manner.
[0177] In the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may mean A or B. The "and / or" in the text is merely a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B may mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality of" means two or more than two.
[0178] In some of the processes described in the embodiments of the present application, there are multiple operations or steps that appear in a specific order. However, it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or may be executed in parallel. The serial numbers of the operations are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in order or in parallel, and these operations or steps may be combined.
[0179] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) as described above and includes several instructions for causing a terminal device to execute the methods described in the various embodiments of the present application.
[0180] The above are only the preferred embodiments of the present application, and do not limit the patent scope of the present application accordingly. Any equivalent structure or equivalent process transformation made by using the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
Claims
1. A flow measurement method, characterized in that: The flow measurement method comprises: For each message in the same traffic group, a fast color result of the current message is determined according to the baseline color result of the current traffic group; For each message in the same traffic group, a first operation and a second operation are performed alternately, wherein the first operation includes: writing a fast color result and a byte count of a current message into a first storage medium, and the second operation includes: reading a fast color result and a byte count of a previous message of the current traffic group from the first storage medium, and adding the fast color result and the byte count of the previous message of the current traffic group together with the fast color result and the byte count of the current message into a task queue as a task of the current traffic group; Tasks are taken out from the task queue according to the first-in-first-out principle, the token bucket information of the corresponding traffic group in the second storage medium is updated according to the fast color result and number of bytes carried by the task, and the baseline color result of the current traffic group is updated according to the updated token bucket information.
2. The flow measurement method according to claim 1, characterized in that: After the step of determining the fast color result of the current message according to the benchmark color result of the current traffic group, the method further includes: If the debit flag of the current flow group is the first value, the debit flag is set to the second value, otherwise the debit flag is set to the first value; The step of alternately performing the first operation and the second operation comprises: If the debit flag of the current flow group is the first value, the first operation is performed, otherwise the second operation is performed.
3. The flow measurement method according to claim 1, characterized in that: When the color-sensitive mode is adopted, the step of determining the fast color result of the current message according to the reference color result of the current traffic group includes: If the baseline color result of the current traffic group and the preset color result of the current message are both green, the fast color result of the current message is green; If the baseline color result of the current traffic group is green and the preset color result of the current message is yellow, the fast color result of the current message is yellow; If the baseline color result of the current traffic group is yellow and the preset color result of the current message is green, the fast color result of the current message is yellow; If the baseline color result of the current traffic group or the preset color result of the current message is red, the fast color result of the current message is red.
4. The flow measurement method according to claim 1, characterized in that: When the color blind mode is adopted, the step of determining the fast color result of the current message according to the reference color result of the current traffic group includes: The baseline color result of the current traffic group is used as the fast color result of the current message.
5. The flow measurement method according to claim 1, characterized in that: When the token bucket adopts a single-rate two-color model, the token bucket information of the corresponding traffic group in the second storage medium is updated according to the fast color result and the number of bytes carried by the task, and the step of updating the benchmark color result of the current traffic group according to the updated token bucket information includes: If the first fast color result is green, the first deduction value is assigned to the first byte number; if the first fast color result is red, the first deduction value is assigned to zero; wherein the first fast color result and the first byte number are the fast color result and the byte number of one of the messages carried by the task; If the second fast color result is green, the first deduction value is added to the second byte number; if the second fast color result is red, the first deduction value remains unchanged; wherein the second fast color result and the second byte number are the fast color result and byte number of another message carried by the task; Subtract the first deduction value from the number of tokens in bucket C of the traffic group corresponding to the task in the second storage medium; If the number of tokens in bucket C after the update is greater than or equal to the first threshold, the baseline color result of the current traffic group is updated to green; If the number of tokens in bucket C after the update is less than the first threshold, the base color result of the current traffic group is updated to red.
6. The flow measurement method according to claim 1, characterized in that: When the token bucket adopts a single-rate three-color model, the token bucket information of the corresponding traffic group in the second storage medium is updated according to the fast color result and the number of bytes carried by the task, and the step of updating the benchmark color result of the current traffic group according to the updated token bucket information includes: If the first fast color result is green, the second deduction value is assigned to the first byte number, and the third deduction value is assigned to zero; if the first fast color result is yellow, the second deduction value is assigned to zero, and the third deduction value is assigned to the first byte number; if the first fast color result is red, the second deduction value and the third deduction value are assigned to zero; wherein the first fast color result and the first byte number are the fast color result and the byte number of one of the messages carried by the task; If the second fast color result is green, the second deduction value is added to the second byte number, and the third deduction value remains unchanged; if the second fast color result is yellow, the second deduction value remains unchanged, and the third deduction value is added to the second byte number; if the second fast color result is red, the second deduction value and the third deduction value remain unchanged; wherein the second fast color result and the second byte number are the fast color result and the byte number of another message carried by the task; The number of tokens in bucket C of the traffic group corresponding to the task in the second storage medium is subtracted from the second deduction value, and the number of tokens in bucket E is subtracted from the third deduction value; If the number of tokens in bucket C after the update is greater than or equal to the second threshold, the baseline color result of the current traffic group is updated to green; If the number of tokens in bucket C after the update is less than the second threshold, and the number of tokens in bucket E is greater than or equal to the third threshold, the base color result of the current traffic group is updated to yellow; If the number of tokens in bucket C after the update is less than the second threshold, and the number of tokens in bucket E is less than the third threshold, the baseline color result of the current traffic group is updated to red.
7. The flow measurement method according to claim 1, characterized in that: When the token bucket adopts the dual-rate three-color model, the token bucket information of the corresponding traffic group in the second storage medium is updated according to the fast color result and the number of bytes carried by the task, and the step of updating the benchmark color result of the current traffic group according to the updated token bucket information includes: If the first fast color result is green, the fourth deduction value and the fifth deduction value are assigned to the first byte number; if the first fast color result is yellow, the fourth deduction value is assigned to zero, and the fifth deduction value is assigned to the first byte number; if the first fast color result is red, the fourth deduction value and the fifth deduction value are assigned to zero; wherein the first fast color result and the first byte number are the fast color result and the byte number of one of the messages carried by the task; If the second fast color result is green, the fourth deduction value and the fifth deduction value are added to the second byte number; if the second fast color result is yellow, the fourth deduction value remains unchanged, and the fifth deduction value is added to the second byte number; if the second fast color result is red, the fourth deduction value and the fifth deduction value remain unchanged; wherein the second fast color result and the second byte number are the fast color result and the byte number of another message carried by the task; Subtract the fourth deduction value from the number of tokens in bucket C of the traffic group corresponding to the task in the second storage medium, and subtract the fifth deduction value from the number of tokens in bucket P; If the number of tokens in bucket C after the update is greater than or equal to the fourth threshold, and the number of tokens in bucket P is greater than or equal to the fifth threshold, the baseline color result of the current traffic group is updated to green; If the number of tokens in bucket C after the update is less than the fourth threshold, and the number of tokens in bucket P is greater than or equal to the fifth threshold, the base color result of the current traffic group is updated to yellow; If the number of tokens in the P bucket after the update is less than the fifth threshold, the base color result of the current traffic group is updated to red.
8. The flow measurement method according to any one of claims 1 to 7, characterized in that: The initial base color result is green.
9. A flow measurement device, characterized in that: The flow measurement device comprises: A fast response module, for determining a fast color result of a current message according to a reference color result of the current flow group for each message in the same flow group; The correction module is used to perform a first operation and a second operation alternately for each message in the same traffic group, wherein the first operation includes: writing a fast color result and a byte number of a current message into a first storage medium, and the second operation includes: reading a fast color result and a byte number of a previous message of the current traffic group from the first storage medium, and adding the fast color result and the byte number of the previous message of the current traffic group together with the fast color result and the byte number of the current message as a task of the current traffic group into a task queue; The meter counting module is used to take tasks from the task queue according to the first-in-first-out principle, update the token bucket information of the corresponding traffic group in the second storage medium according to the fast color result and number of bytes carried by the task, and update the baseline color result of the current traffic group according to the updated token bucket information.
10. A flow measurement device, characterized in that: The flow measurement device comprises a processor, a memory, and a flow measurement program stored in the memory and executable by the processor, wherein when the flow measurement program is executed by the processor, the steps of the flow measurement method according to any one of claims 1 to 8 are implemented.