Message processing method and device, equipment and storage medium

By using the memory mechanism of association management in message processing, the problems of low packet processing efficiency and interlocking in the existing technology are solved, and an efficient and uniform packet processing process is achieved.

CN119544649APending Publication Date: 2025-02-28AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411733877.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

When processing network traffic, it is difficult for the prior art to process a large number of messages in a timely manner, which affects the reliability of security detection and is prone to message mutual exclusion and performance jitter, affecting processing efficiency.

Method used

Through the preset association relationship, the pending message is read from the network card and cached to the first memory, the message header information is obtained from the first memory to determine the processing thread identity, the storage address of the pending message is cached to the second memory associated with the processing thread, and the packet is obtained from the first memory according to the processing thread and the storage address for processing.

Benefits of technology

It realizes one-to-one correspondence in the processing process, ensures the uniqueness of memory writes, eliminates interlocking, improves the efficiency of message processing, makes the message processing process evenly allocated, and improves the efficiency of processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544649A_ABST
    Figure CN119544649A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a message processing method and device, equipment and a storage medium. The method comprises the following steps: reading a to-be-processed message from a corresponding message receiving queue based on a network card according to a preset first association relationship, and caching the to-be-processed message into a first memory; obtaining a to-be-processed message from the first memory, and determining an identifier of a processing thread of the to-be-processed message according to message header information of the to-be-processed message; caching a storage address of the to-be-processed message in the first memory to a second memory corresponding to the identifier of the processing thread according to a preset second association relationship; wherein the preset second association relationship represents the association relationship between the identifier and the second memory; and obtaining the to-be-processed message from the first memory according to the processing thread and the storage address of the to-be-processed message in the second memory in the first memory, and processing the to-be-processed message. The method is used for achieving the effect of improving the message reading and processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of message processing, and in particular to a message processing method, device, equipment and storage medium. Background Art

[0002] A message is a unit of data exchanged and transmitted in a network and is the basic unit of data transmission in a computer network. In the process of security testing of network traffic, a large number of messages need to be processed. For example, the number of messages per second at the Internet entrance of a data center can reach 800,000 to 1.6 million. In the process of security testing, if these messages cannot be processed in time, they can only be discarded, thus affecting the reliability of security testing.

[0003] At present, when receiving and processing messages, there are usually problems such as message mutual exclusion or performance jitter, which affects the processing efficiency. Therefore, how to improve the efficiency of message processing has become an urgent problem to be solved. Summary of the invention

[0004] The embodiments of the present application provide a message processing method, apparatus, device and storage medium to achieve the effect of improving message processing efficiency.

[0005] In a first aspect, an embodiment of the present application provides a message processing method, including:

[0006] According to a preset first association relationship, based on the network card, read the to-be-processed message from the corresponding message receiving queue, and cache the to-be-processed message in the first memory; wherein the preset first association relationship represents the association relationship between the network card and the message receiving queue;

[0007] Obtain the message to be processed from the first memory, and determine the identifier of the processing thread of the message to be processed according to the message header information of the message to be processed; wherein the processing thread represents the way to process the message to be processed;

[0008] According to a preset second association relationship, the storage address of the message to be processed in the first memory is cached in the second memory corresponding to the identifier of the processing thread; wherein the preset second association relationship represents the association relationship between the identifier and the second memory;

[0009] According to the processing thread and the storage address of the to-be-processed message in the second memory in the first memory, the to-be-processed message is obtained from the first memory, and the to-be-processed message is processed.

[0010] In a second aspect, an embodiment of the present application provides a message processing device, including:

[0011] An acquisition unit, configured to read the to-be-processed message from the corresponding message receiving queue based on the network card according to a preset first association relationship, and cache the to-be-processed message in the first memory; wherein the preset first association relationship represents the association relationship between the network card and the message receiving queue;

[0012] An identification unit, used to obtain a message to be processed from the first memory, and determine an identification of a processing thread of the message to be processed according to message header information of the message to be processed; wherein the processing thread represents a method of processing the message to be processed;

[0013] A cache unit, configured to cache the storage address of the message to be processed in the first memory to a second memory corresponding to the identifier of the processing thread according to a preset second association relationship; wherein the preset second association relationship represents the association relationship between the identifier and the second memory;

[0014] A reading unit is used to obtain the message to be processed from the first memory according to the processing thread and the storage address of the message to be processed in the second memory in the first memory, and process the message to be processed.

[0015] In a third aspect, an embodiment of the present application provides a message processing device, including: a memory, a processor;

[0016] The memory stores computer-executable instructions;

[0017] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.

[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.

[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.

[0020] The message processing method provided by the present application is to read the to-be-processed message from the corresponding queue in the network card according to the preset first association relationship, and cache the to-be-processed message in the first memory, read the message header information of the to-be-processed message from the first memory, and determine the identification of the processing thread of the to-be-processed message according to the message header information, store the storage address of the to-be-processed message in the first memory in the second memory corresponding to the identification of the processing thread according to the preset second association relationship, and read the to-be-processed message from the first memory according to the storage address of the to-be-processed message in the first memory in the processing thread and the second memory. By using the first memory and the second memory having respective association relationships, a one-to-one correspondence in the processing process is achieved, the uniqueness of memory writing is guaranteed, and the interlocking phenomenon is eliminated. By determining different second memories and processing threads, the message processing process is evenly distributed, the message processing process is efficient, and the efficiency of message processing is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0022] Figure 1 Schematic diagram of the message processing method provided in this application Figure 1 ;

[0023] Figure 2 A schematic diagram of an exemplary ring memory provided for an embodiment of the present disclosure;

[0024] Figure 3 A schematic diagram of the association relationship provided in the embodiment of the present disclosure;

[0025] Figure 4 Schematic diagram of the message processing method provided in this application Figure 2 ;

[0026] Figure 5 Schematic diagram of the message processing method provided in this application Figure 3 ;

[0027] Figure 6 A schematic diagram of the structure of the message processing device provided by this application;

[0028] Figure 7 A schematic diagram of the structure of the message processing device provided by this application;

[0029] Figure 8 A schematic diagram of the structure of the message processing electronic device provided in this application.

[0030] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0031] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0032] First, the terms involved in this application are explained:

[0033] Message: A message is a data unit exchanged and transmitted in a network, that is, a block of data that a station wants to send at one time.

[0034] Polling: Polling is a common computer science technique used to periodically check a state or resource to determine whether certain actions need to be performed. The polling mechanism queries the server for new data or events by sending requests periodically. If not, an empty response is returned. After receiving the response, the client can continue to send the next request.

[0035] Message header: The message header is an important part of the message. It is located at the beginning of the message and is used to identify the sender and receiver of the message, as well as the content type of the message. The message header usually contains some key information, such as the sender's address, the receiver's address, the length of the message, etc.

[0036] Request message: A request message is a data packet sent by a client to a server to request specific information or services.

[0037] Return message: A request message is a data packet sent by a client to a server to request specific information or services.

[0038] Quintuple: usually refers to source IP address, source port, destination IP address, destination port and transport layer protocol. For example: 192.168.1.1 10000 TCP 121.14.88.76 80 constitutes a quintuple. Its meaning is that a terminal with IP address 192.168.1.1 connects to a terminal with IP address 121.14.88.76 and port 80 through port 10000 and TCP protocol.

[0039] A message is a unit of data exchanged and transmitted in a network. In network communications, a message carries information and is transmitted from one node to another. Security detection of network traffic is currently a widely used means of maintaining network security. In the process of security detection, a large number of messages need to be processed. For example, the Internet entrance of a data center can usually reach 10 Gigabit Ethernet to 20 Gigabit Ethernet, and the number of messages per second can reach 800,000-1.6 million. If these messages cannot be processed in time, they can only be discarded and comprehensive detection cannot be performed, thus affecting the reliability of security detection.

[0040] At present, the method of processing messages is mostly multi-threaded parallel processing. During the processing, if the request message and the response message are processed by different threads, a large number of inter-thread message passing and mutual exclusion locks will be generated, seriously affecting the processing efficiency; during the message processing process, performance jitter occurs, which will cause problems such as network card packet loss.

[0041] The message processing method provided in this application is intended to solve the above technical problems in the prior art.

[0042] The message processing method provided by the present application has a specific application scenario as a message processing process, which reads the message to be processed from the corresponding queue in the network card according to a preset first association relationship, and caches the message to be processed in the first memory, reads the message header information of the message to be processed from the first memory, and determines the identification of the processing thread of the message to be processed according to the message header information, stores the storage address of the message to be processed in the first memory in the corresponding second memory according to the preset second association relationship, and the processing thread reads the storage address of the message to be processed in the first memory from the second memory, and reads the message to be processed from the first memory according to the storage address. By using the first memory and the second memory with their respective association relationships, a one-to-one correspondence in the processing process is achieved, the uniqueness of memory writing is guaranteed, and the interlocking phenomenon is eliminated. By determining different second memories and processing threads, the message processing process is evenly distributed, the message processing process is efficient, and the efficiency of message processing is improved.

[0043] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0044] Figure 1 Schematic diagram of the message processing method provided in this application Figure 1 , the method can be executed by a message processing device.

[0045] like Figure 1 As shown, the method comprises the following steps:

[0046] S101. Read to-be-processed messages from a corresponding message receiving queue based on a network card according to a preset first association relationship, and cache the to-be-processed messages in a first memory; wherein the preset first association relationship represents an association relationship between the network card and the message receiving queue.

[0047] Exemplarily, the hardware attributes of the network card are configured in advance, and the hardware attributes of the network card include the number of receiving queues of the network card and the algorithm of the network card. The number of receiving queues of the network card is configured, which can be configured according to a preset first association relationship. The first association relationship is preset, and the first association relationship represents the association relationship between the network card and the message receiving queue. The first association relationship can be, for example, presetting the number of network card reading threads and the number of reading thread polling queues. The number of network card reading threads is the number of threads used to read the network card; the number of reading thread polling queues is the number of queues polled by each thread. According to the number of network card reading threads and the number of reading thread polling queues, the number of message receiving queues for receiving messages in the network card is determined. For example, the number of network card reading threads can be multiplied by the number of reading thread polling queues. The result is the number of message receiving queues for receiving messages in the network card. The corresponding relationship between the network card and the number of message receiving queues is the first association relationship.

[0048] Configuring the algorithm of the network card may be to pre-set the algorithm of the network card, for example, the network card symmetric hash function may be used to write the request message and the return message of the same network connection in the network card into the same message receiving queue.

[0049] The first memory is pre-configured, and the first memory is a ring memory. The control data and storage units of the ring memory are pre-set. The control data includes at least one of the information such as the number of storage units, the size of storage units, a write cursor, a read cursor, and statistical information. The control data is used to control the working condition of the ring memory. The write cursor is the memory offset in the ring memory, which is used to control the storage unit of the ring memory to perform a write operation. The initial state of the write cursor is 0, and it is incremented by one after each write operation. When the maximum number of storage units is reached, the write cursor is set to 0 and overwritten. The read cursor is used to control the storage unit of the ring memory to perform a read operation. The initial state of the read cursor is 0, and it is incremented by one after each read operation. When the read cursor value is the same as the write cursor, wait for the write cursor to control the storage unit to perform a write operation. The storage unit is used to store information such as data and data status. The data can be content such as a message or a storage unit position, and the data status can be content such as data read or unread.

[0050] A network card reading thread is pre-set, and the network card reading thread is used to read the pending message from the receiving queue of the network card and write the pending message into the first memory. According to the preset first association relationship, based on the pre-configured network card, the network card reading thread reads the pending message from the corresponding message receiving queue and caches the pending message into the first memory.

[0051] Figure 2 FIG. 1 is a schematic diagram of an exemplary ring memory provided by an embodiment of the present disclosure. Figure 2 As shown, Figure 2 The rectangle labeled 1 represents the control data of the ring memory, which is used to control the working condition of the ring memory. The rectangle labeled 2 in the figure represents the storage unit in the ring memory, which is used to store information such as data and data status. The direction of the arrow is the writing direction of the ring memory, that is, the ring memory writes data in the direction of the arrow.

[0052] In this embodiment, caching the message to be processed into the first memory includes:

[0053] According to a preset third association relationship, a first memory corresponding to the message receiving queue is determined; wherein the preset third association relationship represents an association relationship between the message receiving queue and the first memory; and the message to be processed is cached in the first memory.

[0054] Specifically, a third association relationship is set in advance, and the third association relationship is the correspondence between the message receiving queue and the network card reading thread. For any network card reading thread, the network card reading thread can only read the to-be-processed messages from the specified message receiving queue. There is a one-to-one correspondence between the network card reading thread and the first memory. For any network card reading thread, there is a first memory corresponding to the network card reading thread, that is, the third association relationship represents the association relationship between the message receiving queue and the first memory.

[0055] According to the preset third association relationship, the network card reading thread corresponding to the message receiving queue where the message to be processed is located is determined, and the first memory corresponding to the message receiving queue where the message to be processed is located is determined. The network card reading thread reads the message to be processed from the message receiving queue and caches the message to be processed into the corresponding first memory.

[0056] The beneficial effect of such a setting is that there is an association between the message receiving queue and the first memory, and the to-be-processed messages read from the network card can be directly cached into the first memory. The operation is simple and direct, and it effectively avoids problems such as decreased reading efficiency due to performance jitter.

[0057] S102: Obtain a message to be processed from the first memory, and determine an identifier of a processing thread of the message to be processed according to message header information of the message to be processed; wherein the processing thread represents a method of processing the message to be processed.

[0058] Exemplarily, an allocation thread is pre-set, and the allocation thread is used to read the message header information of the message to be processed from the first memory, and determine the identifier of the processing thread of the message to be processed according to the message header information. The identifier of the processing thread is used to indicate that the message to be processed corresponds to the processing thread, and the identifier of the processing thread can be a number or a character number. There is a corresponding relationship between the allocation thread and the first memory, and each first memory corresponds to each allocation thread one by one; there is a corresponding relationship between the allocation thread and the processing thread, and each allocation thread corresponds to at least one processing thread.

[0059] According to the first memory where the message to be processed is located, the allocation thread corresponding to the first memory is determined, and according to the preset allocation thread, the message header information of the message to be processed is read from the first memory, and according to the message header information of the message to be processed, the processing thread identifier of the message to be processed is determined. For example, the identifier of the processing thread corresponding to the source IP can be determined according to the source IP content in the message header of the message to be processed.

[0060] S103. Cache the storage address of the to-be-processed message in the first memory into the second memory corresponding to the identifier of the processing thread according to a preset second association relationship; wherein the preset second association relationship represents the association relationship between the identifier and the second memory.

[0061] Exemplarily, a second association relationship is pre-set, and the second association relationship represents the association relationship between the identifier and the second memory, that is, each second memory corresponds to each processing thread one by one. The second memory is pre-configured, and the second memory is a ring memory, and the control data and storage unit of the ring memory are pre-set.

[0062] Figure 3 This is a schematic diagram of the association relationship provided by the embodiment of the present disclosure. Figure 3 As shown, the network card reading thread corresponds one-to-one to the first memory, and the network card reading thread is used to read the to-be-processed message from the network card and cache it in the first memory; the first memory corresponds one-to-one to the allocation thread, and the allocation thread is used to read the message header information of the to-be-processed message from the first memory, determine the processing thread identifier according to the message header information, and cache the storage address of the to-be-processed message in the first memory into the corresponding second memory; the allocation thread and the second memory are in a one-to-many relationship, that is, one allocation thread can correspond to N second memories; the second memory corresponds one-to-one to the processing thread.

[0063] According to a preset second association relationship, the second memory corresponding to the processing thread identifier is determined, and according to the allocation thread, the second memory corresponding to the processing thread identifier, and the identifier of the processing thread, the storage address of the message to be processed in the first memory is cached in the second memory corresponding to the identifier of the processing thread.

[0064] S104: Obtain the message to be processed from the first memory according to the processing thread and the storage address of the message to be processed in the second memory in the first memory, and process the message to be processed.

[0065] Exemplarily, the processing thread polls and reads the second memory to obtain the storage address of the pending message in the second memory in the first memory. According to the storage address of the pending message in the first memory, the processing thread reads the pending message from the first memory and processes the pending message.

[0066] The message processing method provided by the present application is to read the to-be-processed message from the corresponding queue in the network card according to the preset first association relationship, and cache the to-be-processed message in the first memory, read the message header information of the to-be-processed message from the first memory, and determine the identification of the processing thread of the to-be-processed message according to the message header information, store the storage address of the to-be-processed message in the first memory in the second memory corresponding to the identification of the processing thread according to the preset second association relationship, and read the to-be-processed message from the first memory according to the storage address of the to-be-processed message in the first memory in the processing thread and the second memory. By using the first memory and the second memory having respective association relationships, a one-to-one correspondence in the processing process is achieved, the uniqueness of memory writing is guaranteed, and the interlocking phenomenon is eliminated. By determining different second memories and processing threads, the message processing process is evenly distributed, the message processing process is efficient, and the efficiency of message processing is improved.

[0067] Figure 4 Schematic diagram of the message processing method provided in this application Figure 2 In this embodiment, Figure 1 Based on the embodiment, obtaining the message to be processed from the first memory, and determining the identifier of the processing thread of the message to be processed according to the message header information of the message to be processed is described in detail, and the method includes:

[0068] Obtain the message to be processed from the first memory to obtain the message header information of the message to be processed; determine the number of all preset processing threads; and determine the identifier of the processing thread of the message to be processed according to the message header information of the message to be processed and the number of all preset processing threads.

[0069] like Figure 4 As shown, the method comprises the following steps:

[0070] S401. Read to-be-processed messages from a corresponding message receiving queue based on a network card according to a preset first association relationship, and cache the to-be-processed messages in a first memory; wherein the preset first association relationship represents an association relationship between the network card and the message receiving queue.

[0071] Exemplarily, this step may refer to the above-mentioned step S101 and will not be described in detail.

[0072] S402: Acquire a message to be processed from the first memory, and obtain message header information of the message to be processed.

[0073] Exemplarily, according to the correspondence between the first memory and the allocation thread, the allocation thread corresponding to the first memory where the message to be processed is located is determined as the target allocation thread, and according to the target allocation thread corresponding to the first memory where the message to be processed is located, the message to be processed is read from the first memory where the message to be processed is located to obtain the message header information of the message to be processed.

[0074] The beneficial effect of such a setting is that, according to the correspondence between the first memory and the allocated thread, the message header information of the message to be processed is read from the corresponding first memory, so that the message information will not be cross-read between threads, thereby improving the performance of message reading.

[0075] S403: Determine the number of all preset processing threads.

[0076] Exemplarily, the number of all preset processing threads is determined. For example, the number of processing threads and the correspondence between the allocation threads and the processing threads may be preset, and the correspondence between the allocation threads and the processing threads may be, for example, that each allocation thread corresponds to at least one preset processing thread. According to the preset number of processing threads and the correspondence between the allocation threads and the processing threads, the number of preset processing threads corresponding to the target allocation thread is determined.

[0077] The beneficial effect of such a setting is that, according to the preset number of processing threads and the corresponding relationship between the processing threads and the allocation threads, the number of processing threads corresponding to the target allocation thread is determined, which is convenient for subsequent processing.

[0078] S404: Determine the identifier of the processing thread of the message to be processed according to the message header information of the message to be processed and the number of all preset processing threads.

[0079] Exemplarily, the identification of the processing thread of the message to be processed is determined according to the message header information of the message to be processed and the number of all preset processing threads. For example, the processing threads may be numbered according to the number of processing threads corresponding to the target allocation thread. For example, if the target allocation thread corresponds to 3 processing threads, the processing threads may be numbered to obtain processing thread 1, processing thread 2, and processing thread 3. The identification of the processing thread of the message to be processed is determined according to the message header information of the message to be processed and the number corresponding to the processing thread. For example, according to the message length information in the message header information, the processing thread identification of the message to be processed whose message length is less than the first length threshold is determined as 1; the processing thread identification of the message to be processed whose message length is greater than or equal to the first length threshold and less than the second length threshold is determined as 2; and the processing thread identification of the message to be processed whose message length is greater than or equal to the second length threshold is determined as 3.

[0080] The beneficial effect of such a setting is that the identification of the processing thread of the message to be processed is determined according to the message header information of the message to be processed and the number of processing threads, so that the message can be allocated to different processing threads, and the identification of the processing thread of the message to be processed is determined according to the message header information, so that the distribution of the message is more even.

[0081] In this embodiment, the target information is obtained from the message header information of the message to be processed; wherein the target information includes at least one of the protocol type, source IP, source port, destination IP, and destination port; based on the target information and the preset number of all processing threads, the identifier of the processing thread of the message to be processed is determined.

[0082] Specifically, the target information is obtained from the message header information of the message to be processed, and the target information includes at least one of the protocol type, source IP, source port, destination IP, and destination port. The target information is a five-tuple information, for example: 192.168.1.110000 TCP 121.14.88.76 80 constitutes a target information. Its meaning is that a terminal with an IP address of 192.168.1.1 is connected to a terminal with an IP address of 121.14.88.76 and a port of 80 through port 10000 using the TCP protocol. According to the target information and the number of all preset processing threads, the identification of the processing thread of the message to be processed is determined. For example, according to the target information, the values ​​of the information such as the protocol type, source IP, source port, destination IP, and destination port in the target information are summed to obtain the value of the target information, and the identification of the processing thread of the message to be processed is determined according to the value of the target information and the number corresponding to the processing thread. For example, the processing thread identifier of the pending message whose message length is less than the first numerical threshold is determined to be 1; the processing thread identifier of the pending message whose message length is greater than or equal to the first numerical threshold and less than the second numerical threshold is determined to be 2; and the processing thread identifier of the pending message whose message length is greater than or equal to the second numerical threshold is determined to be 3.

[0083] The beneficial effect of such a setting is that the target information of the message can be determined according to the message header information, and the processing thread identifier of the message to be processed can be determined according to the target information of the message, so that the determined processing thread identifier is more accurate and the distribution of the messages is more uniform.

[0084] In this embodiment, the target information is summed to obtain summed information; the summed information is modulo the number of all preset processing threads to obtain a remainder; and the remainder is determined as the identifier of the processing thread of the message to be processed.

[0085] Specifically, the protocol type, source IP, source port, destination IP, destination port and other information in the target information are numerically summed to obtain the summed information, and the summed information is a numerical value representing the target information. The number of processing threads corresponding to the target allocation thread is obtained, and the processing threads are numbered. According to the number of processing threads, a modulo operation is performed on the summed information to obtain a remainder, and the remainder is determined as the identifier of the processing thread of the message to be processed. For example, if the number of processing threads corresponding to the target allocation thread is 3, the processing threads are numbered to obtain processing thread 1, processing thread 2, and processing thread 3. According to the number of processing threads, a modulo operation is performed on the summed information to obtain a remainder of 2, then the identifier of the processing thread of the message to be processed is 2, that is, the processing thread identifier of the message to be processed corresponds to processing thread 2.

[0086] The beneficial effect of such a setting is that by taking the modulus of the value of the target information and the number of processing threads, the distribution of the messages is made more uniform, the messages can be more accurately distributed to the processing threads, and the efficiency of the message reading process is improved.

[0087] S405. Cache the storage address of the to-be-processed message in the first memory into the second memory corresponding to the identifier of the processing thread according to the preset second association relationship; wherein the preset second association relationship represents the association relationship between the identifier and the second memory.

[0088] Exemplarily, this step may refer to the above-mentioned step S203 and will not be described in detail.

[0089] S406: Obtain the message to be processed from the first memory according to the processing thread and the storage address of the message to be processed in the second memory in the first memory, and process the message to be processed.

[0090] Exemplarily, this step may refer to the above-mentioned step S204 and will not be described in detail.

[0091] The message processing method provided by the present application is to read the to-be-processed message from the corresponding queue in the network card according to the preset first association relationship, and cache the to-be-processed message in the first memory, read the message header information of the to-be-processed message from the first memory, and determine the identification of the processing thread of the to-be-processed message according to the message header information, store the storage address of the to-be-processed message in the first memory in the second memory corresponding to the identification of the processing thread according to the preset second association relationship, and read the to-be-processed message from the first memory according to the storage address of the to-be-processed message in the first memory in the processing thread and the second memory. By using the first memory and the second memory having respective association relationships, a one-to-one correspondence in the processing process is achieved, the uniqueness of memory writing is guaranteed, and the interlocking phenomenon is eliminated. By determining different second memories and processing threads, the message processing process is evenly distributed, the message processing process is efficient, and the efficiency of message processing is improved.

[0092] Figure 5 Schematic diagram of the message processing method provided in this application Figure 3 In this embodiment, Figure 1 Based on the embodiment, obtaining the to-be-processed message from the first memory according to the processing thread and the storage address of the to-be-processed message in the second memory in the first memory is described in detail, and the method includes:

[0093] Based on the processing thread, the storage address of the message to be processed in the first memory is obtained from the second memory; and according to the storage address of the message to be processed in the first memory, the message to be processed is obtained from the first memory.

[0094] like Figure 5As shown, the method comprises the following steps:

[0095] S501. Read to-be-processed messages from a corresponding message receiving queue based on a network card according to a preset first association relationship, and cache the to-be-processed messages in a first memory; wherein the preset first association relationship represents an association relationship between the network card and the message receiving queue.

[0096] Exemplarily, this step may refer to the above-mentioned step S101 and will not be described in detail.

[0097] S502: Obtain a message to be processed from the first memory, and determine an identifier of a processing thread of the message to be processed according to message header information of the message to be processed; wherein the processing thread represents a method of processing the message to be processed.

[0098] Exemplarily, this step may refer to the above-mentioned step S102 and will not be described in detail.

[0099] S503. Cache the storage address of the to-be-processed message in the first memory into the second memory corresponding to the identifier of the processing thread according to a preset second association relationship; wherein the preset second association relationship represents the association relationship between the identifier and the second memory.

[0100] Exemplarily, this step may refer to the above-mentioned step S103 and will not be described in detail.

[0101] S504: Based on the processing thread, obtain from the second memory the storage address of the message to be processed in the first memory.

[0102] Exemplarily, based on a preset second association relationship and an identifier of a processing thread, a processing thread corresponding to a second memory storing an address of a message to be processed in a first memory is determined, that is, there is a corresponding relationship between the processing thread and the processing thread identifier, and the processing thread and the processing thread identifier correspond one-to-one; there is a corresponding relationship between the processing thread and the second memory, and the processing thread and the second memory correspond one-to-one.

[0103] Based on the corresponding processing thread, the storage address of the message to be processed in the first memory is read from the second memory.

[0104] The beneficial effect of such a setting is that the processing thread first obtains the storage address of the to-be-processed message in the first memory from the second memory, so as to facilitate the subsequent reading of the to-be-processed message from the first memory according to the storage address.

[0105] S505: Obtain the message to be processed from the first memory according to the storage address of the message to be processed in the first memory.

[0106] Exemplarily, after obtaining the storage address of the message to be processed in the first memory, the processing thread reads the message to be processed from the corresponding storage address of the first memory according to the storage address of the message to be processed in the first memory.

[0107] The beneficial effect of such a configuration is that the processing thread can accurately read the message to be processed from the first memory according to the storage address of the message to be processed in the first memory.

[0108] The message processing method provided by the present application is to read the to-be-processed message from the corresponding queue in the network card according to the preset first association relationship, and cache the to-be-processed message in the first memory, read the message header information of the to-be-processed message from the first memory, and determine the identification of the processing thread of the to-be-processed message according to the message header information, store the storage address of the to-be-processed message in the first memory in the second memory corresponding to the identification of the processing thread according to the preset second association relationship, and read the to-be-processed message from the first memory according to the storage address of the to-be-processed message in the first memory in the processing thread and the second memory. By using the first memory and the second memory having respective association relationships, a one-to-one correspondence in the processing process is achieved, the uniqueness of memory writing is guaranteed, and the interlocking phenomenon is eliminated. By determining different second memories and processing threads, the message processing process is evenly distributed, the message processing process is efficient, and the efficiency of message processing is improved.

[0109] Figure 6 A schematic diagram of the structure of the message processing device provided in this application.

[0110] For the sake of convenience, only the parts related to the embodiments of the present disclosure are shown. Figure 6 The message processing device 600 provided in this embodiment includes: an acquisition unit 601, an identification unit 602, a cache unit 603 and a reading unit 604.

[0111] The acquisition unit 601 is used to read the to-be-processed message from the corresponding message receiving queue based on the network card according to the preset first association relationship, and cache the to-be-processed message in the first memory; wherein the preset first association relationship represents the association relationship between the network card and the message receiving queue;

[0112] The identification unit 602 is used to obtain the message to be processed from the first memory, and determine the identification of the processing thread of the message to be processed according to the message header information of the message to be processed; wherein the processing thread represents the way to process the message to be processed;

[0113] A cache unit 603, configured to cache the storage address of the to-be-processed message in the first memory to a second memory corresponding to the identifier of the processing thread according to a preset second association relationship; wherein the preset second association relationship represents an association relationship between the identifier and the second memory;

[0114] The reading unit 604 is used to obtain the message to be processed from the first memory according to the processing thread and the storage address of the message to be processed in the second memory in the first memory, and process the message to be processed.

[0115] Figure 7 A schematic diagram of the structure of the message processing device provided in this application.

[0116] exist Figure 6 Based on the embodiment shown, Figure 7 As shown, the identification unit 602 includes an acquisition module 6021 , a quantity module 6022 and an identification module 6023 .

[0117] The acquisition module 6021 is used to acquire the message to be processed from the first memory to obtain the message header information of the message to be processed;

[0118] A quantity module 6022 is used to determine the preset quantity of all processing threads;

[0119] The identification module 6023 is used to determine the identification of the processing thread of the message to be processed according to the message header information of the message to be processed and the number of all preset processing threads.

[0120] In one example, the identification module 6023 includes:

[0121] A target information submodule, used to obtain target information from the message header information of the message to be processed; wherein the target information includes at least one of the protocol type, source IP, source port, destination IP, and destination port;

[0122] The identification submodule is used to determine the identification of the processing thread of the message to be processed according to the target information and the number of all preset processing threads.

[0123] In one example, the identification submodule is specifically used for:

[0124] Performing summation processing on the target information to obtain summation information;

[0125] According to the preset number of all processing threads, the summed information is modulo to obtain a remainder;

[0126] The remainder is determined as the identifier of the processing thread of the message to be processed.

[0127] In one example, the reading unit 604 includes:

[0128] An address module, used for obtaining, from the second memory, a storage address of the message to be processed in the first memory based on the processing thread;

[0129] A reading module is used to obtain the message to be processed from the first memory according to the storage address of the message to be processed in the first memory.

[0130] In one example, it also includes:

[0131] A memory configuration unit is used for the first memory and the second memory to be pre-configured ring memories.

[0132] In one example, the acquisition unit 601 includes:

[0133] An association module, configured to determine a first memory corresponding to the message receiving queue according to a preset third association relationship; wherein the preset third relationship represents an association relationship between the message receiving queue and the first memory;

[0134] A cache module is used to cache the message to be processed in the first memory.

[0135] The message processing device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.

[0136] Figure 8 A schematic diagram of the structure of the message processing electronic device provided in this application.

[0137] like Figure 8 As shown, the electronic device 80 provided in this embodiment includes: at least one processor 801 and a memory 802. Optionally, the device 80 also includes a communication component 803. The processor 801, the memory 802 and the communication component 803 are connected via a bus 804.

[0138] In a specific implementation process, at least one processor 801 executes the computer-executable instructions stored in the memory 802, so that at least one processor 801 executes the above method.

[0139] The specific implementation process of the processor 801 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.

[0140] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0141] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.

[0142] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0143] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.

[0144] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.

[0145] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.

[0146] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.

[0147] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0148] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0149] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0150] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0151] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0152] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A message processing method, characterized in that: include: According to a preset first association relationship, based on the network card, read the to-be-processed message from the corresponding message receiving queue, and cache the to-be-processed message in the first memory; wherein the preset first association relationship represents the association relationship between the network card and the message receiving queue; Acquire the message to be processed from the first memory, and determine the identifier of the processing thread of the message to be processed according to the message header information of the message to be processed; wherein the processing thread represents the way to process the message to be processed; According to a preset second association relationship, the storage address of the to-be-processed message in the first memory is cached in a second memory corresponding to the identifier of the processing thread; wherein the preset second association relationship represents the association relationship between the identifier and the second memory; According to the processing thread and the storage address of the to-be-processed message in the second memory in the first memory, the to-be-processed message is obtained from the first memory, and the to-be-processed message is processed.

2. The method according to claim 1, characterized in that: Acquiring the message to be processed from the first memory, and determining the identifier of the processing thread of the message to be processed according to the message header information of the message to be processed, including: Acquire the message to be processed from the first memory to obtain message header information of the message to be processed; Determine the preset number of all processing threads; The identifier of the processing thread of the message to be processed is determined according to the message header information of the message to be processed and the number of all preset processing threads.

3. The method according to claim 2, characterized in that Determining, according to the message header information of the message to be processed and the number of all the preset processing threads, an identifier of a processing thread of the message to be processed, includes: Acquire target information from the message header information of the message to be processed; wherein the target information includes at least one of a protocol type, a source IP, a source port, a destination IP, and a destination port; The identifier of the processing thread of the message to be processed is determined according to the target information and the number of all preset processing threads.

4. The method according to claim 3, characterized in that Determining, according to the target information and the number of all preset processing threads, an identifier of a processing thread for the message to be processed, including: Performing summation processing on the target information to obtain summation information; According to the preset number of all processing threads, the summed information is modulo to obtain a remainder; The remainder is determined as the identifier of the processing thread of the message to be processed.

5. The method according to claim 1, characterized in that Acquiring the message to be processed from the first memory according to the processing thread and the storage address of the message to be processed in the second memory in the first memory, comprising: Based on the processing thread, obtaining from the second memory a storage address of the message to be processed in the first memory; According to the storage address of the message to be processed in the first memory, the message to be processed is obtained from the first memory.

6. The method according to any one of claims 1 to 5, characterized in that The first memory and the second memory are both pre-configured ring memories.

7. The method according to any one of claims 1 to 5, characterized in that Cache the to-be-processed message in the first memory, comprising: According to a preset third association relationship, determining a first memory corresponding to the message receiving queue; wherein the preset third association relationship represents an association relationship between the message receiving queue and the first memory; The to-be-processed message is cached in the first memory.

8. A message processing device, characterized in that: include: An acquisition unit, configured to read the to-be-processed message from the corresponding message receiving queue based on the network card according to a preset first association relationship, and cache the to-be-processed message in a first memory; wherein the preset first association relationship represents an association relationship between the network card and the message receiving queue; an identification unit, configured to obtain the message to be processed from the first memory, and determine an identification of a processing thread of the message to be processed according to message header information of the message to be processed; wherein the processing thread represents a method of processing the message to be processed; A cache unit, configured to cache the storage address of the to-be-processed message in the first memory to a second memory corresponding to the identifier of the processing thread according to a preset second association relationship; wherein the preset second association relationship represents an association relationship between the identifier and the second memory; A reading unit is used to obtain the message to be processed from the first memory according to the processing thread and the storage address of the message to be processed in the second memory in the first memory, and process the message to be processed.

9. A message processing device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.