Communication method and electronic equipment
By combining a two-level QoS control strategy with HTB and DRR algorithms, the problems of bandwidth allocation and flow control in cross-domain PCIe devices are solved, achieving efficient transmission and scheduling and maximizing hardware resource utilization.
Patent Information
- Application Number
- CN202511284570.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-11-14
AI Technical Summary
In cross-domain shared PCIe device scenarios, how can we balance the bandwidth requirements of different Traffic Classes and Functions, achieve fine-grained bandwidth allocation and traffic control, smoothly handle sudden bandwidth fluctuations, and ensure efficient transmission and scheduling?
A two-level QoS control strategy is adopted, combining HTB and DRR algorithms. The bottom layer performs hierarchical token bucket bandwidth allocation based on traffic category, and the top layer performs deficit round-robin scheduling based on function to ensure the bandwidth requirements of different traffic categories and functions.
It achieves end-to-end QoS guarantee, maximizes hardware resource utilization, performs fine-grained bandwidth allocation and traffic control, smoothly handles sudden bandwidth fluctuations, and ensures efficient transmission and scheduling.
Smart Images

Figure CN120956667A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a communication method and electronic device. Background Technology
[0002] NTB (Non-Transparent Bridge) is a special PCIe bridging technology used to connect two or more independent PCIe domains, allowing them to communicate while maintaining isolation between their respective address spaces. NTEP refers to a PCIe terminal device with NTB functionality. How to enable NTEP to meet the cross-domain access bandwidth requirements of different Traffic Classes and Functions, maximizing hardware resource utilization in scenarios where PCIe devices are shared across domains, and ensuring efficient transmission and scheduling while smoothly handling bandwidth fluctuations caused by sudden cross-domain accesses have become urgent technical problems to be solved by those skilled in the art. Summary of the Invention
[0003] This application provides a communication method and electronic device that enables NTEP to take into account the cross-domain access bandwidth requirements of different Traffic Classes and Functions. In scenarios where PCIe devices are shared across domains, it maximizes hardware resource utilization, performs fine-grained bandwidth allocation and traffic control, and ensures efficient transmission and scheduling while smoothly handling bandwidth fluctuations caused by sudden cross-domain access.
[0004] This application provides a communication method, including: Acquire and parse data packets to obtain the function number, traffic type, and data packet length; The token corresponding to the bandwidth requirement of the data packet is determined based on the data packet length; Based on the tokens filled in the token bucket corresponding to the traffic category, the token corresponding to the bandwidth requirement of the data packet, and the token allocated to the function corresponding to the function number, determine whether to allow the data packet to be sent; If sending the data packet is permitted, then based on the length of the data packet and the value of the deficit counter corresponding to the function, it is determined whether to send the data packet in this round; If the data packet is sent in this round, then the data packet is sent in this round.
[0005] This application also provides a communication device, including: The parsing module is used to acquire and parse data packets to obtain the function number, traffic type, and data packet length. The determining module is used to determine the token corresponding to the bandwidth requirement of the data packet based on the data packet length; The first judgment module is used to determine whether to allow the sending of the data packet based on the tokens filled in the token bucket corresponding to the traffic category, the tokens corresponding to the bandwidth requirements of the data packet, and the tokens allocated to the function corresponding to the function number. The second judgment module is used to determine whether to send the data packet in this round based on the length of the data packet and the value of the deficit counter corresponding to the function if sending the data packet is allowed. The sending module is configured to send the data packet in the current round if the data packet is sent in the current round.
[0006] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement any of the above-described communication methods.
[0007] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described communication methods.
[0008] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described communication methods.
[0009] The beneficial effects are as follows: This application adopts a two-level QoS (Quality of Service) control strategy, combining the underlying HTB (Hierarchy Token Bucket) algorithm with the top-level DRR (Deficit Round Robin) algorithm. The underlying QoS is based on traffic category, using a hierarchical token bucket to implement bandwidth allocation and traffic shaping. Fine-grained bandwidth allocation and traffic shaping are performed on data packets of different traffic categories to ensure that traffic meets QoS requirements during underlying transmission. The top-level QoS is based on function, using deficit round-robin to allocate bandwidth resources. This solves the problem in function scheduling where large data packet transmissions for a particular function consume a lot of bandwidth, leading to excessively long data packet waiting times in the transmission queues of other functions. This two-level QoS control strategy achieves end-to-end QoS assurance, taking into account the bandwidth requirements of different traffic categories and functions. Therefore, in scenarios involving cross-domain shared PCIe devices, it maximizes hardware resource utilization, performs fine-grained bandwidth allocation and traffic control, ensures efficient transmission and scheduling, and smoothly handles bandwidth fluctuations caused by sudden cross-domain access. Attached Figure Description
[0010] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 A flowchart illustrating a communication method provided in an embodiment of this application; Figure 2 A schematic diagram illustrating a QoS policy provided in an embodiment of this application; Figure 3 This is a schematic diagram illustrating an application effect provided in an embodiment of this application; Figure 4 A schematic diagram of a tree structure provided in an embodiment of this application; Figure 5 This is a schematic diagram of the functional modules of an NTEP provided in an embodiment of this application; Figure 6 A schematic diagram illustrating deadlock generation and avoidance provided in an embodiment of this application; Figure 7 A flowchart illustrating a specific implementation of a communication method provided in this application embodiment; Figure 8 This is a schematic diagram of a data flow provided in an embodiment of this application. Detailed Implementation
[0012] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0013] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0014] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0015] The embodiments of this application provide a communication method. The method is described in detail below in conjunction with the execution flow of the method.
[0016] refer to Figure 1 As shown in the embodiment of this application, a communication method includes: S101: Retrieve and parse data packets to obtain the function number, traffic type, and data packet length; S102: Determine the token corresponding to the bandwidth requirement of the data packet based on the data packet length; S103: Determine whether to allow the sending of the data packet based on the tokens filled in the token bucket corresponding to the traffic category, the tokens corresponding to the bandwidth requirements of the data packet, and the tokens allocated to the function corresponding to the function number; S104: If sending the data packet is permitted, determine whether to send the data packet in this round based on the length of the data packet and the value of the deficit counter corresponding to the function; S105: If the data packet is to be sent in this round, then the data packet is to be sent in this round.
[0017] To enable cross-domain sharing of PCIe devices, improve hardware resource utilization, and take into account the bandwidth requirements of PCIe TC (Traffic Class) and each function, this embodiment proposes an NTEP QoS strategy that supports end-to-end QoS.
[0018] refer to Figure 2 As shown in Table 1, this embodiment employs a two-level QoS strategy: top-level QoS and bottom-level QoS. The bottom-level QoS is based on traffic category and uses a hierarchical token bucket to achieve bandwidth allocation and traffic shaping. The top-level QoS is based on function and uses a deficit round-robin scheduling algorithm.
[0019] Table 1
[0020] In the underlying QoS policy, multiple subclasses are used to represent multiple traffic categories, with the parent class being function. The function and the multiple token buckets corresponding to TC are organized into a tree-like queue structure through the hierarchical structure of HTB.
[0021] The effectiveness of the two-level QoS policy can be referenced. Figure 3 As shown.
[0022] refer to Figure 4 As shown, eight subclasses can be used to represent eight types of token buckets (TC0~TC7), with the parent class being function. The hierarchical structure of HTB organizes the function and the multiple token buckets corresponding to the TC into a tree-like queue structure.
[0023] Both the subclass and the parent class have two key parameters: Rassumed represents the token corresponding to the guaranteed bandwidth, i.e., the token corresponding to the minimum usable bandwidth. RCeiling represents the token corresponding to the maximum allowed bandwidth.
[0024] In this embodiment, the execution entity is NTEP. NTEP acquires and parses data packets to obtain the function number, traffic category, and data packet length. The function number refers to the function's identifier. NTEP determines the token corresponding to the bandwidth requirement of the data packet based on the data packet length. NTEP determines whether to allow the data packet to be sent based on the tokens filling the token bucket corresponding to the traffic category, the token corresponding to the data packet's bandwidth requirement, and the bandwidth allocated to the function corresponding to the function number.
[0025] In some embodiments, determining whether to allow the transmission of the data packet based on the tokens filled in the token bucket corresponding to the traffic category, the token corresponding to the bandwidth requirement of the data packet, and the token allocated to the function corresponding to the function number includes: Determine whether the token corresponding to the bandwidth requirement of the data packet is less than or equal to the token corresponding to the guaranteed bandwidth of the traffic category; If the token corresponding to the bandwidth requirement of the data packet is less than or equal to the token corresponding to the guaranteed bandwidth of the traffic category, then the data packet is allowed to be sent. If the token corresponding to the bandwidth requirement of the data packet is greater than the token corresponding to the guaranteed bandwidth of the traffic category, then determine whether the token corresponding to the bandwidth requirement of the data packet is less than the token corresponding to the maximum bandwidth of the traffic category. If the token corresponding to the bandwidth requirement of the data packet is less than the token corresponding to the maximum bandwidth of the traffic category, then the token is borrowed from the function corresponding to the function number, and when the token is borrowed, the data packet is allowed to be sent. If the token corresponding to the bandwidth requirement of the data packet is not less than the token corresponding to the maximum bandwidth of the traffic category, then sending the data corresponding to the guaranteed bandwidth of the traffic category in the data packet is permitted.
[0026] There is a free bandwidth borrowing mechanism between the parent and child classes. If the subclass's bandwidth requirement corresponds to a token Rcurrent exceeding its Rassumed but not reaching RCeiling, it can borrow tokens corresponding to the parent class's free bandwidth, but this cannot exceed the subclass's own maximum bandwidth RCeiling. In subsequent token bucket refill cycles, if the subclass has tokens corresponding to its free bandwidth, it will return the tokens borrowed from the parent class.
[0027] Referring to Table 2, if the token Rcurrent corresponding to the bandwidth requirement of a data packet is less than or equal to the token corresponding to the guaranteed bandwidth of the data packet's traffic class, then the data packet is allowed to be sent. If the token Rcurrent corresponding to the bandwidth requirement of a data packet is greater than the token Rassumed corresponding to the guaranteed bandwidth of the data packet's traffic class but less than the token RCeiling corresponding to the maximum bandwidth of the data packet's traffic class, then a token is borrowed from the parent class. If the token Rcurrent corresponding to the bandwidth requirement of a data packet is greater than or equal to the token RCeiling corresponding to the maximum bandwidth of the data packet's traffic class, then the portion exceeding RCeiling cannot be sent, and subsequent tokens must be waited for.
[0028] Table 2
[0029] In some embodiments, borrowing a token from the function corresponding to the function number includes: Based on the priority of the traffic category, a token is borrowed from the function corresponding to the function number, so that the token of the function corresponding to the function number is borrowed to the traffic category with the highest priority.
[0030] In some embodiments, the method further includes: during the token filling period, if there are idle tokens in the token bucket of the traffic category, returning the borrowed tokens to the function corresponding to the function number.
[0031] There are priorities among the different traffic categories. For example, the priorities of TC0 to TC7 increase sequentially. Tokens are borrowed from the parent category based on the priority of the traffic category, and the higher-priority subcategories are satisfied first.
[0032] Assuming the total bandwidth allocated to the function is 4GB (4096MB), the bandwidth requirements for the 8 traffic categories are shown in Table 3.
[0033] Table 3
[0034] Assuming a token generation interval of 1 second, the token bucket filling rate is the guaranteed bandwidth for the traffic category, and no further tokens are added after the guaranteed bandwidth is reached. The token bucket filling rate for each traffic category is shown in Table 4.
[0035] Table 4
[0036] The determination of whether a data packet is allowed to be sent is as follows: The remaining free tokens of the parent class = 4096 - the tokens corresponding to the guaranteed bandwidth of each subclass = 4096 - (500 + 400 + 300 + 200 + 100 + 100 + 100 + 100) = 2296MB.
[0037] When a subclass borrows an idle token from its parent class, it acquires the token according to its priority level.
[0038] The determination of whether a data packet is allowed to be sent can be found in Table 5.
[0039] Table 5
[0040] TC4 and TC1 intend to borrow the tokens corresponding to the parent class's idle bandwidth. The parent class has 2296MB of remaining idle bandwidth tokens. TC4 and TC1 will each obtain 100MB of tokens according to their priority level. After borrowing, the parent class's remaining idle bandwidth tokens will be 2296-100-100=2096MB.
[0041] The next token is generated at interval Δt, at which time the token is refreshed.
[0042] For example, as shown in Table 6, the token after the parent class refresh is 4096MB.
[0043] Table 6
[0044] The refreshed tokens for each traffic category are shown in Table 7.
[0045] Table 7
[0046] In some embodiments, determining whether to send the data packet in this round based on the length of the data packet and the value of the deficit counter corresponding to the function in this round includes: Determine whether the length of the data packet is less than or equal to the remaining value of the deficit counter corresponding to the function in this round; the remaining value of the deficit counter corresponding to the function is equal to the initial value of the deficit counter corresponding to the function minus the length of the data packets already sent in the transmission queue corresponding to the function; If the length of the data packet is less than or equal to the value of the deficit counter corresponding to the function described in this round, then the data packet is sent in this round; If the length of the data packet is greater than the value of the deficit counter corresponding to the function in this round, then the data packet will not be sent in this round.
[0047] In some embodiments, it also includes: If the transmission queue corresponding to the function is empty, then the value of the deficit counter corresponding to the function is set to zero; If the transmission queue corresponding to the function described in this round is not empty, then the remaining value of the deficit counter corresponding to the function described in the previous round is added to the preset quantum size to obtain the initial value of the deficit counter corresponding to the function described in this round.
[0048] A transmission queue is established for each function, and a deficit counter is established for each function. When a transmission queue is scheduled, a preset quantum size is added to the deficit counter for that transmission queue. If the value of the deficit counter is greater than or equal to the size of the next data packet to be sent in the queue, the data packet can be sent, and the size of the data packet is subtracted from the deficit counter.
[0049] For example, as shown in Table 8, the preset quantum size is 1024B, and the initial value of the deficit counter corresponding to each function is 0.
[0050] Table 8
[0051] Function_0 represents the transmission queue corresponding to function 0, i.e., function number 0. Function_1 represents the transmission queue corresponding to function 1, i.e., function number 1. Function_2 represents the transmission queue corresponding to function 2, i.e., function number 2.
[0052] First round of data transmission process: Function _0 is to send two data packets, one 512 bytes and the other 1024 bytes.
[0053] Function _1: A 512-byte data packet to be sent.
[0054] Function 2: 256-byte data packet to be sent.
[0055] All three transmission queues are not empty.
[0056] The first data packet in Function _0 is 512 bytes, and the queue is not empty.
[0057] load The data packet is 512 bytes smaller than If so, a 512-byte data packet will be sent.
[0058] After sending a 512-byte data packet, The next data packet size is 1024 bytes, which is greater than... If the transmission stops, then the sending process will cease.
[0059] Function_1 sends the first data packet, 512 bytes.
[0060] Then, If the transmission queue is then empty, then Set to 0.
[0061] Function_2 sends the first data packet, 256 bytes.
[0062] If the transmission queue is then empty, then Set to 0.
[0063] Second round of data transmission process: Only one transmission queue is not empty.
[0064] Function 0: The transmission queue is not empty. = 512 (remaining from the previous round) + 1024 (this round) = 1536 bytes, the current data packet to be sent is 1024 bytes.
[0065] The current data packet to be sent is 1024 bytes. Send a 1024-byte data packet. After sending the data packet, the transmission queue is empty. Set to 0.
[0066] Function 1: Skip if the transmission queue is empty. Set to 0.
[0067] Function 2: Skip if the transmission queue is empty. Set to 0.
[0068] In some embodiments, acquiring and parsing data packets includes: Check if the preset queue is empty; If the preset queue is empty, data packets are obtained from the input buffer and parsed to obtain the function number, traffic type, and data packet length. If the preset queue is not empty, then determine whether the fill rate of the preset queue has reached a preset threshold. If the fill rate of the preset queue reaches a preset threshold, then data packets are retrieved from the preset queue and parsed. If the fill rate of the preset queue does not reach the preset threshold, data packets are retrieved from the input buffer and the preset queue in turn and parsed.
[0069] refer to Figure 5 As shown, the main functional modules of NTEP include the NTEP slave interface, the NTEP master interface, TLPheader parsing, HTB token control, DRR deficit polling, and NTEP cross-domain processing logic. The HTB_DRR queue is the preset queue mentioned above.
[0070] The function of each module can be found in Table 9.
[0071] Table 9
[0072] Data packets are written to the input buffer, and it is determined whether the preset queue is empty. If the preset queue is empty, data packets are retrieved from the input buffer and parsed to obtain the function number, traffic type, and data packet length. If the preset queue is not empty, it is determined whether the fill rate of the preset queue has reached a preset threshold; for example, whether the fill rate of the preset queue has reached 70%. If the fill rate of the preset queue has reached the preset threshold, data packets are retrieved from the preset queue and parsed; if the fill rate of the preset queue has not reached the preset threshold, data packets are retrieved from the input buffer and the preset queue in a round-robin fashion for parsing.
[0073] refer to Figure 6 As shown, each HTB_DRR buffer in the preset queue consists of two parts: the physical part is memory (storing one TLP data packet), and the other part is the fill flag corresponding to the register. When a data packet is written to the HTB_DRR buffer, the fill flag is updated to 1; when it is retrieved from the HTB_DRR buffer queue, the flag is set to 0. The fill rate reflects the proportion of buffers with a fill flag of 1 to the total number of buffers.
[0074] Assuming that the HTB_DRR queue is currently empty except for HTB_DRR_queue_buffer_N, Figure 6 middle The TLP data packets, after being delayed by HTB and DRR determination, are written into the HTB_DRR queue HTB_DRR_queue_buffer_N. At this point, the HTB_DRR queue is full. When a TLP data packet enters, it is assumed that it will be delayed after being judged by HTB and DRR. However, if the HTB_DRR queue is already full, it cannot be written. The data is in the data path, and the subsequent flow scheduling logic cannot retrieve the data packet to enter the data path even if it meets the sending conditions, thus causing a deadlock.
[0075] refer to Figure 6 As shown, to avoid deadlock, the flow scheduling logic, upon determining that the HTB_DRR queue is not empty and the fill rate exceeds 70% (with a 30% buffer margin reserved), applies back pressure to the NTEP slave interface, only retrieving data packets from the HTB_DRR queue. After the HTB and DRR checks to ensure that the packets can be sent, cross-domain processing is performed, thus eliminating HTB_DRR queue alarms as quickly as possible.
[0076] In some embodiments, it also includes: Assign a corresponding function number to each function.
[0077] In some embodiments, it also includes: Configure guaranteed bandwidth and maximum bandwidth for each function and each traffic category; Configure the corresponding quantum size for each function.
[0078] refer to Figure 7 As shown, in one specific implementation, the NTEP workflow includes: Power-on initialization.
[0079] Perform PCIe enumeration. The process of PCIe enumeration involves assigning a unique function number to each function.
[0080] After PCIe enumeration is complete, NTEP initialization configuration is performed. NTEP initialization configuration sets the initial minimum and maximum bandwidth limits for each function and traffic category, as well as the initial quantum value for each function.
[0081] Cross-domain TLP packets arrive at the NTEP slave interface.
[0082] TLP packets are written to the input buffer.
[0083] Check if the HTB_DRR queue is empty.
[0084] If the HTB_DRR queue is empty, data packets are retrieved from the input buffer, parsed, and the function number, traffic type, and data packet length are obtained.
[0085] If the HTB_DRR queue is not empty, then check if the HTB_DRR queue is filled to 70%.
[0086] If the threshold of 70% is reached, data packets are retrieved from the HTB_DRR queue, parsed, and the function number, traffic type, and data packet length are obtained.
[0087] If the 70% threshold is not reached, data packets are retrieved from the input buffer and the HTB_DRR queue in a round-robin fashion.
[0088] Based on the function number, traffic category, and data packet length, the token corresponding to the function and traffic category is calculated according to the HTB algorithm.
[0089] The HTB algorithm is used to determine whether the token is sufficient for data packet transmission.
[0090] If the token does not meet the requirements for packet sending, the packet is added to the HTB_DRR queue.
[0091] If the token satisfies the data packet sending requirement, then the function performs a deficit polling to determine whether to send the data packet.
[0092] If a data packet is sent, the cross-domain conversion is completed through the NTEP cross-domain logic, and the cross-domain converted data packet is sent to the PCIe interconnect through the NTEP master interface to reach the host.
[0093] If no data packet is sent, the data packet is added to the HTB_DRR queue.
[0094] For NTEP data flow references Figure 8 As shown. Among them, Figure 8 middle to The meanings are shown in Table 10.
[0095] Table 10
[0096] In summary, this application employs a two-tier QoS control strategy, combining the underlying HTB algorithm with the top-level DRR algorithm. The underlying QoS is based on traffic category, using a hierarchical token bucket to implement bandwidth allocation and traffic shaping. Fine-grained bandwidth allocation and traffic shaping are performed on data packets of different traffic categories to ensure that traffic meets QoS requirements during underlying transmission. The top-level QoS is based on function, using a deficit round-robin allocation of bandwidth resources. This addresses the problem in function scheduling where large data packet transmissions for a particular function consume excessive bandwidth, leading to long waiting times for data packets in the transmission queues of other functions. This two-tier QoS control strategy achieves end-to-end QoS guarantees, balancing the bandwidth requirements of different traffic categories and functions. Therefore, in scenarios involving cross-domain shared PCIe devices, it maximizes hardware resource utilization, performs fine-grained bandwidth allocation and traffic control, ensures efficient transmission and scheduling, and smoothly handles bandwidth fluctuations caused by sudden cross-domain access.
[0097] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0098] Embodiments of this application also provide a communication device, the device comprising: The parsing module is used to acquire and parse data packets to obtain the function number, traffic type, and data packet length. The determining module is used to determine the token corresponding to the bandwidth requirement of the data packet based on the data packet length; The first judgment module is used to determine whether to allow the sending of the data packet based on the tokens filled in the token bucket corresponding to the traffic category, the tokens corresponding to the bandwidth requirements of the data packet, and the tokens allocated to the function corresponding to the function number. The second judgment module is used to determine whether to send the data packet in this round based on the length of the data packet and the value of the deficit counter corresponding to the function if sending the data packet is allowed. The sending module is configured to send the data packet in the current round if the data packet is sent in the current round.
[0099] In some embodiments, the first determination module includes: The first judgment unit is used to determine whether the token corresponding to the bandwidth requirement of the data packet is less than or equal to the token corresponding to the guaranteed bandwidth of the traffic category; The first determining unit is configured to allow the transmission of the data packet if the token corresponding to the bandwidth requirement of the data packet is less than or equal to the token corresponding to the guaranteed bandwidth of the traffic category. The second judgment unit is used to determine whether the token corresponding to the bandwidth requirement of the data packet is less than the token corresponding to the maximum bandwidth of the traffic category if the token corresponding to the bandwidth requirement of the data packet is greater than the token corresponding to the guaranteed bandwidth of the traffic category. The borrowing unit is used to borrow a token from the function corresponding to the function number if the token corresponding to the bandwidth requirement of the data packet is less than the token corresponding to the maximum bandwidth of the traffic category, and when the token is borrowed, the data packet is allowed to be sent. The second determining unit is configured to allow the transmission of data corresponding to the guaranteed bandwidth of the traffic category in the data packet if the token corresponding to the bandwidth requirement of the data packet is not less than the token corresponding to the maximum bandwidth of the traffic category.
[0100] In some embodiments, the borrowing unit is used for: Based on the priority of the traffic category, a token is borrowed from the function corresponding to the function number, so that the token of the function corresponding to the function number is borrowed to the traffic category with the highest priority.
[0101] In some embodiments, it also includes: The return module is used to return the borrowed tokens to the function corresponding to the function number if there are idle tokens in the token bucket of the traffic category during the token filling period.
[0102] In some embodiments, the second determination module includes: The third judgment unit is used to determine whether the length of the data packet is less than or equal to the remaining value of the deficit counter corresponding to the function in this round; the remaining value of the deficit counter corresponding to the function is equal to the initial value of the deficit counter corresponding to the function minus the length of the data packets already sent in the transmission queue corresponding to the function; The third determining unit is used to send the data packet in this round if the length of the data packet is less than or equal to the value of the deficit counter corresponding to the function in this round. The fourth determining unit is configured to not send the data packet in this round if the length of the data packet is greater than the value of the deficit counter corresponding to the function in this round.
[0103] In some embodiments, it also includes: The zeroing module is used to set the value of the deficit counter corresponding to the function to zero if the transmission queue corresponding to the function is empty. The initial value determination module is used to add a preset quantum size to the remaining value of the deficit counter corresponding to the function in the previous round if the transmission queue corresponding to the function in this round is not empty, so as to obtain the initial value of the deficit counter corresponding to the function in this round.
[0104] In some embodiments, the parsing module includes: The fourth judgment unit is used to determine whether the preset queue is empty; The first parsing unit is used to obtain and parse data packets from the input buffer if the preset queue is empty, and obtain the function number, traffic type and data packet length. The fifth judgment unit is used to determine whether the fill rate of the preset queue has reached a preset threshold if the preset queue is not empty. The second parsing unit is used to retrieve and parse data packets from the preset queue if the fill rate of the preset queue reaches a preset threshold. The round-robin unit is used to retrieve and parse data packets from the input buffer and the preset queue in a round-robin fashion if the fill rate of the preset queue does not reach a preset threshold.
[0105] In some embodiments, it also includes: The allocation module is used to assign corresponding function numbers to each function.
[0106] In some embodiments, it also includes: The first configuration module is used to configure the guaranteed bandwidth and maximum bandwidth for each function and each traffic category; The second configuration module is used to configure the corresponding quantum size for each function.
[0107] For a description of the features in the embodiments corresponding to the communication device, please refer to the relevant descriptions in the embodiments corresponding to the communication method, which will not be repeated here.
[0108] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the communication method embodiments described above.
[0109] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described communication method embodiments when it is run.
[0110] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0111] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described communication method embodiments.
[0112] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described communication method embodiments.
[0113] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0114] The communication method and electronic device provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.
Claims
1. A communication method, characterized in that, include: Acquire and parse data packets to obtain the function number, traffic type, and data packet length; The token corresponding to the bandwidth requirement of the data packet is determined based on the data packet length; Based on the tokens filled in the token bucket corresponding to the traffic category, the token corresponding to the bandwidth requirement of the data packet, and the token allocated to the function corresponding to the function number, determine whether to allow the data packet to be sent; If sending the data packet is permitted, then based on the length of the data packet and the value of the deficit counter corresponding to the function, it is determined whether to send the data packet in this round; If the data packet is sent in this round, then the data packet is sent in this round.
2. The communication method according to claim 1, characterized in that, Determining whether to allow the transmission of the data packet based on the tokens filled in the token bucket corresponding to the traffic category, the token corresponding to the bandwidth requirement of the data packet, and the token allocated to the function corresponding to the function number includes: Determine whether the token corresponding to the bandwidth requirement of the data packet is less than or equal to the token corresponding to the guaranteed bandwidth of the traffic category; If the token corresponding to the bandwidth requirement of the data packet is less than or equal to the token corresponding to the guaranteed bandwidth of the traffic category, then the data packet is allowed to be sent. If the token corresponding to the bandwidth requirement of the data packet is greater than the token corresponding to the guaranteed bandwidth of the traffic category, then determine whether the token corresponding to the bandwidth requirement of the data packet is less than the token corresponding to the maximum bandwidth of the traffic category. If the token corresponding to the bandwidth requirement of the data packet is less than the token corresponding to the maximum bandwidth of the traffic category, then the token is borrowed from the function corresponding to the function number, and when the token is borrowed, the data packet is allowed to be sent. If the token corresponding to the bandwidth requirement of the data packet is not less than the token corresponding to the maximum bandwidth of the traffic category, then sending the data corresponding to the guaranteed bandwidth of the traffic category in the data packet is permitted.
3. The communication method according to claim 2, characterized in that, Borrowing a token from the function corresponding to the function number includes: Based on the priority of the traffic category, a token is borrowed from the function corresponding to the function number, so that the token of the function corresponding to the function number is borrowed to the traffic category with the highest priority.
4. The communication method according to claim 2, characterized in that, Also includes: During the token filling cycle, if there are idle tokens in the token bucket of the traffic category, the borrowed tokens are returned to the function corresponding to the function number.
5. The communication method according to claim 1, characterized in that, Determining whether to send the data packet in this round based on the data packet length and the deficit counter value corresponding to the function includes: Determine whether the length of the data packet is less than or equal to the remaining value of the deficit counter corresponding to the function in this round; the remaining value of the deficit counter corresponding to the function is equal to the initial value of the deficit counter corresponding to the function minus the length of the data packets already sent in the transmission queue corresponding to the function; If the length of the data packet is less than or equal to the value of the deficit counter corresponding to the function described in this round, then the data packet is sent in this round; If the length of the data packet is greater than the value of the deficit counter corresponding to the function in this round, then the data packet will not be sent in this round.
6. The communication method according to claim 5, characterized in that, Also includes: If the transmission queue corresponding to the function is empty, then the value of the deficit counter corresponding to the function is set to zero; If the transmission queue corresponding to the function described in this round is not empty, then the remaining value of the deficit counter corresponding to the function described in the previous round is added to the preset quantum size to obtain the initial value of the deficit counter corresponding to the function described in this round.
7. The communication method according to claim 1, characterized in that, Retrieving and parsing data packets includes: Check if the preset queue is empty; If the preset queue is empty, data packets are obtained from the input buffer and parsed to obtain the function number, traffic type, and data packet length; If the preset queue is not empty, then determine whether the fill rate of the preset queue has reached a preset threshold. If the fill rate of the preset queue reaches a preset threshold, then data packets are retrieved from the preset queue and parsed. If the fill rate of the preset queue does not reach the preset threshold, data packets are retrieved from the input buffer and the preset queue in turn and parsed.
8. The communication method according to claim 1, characterized in that, Also includes: Assign a corresponding function number to each function.
9. The communication method according to claim 1, characterized in that, Also includes: Configure guaranteed bandwidth and maximum bandwidth for each function and each traffic category; Configure the corresponding quantum size for each function.
10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the communication method as described in any one of claims 1 to 9.
Citation Information
Cited By
Industrial network session-level bandwidth management method and device and electronic equipment
CN122226705A