Message speed limiting method, electronic equipment and storage medium
By distinguishing the message types and calling the corresponding speed limit bucket for speed limit, the problems of low bandwidth utilization and inaccurate speed limit caused by network speed limit are solved, and flexible message processing and efficient bandwidth utilization are achieved.
Patent Information
- Application Number
- CN202410058899.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-15
- Publication Date
- 2025-07-22
AI Technical Summary
In the prior art, the retransmission phenomenon caused by network speed limits leads to the speed limit traffic performance lower than the expected speed limit rate, and the existing scheme does not distinguish the message categories, resulting in inaccurate speed limits and reduced bandwidth utilization.
Obtain the message type through microcode, determine whether to limit the speed, and call the corresponding speed limit bucket according to the message type to limit the speed, distinguish between packet loss and retransmission, reply non-discarded and ordinary messages, and achieve flexible adaptation.
Improve the accuracy of speed limit, avoiding the actual bandwidth of users using less than the speed limit bandwidth after speed limit, improving bandwidth utilization, and ensuring timely transmission of response messages that cannot be discarded.
Smart Images

Figure CN120358197A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of communications, and in particular, to a method for rate limiting packets, an electronic device, and a storage medium. Background Art
[0002] TCP (Transmission Control Protocol) has a sending window and a receiving window. When the receiver fails to receive the expected packet for some reason, it will send the sequence number of the expected packet back to the sender. Subsequently, the sender will retransmit the packet with the sequence number expected by the receiver. This method ensures that TCP has a reliable connection characteristic. However, when there is rate limiting in the network, since rate limiting may cause some packets in the current sending window to be lost, the receiver will request the sender to retransmit the packet; due to rate limiting, a large number of packets are retransmitted, and the rate-limited traffic performance is lower than the expected rate-limiting rate. Summary of the Invention
[0003] Embodiments of the present disclosure provide a method for rate limiting packets, an electronic device, and a storage medium.
[0004] In a first aspect, embodiments of the present disclosure provide a method for rate limiting packets, the method may include:
[0005] The microcode obtains the packet type of the packet to be transmitted determined by the protocol stack;
[0006] The microcode determines whether to rate limit the packet according to the packet type;
[0007] In the case of determining to rate limit the packet, obtain the rate limiting requirement configured by the protocol stack for the packet, and call the corresponding rate limiting bucket according to the packet type;
[0008] Rate limit the packet based on the rate limiting requirement and the rate limiting bucket.
[0009] In a second aspect, embodiments of the present disclosure provide an electronic device, the electronic device includes:
[0010] One or more processors;
[0011] A memory having one or more programs stored thereon, when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the method for rate limiting packets;
[0012] One or more input / output I / O interfaces, connected between the processor and the memory, configured to implement information interaction between the processor and the memory.
[0013] In a third aspect, an embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the packet rate limiting method described above is implemented.
[0014] In the embodiment of the present disclosure, it is determined whether to limit the rate of a packet based on the packet type. When it is determined to limit the rate of the packet, the packet is rate-limited according to a rate-limiting bucket corresponding to the packet type, thereby implementing the processing of different rate-limiting requirements for different types of packets through microcode, and supporting the flexible adaptation of packet retransmission packets and non-packet retransmission packets to cope with different service scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In the drawings of the embodiments of the present disclosure:
[0016] Figure 1 is a schematic diagram of a timeout retransmission method in the related art;
[0017] Figure 2 is a flowchart of the packet rate limiting method provided by the embodiment of the present disclosure;
[0018] Figure 3 is a schematic diagram of the packet rate limiting method provided by the embodiment of the present disclosure;
[0019] Figure 4 is a block diagram of the composition of the electronic device provided by the embodiment of the present disclosure;
[0020] Figure 5 is a block diagram of the composition of the computer-readable storage medium provided by the embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0021] To enable those skilled in the art to better understand the technical solutions of the present disclosure, the communication perception data processing method and the computer-readable storage medium provided by the embodiments of the present disclosure will be described in detail below with reference to the drawings.
[0022] The present disclosure will be described more fully hereinafter with reference to the accompanying drawings. However, the disclosed embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth below. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0023] The drawings of the embodiments of the present disclosure are used to provide a further understanding of the embodiments of the present disclosure, and constitute a part of the specification, and are used to explain the present disclosure together with the detailed embodiments, and do not constitute a limitation to the present disclosure. By describing the detailed embodiments with reference to the drawings, the above and other features and advantages will become more apparent to those skilled in the art.
[0024] The present disclosure may be described with reference to plan views and / or cross-sectional views by means of ideal schematic diagrams of the present disclosure. Accordingly, the example illustrations may be modified in accordance with manufacturing techniques and / or tolerances.
[0025] In the case of no conflict, the embodiments of the present disclosure and the features in the embodiments may be combined with each other.
[0026] The terms used in the present disclosure are only for describing specific embodiments and are not intended to limit the present disclosure. As used in the present disclosure, the term "and / or" includes any and all combinations of one or more of the related listed items. As used in the present disclosure, the singular forms "a" and "the" are also intended to include the plural forms unless the context clearly indicates otherwise. As used in the present disclosure, the terms "comprising", "made of", specify the presence of the stated features, wholes, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their groups.
[0027] Unless otherwise defined, all terms (including technical and scientific terms) used in the present disclosure have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless the present disclosure clearly defines so.
[0028] The present disclosure is not limited to the embodiments shown in the drawings, but includes modifications to the configurations formed based on the manufacturing process. Accordingly, the regions illustrated in the drawings have schematic properties, and the shapes of the regions shown in the drawings illustrate the specific shapes of the regions of the elements, but are not intended to be restrictive.
[0029] TCP (Transmission Control Protocol) has a sending window and a receiving window. When the receiver fails to receive the expected packet for some reason, the sequence number of the expected packet will be sent back to the sender, and then the sender will retransmit the packet with the sequence number expected by the receiver. This method ensures that TCP has reliable connection characteristics. However, when there is network speed limit, due to the speed limit, some of the packets in the current sending window will be lost, and the receiver will request the sender to retransmit the packets; due to the speed limit, a large number of packets are retransmitted, and the speed limit traffic performance is lower than the expected speed limit rate.
[0030] In addition, the timeout retransmission time in TCP is usually determined by calculating the weighted round-trip time (RTT) of the packet. When a packet retransmission occurs, the next timeout retransmission time will increase based on the previous timeout retransmission time. Typically, the latest timeout retransmission time is twice that of the previously determined timeout retransmission time. At this time, due to the introduction of packet retransmission, there will be a large speed limit error in the speed limit based on the underlying hardware. Even if fast retransmission is adopted, due to packet loss caused by speed limit during the sending of packets or the loss of ACK (acknowledgment) packets, the packet retransmission mechanism will still lead to inaccurate speed limit rates for retransmitted packets of the packet loss type. For example, as Figure 1 shown, the speed limit rate is 10 Mbps (megahertz). The sender sends 300 packets numbered from 0 to 299. Due to speed limit, the packets numbered 100 - 199 in the middle are lost, or the ACK packets for the packets numbered 100 - 199 are lost due to speed limit. In both cases, all packets starting from packet 100 need to be retransmitted, resulting in the bandwidth being occupied by the retransmitted packets and inaccurate speed limit for retransmitted packets of the packet loss type.
[0031] In the current solution, it is generally implemented through hardware. Usually, the hardware is configured according to the speed limit requirements of the protocol stack, and then the hardware fills the speed limit bucket at a fixed rate. When a packet arrives, if the number of packet bytes is less than the number of tokens in the speed limit bucket, the packet is allowed to pass, and the corresponding number of tokens in the speed limit bucket is deducted. If the number of packet bytes is large and the number of tokens is less than the number of packet bytes, the packet cannot pass and will then be discarded. Until the number of tokens in the speed limit bucket meets the condition for the packet to pass (e.g., the number of tokens is greater than or equal to the number of packet bytes), the packet is released. Using such a solution, there will be a situation where due to the speed limit of the speed limit bandwidth, the packets therein are discarded because they cannot obtain enough tokens. At this time, the retransmission mechanism of the protocol will be triggered, resulting in the actual bandwidth used by the user after speed limit being less than the speed limit bandwidth, and there is an inaccurate speed limit phenomenon. And the existing solution does not distinguish between packet types, so the acknowledgment packets replied by the server may also be discarded due to speed limit, causing the client not to receive the acknowledgment packets in time and triggering the retransmission mechanism. Therefore, if packets are discarded due to speed limit, it will cause packet retransmission, resulting in a large number of packets in the speed limit system undergoing retransmission operations, occupying the speed limit bandwidth, leading to inaccurate speed limit, reducing the bandwidth utilization rate, and there is a situation where the actual speed limit bandwidth is lower than the actual bandwidth.
[0032] The existing hardware processing solution for ordinary packets is as follows:
[0033] 1. After receiving a packet, the hardware will perform speed limit according to the configured packet speed limit rules; for packets without configured speed limit rules, no speed limit processing is performed.
[0034] 2. After receiving the speed limit configuration, the kernel protocol stack will send the hardware speed limit rules to the hardware.
[0035] 3. After the hardware receives the configuration sent by the protocol stack, it determines information such as the rate-limiting bucket and the token filling rate according to the rate-limiting rules configured by the protocol stack.
[0036] 4. After the hardware receives a group of packets, it judges the packet byte count based on the number of tokens in the rate-limiting bucket. If the number of tokens is greater than the packet byte count, the packet is allowed to pass and the corresponding tokens are deducted; if the number of tokens is less than the packet byte count, the packet is not allowed to pass and is discarded.
[0037] In the embodiments of the present disclosure, it is determined whether to rate-limit a packet according to the packet type, and when it is determined to rate-limit the packet, the packet is rate-limited according to the rate-limiting bucket corresponding to the packet type, realizing the processing of different rate-limiting requirements for different types of packets through microcode, and supporting the flexible adaptation of retransmission packets with packet loss and non-retransmission packets with packet loss to cope with different service scenarios.
[0038] The packet rate-limiting method in the embodiments of the present disclosure can be executed by any electronic device that needs to perform packet transmission, such as a terminal device or a server. The terminal device may include, but is not limited to: in-vehicle devices, user equipment (UE), mobile devices, computing devices, wearable devices, etc. For example, it includes, but is not limited to, cellular phones, cordless phones, personal digital assistants (PDAs), portable computers, etc. The packet rate-limiting method can be implemented by the processor calling computer-readable program instructions stored in the memory, or can be implemented by the server.
[0039] The solution in the embodiments of the present disclosure can be applied to scenarios where the network processor hardware rate-limits communication packets according to the service scenario to obtain good communication quality, and rate-limiting scenarios with requirements for rate-limiting accuracy.
[0040] The solution in the embodiments of the present disclosure will be introduced in detail below.
[0041] The embodiments of the present disclosure provide a packet rate-limiting method, as Figure 2 、 Figure 3 shown, the method may include steps S11 - S14:
[0042] S11. The microcode obtains the packet type of the packet to be transmitted determined by the protocol stack;
[0043] S12. The microcode determines whether to rate-limit the packet according to the packet type;
[0044] S13. When it is determined to rate-limit the packet, obtain the rate-limiting requirements configured by the protocol stack for the packet, and call the corresponding rate-limiting bucket according to the packet type;
[0045] S14. Rate limit the packets based on the speed limit requirement and the rate limit bucket.
[0046] In the embodiments of the present disclosure, when creating hardware rate limiting in the protocol stack, the rate limiting scheme can be divided into multiple types according to the packet type, so that the corresponding rate limiting scheme can be adopted according to the packet type during rate limiting. For example, for packet types that do not require rate limiting, no rate limiting is set, and the transmission priority can be increased accordingly; for packet types that require rate limiting, different rate limit buckets can be created according to different packet types, so as to facilitate rate limiting by calling the rate limit bucket corresponding to the packet type through microcode, improving the rate limiting accuracy. The solutions of the embodiments of the present disclosure are introduced in detail below.
[0047] In the embodiments of the present disclosure, the packet type can be divided into any of the following multiple types: packet loss retransmission type packets, response non-discardable type packets, and ordinary type packets.
[0048] The characteristic of packet loss retransmission type packets (e.g., TCP data type packets) is that there is a retransmission mechanism; if a packet is rate limited and discarded, it will cause retransmission, and it is possible that not only the discarded packet will be retransmitted. For example, when the server sends 1000 packets, if only packets 100 - 199 and packets 600 - 800 are discarded, all packets after packet 100 will be retransmitted.
[0049] The characteristic of response non-discardable type packets (e.g., TCP response packets) is that if discarded, it will cause the peer to retransmit. For example, in the TCP protocol, after receiving a data packet, an ACK response is required. If the ACK cannot be normally delivered to the peer, it will cause the peer to retransmit the data packet. And in actual use, since such packets have no data content, they should not be counted in the rate limited traffic. Therefore, it is necessary to identify in the protocol and notify the underlying layer not to participate in rate limiting statistics.
[0050] The characteristics of ordinary type packets are similar to UDP (User Datagram Protocol) packets and multicast packets, and they can be discarded and have no retransmission mechanism.
[0051] In the embodiments of the present disclosure, according to the characteristics of the above different packet types, it is possible to first determine whether different packet types need to be rate limited.
[0052] In the embodiments of the present disclosure, the microcode determines whether to rate limit a packet according to the packet type, including:
[0053] In the case where the packet type is a packet loss retransmission type packet or an ordinary type packet, it is determined to rate limit the packet;
[0054] In the case where the packet type is a response non-discardable type packet, it is determined not to rate limit the packet.
[0055] In an embodiment of the present disclosure, after receiving a packet, the microcode first obtains the packet type configured by the protocol stack in the configuration entry corresponding to the packet. If it is determined that the packet type is a packet loss retransmission type packet or a general type packet, the packet is rate-limited. If it is determined that the packet type is an acknowledgment non-discardable type packet, the packet is not rate-limited.
[0056] In an embodiment of the present disclosure, after determining that the packet type is a packet loss retransmission type packet or a general type packet, a rate-limiting bucket corresponding to the packet type is called to rate-limit the packet.
[0057] In an embodiment of the present disclosure, when the packet type includes a packet loss retransmission type packet, calling a corresponding rate-limiting bucket according to the packet type includes: calling a preset rate-limiting bucket for retransmission type packets.
[0058] In an embodiment of the present disclosure, for rate-limiting of packet loss retransmission type packets, the microcode can call a newly added rate-limiting function module in the hardware, that is, a rate-limiting bucket for retransmission type packets.
[0059] In an embodiment of the present disclosure, the rate-limiting bucket for retransmission type packets can be a rate-limiting bucket pre-created by the protocol stack according to the characteristics of packet loss retransmission type packets. The rate-limiting bucket for retransmission type packets can only allow the previous one or more packets in the packet queue to pass according to the rate-limiting requirements, and the subsequent packets are discarded.
[0060] In an embodiment of the present disclosure, for packet loss retransmission type packets, the rate-limiting requirements may include but are not limited to: a first rate-limiting period and a first rate-limiting rate; for example, 10Mbps / S means that the first rate-limiting period is 1S (second), each 1S is a time window, and the first rate-limiting rate is 10Mbps (bits per second); 5Mbps / 0.5S means that the first rate-limiting period is 0.5S, each 0.5S is a time window, and the first rate-limiting rate is 10Mbps.
[0061] In an embodiment of the present disclosure, the protocol stack parses the packet in advance. If it is determined that the packet feature is a packet loss retransmission type packet, corresponding rate-limiting requirements (such as a first rate-limiting period and a first rate-limiting rate) and a rate-limiting bucket (such as a rate-limiting bucket for retransmission type packets) are configured for the packet. The rate-limiting bucket is pre-set according to the rate-limiting requirements. After the microcode calls the rate-limiting bucket for retransmission type packets according to the packet loss retransmission type packet type configured by the protocol stack, the rate-limiting bucket for retransmission type packets rate-limits the packet loss retransmission type packet based on the corresponding rate-limiting requirements.
[0062] In an embodiment of the present disclosure, rate-limiting the packet based on the rate-limiting requirements and the rate-limiting bucket includes:
[0063] When each first rate-limiting period arrives, the rate-limiting bucket for retransmission type packets issues all tokens within the first rate-limiting period; the first quantity of all tokens is determined according to the first rate-limiting rate;
[0064] During the first rate-limiting period, only the first quantity of the first-arriving packets are allowed to pass through.
[0065] In the embodiments of the present disclosure, rate-limiting the packets based on the rate-limiting requirements and the rate-limiting bucket further includes:
[0066] During the first rate-limiting period, the packets that arrive other than the first quantity of the first-arriving packets are discarded, and the discarded packets are retransmitted in the next first rate-limiting period.
[0067] In the embodiments of the present disclosure, for example, if the first rate-limiting period and the first rate-limiting rate are 10 Mbps / S, then the first 10 Mbit (megabit) of packets per second pass through, and all the subsequent packets are discarded (the discard operation is performed by the microcode). If the first rate-limiting period and the first rate-limiting rate are 5 Mbps / 0.5 S, then the first 2.5 Mbit of packets per 0.5 seconds pass through, and all the subsequent packets are discarded (the discard operation is performed by the microcode), thereby minimizing the packet retransmission mechanism to the greatest extent.
[0068] In the embodiments of the present disclosure, the token filling period of the retransmission-type packet rate-limiting bucket is determined according to the first rate-limiting period, that is, it is the same as the first rate-limiting period; the number of tokens filled each time in the retransmission-type packet rate-limiting bucket is all the tokens required within the first rate-limiting period filled at one time. For example, for the case where the first rate-limiting period and the first rate-limiting rate are 10 Mbps / S, all the tokens corresponding to 10 Mbit of packets are filled at one time at the beginning of each 1S. The bucket depth of the retransmission-type packet rate-limiting bucket can be flexibly configured according to requirements without limitation.
[0069] In the embodiments of the present disclosure, by calling the retransmission-type packet rate-limiting bucket and flexibly configuring the retransmission-type packet rate-limiting bucket according to the rate-limiting requirements, the first quantity of packets within each set first rate-limiting period (or time window) can pass through smoothly, without packet loss caused by rate-limiting, and the rate-limiting packet loss triggering the packet retransmission mechanism is avoided to the greatest extent.
[0070] In the embodiments of the present disclosure, the method further includes:
[0071] The microcode obtains the packet identifiers corresponding to the passed packets and the discarded packets respectively returned by the rate-limiting bucket after rate-limiting the packets;
[0072] The microcode discards or allows the corresponding packets to pass according to the packet identifiers returned by the rate-limiting bucket.
[0073] In the embodiments of the present disclosure, after rate-limiting the corresponding packets in each time window, the retransmission-type packet rate-limiting bucket records the packet identifiers of the passed packets and the packet identifiers of the discarded packets, and returns these packet identifiers to the microcode. The microcode passes or discards the corresponding packets according to the obtained packet identifiers.
[0074] In an embodiment of the present disclosure, an embodiment of rate limiting for packet loss retransmission messages is given below.
[0075] After the microcode determines that the message type is a packet loss retransmission message according to the configuration of the protocol stack, it calls the retransmission message rate limiting bucket. The retransmission message rate limiting bucket then determines whether the current message can pass according to the set first rate limiting rate and the first rate limiting period. The microcode controls whether the corresponding message can pass according to the message identifier of the message that passes through the retransmission message rate limiting bucket and the message identifier of the discarded message. For example, when the rate limiting rate is set to 10 Mbps and the rate limiting time window is set to 0.5 s, then the called retransmission message rate limiting bucket issues all the tokens for the 0.5 s time window at the beginning of each 0.5 s, and the first 5 Mbit of messages that arrive within 0.5 s will not be restricted and can be allowed to pass directly. Subsequent messages will not be able to pass due to the limited number of tokens.
[0076] When the next time window arrives, that is, when each time window starts, the tokens that should be issued within the current time window are directly issued into the retransmission message rate limiting bucket. Here, there is a difference from the rate limiting scheme of the existing rate limiting bucket. In the rate limiting scheme of the existing rate limiting bucket, the token issuance is mainly to ensure a stable rate limiting rate, and tokens are issued at a certain rate. And when the number of messages is less than or equal to the number of tokens in the bucket, the corresponding messages can pass directly and the corresponding tokens are deducted from the bucket; when the number of messages is greater than the number of tokens, these messages cannot pass. Since the scheme of the embodiment of the present disclosure issues all the tokens within the current time window at the beginning of the current time window, there will be no messages passing through during the remaining time after the tokens within the current time window are used up. Due to the TCP protocol characteristics, the messages in the remaining time window will be all discarded, and these discarded messages will be retransmitted in the next time window. However, if the number of tokens within the current time window is sufficient, the packet loss retransmission messages will all be normally transmitted, thus reducing the message packet loss and retransmission phenomena caused by rate limiting.
[0077] In an embodiment of the present disclosure, when the message type includes ordinary messages, the corresponding rate limiting bucket is called according to the message type, including: calling a preset ordinary message rate limiting bucket.
[0078] In an embodiment of the present disclosure, the characteristic of ordinary messages is that they are not retransmitted even if packet loss occurs and there is no retransmission mechanism. For example, UDP messages, multicast messages, etc. Therefore, for rate limiting of ordinary messages, the microcode can call the existing rate limiting function module of the hardware, that is, the ordinary message rate limiting bucket; the ordinary message rate limiting bucket can perform rate limiting according to the current hardware rate limiting scheme.
[0079] In an embodiment of the present disclosure, when the packet type includes general packets, the rate limiting requirements may include, but are not limited to: the second rate limiting rate;
[0080] Rate limiting the packets based on the rate limiting requirements and the rate limiting bucket may include:
[0081] The general packet rate limiting bucket determines the number of packets according to the second number of tokens in the general packet rate limiting bucket; the second number is obtained according to the second rate limiting rate;
[0082] When the second number is greater than or equal to the number of packets, the packets are allowed to pass, and the number of tokens corresponding to the number of packets is deducted from the general packet rate limiting bucket;
[0083] When the second number is less than the number of packets, the packets are not allowed to pass and are discarded.
[0084] In an embodiment of the present disclosure, for the rate limiting of general packets, the configured rate limiting requirements are also obtained. For the packet loss retransmission packets, configurations such as the first rate limiting period and the first rate limiting rate can be performed; for the non-packet loss retransmission packets, they can be configured according to the existing rate limiting requirements. For example, the second rate limiting rate can be configured, and the protocol stack can send the configured rate limiting requirements and the packet category to the microcode part together.
[0085] In an embodiment of the present disclosure, for example, the general packet rate limiting bucket issues tokens according to the second rate limiting rate. When a batch of packets is received, if the number of tokens in the current general packet rate limiting bucket is less than the number of this batch of packets, then this batch of packets cannot all pass and are all discarded. If the number of tokens in the current general packet rate limiting bucket is greater than or equal to the number of this batch of packets, then this batch of packets can pass.
[0086] In an embodiment of the present disclosure, the filling time of general packets is very short. The advantage of the rate limiting scheme for general packets is that the egress packets are stable and there is no burst, which is very friendly to rate limiting with a rate difference. For example, for the 10 Gbps (gigabits per second) packets in the PON (Passive Optical Network) port downstream, the LAN (Local Area Network) port only has a rate of 100 Mbps. If the packet loss retransmission packets (such as TCP data packets) method is used, it will cause serious bursts at the LAN port. Here, the rate limiting rate is 100 Mbps, and maybe only 2 Mbps (port forwarding capacity + cache capacity) can be actually forwarded out. And the current rate limiting scheme for general packets, combined with the cache, can make the LAN port receive 100 Mbps and forward all of them out, and it also has great advantages in terms of delay and packet smoothness.
[0087] In the embodiments of the present disclosure, after the general class packet rate limiting bucket limits the rate of packets, it records the packet identifiers of the passed packets or the discarded packets, and returns these packet identifiers to the microcode. The microcode passes or discards the corresponding packets according to the obtained packet identifiers.
[0088] In the embodiments of the present disclosure, an embodiment of rate limiting the general class packets is given below.
[0089] When general class packets (such as non-packet-loss retransmission packets like UDP) arrive, the microcode hands them over to the general packet rate limiting hardware for processing, that is, calls the general class packet rate limiting bucket, and the existing rate limiting scheme can be implemented through the general class packet rate limiting bucket. The token filling in the general class packet rate limiting bucket is carried out at a certain rate, and the filling time is short. For example, when a UDP packet arrives and the rate limiting requirement is 10 Mbps, here we issue tokens to the general class packet rate limiting bucket at a rate of 10 M / s (megabits per second) (this is just an example, the actual packet type is not limited to UDP packets, and the rate limiting rate can also be changed as needed). When the number of tokens in the general class packet rate limiting bucket is sufficient, the currently received packet is directly forwarded and the corresponding number of tokens is deducted; when the tokens in the general class packet rate limiting bucket are not enough, the currently received packet cannot be sent, and when it exceeds the cache, the packet is discarded. However, as the tokens are continuously filled, the number of packets is less than or equal to the number of tokens in the rate limiting bucket at a certain moment, and the packet can be sent. This ensures a stable export packet rate and avoids packet burst phenomena. And for the rate limiting scenario where there is a rate difference between the upstream and downstream ports, it can be better adapted without affecting the accuracy and function of rate limiting.
[0090] In the embodiments of the present disclosure, the method further includes: in the case of determining that a packet is not rate limited, setting a preset mark on the packet descriptor of the packet, so that when the preset chip hardware recognizes the preset mark, the packet is passed, and the priority of the packet in the queue is increased to the target priority to preferentially transmit the packet.
[0091] In the embodiments of the present disclosure, the preset chip hardware may include, but is not limited to, one or more exits of the packet.
[0092] In the embodiments of the present disclosure, in the case where the microcode determines that the packet type is a non-discardable response packet, it can be determined that the corresponding packet is not rate limited.
[0093] In the embodiments of the present disclosure, the characteristic of the response non-discardable message is that if this type of message is discarded, it will cause the sending peer to retransmit the message. For example, the ACK response message in the TCP protocol. When the data message is normally received by the receiving end, but the ACK response message of the receiving end cannot be normally delivered to the sending end, it will cause the sending end to retransmit; and the ACK message does not carry data, so this type of message should be avoided from being rate-limited and discarded. Therefore, the protocol stack can identify this type of message and notify the underlying layer not to participate in the rate-limiting statistics and not to discard it, and can also increase the priority of this type of message in the internal queue to ensure that this type of message can be preferentially transmitted.
[0094] In the embodiments of the present disclosure, after the microcode identifies the response non-discardable message, a specific mark (i.e., the above-mentioned preset mark) can be set in the message descriptor of this type of message. After the chip hardware identifies this preset mark, it will make the message not participate in all rate-limiting and preferentially forward and schedule this message.
[0095] In the embodiments of the present disclosure, before increasing the priority of the message in the queue, the method may further include:
[0096] The microcode obtains the target priority of the message configured by the protocol stack;
[0097] The microcode sends this target priority to the chip hardware through the message descriptor.
[0098] In the embodiments of the present disclosure, the priority level of scheduling can be configured by the protocol stack to the microcode through the driver, and the microcode notifies the chip hardware through the message descriptor.
[0099] In the embodiments of the present disclosure, in the above transmission scheme for the response non-discardable message, since it does not go through the rate-limiting process, the rate-limiting bucket will not be called, and the corresponding token number will not be deducted from the rate-limiting bucket. In this way, it is avoided that the response message is not lost due to the rate-limiting function, thereby avoiding the inaccuracy of rate-limiting caused by unnecessary message retransmission. And the subsequent process can also flexibly schedule and process this type of message according to the marked priority.
[0100] In the embodiments of the present disclosure, it has at least the following advantages:
[0101] 1. It improves the rate-limiting accuracy of the rate-limiting bucket for the retransmission messages due to packet loss, and avoids the actual available bandwidth of the user being less than the rate-limiting bandwidth after rate-limiting.
[0102] 2. It can implement the processing of different rate-limiting requirements for different types of messages through the microcode, support the flexible adaptation of the retransmission messages due to packet loss and the non-retransmission messages due to packet loss to cope with different service scenarios.
[0103] 3. The reply response message that can identify the packet loss retransmission type message ensures that such messages will not cause packet loss due to the rate-limiting bucket in the response message, thereby triggering the packet retransmission phenomenon, resulting in a large fluctuation in the rate-limiting rate and failing to meet the requirement of accurately rate-limiting the required service scenarios.
[0104] 4. It is compatible with the existing packet rate-limiting scheme, avoiding the risk of the smoothness of the egress packets caused by the traffic burst after rate-limiting the ordinary type packets.
[0105] The embodiment of the present disclosure also provides an electronic device 100, as Figure 4 shown, the electronic device 100 includes:
[0106] One or more processors 101;
[0107] A memory 102, on which one or more programs are stored. When the one or more programs are executed by the one or more processors 101, the one or more processors 101 implement the packet rate-limiting method;
[0108] One or more input / output I / O interfaces 103, connected between the processor 101 and the memory 102, configured to implement the information interaction between the processor 101 and the memory 102.
[0109] Among them, the processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU), etc.; the memory 102 is a device with data storage capabilities, including but not limited to a random access memory (RAM, more specifically such as SDRAM, DDR, etc.), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory (FLASH); the I / O interface (read / write interface) 103 is connected between the processor 101 and the memory 102 and can implement the information interaction between the processor 101 and the memory 102, including but not limited to a data bus (Bus), etc.
[0110] In some embodiments, the processor 101, the memory 102, and the I / O interface 103 are interconnected through a bus 104 and are further connected to other components of the computing device.
[0111] The embodiment of the present disclosure also provides a computer-readable storage medium 200, as Figure 5 shown. A computer program is stored on the computer-readable storage medium 200, and when the computer program is executed by a processor, the packet rate-limiting method is implemented.
[0112] Those of ordinary skill in the art can understand that all or some of the functional modules / units disclosed above can be implemented as software, firmware, hardware, and their appropriate combinations.
[0113] In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a single physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation.
[0114] Some or all physical components may be implemented as software executed by a processor, such as a central processing unit (CPU), a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, random access memory (RAM, more specifically SDRAM, DDR, etc.), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory (FLASH), or other magnetic disk storage; compact disc read only memory (CD-ROM), digital versatile disc (DVD), or other optical disc storage; magnetic cassettes, tapes, disk storage, or other magnetic storage; and any other medium that can be used to store the desired information and that can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0115] The present disclosure has disclosed example embodiments, and although specific terms have been employed, they are used only and should be construed only as general descriptive meanings and not for the purpose of limitation. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly specified, features, characteristics, and / or elements described in connection with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in connection with other embodiments. Accordingly, those skilled in the art will understand that various forms and details may be changed without departing from the scope of the present disclosure as set forth by the appended claims.
Claims
1. A method for limiting the speed of a message, characterized in that, The method includes: The packet type of the packet to be transmitted determined by the microcode acquisition protocol stack; The microcode determines whether to limit the speed of the packet according to the packet type; When it is determined to limit the speed of the packet, obtain the speed limit requirement configured by the protocol stack for the packet, and call the corresponding speed limit bucket according to the packet type; Limit the speed of the packet based on the speed limit requirement and the speed limit bucket.
2. The message rate limiting method according to claim 1, wherein The packet type includes any one of the following: retransmission packet for lost packets, non-discardable acknowledgment packet, and ordinary packet; The microcode determines whether to limit the speed of a packet according to the packet type, including: When the packet type is the retransmission packet for lost packets or the ordinary packet, it is determined to limit the speed of the packet; When the packet type is the non-discardable acknowledgment packet, it is determined not to limit the speed of the packet.
3. The packet rate limiting method according to claim 2, wherein When the packet type includes the retransmission packet for lost packets, the calling of the corresponding speed limit bucket according to the packet type includes: calling the preset speed limit bucket for retransmission packets.
4. The message rate limiting method according to claim 3, wherein The speed limit requirement includes: a first speed limit period and a first speed limit rate; The limiting the speed of the packet based on the speed limit requirement and the speed limit bucket includes: When each first speed limit period arrives, the retransmission packet speed limit bucket issues all the tokens within the first speed limit period; the first quantity of all the tokens is determined according to the first speed limit rate; Within the first speed limit period, only the first quantity of the first-arriving packets is allowed to pass.
5. The packet rate limiting method according to claim 4, wherein The limiting the speed of the packet based on the speed limit requirement and the speed limit bucket further includes: Within the first speed limit period, the packets that arrive other than the first quantity of the first-arriving packets are discarded, and the discarded packets are retransmitted in the next first speed limit period.
6. The packet rate limiting method according to claim 2, wherein When the packet type includes the ordinary packet, the calling of the corresponding speed limit bucket according to the packet type includes: calling the preset speed limit bucket for ordinary packets.
7. The packet rate limiting method according to claim 6, wherein The speed limit requirement includes: a second speed limit rate; The limiting the speed of the packet based on the speed limit requirement and the speed limit bucket includes: The ordinary packet speed limit bucket judges the number of packets according to the second quantity of tokens in the ordinary packet speed limit bucket; the second quantity is obtained according to the second speed limit rate; When the second quantity is greater than or equal to the number of packets, the packet is allowed to pass, and the token quantity corresponding to the number of packets is deducted from the ordinary packet speed limit bucket; When the second quantity is less than the number of packets, the packet is not allowed to pass and is discarded.
8. The packet rate limiting method according to any one of claims 1-7, characterized in that, The method further includes: The microcode obtains the packet identifiers corresponding to the passed packets and discarded packets respectively returned by the speed limit bucket after limiting the speed of the packet; The microcode discards or allows the corresponding packets to pass according to the packet identifiers returned by the speed limit bucket.
9. The message rate limiting method according to claim 1 or 2, characterized in that The method further includes: When it is determined that the message is not to be rate-limited, a preset mark is set for the message descriptor of the message, so that when the preset chip hardware recognizes the preset mark, the message is passed through, and the priority of the message in the queue is increased to a target priority to preferentially transmit the message.
10. The packet rate limiting method according to claim 9, wherein Before increasing the priority of the message in the queue, the method further includes: The microcode obtains the target priority of the message configured by the protocol stack; The microcode sends the target priority to the chip hardware through the message descriptor.
11. An electronic device, characterized in that, The electronic device includes: One or more processors; A memory storing one or more programs thereon, which when executed by the one or more processors cause the one or more processors to implement the message rate-limiting method according to any one of claims 1-10; One or more input / output I / O interfaces connected between the processor and the memory and configured to implement information interaction between the processor and the memory.
12. A computer-readable storage medium having a computer program stored thereon, where the computer program, when executed by a processor, implements the message rate-limiting method according to any one of claims 1-10.