A high-speed low-overhead traffic shaping method and apparatus

By using a multi-level time wheel storage structure and a shaping speed estimation module, the high CPU overhead and memory usage problems of high-concurrency flow and high-speed shaping in data center networks are solved, achieving accurate flow shaping and efficient memory utilization.

CN116366566BActive Publication Date: 2026-05-12XI AN JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XI AN JIAOTONG UNIV
Filing Date
2023-02-28
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing software traffic shaping algorithms suffer from high CPU overhead and memory consumption in data center networks, making it difficult to achieve accurate traffic shaping, especially under high-concurrency flow and high-speed shaping requirements.

Method used

The system employs a multi-level time wheel storage structure (MLTW). The enqueue module categorizes packets according to their shaping speed and stores them in a time wheel queue with matching granularity. The dequeue module efficiently searches for and sends packets, while the shaping speed estimation module adjusts the stream's shaping speed in real time, reducing CPU overhead and improving memory utilization.

Benefits of technology

It achieves accurate traffic shaping under high concurrency and high-speed shaping, reduces CPU overhead, improves memory utilization, and supports shaping speeds up to 98Gbps, which is 2.6 times faster than existing algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116366566B_ABST
    Figure CN116366566B_ABST
Patent Text Reader

Abstract

The application discloses a high-speed low-overhead traffic shaping method and device, which comprises the following steps: (1) an MLTW composed of multiple time wheels with exponentially increasing granularity is used to store the packets which have not reached the sending time; (2) when the packets arrive, an enqueuing module calculates the EDT of the packets, classifies the packets according to the destination IP, and obtains the shaping speed of the category from a shaping speed estimation module; the enqueuing module selects the storage position of the packets in the MLTW according to the shaping speed and the EDT of the packets, and enqueues the packets; (3) a dequeuing module accesses the MLTW at a certain frequency, and dequeues the packets in the MLTW which meet the sending conditions; after the packets are dequeued, the shaping speed is estimated, and then the packets are sent out by a network card; (4) a shaping speed estimation module estimates the shaping speed according to the packet information, and updates the shaping speed estimation information of the category to which the packets belong. The application can eliminate the internal burst of the flow, and realizes accurate traffic shaping.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of data center network technology, specifically relating to a high-speed, low-overhead traffic shaping method and apparatus. Background Technology

[0002] In data center networks, traffic shaping (or rate limiting / synchronization) is a crucial function of end hosts. For example, in cloud networks, a large number of network tenants and applications share network bandwidth, so cloud service providers need to use rate limiting to isolate network tenants and applications from each other. At the transport layer, congestion control also requires packet synchronization: on the one hand, most congestion control algorithms are speed-based, requiring fine-grained transmission speed adjustment capabilities; on the other hand, congestion control also needs to eliminate bursts through packet synchronization, because bursts can obscure congestion signals and may even lead to packet loss in small buffer switches.

[0003] Traffic shaping can be implemented in two ways: hardware and software. Hardware implementation offers faster processing speeds, while software implementation has two main advantages: first, it's more flexible in development and deployment because it doesn't require dedicated hardware and supports high-level programming languages, allowing for easy deployment on any host; second, it has access to more abundant resources such as memory, enabling support for more complex network mechanisms. Therefore, software implementations are more commonly used in network production compared to hardware implementations.

[0004] Historically, numerous software traffic shaping mechanisms have been proposed. Based on their core algorithmic ideas, current mainstream traffic shaping algorithms can be divided into two categories: 1. Token bucket-based models, such as the Token Bucket Filter (TBF) and Hierarchical Token Bucket (HTB); 2. Earliest Departure Time (EDT)-based models, such as the Fair Queue (FQ) and Carousel algorithms. The token bucket model has the advantage of being relatively simple in its mechanism, easy to implement, and having low computational overhead. However, when the number of concurrent flows in the system reaches tens of thousands, a large number of token buckets and queues need to be created, consuming significant memory. Group lookup and maintenance of related data structures also incur substantial CPU overhead. Therefore, it is not suitable for the complex network environments of high-speed, high-flow data centers.

[0005] Many advanced international flow shaping algorithms are based on the EDT model. The FQ algorithm uses red-black trees to manage packets and EDTs. However, when the number of flows is large and the shaping speed is high, frequent lookups, deletions, and rotations of red-black tree nodes can lead to significant CPU overhead. The Carousel algorithm uses a time wheel structure to shape flow. The time complexity of enqueueing and dequeueing operations of the time wheel is O(1), which is more efficient than red-black trees. However, the shaping accuracy of the Carousel algorithm is related to the granularity of the time wheel; finer granularity results in higher accuracy, but also higher memory usage, and the granularity of the time wheel cannot be changed during algorithm execution. Summary of the Invention

[0006] The purpose of this invention is to provide a high-speed, low-overhead software traffic shaping method and apparatus that eliminates internal bursts in the flow, achieves accurate traffic shaping, and has low memory usage and high memory utilization.

[0007] This invention comprises four parts: an enqueue module, a multi-level timing wheel (MLTW) storage structure, a dequeue module, and a shaping rate estimation module. When a packet arrives, the enqueue module classifies the packet, calculates its earliest departure time (EDT), and temporarily stores it in a suitable location within the MLTW. The MLTW is a multi-queue structure composed of multiple exponentially increasing timing wheels used to temporarily store packets whose transmission time has not yet arrived. The dequeue module identifies packets in the MLTW whose transmission time is no later than the current time and sends them out. The shaping rate estimation module estimates the sum of shaping rates for flows with the same destination IP address when a packet is dequeued. When selecting a location in the MLTW to store a packet, the enqueue module needs to obtain the shaping rate estimation information for the packet's category from this module.

[0008] 1. MLTW storage structure

[0009] MLTW has the following four structural features:

[0010] (1) Composed of multiple time wheel queues;

[0011] (2) Each time wheel queue consists of a fixed number of time slots, and different time wheel queues have the same number of time slots. Each time slot has a transmission time, and the interval between the transmission times of adjacent time slots in the same time wheel queue is a constant, which is called the granularity of the time wheel;

[0012] (3) The granularity of queues at different time rounds increases exponentially, that is, the granularity of queue i (i = 0, 1, 2...) is g. min ×2 i (where g) min This represents the smallest time granularity, which is also the time granularity of queue 0.

[0013] (4) Different time wheel queues in MLTW share the same start time front_time, that is, the sending time of the j-th time slot of the i-th queue is front_time+g. min ×2 i ×j (j = 0, 1, 2...).

[0014] For all arriving packets, their storage location in MLTW is determined according to the storage location rules described below:

[0015] Step 1: Select the time wheel queue with the best granularity for the group based on the shaping rate of the flow to which the group belongs. The selected queue number qid is calculated by the following formula:

[0016]

[0017] Among them, g min R is the minimum time wheel granularity of MLTW, R is the shaping rate of the stream, and MTU is the maximum transmission unit length of a packet.

[0018] Step 2: If the EDT of a group exceeds the maximum time of its time wheel queue, select a time wheel queue with a larger time range to store it until the EDT of the group does not exceed the maximum time of the time wheel queue, and then modify qid to the selected time wheel queue number.

[0019] Step 3: Based on the queue number qid of the selected queue, calculate the slot number (slotid) for storing this group using the following formula:

[0020]

[0021] t represents the earliest departure time of the group;

[0022] Step 4: If a time wheel queue possesses both of the following properties, then place the group into that time wheel queue:

[0023] Property 1: The granularity of this time wheel is coarser than the granularity of the current queue;

[0024] Property 2: This time wheel contains a time slot, the sending time of which is the same as the sending time of the currently selected time slot (i.e., slotid × g). min ×2 i )same.

[0025] MLTW also includes a queue state maintenance structure, which maintains information on whether each time round queue in MLTW is empty (i.e., whether it contains groups). This structure allows for quick lookup of the queue containing the stream with the highest integer forming speed in MLTW, i.e., the smallest non-empty queue number. This structure uses an integer as a bitmap to store the queue state. Each bit in the bitmap indicates whether a queue is empty; a bit value of 0 indicates an empty queue, and a bit value of 1 indicates a non-empty queue. The queue state maintenance structure has the following operations:

[0026] (1) Mark the queue of time wheel number qid as non-empty:

[0027] bitmap=bitmap|(1<<qid) (3)

[0028] (2) Mark the queue of time wheel number qid as empty:

[0029] bitmap=bitmap&~(1<<qid) (4)

[0030] (3) Obtain the smallest non-empty queue number sqid:

[0031] sqid=min(FFS(bitmap), queue_num-1) (5)

[0032] FFS is a CPU-provided instruction used to find the position of the least significant bit of the binary value corresponding to an integer (i.e., the position where the number 1 first appears from the least significant bit to the most significant bit of the corresponding binary value, starting from 0, for example, FFS(01000) = 3). queue_num represents the total number of time wheel queues in an MLTW.

[0033] 2. Enlistment Module

[0034] Once a group arrives, the enqueue module calculates the queue number and time slot number where the group should be stored, which involves the following steps:

[0035] Step 1: When a packet arrives, the enqueue module parses the packet, obtains the packet's quintuple information, and records the packet length, denoted by L;

[0036] Step 2: The enqueue module obtains the sending time prev_t of the previous packet in the current stream and the stream shaping rate R based on the 5-tuple information;

[0037] Step 3: The enqueue module calculates the group EDT, denoted as t, and updates the prev_t of the stream to t;

[0038] Step 4: The enqueue module classifies the packet according to the destination IP address and obtains the sum of the shaping rates of the flow class. During the first calculation, the initial value of the sum of the shaping rates of each flow class is obtained. Starting from the second calculation, the sum of the shaping rates of the flow class is obtained from the shaping rate estimation module.

[0039] Step 5: The enqueue module calculates the storage location in MLTW for this group according to the storage location rules;

[0040] Step 6: The enqueue module puts the group into the MLTW and updates the queue state maintenance structure of the MLTW, marking the queue as non-empty.

[0041] Furthermore, the five-tuple information in step 1 consists of the source IP address, destination IP address, source port number, destination port number, and protocol number. The source IP address, destination IP address, and protocol number are obtained from the IP header of the packet; for TCP or UDP packets, the source port number and destination port number are obtained from the TCP or UDP header of the packet; for other packets, the source port number and destination port number are 0.

[0042] Furthermore, in step 2, the enqueue module maintains a hash table where the keys are quintuples and the values ​​are the stream's integer shaping rate and the EDT of the previous packet in the stream. After obtaining the quintuple of the packet, the enqueue module retrieves the relevant integer information from the hash table.

[0043] Furthermore, the calculation method for the grouped EDT in step 3 is as follows:

[0044]

[0045] Where now represents the current time.

[0046] Furthermore, in step 4, information is retrieved from the hash table maintained by the integer speed estimation module using the destination IP address as the key. The values ​​of this hash table are speed estimation information for the destination IP address, including the total amount of data sent (send_bytes), sensitivity α, the sum of the integer speeds of all flows hashed to that position (rate), the minimum and maximum dequeue times (edt_min and edt_max), and the previous packet time slot (prev_slot). This hash table does not require resolution of hash collisions.

[0047] Furthermore, step 5, which calculates the location in the MLTW where the group should be stored, includes the following steps:

[0048] Step 5.1: Based on the sum of the shaping speeds for this category obtained in Step 4, select the queue with the best granularity from MLTW and denote the queue number as qid0. qid0 can be calculated using the following formula:

[0049] qid0=FLS(max_supported_rate)-FLS(rate) (7)

[0050] FLS is a CPU instruction that quickly finds the position of the most significant bit of an integer's binary value (i.e., the position of the last occurrence of the digit 1 from the least significant bit to the most significant bit, starting from the least significant bit with an index of 0); max_supported_rate can be given by the following formula:

[0051]

[0052] Step 5.2: If t exceeds the sending time of the tail time slot of the qid0 queue, then qid0 should be corrected according to the following formula:

[0053]

[0054] Where slot_num is the number of time slots in a time wheel queue in MLTW.

[0055] Step 5.3: Calculate the slot number (slotid0) of the time slot to be stored in the qid0 queue according to the following formula.

[0056]

[0057] Step 5.4: Select the actual queue number real_qid0 for grouping based on qid0 and slotid0. real_qid0 is obtained by the following formula:

[0058] real_qid0=qid0+FFS(slotid0) (11)

[0059] Then, based on real_qid0, calculate the time slot number real_slotid0 to be stored in the queue for the group. real_slotid0 is obtained by the following formula.

[0060]

[0061] Step 5.5: The storage location of the group in MLTW is: real_slotid0%slot_num time slot in time wheel queue real_qid0, where % is the modulo operator and slot_num is the total number of time slots in a time wheel queue in MLTW.

[0062] Further, step 6 updates the bitmap according to the following formula to mark the queue as non-empty in the queue state maintenance structure of MLTW.

[0063] bitmap=bitmap|(1<<real_qid0) (12)

[0064] 3. Departure Module

[0065] The dequeue module is responsible for finding packets in the MLTW that have arrived at their departure time, then dequeuing and sending the packets out. The dequeue module executes the following steps:

[0066] Step 1: Obtain the smallest non-empty queue number from the queue state maintenance structure of MLTW, denoted as sqid0. Obtain the granularity of the time wheel queue from sqid0, denoted as granularity.

[0067] Step 2: Query the time slots of queue sqid0 one by one, and dequeue the groups that have reached their departure time;

[0068] Step 3: If the queue is empty, update the MLTW's queue state maintenance structure to mark the queue as empty;

[0069] Step 4: Submit the grouping information of the outgoing teams to the shaping speed estimation module to estimate and update the shaping speed.

[0070] Furthermore, in step 1, sqid0 is obtained from the following formula.

[0071] sqid0=min(FFS(bitmap),queue_num-1)

[0072] granularity is obtained from the following formula

[0073] granularity = g min <<sqid0 (13)

[0074] Furthermore, step 2 is a loop search process that continues until there are no groups in the MLTW or the front_time of the MLTW exceeds the current time. Step 2 is executed as follows:

[0075] Step 2.1: If front_time exceeds the current time, then end; otherwise, obtain the time wheel queue real_qid1 and time slot real_slotid1 for group storage based on sqid0 and front_time;

[0076] Step 2.2: Check if the real_slotid1%slot_num time slot in the real_qid1 time wheel queue of MLTW is empty: if it is empty, add granularity to front_time and return to step 2.1; otherwise, execute step 2.3.

[0077] Step 2.3: In the real_qid1 time wheel queue, dequeue all groups in the real_slotid1%slot_num time slot;

[0078] Step 2.4: If the real_qid1 time wheel queue becomes empty (i.e., does not contain any groups), then mark the queue as empty in the queue state maintenance structure.

[0079] Further, step 2.1 obtains real_qid1 and real_slotid1 as follows:

[0080] Step 2.1.1: Calculate the time slot number slotid1 using the following formula.

[0081]

[0082] Step 2.1.2: Calculate the sequence number real_qid1 of the actual time wheel queue where the group is stored using the following formula.

[0083] real_qid1=sqid0+FFS(slotid1)

[0084] Step 2.1.3: Use the following formula to obtain the time slot number real_slotid1

[0085]

[0086] Further, step 2.4 uses the following formula to mark the real_qid1 time wheel queue as empty:

[0087] bitmap=bitmap&~(1<<real_qid1)

[0088] 4. Shaping speed estimation module

[0089] When a group is dequeued, the group is handed over to the shaping velocity estimation module. The shaping velocity estimation module performs the following steps:

[0090] Step 1: Obtain the total integer speed estimate information of the packet's class based on the packet's destination IP address, denoted as info;

[0091] Step 2: Based on the EDT of the group, update the maximum EDT and minimum EDT of the info record, denoted as info.max_edt and info.min_edt respectively;

[0092] Step 3: If info.send_bytes > 5 × MTU, and the slotid of this packet is not equal to the slot number of the previous packet when it was dequeued, info.prev_slot, then calculate and update the shaping rate info.rate; otherwise, add the length of this packet to the total number of bytes sent, info.send_bytes.

[0093] Step 4: Update info.prev_slot to slotid.

[0094] Furthermore, in step 1, the destination IP address of the packet is used as the key to retrieve info from the hash table maintained by the shaping rate estimation module. The info contains information such as: total data sent_bytes, sensitivity α, the sum of shaping rates of all streams hashed to this position rate, minimum and maximum dequeue times edt_min and edt_max, and the previous packet time slot prev_slot. This hash table does not need to resolve hash collisions.

[0095] Furthermore, in step 2, the maximum EDT and minimum EDT are updated according to the following formula:

[0096] info.max_edt=max(EDT, info.max_edt) (14)

[0097] info.min_edt=min(EDT, info.min_edt) (15)

[0098] Furthermore, in step 3, the velocity is estimated and updated using equation (16), where α determines the sensitivity of the velocity estimate to changes, and the value in this invention is 0.25.

[0099]

[0100] Compared with the prior art, the present invention has at least the following beneficial technical effects:

[0101] 1) This invention can eliminate internal bursts in a flow and achieve precise flow shaping. The enqueue module selects the queue with the most suitable granularity to store the groups based on the flow's shaping speed, so that groups from the same flow will not pile up in one slot, thus avoiding internal bursts in the flow and ensuring the accuracy of shaping.

[0102] 2) This invention consumes little memory and has high memory utilization. The MLTW structure of this invention selects the queue with the best matching granularity for each flow, which makes the groups evenly distributed in each slot of the queue, without a large number of idle positions.

[0103] 3) This invention features lower CPU overhead and supports higher shaping speeds and more concurrent connections. Based on the original EDT model, this invention considers the characteristics of data center networks. Bursts caused by inter-flow packet batch processing can be naturally eliminated before queue accumulation; only intra-flow packet batch processing harms network performance. Therefore, step 5 of the enqueue module aggregates packets from different flows with the same sending time into a coarsest-grained queue. This significantly reduces the number of dequeue operations, especially in multi-flow environments, thereby lowering CPU overhead. Experiments show that this invention can support shaping speeds up to 98Gbps, approximately 2.6 times faster than the more advanced Carousel traffic shaping algorithm. Further experiments demonstrate that this invention maintains high-precision shaping even with 100,000 concurrent connections.

[0104] 4) The shaping speed estimation module of this invention classifies flows based on the destination IP and estimates the speed during dequeueing. When a flow contains multiple connections or is affected by different shaping strategies, this invention can accurately obtain the shaping speed of the flow. Furthermore, this invention can also detect changes in the shaping speed of a flow in a timely manner, thereby reselecting the time-round queue with the best granularity for enqueueing. Attached Figure Description

[0105] Figure 1 A structural diagram of a high-speed, low-overhead software traffic shaping method and apparatus;

[0106] Figure 2 This is a schematic diagram of a multi-level time wheel storage structure;

[0107] Figure 3a This is a pseudocode diagram of the enqueue module algorithm;

[0108] Figure 3b This is a pseudocode diagram of the dequeue module algorithm;

[0109] Figure 3c This is a pseudocode diagram of the shaping velocity estimation module algorithm;

[0110] Figure 4 This represents the maximum shaping speed supported by the present invention at different flow rates in user mode.

[0111] Figure 5 This is a comparison of the memory usage of this invention with other algorithms;

[0112] Figure 6 This invention compares the CPU load of different algorithms with varying numbers of connections in kernel mode.

[0113] Figure 7 a represents the CPU load of this invention compared to other algorithms when 1-1k connections coexist in kernel mode;

[0114] Figure 7 b represents the absolute difference between the theoretical shaping speed and the actual shaping speed when 10k-100k connections coexist in user mode according to this invention. Detailed Implementation

[0115] To make the objectives and technical solutions of this invention clearer and easier to understand, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. The specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention.

[0116] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more. In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0117] This invention proposes a software traffic shaping device and method. The structure of the shaping device and the connection method of each module are shown in the attached figure. Figure 1As shown. This invention comprises four parts: an enqueue module, a multi-level timing wheel (MLTW) storage structure, a dequeue module, and a shaping rate estimation module. The enqueue module includes a classifier and an enqueue locator. The output of the classifier is connected to the input of the enqueue locator, the output of the enqueue locator is connected to the input of the multi-level timing wheel storage structure, the output of the multi-level timing wheel storage structure is connected to the input of the dequeue module, and the output of the dequeue module is connected to the input of the shaping rate estimation module. The output of the shaping rate estimation module is connected to the input of the enqueue locator. The enqueue module calculates the earliest departure time (EDT) of a packet based on its 5-tuple information and temporarily stores it in a suitable position in the MLTW. The MLTW is a multi-queue structure composed of multiple timing wheel queues, used to temporarily store packets whose transmission time has not yet arrived. The dequeue module identifies packets in the MLTW whose transmission time is no later than the current time and sends them out. The shaping rate estimation module estimates the sum of the shaping rates of flows with the same destination IP address when packets are dequeued.

[0118] 1. Multi-level time wheel storage structure

[0119] This invention uses the concept of inter-stream batch processing for flow shaping, and MLTW is the core structure for achieving efficient flow shaping. (Appendix) Figure 2 This demonstrates a simplified MLTW structure. The diagram also shows the storage locations of the groups for three streams with different shaping rates. The following section, in conjunction with the appendix, illustrates this. Figure 2 The structure of MLTW and the rules for storing groups are explained in detail.

[0120] (1) MLTW structure

[0121] MLTW is a multi-queue structure composed of multiple timing wheels. A timing wheel is a circular queue structure with time attributes, possessing the following characteristics:

[0122] 1) There are several slots for storing elements, and each slot is a first-in-first-out (FIFO) queue;

[0123] 2) Each slot has a time attribute (hence the slot is also called a time slot). In traffic shaping, this time attribute usually represents the transmission time of packets within the slot.

[0124] 3) In any two adjacent time slots, the absolute value of the difference in their time attributes is the same. This absolute value of the difference is called the granularity of the time wheel.

[0125] 4) The time wheel also has an attribute front_time, which represents the time of the head of the time wheel.

[0126] While time wheels can achieve effective traffic shaping, they also have some inherent drawbacks. For example, their granularity cannot be changed once the system starts. To meet various shaping speed requirements and maintain a certain level of precision, the granularity of the time wheel may be set very small, leading to high memory consumption. Furthermore, the structural characteristics of the time wheel result in unreasonable placement of packets in the queue, leading to more dequeue operations.

[0127] This invention designs an efficient MLTW (Multi-Level Lightning Buffer) structure for group caching and lookup, which has the following characteristics:

[0128] 1) It consists of multiple time wheel queues;

[0129] 2) All time wheel queues have the same number of time slots, and the number of time slots depends on the maximum number of bytes the queue buffers for each stream. In Linux, TSQ limits the maximum number of bytes buffered for each stream in the kernel protocol stack to 128KB by default. Therefore, in kernel mode, 128 time slots are sufficient for each queue. In the user-space implementation of this invention, the number of time slots is set to 1024.

[0130] 3) The granularity of the time-sharing queue grows exponentially, that is, the granularity of the i-th queue (i = 0, 1, 2...) is g. min ×2 i , where g min This represents the smallest time granularity, which is also the time granularity of queue number 0;

[0131] 4) All time wheel queues in M ​​share the same start time front_time, that is, the sending time of the j-th time slot of the i-th queue is front_time + g. min ×2 i ×j.

[0132] MLTW also includes a queue state maintenance structure to maintain information on whether each time-round queue in MLTW has packets to be sent. This structure allows for quick lookup of the queue containing the stream with the highest integer speed in the MLTW cache, i.e., the smallest non-empty queue number. The queue state maintenance structure uses an integer data type as a bitmap to store the queue state. Each bit in the bitmap indicates whether a queue is empty; a bit value of 0 indicates an empty queue, and a bit value of 1 indicates a non-empty queue. The queue state maintenance structure has the following operations:

[0133] 1) Mark queue number qid as non-empty:

[0134] bitmap=bitmap|(1<<qid) (1)

[0135] 2) Mark queue number qid as empty:

[0136] bitmap=bitmap&~(1<<qid) (2)

[0137] 3) Query the smallest non-empty queue number sqid:

[0138] sqid=min(FFS(bitmap), queue_num-1) (3)

[0139] FFS is a CPU-provided instruction used to find the position of the least significant bit of the binary value corresponding to an integer (i.e., the position where the number 1 first appears from the least significant bit to the most significant bit of the corresponding binary value, starting from 0, for example, FFS(01000) = 3). queue_num represents the total number of time wheel queues in an MLTW.

[0140] (2) MLTW group storage rules

[0141] When a packet arrives, a queue with the best granularity is first selected based on the shaping speed of the packet's category. If the transmission time of the last time slot in that queue is still less than the packet's transmission time, a new queue capable of accommodating that packet's transmission time is selected. In MLTW, there are time slots with the same transmission time in different queues. To reduce the number of dequeue operations, the actual storage location for packets in these time slots is reselected, so that packets with the same transmission time in different queues are grouped into the same time slot. The following section, in conjunction with the appendix... Figure 2 The example of three streams provides a detailed explanation of the MLTW packet storage method described above:

[0142] Step 1: Select the queue qid that best matches the granularity of the grouping based on the stream shaping rate R. The qid is obtained using the following formula:

[0143]

[0144] Among them, g min R is the minimum time wheel granularity of MLTW, R is the shaping rate of the stream, and MTU is the maximum transmission unit length of a packet.

[0145] For example, appendix Figure 2 Three streams are shaped using MLTW, with expected shaping speeds of 12Gbps, 6Gbps, and 3Gbps, respectively. Based on step 1, it is initially determined that the packets of the three streams will be placed into time wheel 0 (granularity of 1 microsecond), time wheel 1 (granularity of 2 microseconds), and time wheel 2 (granularity of 4 microseconds), respectively.

[0146] Step 2: If the earliest departure time t of a group exceeds the maximum time for selecting a queue, MLTW reselects a larger-granularity queue for the group until the queue's time range can accommodate t. Specifically, MLTW corrects qid using the following formula.

[0147]

[0148] FLS is a CPU instruction that can quickly find the position of the most significant bit of the binary value corresponding to an integer, that is, the position of the last occurrence of the digit 1 from the least significant bit to the most significant bit. It starts counting from the least significant bit, with the least significant bit having the index 0.

[0149] Step 3: Reselect the actual queue (real_qid) and time slot number (real_slotid) within the queue for the group. Specifically, MLTW obtains real_qid using the following formula:

[0150] real_qid=sqid+FFS(slotid) (6)

[0151] Where slotid is the time slot number that the group should be stored in the qid queue, and slotid is obtained by the following formula.

[0152]

[0153] Similarly, MLTW obtains real_slotid from the following formula.

[0154]

[0155] Appendix Figure 2 A simplified MLTW structure with three time wheels is demonstrated, with time wheel granularities of 1 microsecond, 2 microseconds, and 4 microseconds. Three streams (stream 0, stream 1, and stream 2) are shaped using MLTW, with desired shaping speeds of 12 Gbps, 6 Gbps, and 3 Gbps, respectively. According to step 1, it is initially determined that the packets of the three streams will be placed in time wheel 0 (granularity of 1 microsecond), time wheel 1 (granularity of 2 microseconds), and time wheel 2 (granularity of 4 microseconds), respectively. According to step 3, streams 0 and 1 both have packets with an EDT of 2 microseconds, so the packets at that position in stream 0 are moved to time wheel 1. Streams 0, 1, and 2 all have packets with EDTs of 0 microseconds and 4 microseconds, so the packets at the corresponding positions in streams 0 and 1 are moved to positions with the same EDT in time wheel 2.

[0156] 2. Enlistment Module

[0157] This invention proposes an enqueue module adapted for MLTW (Multi-Level Television). When a packet arrives, the enqueue module calculates the packet's storage position in the MLTW based on the packet storage rules. The enqueue module maintains a hash table where the key is a 5-tuple, and the value is the shaping rate of the corresponding stream and the sending time of the previous packet in that stream. When a packet arrives, the enqueue module's workflow can be divided into four steps: calculating the earliest departure time of the packet, classifying the packet by its destination IP address and obtaining the shaping rate of that category, calculating the packet's storage position in the MLTW, and enqueuing the packet and updating the queue status. Figure 3a This is a pseudocode diagram of the enqueue module algorithm.

[0158] (1) Calculate the earliest departure time of the group.

[0159] The enqueue module obtains the quintuple information and the number of bytes L of the packet from the packet. Using the quintuple as the key, it obtains the integer speed R of the stream and the sending time prev_send of the previous packet from the hash table, and then calculates the earliest departure time t of the packet using the following formula.

[0160]

[0161] Furthermore, the five-tuple information in step 1 consists of the source IP address, destination IP address, source port number, destination port number, and protocol number. The source IP address, destination IP address, and protocol number are obtained from the IP header of the packet; for TCP or UDP packets, the source port number and destination port number are obtained from the TCP or UDP header of the packet; for other packets, the source port number and destination port number are 0.

[0162] (2) Classify packets according to their destination IP address and obtain the shaping speed of each category.

[0163] In this invention, the enqueue module classifies packets according to their destination IP addresses. Using the destination IP address as the key, it retrieves the sum of the shaping rates (rate) of flows with the same destination IP address from a hash table maintained by the shaping rate estimation module. The values ​​in this hash table are the rate estimation information for that destination IP address, including the total amount of data sent (send_bytes), sensitivity α, the sum of the shaping rates (rate) of all flows hashed to that position, the minimum and maximum dequeue times (edt_min and edt_max), and the previous packet time slot (prev_slot). Furthermore, this hash table does not require hash collision resolution.

[0164] (3) Calculate the storage location of the group in MLTW

[0165] The enqueue module calculates the location of the group in MLTW according to the group storage rules of MLTW. This process includes the following steps.

[0166] Step 1: Using rate as the integer shaping speed, select the queue with the best granularity from the MLTW and denote the queue number as qid0. qid0 can be calculated using the following formula:

[0167] qid0=FLS(max_supported_rate)-FLS(rate) (9)

[0168] FLS is a CPU instruction that can quickly find the position of the most significant bit of the binary value corresponding to an integer, that is, the position of the last occurrence of the digit 1 from the least significant bit to the most significant bit. It starts counting from the least significant bit, with the least significant bit having the index 0.

[0169] The maximum supported integer shaping rate, max_supported_rate, can be given by the following formula:

[0170]

[0171] Step 2: If t exceeds the sending time of the tail time slot of the qid0 queue, then qid0 should be corrected according to the following formula:

[0172]

[0173] Where slot_num is the number of time slots in a time wheel queue in MLTW.

[0174] Step 3: Calculate the time slot number to be stored in the qid0 queue according to the following formula, and denote it as slotid0.

[0175]

[0176] Step 4: Select the actual storage queue based on qid0 and slotid0, denoted as real_qid0. real_qid0 is obtained by the following formula.

[0177] real_qid0 = qid0 + FFS(slotid0)

[0178] Then, based on real_qid0, calculate the time slot real_slotid0 of the group in this queue. real_slotid0 is obtained by the following formula.

[0179]

[0180] Step 5: The storage location of the group in MTLTW is: real_qid0 time wheel queue real_slotid0%slot_num time slot (where % is the modulo operator and slot_num is the total number of time slots).

[0181] (4) Enqueue the groups and update the queue status.

[0182] The enqueue module places the group into time slot real_slotid0%slot_num of time wheel queue MLTWreal_qid0. Then, it updates the MLTW queue state maintenance structure to mark the queue as non-empty.

[0183] bitmap=bitmap|(1<<real_qid0)

[0184] 3. Departure Module

[0185] This invention proposes a dequeue module adapted for Multi-Level Video Flow (MLTW) to locate packets in the MLTW that have reached their transmission time, then dequeue and send the packets. To meet the shaping requirements of all streams, the dequeue module should access the MLTW at a frequency compatible with the maximum shaping rate of active streams in the MLTW. Therefore, the dequeue module first finds the sequence number of the queue containing packets from the stream with the highest shaping rate in the MLTW, i.e., the smallest non-empty queue sequence number in the MLTW. Then, it traverses each storage slot of this queue, checking if there is a packet at that location. During traversal, the dequeue module calculates the actual storage location of the packet at that location, then accesses that location; if it is not empty, the packet is dequeued. Figure 3b This is a pseudocode diagram of the dequeue module algorithm. The dequeue module includes the following operations:

[0186] Step 1: Obtain the smallest non-empty queue number from the queue state maintenance structure of MLTW, denoted as sqid0. Obtain the granularity of the time wheel queue from sqid0, denoted as granularity.

[0187] Step 2: Query the time slots of time wheel number sqid0 one by one, and dequeue the groups that have reached their departure time;

[0188] Step 3: If the queue is empty, update the MLTW's queue state maintenance structure to mark the queue as empty;

[0189] Step 4: Submit the grouping information of the outgoing teams to the shaping speed estimation module to estimate and update the shaping speed.

[0190] Furthermore, in step 1, sqid0 is obtained from the following formula.

[0191] sqid0=min(FFS(bitmap),queue_num-1)

[0192] granularity is obtained from the following formula

[0193] granularity = g min<<sqid0 (11)

[0194] Furthermore, step 2 is a loop search process that continues until there are no groups in the MLTW or the front_time of the MLTW exceeds the current time. Step 2 is executed as follows:

[0195] Step 2.1: If front_time exceeds the current time, then end Step 2; otherwise, obtain the time wheel queue real_qid1 and time slot real_slotid1 for group storage based on sqid0 and front_time.

[0196] Step 2.2: Check if the real_slotid1%slot_num time slot in the real_qid1 time wheel queue of MLTW is empty. If it is empty, add granularity to front_time and return to step 2.1; otherwise, execute step 2.3.

[0197] Step 2.3: In the real_qid1 time wheel queue, dequeue all groups in the real_slotid1%slot_num time slot.

[0198] Step 2.4: If the real_qid1 queue becomes empty (i.e., does not contain any packets), update the queue state maintenance structure in MLTW to mark the queue as empty.

[0199] Further, step 2.1 obtains real_qid1 and real_slotid1 as follows:

[0200] Step 2.1.1: Calculate the time slot number slotid1 using the following formula.

[0201]

[0202] Step 2.1.2: Calculate the sequence number real_qid1 of the actual time wheel queue where the group is stored using the following formula.

[0203] real_qid1=sqid0+FFS(slotid1)

[0204] Step 2.1.3: Use the following formula to obtain the time slot number real_slotid1

[0205]

[0206] Further, in step 2.4, the real_qid1 time wheel queue is marked as empty according to the following formula.

[0207] bitmap=bitmap&~(1<<real_qid1)

[0208] 4. Shaping speed estimation module

[0209] This invention proposes a shaping rate estimation module for real-time sensing of changes in shaping rate. The rate estimation module includes a hash table that maintains shaping rate estimation information. The keys of the hash table are the destination IP addresses, and the values ​​are the rate estimation information for those destination IP addresses, including the total data sent (send_bytes), sensitivity α, the sum of shaping rates (rate) of all streams hashed to that position, the time slot (prev_slot) of the previous packet dequeue, and the minimum and maximum dequeue times (max_edt and min_edt). Figure 3c This is a pseudocode diagram of the shaping velocity estimation module algorithm;

[0210] The queuing module of this invention needs to quickly classify packets based on their destination IP address to determine the connection to which the packet belongs. This invention assumes that a host can be uniquely identified by its destination IP address. However, the method proposed in this invention can also be extended to scenarios where a host contains multiple IP addresses. In such scenarios, this invention classifies packets based on an explicit mapping between IP addresses and host IDs.

[0211] A common method for establishing mappings is using hash tables. However, a single server may establish connections with thousands of hosts. Therefore, a regular hash table needs to handle frequent hash collisions, or a very large hash table needs to be used to reduce the collision frequency. Either way, this incurs a significant overhead in accessing and maintaining the hash table.

[0212] The design of hash tables can be simplified and overhead reduced based on the following two factors: (1) The hash table does not need to be too large. The size of the hash table determines the number of streams that this invention can batch process. However, as the number of batch processing streams increases, the efficiency improvement brought by batch processing is no longer significant. Therefore, even if the number of destination addresses may be in the tens of thousands, it is not necessary to distinguish them accurately. Instead, it is only necessary to divide the groups into hundreds of categories. Therefore, a hash table containing 512 elements is sufficient.

[0213] (2) No need to handle hash collisions. When a hash collision occurs, the two streams are treated as the same stream. This approach only reduces the number of packets processed in the dequeue module by 1 and does not have any other negative impacts. Hash collisions only occur frequently when the number of streams exceeds the size of the hash table. At this point, the number of streams is already sufficient, and even if the number of packets processed in the batch is increased, the CPU overhead of the dequeue operation will not be significantly reduced.

[0214] The shaping velocity estimation module includes a basic operation: EstimateRate(packets, slotid), where packets represents the set of packets to be velocity estimated, and slotid represents the slot number when a packet is dequeued. This operation is explained below:

[0215] Step 1: Obtain the total integer shaping speed estimate information of the packet's class based on the packet's destination IP address, denoted as info.

[0216] Step 2: Based on the EDT of the group, update the maximum EDT and minimum EDT of the info record, denoted as info.max_edt and info.min_edt respectively;

[0217] Step 3: If info.send_bytes > 5 × MTU, and the slotid of this packet is not equal to the slot number of the previous packet when it was dequeued, info.prev_slot, then calculate and update the shaping rate info.rate; otherwise, add the number of bytes in this packet to the total number of bytes sent, info.send_bytes.

[0218] Step 4: Update info.prev_slot to slotid.

[0219] Furthermore, in step 2, the maximum EDT and minimum EDT are updated according to the following formula:

[0220] info.max_edt=max(EDT, info.max_edt) (12)

[0221] info.min_edt=min(EDT, info.min_edt) (13)

[0222] Furthermore, in step 3, the shaping speed info.rate is estimated and updated by equation (14), where α determines the sensitivity of the speed estimate to speed changes, and the value of α in this invention is 0.25.

[0223]

[0224] Test Results

[0225] To evaluate the effectiveness of this invention, we implemented its traffic shaping mechanism in both kernel and user space: in kernel space, it was implemented as a new queuing rule module (qdisc), and in user space, it was implemented using the software network interface card BESS. We verified the effectiveness of this invention in kernel-space experiments, user-space experiments, and large-scale simulation experiments. The experimental results are summarized below:

[0226] CPU efficiency: This invention can support a shaping speed of up to 98Gbps under single-core conditions, which is 2.6 times and 2.7 times higher than Carousel and Eiffel, respectively.

[0227] Memory efficiency: The multi-level time wheel queue structure proposed in this invention only requires 1.1MB of memory to accommodate a wide range of shaping speeds, which is three orders of magnitude lower than Carousel and Eiffel.

[0228] Scalability: The invention has excellent scalability and can still perform well even with 100K concurrent connections.

[0229] Transmission performance: This invention can transmit packets in batches without compromising network performance.

[0230] To test the performance of this invention in kernel mode and user mode, we built two test environments with network bandwidths of 10Gbps and 100Gbps, respectively. The 10Gbps test environment included two servers and one server simulating a switch. Each server was equipped with a 10GbE network card, an 8-core CPU, and 16GB of memory. The two 10GbE network cards were connected to the switch's 10GbE four-port network card. The 100Gbps test environment included two servers, each equipped with a 100GbE dual-port network card, a 6-core CPU, and 16GB of memory. We tested the performance of this invention in kernel mode and user mode in both the 10Gbps and 100Gbps test environments, using Carousel and Eiffel as comparison mechanisms. The main parameter configurations in the experiments are shown in Table 1.

[0231] Table 1 Main parameters of the test environment

[0232]

[0233] In the above test environment, we tested the CPU efficiency, memory efficiency, and scalability of the present invention in both kernel mode and user mode:

[0234] Figure 4 The maximum speed supported for different numbers of streams in user space is shown. This invention can support a shaping speed of 98Gbps with 4 streams, which is 2.6 times and 2.7 times higher than Carousel and Eiffel, respectively.

[0235] Figure 5The figure shows the memory efficiency of different mechanisms in kernel mode. As can be seen, this invention only requires approximately 1.1MB of memory. Under the same conditions, Carousel and Eiffel require approximately 540MB and 236MB of memory, respectively. Furthermore, in 40 / 100Gbps networks, to evenly store packets, Carousel and Eiffel require finer-grained time intervals; at a 0.1µs time granularity, Carousel and Eiffel require approximately 6.9GB and 2.3GB of memory, respectively. And this is just the memory requirement of a single Carousel / Eiffel qdisc. When scaling to multi-core systems, deploying a qdisc for each CPU core would result in an unacceptable memory footprint.

[0236] Figure 6 The comparison of CPU load and soft interrupt frequency in kernel mode for 1-stream and 16-stream scenarios is shown. In the 1-stream scenario, although this invention does not perform batch processing on packets, it still shows a smaller CPU overhead advantage compared to Carousel and Eiffel. This is because the enqueue and dequeue operations of this invention also achieve a time complexity of O(1). As the number of streams increases, this invention utilizes batch processing to achieve even lower CPU overhead, with CPU load reduced by 12-28% and 7-20% compared to Carousel and Eiffel, respectively.

[0237] Figure 7 The diagram shows the CPU load of different mechanisms under different connection counts in kernel mode. Compared to Carousel and Eiffel, this invention has better scalability. When the number of connections increases from 100 to 1000, the CPU load of this invention only increases by about 10%, which is about 2.1 times better than Eiffel.

[0238] Figure 7 b shows that even when 10K-100K connections coexist in user space, the present invention can still achieve high-precision traffic shaping. The absolute difference between the theoretical shaping speed and the actual shaping speed is always less than 10Mbps, thanks to the O(1) complexity of the enqueue and dequeue operations of the present invention.

[0239] The above description, which discloses specific embodiments and drawings of the present invention for illustrative purposes only, aims to help understand the content of the invention and implement it accordingly. However, those skilled in the art should understand that various substitutions, variations, and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. The present invention should not be limited to the content disclosed in the embodiments and drawings of this specification; the scope of protection of the present invention is defined by the claims.

Claims

1. A high-speed, low-overhead flow shaping device, characterized in that, include: The enqueue module is used to classify groups when they arrive and temporarily store them in the appropriate location in the multi-level time wheel storage structure. The multi-level time wheel storage structure is a multi-queue structure composed of multiple time wheels, used to temporarily store packets that have not yet reached their sending time; The dequeue module is used to find packets whose sending time is no later than the current time from the multi-level time wheel storage structure and send them out. The shaping rate estimation module is used to estimate the sum of shaping rates of flows with the same destination IP address when dequeuing packets; When the enqueue module selects the location of the group in the multi-level time wheel storage structure, it obtains the sum of the integer shaping speeds of the group's category. The multi-level time wheel storage structure has the following structural features: each time wheel queue includes a fixed number of time slots, and different time wheel queues have the same number of time slots; each time slot has a transmission time, and the interval between the transmission times of adjacent time slots in the same time wheel queue is a constant, which is called the granularity of the time wheel; The granularity of queues at different time points increases exponentially; Different time wheel queues share the same start time; The above-mentioned device implements the following method: S1. When a group arrives, calculate the earliest departure time of the group, classify the group, obtain the sum of the shaping rates of the streams of that type according to the group's category, and calculate the storage location of the group in the multi-level time wheel storage structure based on the earliest departure time of the group and the sum of the shaping rates of the streams of that type. S2. Store the group in the storage location obtained in S1; S3. The dequeue module finds the group whose earliest departure time is no later than the current time from the multi-level time wheel storage structure and sends it out. S4. The shaping rate estimation module estimates the sum of the shaping rates of flows with the same destination IP address when dequeuing groups. Step S1 includes the following steps: S1.1: When a packet arrives, parse the packet, obtain the packet's 5-tuple information, and record the packet length; S1.2: Obtain the sending time of the previous packet in the current stream and the stream shaping rate based on the quintuple information; S1.3: Calculate the earliest departure time of the packet and update the sending time of the previous packet in the flow to the earliest departure time of the packet; S1.4: Classify the packet according to its destination IP address and obtain the sum of the shaping velocities of this type of flow from the shaping velocity estimation module; S1.5: Calculate the storage location of the group in the multi-level time wheel storage structure based on the sum of the earliest departure time of the group and the shaping rate of the stream of this type; Step S1.5 includes the following steps: S1.5.1: Based on the sum of the shaping speeds of this category obtained in step 4, select the queue with the best granularity from the multi-level time wheel storage structure, and record the queue number as... ; S1.5.2: If the earliest departure time of the group Exceeded The sending time of the time slot at the tail of the queue will then be Make corrections as follows: FLS is a CPU-provided instruction used to locate the most significant bit of a binary value corresponding to an integer. The start time, For the smallest time granularity, It is the number of time slots in a time wheel queue in MLTW; S1.5.3: Calculate the group to be stored according to the following formula. Time slot number in the queue ; S1.5.4: According to and time slot number Select the actual queue number for grouping. ;according to Calculate the time slot number in which the group is to be stored in the actual storage queue. ; S1.5.5: Based on the time slot number of the group to be stored in the actual storage queue. Determine the storage location of the group in MLTW.

2. The high-speed, low-overhead flow shaping device according to claim 1, characterized in that, S3 includes the following steps: S3.1: Obtain the smallest non-empty queue number from the queue state maintenance structure of the multi-level time wheel storage structure. ; S3.2: Query one by one The time slot of the queue will dequeue groups whose departure time has arrived. S3.3: If the queue is empty, update the queue state maintenance structure of the multi-level time wheel storage structure and mark the queue as empty; S3.4: Submit the grouping information of the outgoing teams to the shaping speed estimation module to estimate and update the shaping speed.

3. The high-speed, low-overhead flow shaping device according to claim 2, characterized in that, Furthermore, step S3.2 is a cyclic search process that continues until there are no groups in the multi-level time wheel storage structure or the start time of the multi-level time wheel storage structure is reached. If the current time has elapsed, step 3.2 will proceed as follows: S3.2.1: If If the current time is exceeded, the process ends; otherwise, it proceeds according to... and Obtain the actual time wheel queue number where the group is stored. and time slot number ; S3.2.2: Querying the multi-level time wheel storage structure in The time wheel queue Is time slot number 1 empty? The total number of time slots in a time wheel queue in MLTW: if empty, then... Plus If the granularity of the queue is determined, return to step S3.2.1; otherwise, proceed to step S3.2.

3. S3.2.3: In The time wheel queue In time slot number 1, order all groups to leave the queue; S3.2.4: If If the queue of the time wheel becomes empty, then the queue is marked as empty in the queue state maintenance structure.

4. The high-speed, low-overhead flow shaping device according to claim 3, characterized in that, Step S3.2.1 involves obtaining the actual time wheel queue number where the group is stored, following these steps: and time slot number : 1): Calculate the time slot number using the following formula. 2): Use the following formula to calculate the sequence number of the time wheel queue where the group is actually stored. 3)2.1.3: Use the following formula to obtain the time slot number. in, With the smallest time granularity, FFS is a CPU-provided instruction used to locate the least significant bit of the binary value corresponding to an integer.

5. The high-speed, low-overhead flow shaping device according to claim 1, characterized in that, S4 includes the following steps: S4.1: Obtain the total integer speed estimate information of the packet's class based on the packet's destination IP address. ; S4.2: Update based on the earliest departure time (EDT) of the group. Record the maximum and minimum EDT; S4.3: If And the time slot number of the group is stored. Not equal to the time slot number when the previous group left the queue. Then the speed of plastic surgery Calculate and update; otherwise, send the total number of bytes. Add the length of the packet; MTU is the maximum transmission unit length of a packet; S4.4: Will Updated to the time slot number stored in this group. .

6. The high-speed, low-overhead flow shaping device according to claim 5, characterized in that, In S4.3, the shaping speed The velocity is estimated and updated using the following formula: in, For sensitivity, The earliest arrival time is the maximum. This represents the minimum and earliest arrival time.