Traffic shaping method and device and storage medium
By using differentiated deduction multiplier and dynamic token management, the problems of resource contention and load imbalance among multiple cache units are solved, improving the forwarding efficiency and stability of the traffic shaping device in multi-service scenarios and adapting to complex network environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU YIGE TECH CO LTD
- Filing Date
- 2026-01-09
- Publication Date
- 2026-04-21
AI Technical Summary
In existing traffic shaping technologies, resource contention and load imbalance caused by independent token management in multiple buffer units result in high-bandwidth packets continuously occupying forwarding resources, while low-bandwidth packets accumulate. Furthermore, the lack of a global coordination mechanism leads to a decrease in the overall forwarding efficiency of the system, making it unsuitable for complex scenarios involving multiple services.
By setting differentiated deduction multiplier coefficients for messages of different priorities, and combining the token management module, cache monitoring unit, backup cache partition, clock calibration unit, shared token pool and feedback processing unit, business-aware traffic control and dynamic resource allocation are achieved, optimizing bandwidth matching accuracy and overall forwarding efficiency.
It significantly reduces the forwarding latency of high-priority packets, alleviates the backlog of low-bandwidth flow packets, improves the overall forwarding efficiency and service quality of the system in complex multi-service environments, enhances system stability and resource utilization, and adapts to dynamic network environments.
Smart Images

Figure CN121907779A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and specifically to a traffic shaping method, apparatus, and storage medium. Background Technology
[0002] In the field of communication technology, traffic shaping is a key technology for ensuring network transmission stability. Its core principle is to regulate the packet transmission rate through a token bucket mechanism, ensuring that packets are forwarded evenly with a preset bandwidth. In existing technologies, traffic shaping devices configure a token bucket for each buffer unit. The token management module periodically replenishes tokens, and deducts tokens based on the number of bytes when forwarding packets. If there are enough tokens, the packet is forwarded; otherwise, it waits or is discarded. The bandwidth is matched using the formula "replenishment quantity × 8 / replenishment period," where 8 represents the 8-fold conversion between bytes and bits.
[0003] However, in practical applications, the replenishment period must be an integer multiple of the ratio of the system clock to the number of cache units, and the replenishment quantity must be a positive integer, which often makes it difficult to accurately match the configured bandwidth. Traditional solutions reduce errors by increasing the replenishment period, but this leads to a synchronous increase in the replenishment quantity, causing a sudden increase in the forwarding volume of cache units. Some improved solutions deduct tokens exceeding the number of packet bytes during forwarding, optimizing bandwidth accuracy with "8 × replenishment quantity / (n × replenishment period)," where n is the ratio of the deducted quantity to the number of bytes, i.e., the deduction multiplier. However, this does not solve the resource contention problem in multi-cache unit scenarios. High-bandwidth units continuously occupy forwarding resources due to sufficient tokens, while low-bandwidth units are prone to packet backlog; moreover, each unit independently controls tokens, lacking a global balancing mechanism, resulting in a decrease in overall forwarding efficiency and making it difficult to adapt to complex network environments with multiple services coexisting. Summary of the Invention
[0004] This invention provides a traffic shaping method, apparatus, and storage medium to solve the problems of resource contention and load imbalance caused by independent token management in multiple buffer units in existing traffic shaping technologies. Specifically, high-bandwidth packets continuously occupy forwarding resources, leading to the backlog of low-bandwidth flow packets, and the overall system forwarding efficiency decreases due to the lack of a global coordination mechanism, making it unsuitable for complex scenarios with multiple services.
[0005] In a first aspect, the present invention provides a traffic shaping device, comprising: a message receiving module for receiving a message to be forwarded sent by a sender and storing the message to be forwarded in a corresponding cache unit; multiple cache units, each cache unit storing a message to be forwarded of a service type; a message forwarding module for forwarding the message to be forwarded in the cache unit to the receiver; and a token management module for maintaining a token bucket for each cache unit. The token management module includes a token replenishment unit and a token deduction unit: the token replenishment unit periodically replenishes tokens to the token bucket corresponding to each cache unit; and the token deduction unit, when the message forwarding module forwards a message to be forwarded, determines a corresponding deduction multiplier based on the priority of the message to be forwarded and deducts a corresponding number of tokens from the token bucket corresponding to the cache unit where the message to be forwarded is located, wherein the number of tokens deducted is determined by the product of the number of bytes of the message to be forwarded and the deduction multiplier; the deduction multiplier corresponding to a high-priority message is less than the deduction multiplier corresponding to a low-priority message.
[0006] This invention sets differentiated deduction ratio coefficients for packets of different priorities, enabling high-priority packets to quickly obtain the tokens required for forwarding with a smaller deduction ratio, thereby significantly reducing their forwarding latency. At the same time, this mechanism realizes business-aware traffic control under a unified token bucket architecture, effectively alleviating the problem of low-bandwidth stream packet backlog caused by resource contention in multi-caching unit scenarios, and improving the overall forwarding efficiency and service quality adaptability of the system in complex multi-service environments.
[0007] In one optional implementation, the device further includes a message priority identification unit; the message priority identification unit is used to identify the priority of the message to be forwarded by parsing the header information of the message to be forwarded or according to the preset service level agreement rules; the token deduction unit integrates a learning model, which is configured to determine the deduction multiplier coefficient corresponding to each priority based on historical message forwarding data and network status data, and the deduction multiplier coefficient is a value greater than or equal to 1.
[0008] This implementation combines a message priority identification unit with a learning model to achieve intelligent dynamic adaptation of the deduction multiplier coefficient: on the one hand, it accurately identifies service priorities based on message headers or service level agreement rules; on the other hand, it optimizes the deduction multiplier coefficient of each priority by utilizing historical and network data, thereby ensuring low latency for high-priority services while improving the adaptability to dynamic network environments and the overall accuracy of resource regulation.
[0009] In one optional embodiment, the device further includes: a cache monitoring unit for real-time monitoring of the occupancy rate of each cache unit; a spare cache partition composed of free storage space in multiple cache units; when the cache monitoring unit detects that the occupancy rate of any cache unit exceeds a preset threshold, it performs at least one of the following operations: sending an expedited signal to the token management module to temporarily shorten the replenishment cycle of the token bucket corresponding to the cache unit whose occupancy rate exceeds the preset threshold; and migrating low-priority packets that meet preset conditions in the cache unit whose occupancy rate exceeds the preset threshold to the spare cache partition for temporary storage.
[0010] This implementation method constructs a proactive overflow protection mechanism by introducing a cache monitoring unit and a backup cache partition: when the cache occupancy rate is detected to exceed the standard, the token replenishment can be dynamically accelerated to improve the message sending capability, while low-priority messages are migrated to the backup partition for temporary storage, thereby effectively mitigating the risk of cache overflow and packet loss that may occur when the message receiving rate exceeds the token replenishment rate, and significantly enhancing the stability and data reliability of the system under high load.
[0011] In one optional implementation, the token management module further includes a clock calibration unit; the clock calibration unit is used to periodically acquire the actual frequency of the system clock, compare the actual frequency with a preset reference frequency, and adjust the replenishment period and / or replenishment quantity of tokens for each cache unit according to the comparison result.
[0012] This implementation uses a clock calibration unit to periodically monitor the system clock frequency and actively correct token replenishment cycle deviations caused by hardware or environmental fluctuations, thereby ensuring the actual execution accuracy of traffic shaping parameters and effectively improving the anti-interference capability and long-term stability of the data transmission process.
[0013] In one optional implementation, the token management module further includes a shared token pool and a resource scheduling unit; the resource scheduling unit is used to monitor the token balance of the token buckets corresponding to each cache unit, and when the token balance of any token bucket exceeds a first threshold, transfer the tokens in the token bucket that exceed the first threshold to the shared token pool, and when the token balance of any token bucket is lower than a second threshold, replenish tokens from the shared token pool to the token bucket.
[0014] This implementation method introduces a shared token pool and a resource scheduling unit to achieve dynamic allocation of token resources across cache units. It can transfer excess tokens from idle units to cache units with higher loads, thereby significantly improving the overall utilization rate of token resources while maintaining independent shaping control of each service flow. This effectively alleviates the problems of resource idleness and local congestion in scenarios with unbalanced loads of multiple services.
[0015] In one optional embodiment, the apparatus further includes a feedback processing unit; the feedback processing unit is used to receive reception capability feedback information from the receiving end, and adjust the number of tokens replenished by the token replenishment unit to replenish the buffer unit and / or adjust the deduction multiplier used by the token deduction unit according to the reception capability feedback information, so as to adapt to the actual reception capability of the receiving end.
[0016] This implementation introduces receiver capability feedback through a feedback processing unit, realizing dynamic adaptation between the transmitter's shaping parameters and the receiver's actual processing capability. It transforms unidirectional rate control into a bidirectional collaborative mechanism, effectively avoiding message loss caused by a momentary decrease in the receiver's processing capability, and improving the reliability of data transmission.
[0017] In one optional embodiment, the apparatus further includes an error management unit; the error management unit is used to determine the corresponding bandwidth error tolerance threshold according to the service type of the message to be forwarded; and to determine the replenishment period and replenishment quantity of the token replenishment unit for replenishing the corresponding cache unit based on the bandwidth error tolerance threshold; wherein, if the bandwidth error tolerance threshold of the first service type is less than the bandwidth error tolerance threshold of the second service type, then the absolute value of the actual bandwidth error generated by the replenishment period and replenishment quantity determined for the first service type is less than the absolute value of the actual bandwidth error generated by the replenishment period and replenishment quantity determined for the second service type.
[0018] This implementation uses an error management unit to set differentiated bandwidth error tolerance thresholds for different service types and configures token supplementation parameters accordingly, enabling services with strict error requirements to obtain higher control precision. This optimizes the overall computing resource allocation efficiency of the system while ensuring the quality of critical service services.
[0019] Secondly, the present invention provides a traffic shaping method, comprising: periodically replenishing tokens in the token bucket corresponding to each cache unit; receiving a message to be forwarded sent by the sender and storing the message to be forwarded in the corresponding cache unit; when it is necessary to forward the message to be forwarded from the cache unit, performing the following steps: determining the priority of the message to be forwarded and determining the corresponding deduction multiplier coefficient according to the priority, wherein the deduction multiplier coefficient determined for high-priority messages is less than the deduction multiplier coefficient determined for low-priority messages; determining whether the current number of tokens in the token bucket corresponding to the cache unit where the message to be forwarded is located is greater than or equal to the product of the number of bytes of the message to be forwarded and the deduction multiplier coefficient; if so, forwarding the message to be forwarded and deducting from the token bucket a number of tokens equal to the product of the number of bytes of the message and the deduction multiplier coefficient; otherwise, pausing the forwarding of the message to be forwarded.
[0020] This method dynamically determines and applies differentiated deduction multiplier coefficients based on packet priority during forwarding, enabling high-priority packets to obtain forwarding opportunities with less token deduction cost. This effectively reduces queuing latency for high-priority services while ensuring the basic function of traffic shaping, and achieves graded service quality assurance among multiple service flows.
[0021] In one optional implementation, after pausing the forwarding of the message to be forwarded, the method further includes: waiting for a preset time and then re-executing the step of determining whether the current number of tokens in the token bucket corresponding to the cache unit where the message to be forwarded is located is greater than or equal to the product of the number of bytes of the message to be forwarded and the deduction multiplier.
[0022] This implementation introduces a waiting and retry mechanism after packet forwarding is paused, providing a buffer time for the periodic replenishment of tokens. This avoids dropping packets directly due to a momentary shortage of tokens, thereby improving the success rate of packet forwarding and the robustness of system processing while maintaining the traffic shaping rate control effect.
[0023] Thirdly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the flow shaping method of the first aspect or any corresponding embodiment thereof. Attached Figure Description
[0024] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0025] Figure 1 This is a first structural block diagram of a flow shaping device according to an embodiment of the present invention; Figure 2 This is a second structural block diagram of a flow shaping device according to an embodiment of the present invention; Figure 3 This is a flowchart illustrating the flow shaping method according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0028] Existing traffic shaping technologies rely on the token bucket mechanism, matching the target bandwidth using "replenishment quantity × 8 / replenishment period". However, due to hardware integer constraints on the replenishment period and quantity, precise matching is difficult. Traditional methods of increasing the period to improve accuracy exacerbate burst traffic. While improved solutions introduce a deduction coefficient n to optimize accuracy, they still fail to address the resource contention problem caused by isolated token resource allocation among multiple buffer units. This results in high-bandwidth flows continuously occupying forwarding resources, while low-bandwidth flows are prone to backlog, and the lack of a global coordination mechanism leads to insufficient overall system efficiency in complex multi-service scenarios. Therefore, this invention provides a traffic shaping method, apparatus, and storage medium to solve the resource contention and load imbalance problems caused by independent token management in multiple buffer units in existing traffic shaping technologies. Specifically, high-bandwidth packets continuously occupy forwarding resources, leading to backlog of low-bandwidth packets, and the lack of a global coordination mechanism causes a decrease in overall system forwarding efficiency, making it unsuitable for complex multi-service scenarios.
[0029] This embodiment provides a flow shaping device. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0030] This embodiment provides a flow shaping device, such as... Figure 1 As shown, it includes: The message receiving module is used to receive messages to be forwarded sent by the sending end and store the messages to be forwarded into the corresponding buffer unit; Multiple cache units, each cache unit is used to store a message to be forwarded of a certain service type, and there are N cache units in this embodiment; The message forwarding module is used to forward messages to be forwarded in the buffer unit to the receiving end; The token management module maintains a token bucket for each cache unit; the token management module includes a token replenishment unit and a token deduction unit. The token replenishment unit is used to periodically replenish the token bucket corresponding to each cache unit; The token deduction unit is used to determine the corresponding deduction multiplier coefficient based on the priority of the message to be forwarded when the message forwarding module forwards the message to be forwarded, and deduct the corresponding number of tokens from the token bucket corresponding to the cache unit where the message to be forwarded is located. The number of tokens deducted is determined by the product of the number of bytes of the message to be forwarded and the deduction multiplier coefficient. The deduction multiplier coefficient corresponding to a higher priority message is less than the deduction multiplier coefficient corresponding to a lower priority message.
[0031] In existing solutions, the specified number (n times the number of bytes) deducted when forwarding a 1-byte message is a fixed value, such as a fixed deduction of 2 or 4 times the token, without considering differences in message type. This embodiment provides a traffic shaping device that, upon receiving a message, determines the corresponding deduction multiplier n based on the priority of the message to be forwarded. For example, for urgent messages (such as equipment failure commands), the value of n is temporarily reduced (e.g., from deducting 4 times to deducting 2 times), allowing it to obtain tokens for forwarding faster and avoiding delays in urgent messages due to an excessively large n value; for ordinary messages, the original n value is maintained to control bursts. This resolves the contradiction between the existing fixed n value and the inability to balance "controlling bursts" and "prioritizing the forwarding of urgent messages," and the optimized solution improves business adaptability without disrupting core logic.
[0032] This embodiment also provides another flow shaping device, such as Figure 2 As shown, in addition to the message receiving module, multiple buffer units, message forwarding module, and token management module, the traffic shaping device also includes: a message priority identification unit, which identifies the priority of a message to be forwarded by parsing the header information of the message to be forwarded or according to preset service level agreement rules; and a token deduction unit that integrates a learning model, which is configured to determine the deduction multiplier corresponding to each priority based on historical message forwarding data and network status data, wherein the deduction multiplier is a value greater than or equal to 1. In this embodiment, the message priority identification unit is set up to first determine the message priority, such as "emergency control message" or "normal data message". The adjustment relationship between priority and multiplier n is realized by the learning model, which can predict the n value that best suits the current bandwidth based on historical data.
[0033] The aforementioned priority can be determined by the data transmission protocol, such as the FC transmission protocol, which specifies the priority of data packets; or it can be user-defined, with a priority field in the data packet.
[0034] When determining the deduction factor, one can also create a window based on multiple historical data points, averaging the corresponding historical data within the window to predict future data. Furthermore, if the actual received data deviates significantly from the predicted data, the window size should be gradually increased; conversely, the data window should be decreased.
[0035] In some optional embodiments, the device further includes a cache monitoring unit for real-time monitoring of the occupancy rate of each cache unit; a spare cache partition consisting of free storage space in multiple cache units; when the cache monitoring unit detects that the occupancy rate of any cache unit exceeds a preset threshold, it performs at least one of the following operations: first, it sends an expedited signal to the token management module, causing the token replenishment unit to temporarily shorten the replenishment cycle of the token bucket corresponding to the cache unit whose occupancy rate exceeds the preset threshold; second, it migrates low-priority packets that meet preset conditions in the cache unit whose occupancy rate exceeds the preset threshold, such as expired ordinary historical packets, to the spare cache partition for temporary storage.
[0036] Existing technologies do not address the issue of "what to do when the cache is full." If the message receiving speed far exceeds the token replenishment speed, the cache may still overflow and cause packet loss. Therefore, this implementation adds a cache monitoring unit to the cache unit to monitor the cache occupancy rate in real time. When the occupancy rate exceeds a preset threshold, such as 80%, relevant actions are automatically triggered. The adjustment relationship of the replenishment period parameter is implemented by a learning model, which can predict the value that best suits the current bandwidth based on historical data. Specifically, it can be determined by the adjustment ratio output by the prediction model. This ratio is determined by the prediction model first providing a predicted value. If the result meets expectations, this result is saved, and a new predicted value is given again. This process continues until the result deviates from expectations, at which point the last predicted value that meets expectations is used as the final ratio coefficient. Existing solutions rely solely on token control sending speed and do not prevent "cache overflow caused by message accumulation at the receiving end." This implementation, after optimization, can reduce the risk of packet loss and improve system stability.
[0037] In some optional implementations, the token management module further includes a clock calibration unit; the clock calibration unit is used to periodically acquire the actual frequency of the system clock, compare the actual frequency with a preset reference frequency, and adjust the replenishment period and / or replenishment quantity of tokens for each cache unit according to the comparison result.
[0038] In existing solutions, the calculation of the replenishment period relies on the "system clock frequency." However, the clock may deviate due to temperature and voltage fluctuations during device operation. For example, if the clock slows down, the actual period corresponding to the token replenishment period will be inaccurate, leading to a larger bandwidth error. Therefore, this implementation method sets up a clock calibration unit to periodically (e.g., every 10 seconds) read the actual system clock frequency and compare it with the preset frequency. If the actual clock slows down (e.g., preset 1GHz, actual 980MHz), the replenishment period is automatically adjusted proportionally (e.g., the original Tfill=10μs is adjusted to 10.2μs) to ensure that the "token replenishment period" meets the design expectations. At the same time, the calculated value of the replenishment quantity is corrected synchronously to ensure that the bandwidth error remains within the preset range. The aforementioned adjustment of the supplementary period can be implemented in two ways. The first method involves replenishing the traffic in the next time period after a deviation in the actual period parameters, maintaining the average bandwidth unchanged. The second method uses a learning model to predict the value in advance within the current period. This model can predict the value that best matches the current bandwidth based on historical data. For example, in practical applications, clock deviation is strongly correlated with temperature. The learning model will provide a predicted value based on historical parameters. When this temperature reappears, the supplementary period is adjusted in advance to make the real-time bandwidth more accurate. Existing solutions assume a stable system clock and do not consider the impact of actual hardware fluctuations. This optimized implementation improves the anti-interference capability of parameter configuration.
[0039] The specific implementation of the above-mentioned proportional adjustment and replenishment cycle can be the adjustment ratio output by the prediction model. Here, the ratio is given by the prediction model first. If the result meets the expectations, the result will be saved and a new prediction value will be given again. When the result deviates from the expectations, the last prediction value that meets the expectations will be used as the final proportional coefficient.
[0040] In some optional implementations, the token management module further includes a shared token pool and a resource scheduling unit; the resource scheduling unit is used to monitor the token balance of the token buckets corresponding to each cache unit, and when the token balance of any token bucket exceeds a first threshold, transfer the tokens exceeding the first threshold in the token bucket to the shared token pool, and when the token balance of any token bucket is lower than a second threshold, replenish tokens from the shared token pool to the token bucket.
[0041] In existing technologies, each cache unit corresponds to an independent token bucket. If one cache unit has an excess of tokens (e.g., no packets are being received yet) while another cache unit has insufficient tokens (e.g., packets are densely packed), token resources will be wasted. A shared token pool can be added to the token management module, where cache units can be bound to priorities and channel numbers to achieve independent traffic management across multiple channels and priorities. All cache unit token buckets are connected to the shared token pool: when the remaining tokens for cache unit 1 exceed a threshold (e.g., 50% of the full bucket), the excess tokens are automatically transferred to the shared pool; when cache unit 2 has insufficient tokens, tokens are first requested from the shared token pool, and then the original replenishment cycle is triggered to replenish tokens. This implementation breaks through the independent "single cache, single token bucket" model, improving token resource utilization without changing the core logic of "multiple token deductions to control bursts," and is particularly suitable for scenarios with uneven load across multiple cache units, such as when only some caches have packets at a certain time.
[0042] In some optional embodiments, the apparatus further includes a feedback processing unit; the feedback processing unit is used to receive reception capability feedback information from the receiving end, and adjust the number of tokens replenished by the token replenishment unit to replenish the buffer unit and / or adjust the deduction multiplier used by the token deduction unit according to the reception capability feedback information, so as to adapt to the actual reception capability of the receiving end.
[0043] Existing solutions rely solely on the preset "configured bandwidth (Rate)" setting parameters at the sending end, neglecting the actual receiving capacity of the receiving end. If the receiving end experiences temporary lag, it may be unable to receive data at full bandwidth. Therefore, a feedback processing unit corresponding to the receiving end can be added: the sending end periodically sends back "current sending capacity" to the device, and the receiving end periodically sends back "current receiving capacity," such as "only 80% of the original bandwidth can be received." Upon receiving feedback, the parameters can be automatically adjusted in two ways: Method 1, reducing the number of supplementary tokens; Method 2, appropriately increasing the deduction multiplier, such as from 2x to 3x, indirectly reducing the actual sending speed and preventing packet loss at the receiving end. This implementation allows traffic shaping to better reflect the actual communication link status, solving the problem of "the sending end sending at the preset bandwidth, but the receiving end cannot receive."
[0044] In some optional embodiments, the apparatus further includes an error management unit; the error management unit is used to determine the corresponding bandwidth error tolerance threshold according to the service type of the message to be forwarded; and to determine the replenishment period and replenishment quantity of the token replenishment unit for replenishing the corresponding cache unit based on the bandwidth error tolerance threshold; wherein, if the bandwidth error tolerance threshold of the first service type is less than the bandwidth error tolerance threshold of the second service type, then the absolute value of the actual bandwidth error generated by the replenishment period and replenishment quantity determined for the first service type is less than the absolute value of the actual bandwidth error generated by the replenishment period and replenishment quantity determined for the second service type.
[0045] In existing technologies, the "preset value" for bandwidth error is globally uniform, such as controlling all services with a 1% error. However, in real-world scenarios, different services have different tolerances for error; for example, video calls require an error of <0.5%, while ordinary file transfers can tolerate an error of 3%. Therefore, in this implementation, when receiving a message, the service type is first identified, such as through the message header identifier, and then the corresponding error threshold is retrieved from a preset mapping table: for high-requirement services such as video, the "supplement period / supplement quantity" is calculated based on "smaller error priority"; for low-requirement services, the error can be appropriately relaxed, reducing the computational complexity of the supplement quantity, such as using simpler integer values. This implementation breaks through the limitations of "globally uniform error control," allowing for more flexible parameter configuration, satisfying the accuracy requirements of high-requirement services while reducing the computational resource consumption of low-requirement services.
[0046] This embodiment provides another traffic shaping device that focuses on optimizing the adaptability, stability, and resource utilization of existing traffic shaping technologies. By adding a packet priority identification unit and a learning model, it achieves differentiated control by reducing the n-value of urgent packets for accelerated forwarding and maintaining the n-value of ordinary packets to control bursts. When the cache exceeds the threshold, it triggers expedited token replenishment and temporary storage of low-priority packets to prevent overflow and packet loss. A calibration logic is added to the configuration unit to adjust the token replenishment cycle and quantity through real-time correction or model prediction to offset the impact of hardware fluctuations. A shared token pool is added to realize token surplus and shortage allocation, breaking through the single-bucket independent mode and revitalizing idle resources. Combined with dynamic parameter adjustment based on receiver feedback and a service-error mapping table, it achieves graded adaptation of accuracy and overhead, comprehensively improving the scenario adaptability and operational reliability of traffic shaping.
[0047] According to an embodiment of the present invention, a flow shaping method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0048] This embodiment provides a flow shaping method. Figure 3 This is a flowchart of a flow shaping method according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps: Step S301: Periodically replenish tokens to the token bucket corresponding to each cache unit; Step S302: Receive the message to be forwarded sent by the sender and store the message to be forwarded in the corresponding buffer unit; Step S303: When it is necessary to forward a message to be forwarded from the buffer unit, perform the following steps: Step S3031: Determine the priority of the message to be forwarded, and determine the corresponding deduction multiplier coefficient according to the priority. The deduction multiplier coefficient determined for high-priority messages is less than that determined for low-priority messages. Step S3032: Determine whether the current number of tokens in the token bucket corresponding to the cache unit where the message to be forwarded is located is greater than or equal to the product of the number of bytes of the message to be forwarded and the deduction multiplier. If so, forward the message to be forwarded and deduct a number of tokens from the token bucket equal to the product of the number of bytes of the message and the deduction multiplier; otherwise, suspend forwarding the message to be forwarded.
[0049] In some optional implementations, after pausing the forwarding of the message to be forwarded, the method further includes: waiting for a preset time and then re-executing the step of determining whether the current number of tokens in the token bucket corresponding to the cache unit where the message to be forwarded is located is greater than or equal to the product of the number of bytes of the message to be forwarded and the deduction multiplier.
[0050] The traffic shaping method provided in this embodiment effectively reduces the forwarding delay of urgent messages through dynamic adaptation of token deduction ratio and hierarchical error control mechanism. It can accurately control the bandwidth error of high-requirement services (such as video) and reduce the computational overhead of low-requirement services (such as file transfer), achieving efficient adaptation to multiple service scenarios. With the help of cache redundancy protection and early warning mechanism and clock fluctuation dynamic calibration logic, the packet loss rate of cache overflow is greatly reduced, and the bandwidth deviation caused by hardware fluctuation is effectively offset, significantly enhancing stability and anti-interference in complex environments. The multi-cache token pool sharing mechanism revitalizes idle token resources, solves the problem of resource waste in unbalanced load scenarios, improves the overall forwarding throughput under the same hardware configuration, and optimizes resource utilization. It responds to changes in receiver capabilities in real time, avoiding the packet loss problem of "sender sending at full speed, receiver unable to receive", which is more in line with dynamic link status and improves data transmission integrity and link utilization.
[0051] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0052] The following is a detailed reference. Figure 4 This diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present invention. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 401, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 402 or a program loaded from memory 408 into random access memory (RAM) 403. The RAM 403 also stores various programs and data required for the operation of the electronic device. The processor 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0053] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 408 including, for example, magnetic tapes, hard disks, etc.; and communication devices 409. Communication device 409 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0054] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 409, or installed from a memory 408, or installed from a ROM 402. When the computer program is executed by the processor 401, it performs the functions defined in the flow shaping method of the embodiments of the present invention.
[0055] Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0056] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the flow shaping method shown in the above embodiments is implemented.
[0057] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0058] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A flow shaping device, characterized in that, The device includes: The message receiving module is used to receive the message to be forwarded sent by the sending end and store the message to be forwarded in the corresponding cache unit; Multiple cache units, each of which stores a message to be forwarded for a specific service type; The message forwarding module is used to forward the messages to be forwarded in the cache unit to the receiving end; The token management module is used to maintain a token bucket for each cache unit; the token management module includes a token replenishment unit and a token deduction unit. The token replenishment unit is used to periodically replenish tokens to the token bucket corresponding to each cache unit; The token deduction unit is used to determine the corresponding deduction multiplier coefficient according to the priority of the message to be forwarded when the message forwarding module forwards the message to be forwarded, and deduct a corresponding number of tokens from the token bucket corresponding to the cache unit where the message to be forwarded is located. The number of tokens deducted is determined by the product of the number of bytes of the message to be forwarded and the deduction multiplier coefficient. The deduction multiplier coefficient corresponding to a high-priority message is less than the deduction multiplier coefficient corresponding to a low-priority message.
2. The flow shaping device according to claim 1, characterized in that, The device also includes a message priority identification unit; The message priority identification unit is used to identify the priority of the message to be forwarded by parsing the header information of the message to be forwarded or according to the preset service level agreement rules. The token deduction unit integrates a learning model, which is configured to determine the deduction multiplier coefficient corresponding to each priority based on historical packet forwarding data and network status data. The deduction multiplier coefficient is a value greater than or equal to 1.
3. The flow shaping device according to claim 1 or 2, characterized in that, The device further includes: A cache monitoring unit is used to monitor the occupancy rate of each cache unit in real time. The spare cache partition is composed of free storage space from multiple cache units; When the cache monitoring unit detects that the occupancy rate of any cache unit exceeds a preset threshold, it performs at least one of the following operations: Send an expedited signal to the token management module to temporarily shorten the replenishment cycle of the token bucket corresponding to the cache unit whose occupancy rate exceeds a preset threshold. Low-priority packets that meet preset conditions in cache units where the occupancy rate exceeds a preset threshold are migrated to the spare cache partition for temporary storage.
4. The flow shaping device according to any one of claims 1-3, characterized in that, The token management module also includes a clock calibration unit; The clock calibration unit is used to periodically acquire the actual frequency of the system clock, compare the actual frequency with a preset reference frequency, and adjust the replenishment period and / or replenishment quantity of tokens for each cache unit according to the comparison result.
5. The flow shaping device according to any one of claims 1-4, characterized in that, The token management module also includes a shared token pool and a resource scheduling unit; The resource scheduling unit is used to monitor the token balance of the token buckets corresponding to each cache unit, and when the token balance of any token bucket exceeds a first threshold, transfer the tokens in the token bucket that exceed the first threshold to the shared token pool, and when the token balance of any token bucket is lower than a second threshold, replenish tokens from the shared token pool to the token bucket.
6. The flow shaping device according to any one of claims 1-5, characterized in that, The device also includes a feedback processing unit; The feedback processing unit is used to receive reception capability feedback information from the receiving end, and adjust the number of tokens replenished by the token replenishment unit to replenish the cache unit and / or adjust the deduction multiplier used by the token deduction unit according to the reception capability feedback information, so as to adapt to the actual reception capability of the receiving end.
7. The flow shaping device according to any one of claims 1-6, characterized in that, The device also includes an error management unit; The error management unit is used to determine the corresponding bandwidth error tolerance threshold according to the service type of the message to be forwarded; and to determine the replenishment period and replenishment quantity of the token replenishment unit for the corresponding cache unit based on the bandwidth error tolerance threshold. Wherein, if the bandwidth error tolerance threshold of the first service type is less than the bandwidth error tolerance threshold of the second service type, then the absolute value of the actual bandwidth error caused by the supplementary period and supplementary quantity determined for the first service type is less than the absolute value of the actual bandwidth error caused by the supplementary period and supplementary quantity determined for the second service type.
8. A flow shaping method, characterized in that, The method includes: Periodically replenish tokens to the token bucket corresponding to each cache unit; Receive the message to be forwarded sent by the sender and store the message to be forwarded in the corresponding cache unit; When it is necessary to forward a message from the buffer unit, the following steps are performed: Determine the priority of the message to be forwarded, and determine the corresponding deduction multiplier coefficient based on the priority, wherein the deduction multiplier coefficient determined for high-priority messages is less than the deduction multiplier coefficient determined for low-priority messages; Determine whether the current number of tokens in the token bucket corresponding to the cache unit where the message to be forwarded is located is greater than or equal to the product of the number of bytes of the message to be forwarded and the deduction multiplier. If so, forward the message to be forwarded and deduct a number of tokens from the token bucket equal to the product of the number of bytes of the message and the deduction multiplier; otherwise, suspend forwarding the message to be forwarded.
9. The flow shaping method according to claim 8, characterized in that, After pausing the forwarding of the message to be forwarded, the following is also included: After waiting for a preset time, the step of determining whether the current number of tokens in the token bucket corresponding to the cache unit where the message to be forwarded is located is greater than or equal to the product of the number of bytes of the message to be forwarded and the deduction multiplier is re-executed.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the flow shaping method according to any one of claims 8 to 9.