Message transmission methods, apparatus, systems, computer equipment and storage media

By using a lock-free network rate limiting method with hardware queues and enqueue and dequeue units, the counting error caused by concurrent token bucket operations in multi-core processors is solved, achieving more accurate rate limiting and stable network transmission.

CN116886628BActive Publication Date: 2026-03-10CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In multi-core processor scenarios, concurrent operations of the token bucket can lead to incorrect token counting. Existing lock optimization operations result in a significant difference between the rate-limited rate and the target rate, affecting network transmission performance.

Method used

A hardware queue is used to communicate with the enqueue and dequeue units. The global token bucket is accessed in a lock-free manner, and the tokens are sorted and stored according to the message identifier to achieve lock-free network rate limiting.

Benefits of technology

It improves the accuracy of the rate after speed limiting, prevents data congestion, and enhances the stability and efficiency of network transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116886628B_ABST
    Figure CN116886628B_ABST
Patent Text Reader

Abstract

This application provides a message transmission method, apparatus, system, computer device, storage medium, and computer program product. The system includes: obtaining a first message to be transmitted and a message identifier corresponding to each first message to be transmitted from an enqueue unit; the enqueue unit is used to obtain the first messages to be transmitted and generate message identifiers for each first message to be transmitted; storing each first message to be transmitted according to the order of its message identifiers; sending the first messages to be transmitted to a dequeue unit according to the order of their message identifiers; the dequeue unit is used to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted upon receiving the token. This method can improve the accuracy of the rate after rate limiting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data transmission technology, and in particular to a message transmission method, apparatus, system, computer equipment, storage medium, and computer program product. Background Technology

[0002] Common methods for network resource allocation include rate limiting and traffic shaping, both of which are based on the token bucket algorithm. The algorithm generates tokens at a set rate and adds them to a token bucket. Each user request needs to apply for a token; if there are not enough tokens, the request is rejected. Modern processors are mostly multi-core. To increase processing speed, multiple CPU cores on the device must simultaneously participate in generating and consuming tokens as data flows through it. To prevent errors caused by concurrent processing of token bucket data, spinlocks are typically used to protect the data processed by multiple CPU cores.

[0003] However, in multi-core processor scenarios, concurrent operations without protection of the token bucket can lead to incorrect token counts within the bucket. Therefore, software token bucket schemes running on multi-core processors use locks to protect the token bucket. Since locks can probabilistically reduce forwarding performance, current optimizations are implemented to address this issue. However, these optimizations can result in significant discrepancies between the rate-limited rate and the target rate. Summary of the Invention

[0004] Therefore, it is necessary to provide a message transmission method, apparatus, system, computer equipment, storage medium, and computer program product to address the aforementioned technical problems.

[0005] Firstly, this application provides a message transmission method. The method includes:

[0006] The first message to be transmitted and the message identifier corresponding to each first message to be transmitted are obtained from the queuing unit; the queuing unit is used to obtain the first message to be transmitted and generate the message identifier of the first message to be transmitted.

[0007] Each of the first messages to be transmitted is stored in the order of the message identifiers;

[0008] The first message to be transmitted is sent to the dequeue unit in the order of the message identifiers. The dequeue unit is used to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted when the token is received.

[0009] In one embodiment, each of the first messages to be transmitted includes a priority identifier; storing each of the first messages to be transmitted in the order of the message identifiers includes: sorting each of the first messages to be transmitted according to the priority identifiers contained in each of the first messages to be transmitted, and storing each of the first messages to be transmitted in the order of the message identifiers.

[0010] In one embodiment, each of the first messages to be transmitted further includes a data stream identifier; storing each of the first messages to be transmitted in the order of the message identifiers includes: sorting each of the first messages to be transmitted according to the priority identifier and the data stream identifier contained in each of the first messages to be transmitted, and storing each of the first messages to be transmitted in the order of the message identifiers.

[0011] In one embodiment, sorting the first messages to be transmitted according to the priority identifier and data stream identifier contained in each first message to be transmitted includes: obtaining the data stream to be transmitted corresponding to each first message to be transmitted according to the data stream identifier; sorting the plurality of second messages to be transmitted contained in each data stream to be transmitted according to the message identifier and the priority identifier to determine the order of each first message to be transmitted in the corresponding data stream to be transmitted; and sorting the data streams to be transmitted according to the priority identifier of each data stream to be transmitted.

[0012] In one embodiment, storing each of the first messages to be transmitted in the order of the message identifiers includes: obtaining the metadata information and message content information of each of the first messages to be transmitted; and storing the message identifier, the metadata information and the message content information of each of the first messages to be transmitted in the hardware queue.

[0013] In one embodiment, sending the first message to be transmitted to the dequeue unit in the order of the message identifiers includes: sending the first message to be transmitted to the dequeue unit that meets preset conditions in the order of the message identifiers.

[0014] In one embodiment, the preset condition includes that the load of the dequeue unit is lower than a preset load threshold; the step of sending the first message to be transmitted to the dequeue unit that meets the preset condition in the order of the message identifier includes: sending the first message to be transmitted to the dequeue unit whose load is lower than the preset load threshold in the order of the message identifier.

[0015] Secondly, this application provides a message transmission apparatus for use in a hardware queue that is communicatively connected to an enqueue unit and a dequeue unit. The apparatus includes:

[0016] The acquisition module is used to acquire a first message to be transmitted and a message identifier corresponding to each first message to be transmitted from the queuing unit; the queuing unit is used to acquire the first message to be transmitted and generate a message identifier for the first message to be transmitted.

[0017] The storage module is used to store each of the first messages to be transmitted in the order of the message identifiers;

[0018] The sending module is used to send the first message to be transmitted to the dequeue unit in the order of the message identifiers; the dequeue unit is used to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted when the token is received.

[0019] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:

[0020] The first message to be transmitted and the message identifier corresponding to each first message to be transmitted are obtained from the queuing unit; the queuing unit is used to obtain the first message to be transmitted and generate the message identifier of the first message to be transmitted.

[0021] Each of the first messages to be transmitted is stored in the order of the message identifiers;

[0022] The first message to be transmitted is sent to the dequeue unit in the order of the message identifiers. The dequeue unit is used to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted when the token is received.

[0023] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0024] The first message to be transmitted and the message identifier corresponding to each first message to be transmitted are obtained from the queuing unit; the queuing unit is used to obtain the first message to be transmitted and generate the message identifier of the first message to be transmitted.

[0025] Each of the first messages to be transmitted is stored in the order of the message identifiers;

[0026] The first message to be transmitted is sent to the dequeue unit in the order of the message identifiers. The dequeue unit is used to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted when the token is received.

[0027] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0028] The first message to be transmitted and the message identifier corresponding to each first message to be transmitted are obtained from the queuing unit; the queuing unit is used to obtain the first message to be transmitted and generate the message identifier of the first message to be transmitted.

[0029] Each of the first messages to be transmitted is stored in the order of the message identifiers;

[0030] The first message to be transmitted is sent to the dequeue unit in the order of the message identifiers. The dequeue unit is used to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted when the token is received.

[0031] In the above-mentioned message transmission method, apparatus, system, computer equipment, storage medium, and computer program product, in order to prevent congestion during the message transmission process and network resource allocation, traffic rate limiting can be performed, and hardware queues can be introduced to achieve lock-free network rate limiting. Specifically, the hardware queue is communicatively connected to the enqueue unit and the dequeue unit. The enqueue unit can obtain a first message to be transmitted, generate a message identifier for the first message to be transmitted, and send the first message to be transmitted and its message identifier to the hardware queue. The hardware queue can obtain the first message to be transmitted and the message identifier corresponding to each first message to be transmitted from the enqueue unit. Thus, the first messages to be transmitted can be sorted and stored in order. Furthermore, the first messages to be transmitted can be sent to the dequeue unit that meets the preset conditions according to the order of their message identifiers. The dequeue unit can access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted if the token is received. The message transmission method provided in this application can sort and store each message to be transmitted through a hardware queue, so that the dequeue unit can obtain the token of each message to be transmitted from the global token bucket in a lock-free access manner, thereby realizing lock-free network rate limiting and improving the accuracy of the rate after rate limiting. Attached Figure Description

[0032] Figure 1 An application environment diagram for a message transmission method provided in one embodiment;

[0033] Figure 2 A flowchart illustrating a message transmission method provided in one embodiment;

[0034] Figure 3 A flowchart illustrating a message transmission method provided for another embodiment;

[0035] Figure 4 A schematic diagram of the structure of a message transmission apparatus provided for another embodiment;

[0036] Figure 5 An internal structural diagram of a computer device is provided for one embodiment;

[0037] Figure 6 An internal structural diagram of a computer device is provided for another embodiment. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0039] The message transmission method provided in this application embodiment can be applied to, for example... Figure 1 The application environment shown. The message transmission system implementing this message transmission method may include a hardware queue, and enqueue and dequeue units communicatively connected to the hardware queue.

[0040] The enqueue unit can acquire multiple messages to be transmitted and generate a message identifier for each message. This message identifier can include a queue identifier and a data packet identifier. The queue identifier can be used to represent the hardware queue corresponding to each message to be transmitted, and the data packet identifier can be used to represent the identity information of each message to be transmitted. Next, each message to be transmitted and its message identifier can be sent to the hardware queue.

[0041] The hardware queue can obtain the first message to be transmitted and the message identifier corresponding to each first message to be transmitted from the enqueue unit; thus, it can sort the first messages to be transmitted and store them in order; then, it can send the first messages to be transmitted to the dequeue unit that meets the preset conditions according to the order of the message identifiers.

[0042] The dequeue unit can access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted if the token is received.

[0043] In one embodiment, such as Figure 2 As shown, a message transmission method is provided. This embodiment illustrates the method by applying it to a hardware queue that is communicatively connected to the enqueue unit and the dequeue unit.

[0044] Step S201: Obtain the first message to be transmitted and the message identifier corresponding to each first message to be transmitted from the queuing unit.

[0045] The enqueue unit is used to acquire the first message to be transmitted and generate its message identifier. Typically, in network resource allocation, multi-core processors are used. In multi-core processor scenarios, when rate limiting a network data stream, multiple cores of the processor lock the token bucket, potentially reducing network transmission performance. In some implementations, the multi-core processor's cores can be divided into two groups: an enqueue unit and a dequeue unit. The enqueue unit acquires the first message to be transmitted, generates its message identifier, and enqueues each message and its identifier into a hardware queue. After sorting the messages, the hardware queue stores them sequentially and allocates a dequeue unit that meets preset conditions. The dequeue unit accesses the global token bucket lock-free, acquires tokens from each queue, and transmits the first message upon receiving the token. The message identifier can include a queue identifier and a data packet identifier; the queue identifier can be used to represent the hardware queue corresponding to each message to be transmitted, and the data packet identifier can be used to represent the identity information of each message to be transmitted.

[0046] Step S202: Store each first message to be transmitted in the order of message identifiers.

[0047] Each first message to be transmitted may include a priority identifier and a data stream identifier. The priority identifier can be used to characterize the priority order of each first message to be transmitted, and the data stream identifier can be used to characterize the data stream to which each first message to be transmitted belongs. The hardware queue can sort each first message to be transmitted according to the priority identifier and the data stream identifier, ensuring that each first message to be transmitted in the same data stream is arranged sequentially and adjacently. Furthermore, the data streams are sorted according to their priority identifiers. Then, each first message to be transmitted can be stored sequentially in the hardware queue. The storage information of each first message to be transmitted may include, but is not limited to, the message identifier, metadata information, and content information corresponding to each first message to be transmitted.

[0048] Step S203: Send the first message to be transmitted to the dequeue unit in the order of the message identifiers.

[0049] The dequeue unit can access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner. Based on the message identifier of the received first message to be transmitted, it retrieves the token for the received first message to be transmitted from the global token bucket, and transmits the first message to be transmitted upon receiving the token. The hardware queue sequentially allocates each first message to be transmitted queue to a dequeue unit that meets preset conditions, also known as a consumer, according to the order of the first message to be transmitted queues. Multiple dequeue units can be included. In some possible implementations, the dequeue unit that meets the preset conditions can be the dequeue unit with a load less than a preset load threshold. In other possible implementations, the dequeue unit that meets the preset conditions can also be the dequeue unit with the lowest load.

[0050] In this embodiment, during message transmission and network resource allocation, to prevent congestion, traffic rate limiting can be implemented by introducing a hardware queue to achieve lock-free network rate limiting. Specifically, the hardware queue is communicatively connected to an enqueue unit and a dequeue unit. The enqueue unit can obtain a first message to be transmitted, generate a message identifier for the first message to be transmitted, and send the first message to be transmitted and its message identifier to the hardware queue. The hardware queue can obtain the first message to be transmitted and its corresponding message identifier from the enqueue unit. Therefore, the first messages to be transmitted can be sorted and stored sequentially. Furthermore, the first messages to be transmitted can be sent to the dequeue unit that meets preset conditions according to the order of their message identifiers. The dequeue unit can access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token for the received first message to be transmitted from the global token bucket based on the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted upon receiving the token. The message transmission method provided in this application can sort and store each message to be transmitted through a hardware queue, so that the dequeue unit can obtain the token of each message to be transmitted from the global token bucket in a lock-free access manner, thereby realizing lock-free network rate limiting and improving the accuracy of the rate after rate limiting.

[0051] In some embodiments, step S202 may include:

[0052] Based on the priority identifier contained in each first message to be transmitted, the first messages to be transmitted are sorted and stored in the order of the message identifiers.

[0053] Each first message to be transmitted contains a priority identifier. The priority identifier in each first message to be transmitted determines its priority on the transmission bus; generally, the smaller the priority identifier, the higher the priority. This hardware queue has a reordering function for each first message to be transmitted, ensuring the order of the messages. Therefore, the hardware queue can sort the first messages to be transmitted based on their priority identifiers and store them according to their message identifiers.

[0054] In the method of this embodiment, the hardware queue can sort each first message to be transmitted to ensure the accuracy of data transmission, realize lock-free network rate limiting, improve the accuracy of the rate after rate limiting, and prevent data transmission congestion.

[0055] In some embodiments, step S202 may further include:

[0056] Based on the priority identifier and data stream identifier contained in each first message to be transmitted, the first messages to be transmitted are sorted and stored in the order of the message identifiers.

[0057] Each of the first messages to be transmitted also includes a data stream identifier. This data stream can be a set of ordered messages, such as a video stream or an audio stream.

[0058] Specifically, in some embodiments, sorting the first messages to be transmitted according to their priority identifiers and data stream identifiers may include:

[0059] Based on the data stream identifier, obtain the data stream to be transmitted corresponding to each first message to be transmitted; based on the message identifier and priority identifier, sort the multiple second messages to be transmitted contained in each data stream to be transmitted to determine the order of each first message to be transmitted in the corresponding data stream to be transmitted; based on the priority identifier of each data stream to be transmitted, sort the data streams to be transmitted.

[0060] The data stream can be a set of ordered messages, such as a video stream or an audio stream. Each data stream, for example, each data stream to be transmitted can contain multiple second messages to be transmitted, and these multiple second messages to be transmitted have a priority order. The multiple first messages to be transmitted can each correspond to a different data stream to be transmitted. From the multiple first messages to be transmitted, the second messages to be transmitted belonging to each data stream to be transmitted are obtained, and the multiple second messages to be transmitted in each data stream to be transmitted are sorted within the data stream. Each data stream to be transmitted can also contain a priority identifier, so that each data stream to be transmitted can be sorted according to the priority identifier of each data stream to be transmitted. Thus, the sorting of multiple first messages to be transmitted can be completed.

[0061] In the method of this embodiment, each packet to be transmitted can be sorted and stored through a hardware queue, so that the dequeue unit can obtain the token of each packet to be transmitted from the global token bucket in a lock-free access manner, thereby realizing lock-free network rate limiting and improving the accuracy of the rate after rate limiting.

[0062] In some embodiments, step S202 may include:

[0063] Obtain the metadata and message content information of each first message to be transmitted; store the message identifier, metadata and message content information of each first message to be transmitted in a hardware queue.

[0064] The metadata information can be information describing the corresponding first message to be transmitted; the message content information can be the specific data content of the first message to be transmitted. In the hardware queue, the storage information of each first message to be transmitted can include the message identifier, metadata information, and message content information of each first message to be transmitted.

[0065] In some embodiments, step S203 may include:

[0066] The first message to be transmitted is sent to the dequeue unit that meets the preset conditions in the order of the message identifiers. Specifically, in some embodiments, the preset conditions may include: the load of the dequeue unit is lower than the preset load threshold; the first message to be transmitted is sent to the dequeue unit with the load lower than the preset load threshold in the order of the message identifiers. In other possible implementations, the dequeue unit that meets the preset conditions may also be the dequeue unit with the lowest load.

[0067] In this embodiment, each first message to be transmitted is sequentially assigned to a dequeue unit whose load meets the requirements, which facilitates subsequent token acquisition and data transmission and can improve the transmission efficiency of each first message to be transmitted.

[0068] In another embodiment, such as Figure 3 As shown, a message transmission method is provided, which may include:

[0069] Step S301: The enqueue unit obtains the first message to be transmitted and generates the message identifier of the first message to be transmitted.

[0070] Step S302: The hardware queue obtains the first message to be transmitted and the message identifier corresponding to each first message to be transmitted from the enqueuing unit.

[0071] The enqueue unit is used to acquire the first message to be transmitted and generate its message identifier. Typically, in network resource allocation, multi-core processors are used. In multi-core processor scenarios, when rate limiting a network data flow, multiple cores of the processor lock the token bucket, potentially reducing network transmission performance. In some implementations, the multi-core processor's cores can be divided into two groups: an enqueue unit and a dequeue unit. The enqueue unit acquires the first message to be transmitted, generates its message identifier, and enqueues each message and its identifier into a hardware queue. After sorting the messages, the hardware queue stores them sequentially and allocates a dequeue unit that meets preset conditions. The dequeue unit can access the global token bucket lock-free, acquire tokens for each queue, and transmit the first message upon receiving a token. The message identifier can include a queue identifier and a data packet identifier; the queue identifier can be used to represent the hardware queue corresponding to each message to be transmitted, and the data packet identifier can be used to represent the identity information of each message to be transmitted.

[0072] Step S303: Sort each first message to be transmitted according to the priority identifier and data stream identifier contained in each first message to be transmitted, and store each first message to be transmitted in the order of the message identifiers.

[0073] Each first message to be transmitted may include a priority identifier and a data stream identifier. The priority identifier can be used to characterize the priority order of each first message to be transmitted, and the data stream identifier can be used to characterize the data stream to which each first message to be transmitted belongs. The hardware queue can sort each first message to be transmitted according to the priority identifier and the data stream identifier, ensuring that each first message to be transmitted in the same data stream is arranged sequentially and adjacently. Furthermore, the data streams are sorted according to their priority identifiers. Then, each first message to be transmitted can be stored sequentially in the hardware queue. The storage information of each first message to be transmitted may include, but is not limited to, the message identifier, metadata information, and content information corresponding to each first message to be transmitted.

[0074] Specifically, based on the data stream identifier, the data stream to be transmitted corresponding to each first data stream to be transmitted is obtained; based on the message identifier and priority identifier, the multiple second data streams to be transmitted contained in each data stream to be transmitted are sorted to determine the order of each first data stream to be transmitted in its corresponding data stream; based on the priority identifier of each data stream to be transmitted, each data stream to be transmitted is sorted. This data stream can be a set of ordered messages, such as a video stream or an audio stream. Each data stream, for example, each data stream to be transmitted can contain multiple second data streams to be transmitted, and these multiple second data streams to be transmitted have a priority order. These multiple first data streams to be transmitted can each correspond to a different data stream to be transmitted. From these multiple first data streams to be transmitted, the second data streams to be transmitted belonging to each data stream to be transmitted are obtained, and the multiple second data streams to be transmitted are sorted within the data stream; each data stream to be transmitted can also contain a priority identifier, thus, each data stream to be transmitted can be sorted according to its priority identifier, thereby completing the sorting of multiple first data streams to be transmitted.

[0075] Step S304: Send the first message to be transmitted to the dequeue unit that meets the preset conditions in the order of the message identifiers.

[0076] The dequeue unit can access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner. Based on the message identifier of the received first message to be transmitted, it retrieves the token for the received first message to be transmitted from the global token bucket, and transmits the first message to be transmitted upon receiving the token. The hardware queue sequentially allocates each first message to be transmitted queue to a dequeue unit that meets preset conditions, also known as a consumer, according to the order of the first message to be transmitted queues. Multiple dequeue units can be included. In some possible implementations, the dequeue unit that meets the preset conditions can be the dequeue unit with a load less than a preset load threshold. In other possible implementations, the dequeue unit that meets the preset conditions can also be the dequeue unit with the lowest load.

[0077] Step S305: The dequeue unit accesses the global token bucket corresponding to the first message to be transmitted received in a lock-free manner.

[0078] Step S306: The dequeue unit obtains the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmits the first message to be transmitted if the token is received.

[0079] The token bucket algorithm is a common rate-limiting mechanism. It works by generating tokens and adding them to a token bucket at a set rate. Each user requesting to transmit a message needs to apply for a token; if there are insufficient tokens, the request is rejected. The basic process is as follows: every 1 / R seconds, one token is added to the token bucket, which can hold a maximum of B tokens. If the bucket is full, newly added tokens are discarded. When an N-byte data packet arrives, N tokens are consumed before the packet is sent. If the number of available tokens in the bucket is less than N, the packet is either buffered or discarded.

[0080] In this embodiment, during message transmission and network resource allocation, to prevent congestion, traffic rate limiting can be implemented by introducing a hardware queue to achieve lock-free network rate limiting. Specifically, the hardware queue is communicatively connected to an enqueue unit and a dequeue unit. The enqueue unit can obtain a first message to be transmitted, generate a message identifier for the first message to be transmitted, and send the first message to be transmitted and its message identifier to the hardware queue. The hardware queue can obtain the first message to be transmitted and its corresponding message identifier from the enqueue unit. Therefore, the first messages to be transmitted can be sorted and stored sequentially. Furthermore, the first messages to be transmitted can be sent to the dequeue unit that meets preset conditions according to the order of their message identifiers. The dequeue unit can access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token for the received first message to be transmitted from the global token bucket based on the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted upon receiving the token. The message transmission method provided in this application can sort and store each message to be transmitted through a hardware queue, so that the dequeue unit can obtain the token of each message to be transmitted from the global token bucket in a lock-free access manner, thereby realizing lock-free network rate limiting and improving the accuracy of the rate after rate limiting.

[0081] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0082] Based on the same inventive concept, this application also provides a message transmission apparatus for implementing the message transmission method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more message transmission apparatus embodiments provided below can be found in the limitations of the message transmission method described above, and will not be repeated here.

[0083] In one embodiment, such as Figure 4 As shown, a message transmission device is provided, including: an acquisition module 401, a storage module 402, and a transmission module 403, wherein:

[0084] The acquisition module 401 is used to acquire a first message to be transmitted and a message identifier corresponding to each first message to be transmitted from the queuing unit; the queuing unit is used to acquire the first message to be transmitted and generate a message identifier for the first message to be transmitted.

[0085] The storage module 402 is used to store each of the first messages to be transmitted in the order of the message identifiers;

[0086] The sending module 403 is used to send the first message to be transmitted to the dequeue unit in the order of the message identifiers; the dequeue unit is used to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted when the token is received.

[0087] The storage module 402 is further configured to: sort each of the first messages to be transmitted according to the priority identifier contained in each of the first messages to be transmitted, and store each of the first messages to be transmitted in the order of the message identifiers.

[0088] Furthermore, the storage module 402 is also configured to: sort each of the first messages to be transmitted according to the priority identifier and data stream identifier contained in each of the first messages to be transmitted, and store each of the first messages to be transmitted in the order of the message identifiers.

[0089] The storage module 402 is further configured to: obtain the data stream to be transmitted corresponding to each of the first data streams to be transmitted according to the data stream identifier; sort the multiple second data streams to be transmitted contained in each data stream to be transmitted according to the data stream identifier and the priority identifier, and determine the order of each of the first data streams to be transmitted in the corresponding data streams to be transmitted; and sort each data stream to be transmitted according to the priority identifier of each data stream to be transmitted.

[0090] The storage module 402 is further configured to: acquire metadata information and message content information of each of the first messages to be transmitted; and store the message identifier, metadata information and message content information of each of the first messages to be transmitted in the hardware queue.

[0091] The sending module 403 is further configured to: send the first message to be transmitted to the dequeue unit that meets the preset conditions in the order of the message identifiers.

[0092] The sending module 403 is further configured to: send the first message to be transmitted to the dequeue unit whose load is lower than a preset load threshold in the order of the message identifiers.

[0093] In one embodiment, such as Figure 1 As shown, a message transmission system is provided, including: a hardware queue, and an enqueue unit and a dequeue unit communicatively connected to the hardware queue, wherein...

[0094] The enqueue unit is used to acquire the first message to be transmitted and generate a message identifier for each of the first messages to be transmitted; and send the first message to be transmitted and the message identifiers for each of the first messages to be transmitted to the hardware queue corresponding to the message identifier.

[0095] The hardware queue is used to obtain a first message to be transmitted and a message identifier corresponding to each first message to be transmitted from the enqueue unit, and to store each first message to be transmitted in the order of the message identifiers; and to send the first messages to be transmitted to the dequeue unit in the order of the message identifiers.

[0096] The dequeue unit is configured to access the global token bucket corresponding to the received first message to be transmitted in a lock-free manner, obtain the token of the received first message to be transmitted from the global token bucket according to the message identifier of the received first message to be transmitted, and transmit the first message to be transmitted upon receiving the token.

[0097] Each module in the aforementioned message transmission device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware within or independently of the processor in a computer device, or stored in software within the memory of the computer device, so that the processor can invoke and execute the operations corresponding to each module.

[0098] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores data related to message transmission. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a message transmission method.

[0099] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a message transmission method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0100] Those skilled in the art will understand that Figure 5 and Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0101] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0102] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0103] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0104] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0105] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0106] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0107] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method of transmitting a packet, characterized by, The method is applied to a hardware queue in communication connection with an enqueuing unit and a plurality of dequeuing units, and comprises the following steps: Obtaining first to-be-transmitted messages from the enqueuing unit, and message identifiers corresponding to the first to-be-transmitted messages; the enqueuing unit is used for obtaining the first to-be-transmitted messages and generating message identifiers of the first to-be-transmitted messages; Storing the first to-be-transmitted messages in order of the message identifiers; Distributing the first to-be-transmitted messages to the dequeuing units in order of the message identifiers; the dequeuing unit receiving a first to-be-transmitted message is used for accessing a global token bucket corresponding to the received first to-be-transmitted message in a lock-free manner, obtaining a token of the received first to-be-transmitted message from the global token bucket according to a message identifier of the received first to-be-transmitted message, and transmitting the first to-be-transmitted message when the token is received.

2. The method of claim 1, wherein, The first to-be-transmitted messages each contain a priority identifier; the storing of the first to-be-transmitted messages in order of the message identifiers comprises the following steps: Sorting the first to-be-transmitted messages according to the priority identifiers contained in the first to-be-transmitted messages, and storing the first to-be-transmitted messages in order of the message identifiers.

3. The method of claim 2, wherein, The first to-be-transmitted messages each further contain a data flow identifier; the storing of the first to-be-transmitted messages in order of the message identifiers comprises the following steps: Sorting the first to-be-transmitted messages according to the priority identifiers and the data flow identifiers contained in the first to-be-transmitted messages, and storing the first to-be-transmitted messages in order of the message identifiers.

4. The method of claim 3, wherein, The sorting of the first to-be-transmitted messages according to the priority identifiers and the data flow identifiers contained in the first to-be-transmitted messages comprises the following steps: Obtaining to-be-transmitted data flows corresponding to the first to-be-transmitted messages according to the data flow identifiers; Sorting a plurality of second to-be-transmitted messages contained in each to-be-transmitted data flow according to the message identifiers and the priority identifiers, and determining the order of each first to-be-transmitted message in the corresponding to-be-transmitted data flow; Sorting the to-be-transmitted data flows according to the priority identifiers of the to-be-transmitted data flows.

5. The method of claim 3, wherein, The storing of the first to-be-transmitted messages in order of the message identifiers comprises the following steps: Obtaining metadata information and message content information of the first to-be-transmitted messages; Storing the message identifiers, the metadata information and the message content information of the first to-be-transmitted messages in the hardware queue.

6. The method of claim 1, wherein, The distributing of the first to-be-transmitted messages to the dequeuing units in order of the message identifiers comprises the following steps: Sending the first to-be-transmitted messages to the dequeuing units satisfying a preset condition in the plurality of dequeuing units in order of the message identifiers.

7. The method of claim 6, wherein, The preset condition comprises that the load of the dequeuing unit is lower than a preset load threshold; The distributing of the first to-be-transmitted messages to the dequeuing units satisfying a preset condition in the plurality of dequeuing units in order of the message identifiers comprises the following steps: sending the first to-be-transmitted messages to the de-queuing units with a load lower than a preset load threshold in the plurality of de-queuing units in order of the message identifiers.

8. A packet transmission apparatus characterized by comprising: The device is applied to a hardware queue in communication connection with a de-queuing unit and a plurality of de-queuing units, and comprises: an acquisition module, configured to acquire first to-be-transmitted messages and message identifiers corresponding to the first to-be-transmitted messages from the de-queuing unit; the de-queuing unit is configured to acquire the first to-be-transmitted messages and generate message identifiers of the first to-be-transmitted messages; a storage module, configured to store the first to-be-transmitted messages in order of the message identifiers; a sending module, configured to distribute the first to-be-transmitted messages to the de-queuing units in order of the message identifiers; the de-queuing unit receiving the first to-be-transmitted message is configured to access a global token bucket corresponding to the received first to-be-transmitted message in a lock-free manner, acquire a token of the received first to-be-transmitted message from the global token bucket according to a message identifier of the received first to-be-transmitted message, and transmit the first to-be-transmitted message when the token is received.

9. A message transfer system comprising: The hardware queue, the de-queuing unit and the plurality of de-queuing units in communication connection with the hardware queue, wherein the de-queuing unit is configured to acquire first to-be-transmitted messages, generate message identifiers of the first to-be-transmitted messages, and send the first to-be-transmitted messages and the message identifiers of the first to-be-transmitted messages to the hardware queue corresponding to the message identifiers; the hardware queue is configured to acquire first to-be-transmitted messages and message identifiers corresponding to the first to-be-transmitted messages from the de-queuing unit, store the first to-be-transmitted messages in order of the message identifiers, and distribute the first to-be-transmitted messages to the de-queuing units in order of the message identifiers; the de-queuing unit is configured to access a global token bucket corresponding to the received first to-be-transmitted message in a lock-free manner when the first to-be-transmitted message is received, acquire a token of the received first to-be-transmitted message from the global token bucket according to a message identifier of the received first to-be-transmitted message, and transmit the first to-be-transmitted message when the token is received. 10.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-9. The processor executes the computer program to implement the steps of the method of any one of claims 1-7.

11. A computer readable storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the steps of the method of any one of claims 1-7.

12. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1-7.

Citation Information

Patent Citations

  • Multicast message control method and system, storage medium and electronic equipment

    CN115460152A

  • Message processing method and device

    CN116016356A