CN115499387A - Message processing method and device, electronic equipment and storage medium - Google Patents

Message processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115499387A
CN115499387A CN202211111363.3A CN202211111363A CN115499387A CN 115499387 A CN115499387 A CN 115499387A CN 202211111363 A CN202211111363 A CN 202211111363A CN 115499387 A CN115499387 A CN 115499387A
Authority
CN
China
Prior art keywords
network card
message
cpu core
packet
sending
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202211111363.3A
Other languages
Chinese (zh)
Other versions
CN115499387B (en
Inventor
王越
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202211111363.3A priority Critical patent/CN115499387B/en
Publication of CN115499387A publication Critical patent/CN115499387A/en
Application granted granted Critical
Publication of CN115499387B publication Critical patent/CN115499387B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/62Queue scheduling characterised by scheduling criteria
    • H04L47/625Queue scheduling characterised by scheduling criteria for service slots or service orders
    • H04L47/6275Queue scheduling characterised by scheduling criteria for service slots or service orders based on priority
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • H04L47/2425Traffic characterised by specific attributes, e.g. priority or QoS for supporting services specification, e.g. SLA
    • H04L47/2433Allocation of priorities to traffic types

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application relates to the technical field of network communication, and provides a message processing method, a message processing device, electronic equipment and a storage medium. The method comprises the following steps: when a message is received, determining the type of the message, and distributing the message to a corresponding packet receiving queue of the network card; controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card; determining the priority of each received message, and sending the messages with high priority into a special packet sending queue of a corresponding packet sending network card through a special process to send packets; and controlling each CPU core to send the messages with the medium and low priority levels into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages. The method and the device ensure the integrity and timeliness of high-priority message transmission.

Description

Message processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of network communication technologies, and in particular, to a method and an apparatus for processing a packet, an electronic device, and a storage medium.
Background
With the rapid development of computer and internet technologies, china has entered the age of network informatization, and network communication equipment has become a necessity in the work and life of people. With the increasing types of information transmitted by networks, the amount of information transmitted by networks is also increasing, and the pressure borne by the network card is higher. When a large amount of network messages to be transmitted appear instantly, the packet sending queue of the network card may be fully loaded and overflow, which easily causes the loss or delay delivery of important messages. Therefore, a message processing method is needed to solve the problem of important message loss caused by large amount of network transmission information.
Disclosure of Invention
In view of the above, the present application provides a message processing method, an apparatus, an electronic device, and a storage medium, and aims to solve the problem of important messages being lost due to a large amount of network transmission information.
In order to achieve the above object, the present application provides a message processing method, where the method includes:
when a certain network card receives a message, determining the type of the message, and distributing the message to a corresponding packet receiving queue of the network card according to the type;
controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card;
determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending;
and controlling each CPU core to send the messages with the medium and low priority into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages.
Optionally, the distributing the packet to the corresponding packet receiving queue of the network card according to the type includes:
if the type of the message is a preset type, acquiring a source address, a source port number, a protocol number, a destination address and a destination port of the message, and constructing a five-tuple corresponding to the message;
and determining a corresponding packet receiving queue of the message on the network card based on the five-tuple.
Optionally, the determining, based on the quintuple, a corresponding packet receiving queue of the packet in the network card includes:
calculating the hash value of the quintuple;
performing modulus on the hash value to obtain a modulus result;
and determining the corresponding packet receiving queue of the message on the network card according to the modulus taking result.
Optionally, the calculating the hash value of the five-tuple includes:
respectively calculating an initial hash value corresponding to each element in the quintuple;
acquiring the weight corresponding to each predetermined element;
and calculating the hash value of the quintuple according to the initial hash value and the weight.
Optionally, the distributing the packet to the corresponding packet receiving queue of the network card according to the type includes:
and if the type of the message is not the preset type, sending the message into an appointed packet receiving queue of the network card.
Optionally, the process of determining the mapping relationship between the CPU core and the packet receiving queue of each network card includes:
determining a first number of CPU cores for receiving and sending packets and a second number of packet receiving queues for receiving and sending packets by each network card according to the total number of the CPU cores and the number of the queues supported by each network card;
selecting a first number of CPU cores as a CPU core group, selecting a second number of queues from the queues of each network card as a packet receiving queue group of each network card, and establishing a mapping relation between the CPU core group and the packet receiving queue group of each network card.
Optionally, the establishing a mapping relationship between the CPU core group and the packet receiving queue group of each network card includes:
selecting one CPU core from the CPU core group as a special CPU core, and using the rest CPU cores in the CPU core group as an updated CPU core group;
selecting a packet receiving queue from the packet receiving queue group of each network card as an appointed packet receiving queue of each network card, and taking the remaining packet receiving queues in the packet receiving queues of each network card as the updated packet receiving queue group of each network card;
establishing a mapping relation between the CPU cores in the updated CPU core group and the appointed packet receiving queues of each network card one by one;
and establishing a mapping relation between each CPU core in the updated CPU core group and each packet receiving queue in the packet receiving queue group updated by each network card in sequence.
In order to achieve the above object, the present application further provides a message processing apparatus, where the apparatus includes:
the receiving module is used for determining the type of a message when the message is received by a certain network card and distributing the message to a corresponding packet receiving queue of the network card according to the type;
the receiving module is used for controlling each CPU core to receive the message from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card;
the determining module is used for determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending;
and the sending module is used for controlling each CPU core to send the messages with the medium and low priority levels into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card so as to complete the packet sending processing of the messages.
In order to achieve the above object, the present application also provides an electronic device, wherein the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a message processing program executable by the at least one processor, the message processing program being executable by the at least one processor to enable the at least one processor to perform any of the message processing methods described above.
In order to achieve the above object, the present application also provides a computer readable storage medium, wherein the computer readable storage medium stores a message processing program, and when the message processing program is executed by a processor, the message processing program implements the steps of the message processing method according to any one of the above.
According to the message processing method, the message processing device, the electronic equipment and the storage medium, firstly, when a network card receives a message, the type of the message is determined, and the message is distributed to a corresponding packet receiving queue of the network card according to the type; then, controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card; then, determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending; and finally, controlling each CPU core to send the messages with the medium and low priority levels into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages. According to the method and the device, the high-priority message is sent to the special packet sending queue for packet sending through the special process, the problem that important messages are lost due to large network transmission information amount is solved, and the integrity and timeliness of high-priority message transmission are guaranteed.
Drawings
Fig. 1 is a schematic flow chart of a message processing method according to an embodiment of the present application;
fig. 2 is a schematic diagram of a process in which each CPU core receives a message from a packet receiving queue of a network card according to the embodiment of the present application;
fig. 3 is a schematic diagram of a process in which each CPU core sends a message to a packet sending queue of a network card according to the embodiment of the present application;
fig. 4 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
The implementation, functional features and advantages of the object of the present application will be further explained with reference to the embodiments, and with reference to the accompanying drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a message processing method. Fig. 1 is a schematic flowchart of a message processing method according to an embodiment of the present disclosure. The method may be performed by an electronic device, which may be implemented by software and/or hardware, the method comprising the steps S1-S4:
s1, when a certain network card receives a message, determining the type of the message, and distributing the message to a corresponding packet receiving queue of the network card according to the type;
in this embodiment, the above network card is a network card in a network device, the network device has a plurality of CPU cores and a plurality of network cards, and in general, each network card may transmit or receive packets, so that each network card may have a packet receiving queue and a packet transmitting queue at the same time. Which network card receives the packet is determined according to the physical link (such as network cable) connection deployed in the actual network environment, which network card sends the packet is the network card for sending the packet determined by the network device according to the route inquired by the message destination address and the result of the route search.
The types of the messages comprise IP messages, arp messages and the like.
The step of distributing the message to the corresponding packet receiving queue of the network card according to the type comprises the steps of A11-A12:
a11, if the type of the message is a preset type, obtaining a source address, a source port number, a protocol number, a destination address and a destination port of the message, and constructing a five-tuple corresponding to the message;
in this embodiment, the preset type is an IP packet type.
And A12, determining a corresponding packet receiving queue of the message on the network card based on the quintuple.
The determining of the corresponding packet receiving queue of the message on the network card based on the quintuple comprises the following steps of B11-B13:
b11, calculating the hash value of the quintuple;
in this embodiment, the process of calculating the hash value occurs inside the network card hardware, and different manufacturers configure different hash functions for the network cards produced by the manufacturers to perform hash operation.
The calculating the hash value of the five-tuple includes steps C11-C13:
c11, respectively calculating an initial hash value corresponding to each element in the five-tuple;
and calculating an initial hash value corresponding to each element in the quintuple through a hash function corresponding to the network card.
C12, acquiring the weight corresponding to each predetermined element;
in this embodiment, corresponding weights are set in advance for the source address, the source port number, the protocol number, the destination address, and the destination port, respectively.
And C13, calculating the hash value of the quintuple according to the initial hash value and the weight.
In this embodiment, the hash values corresponding to the quintuple are obtained by performing weighted summation on the initial hash values of the five elements in the quintuple.
B12, performing modulus extraction on the hash value to obtain a modulus extraction result;
in this embodiment, the hash value is modulo according to the number of packet receiving queues to be allocated, for example, if the network card receiving the packet is the number 0 network card, and the packet receiving queues for the IP packet include 3 packet receiving queues, i.e., the number 1, the number 2, and the number 3, the modulo is performed on the number 3.
And B13, determining a corresponding packet receiving queue of the message on the network card according to the modulus taking result.
And selecting a packet receiving queue with the same number as the modulus result as a corresponding packet receiving queue of the message. For example, if the modulo result is 1, the corresponding packet receiving queue of the packet is the packet receiving queue No. 1.
The distributing the message to the corresponding packet receiving queue of the network card according to the type comprises the following steps:
and if the type of the message is not the preset type, sending the message into a specified packet receiving queue of the network card.
In this embodiment, a designated packet receiving queue (for example, packet receiving queue No. 0) corresponding to another packet (for example, an arp packet) other than the IP packet is preset.
S2, controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card;
in this embodiment, a mapping relationship between the CPU core and the packet receiving queue of each network card is pre-established, and each CPU core processes a message in the packet receiving queue corresponding to each network card in the mapping relationship.
The process for determining the mapping relationship between the CPU core and the packet receiving queue of each network card comprises the following steps of D11-D12:
d11, determining a first number of CPU cores for receiving and sending packets and a second number of packet receiving queues for receiving and sending packets by each network card according to the total number of the CPU cores and the number of the queues supported by each network card;
the number of queues supported by the network card is designed by hardware manufacturers, the number of queues supported by the network card is different for different types of network cards of different manufacturers, and the number of the network card queues cannot be modified during software development, but the number of the packet receiving queues for performing packet receiving operation can be set.
In this embodiment, the first number is equal to the second number, that is, the number of CPU cores that perform packet receiving and sending operations is the same as the number of packet receiving queues that perform packet receiving operations.
And if the number of the queues supported by each network card of the network equipment is different, selecting the network card with the least number of the supported queues to determine the first number and the second number.
For example, if the total number of CPU cores of the network device is 4, and the number of queues supported by the network card 1 (assuming that the number of queues supported by the network card 1 is the minimum) is 8, the 4 CPU cores are all used for packet receiving and sending operations, and 4 queues are selected from the 8 queues supported by each network card for performing packet receiving operations; if the total number of CPU cores of the network device is 8 and the number of queues supported by the network card 1 (assuming that the number of queues supported by the network card 1 is the minimum) is 4, only 4 CPU cores are selected for performing the packet receiving and transmitting operation, and 4 queues are selected from the queues supported by each network card for the packet receiving operation.
And D12, selecting a first number of CPU cores as a CPU core group, selecting a second number of queues from the queues of each network card as a packet receiving queue group of each network card, and establishing a mapping relation between the CPU core group and the packet receiving queue group of each network card.
The establishing of the mapping relation between the CPU core group and the packet receiving queue group of each network card comprises the following steps of E11-E14:
e11, selecting a CPU core from the CPU core group as a special CPU core, and using the rest CPU cores in the CPU core group as an updated CPU core group;
for example, assume that a CPU core group includes 4 CPU cores: if the CPU core 3 is selected as the special CPU core, the updated CPU core group comprises three CPU cores of the CPU core 0, the CPU core 1 and the CPU core 2.
E12, selecting a packet receiving queue from the packet receiving queue group of each network card as an appointed packet receiving queue of each network card, and taking the residual packet receiving queues in the packet receiving queues of each network card as the updated packet receiving queue group of each network card;
for example, assume that the packet receiving queue group of each network card includes 4 packet receiving queues: and if the No. 0 packet receiving queue is selected as the appointed packet receiving queue of each network card, the updated packet receiving queue group of each network card comprises the No. 1 packet receiving queue, the No. 2 packet receiving queue and the No. 3 packet receiving queue.
E13, establishing a mapping relation between the updated CPU cores in the CPU core group and the appointed packet receiving queues of the network cards one by one;
for example, the mapping relationship between the updated CPU cores in the CPU core group and the designated packet receiving queues of each network card one by one may be:
the CPU core 0 establishes a mapping relation with a packet receiving queue number 0 of the network card 0 (namely, a designated packet receiving queue of the network card 0), the CPU core 1 establishes a mapping relation with a packet receiving queue number 0 of the network card 1, and the CPU core 2 establishes a mapping relation with a packet receiving queue number 0 of the network card 2.
If the number of the network cards is greater than the number of the CPU cores in the updated CPU core group, for example, if there are 5 network cards, the extra network cards traverse the updated CPU core group again, bind the number 0 packet receiving queue of the network card 3 to the CPU core 0, and bind the number 0 packet receiving queue of the network card 4 to the CPU core 1.
And E14, establishing a mapping relation between each CPU core in the updated CPU core group and each packet receiving queue in the packet receiving queue group updated by each network card in sequence.
The updated CPU core group comprises three CPU cores of a CPU core 0, a CPU core 1 and a CPU core 2, the updated package receiving queue group of each network card comprises a package receiving queue No. 1, a package receiving queue No. 2 and a package receiving queue No. 3, the CPU core 0 is bound with the package receiving queue No. 1 of each network card, the CPU core 1 is bound with the package receiving queue No. 2 of each network card, and the CPU core 2 is bound with the package receiving queue No. 3 of each network card.
As shown in fig. 2, a schematic diagram of a process of receiving, by each CPU core, a packet from a packet receiving queue of a network card according to the embodiment of the present application is shown. CPU core 0 receives the message in number 1 packet receiving queue of each network card, and receives the message in number 0 packet receiving queue of network card 0; the CPU core 1 receives the message in the number 2 packet receiving queue of each network card and receives the message in the number 0 packet receiving queue of the network card 1; and the CPU core 2 receives the message in the number 3 packet receiving queue of each network card and receives the message in the number 0 packet receiving queue of the network card 2.
S3, determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending;
in order to ensure the timely transmission of important packets, the priority ordering of the received packets is required, and in general, the priority level of a packet may be identified by using the 802.1p priority in a VLAN frame and the priority bit of the ToS (Type Service) field of an IP packet header.
The 802.1p priority is located at the header of the two-layer VLAN frame, and the 4-byte 802.1Q Tag header includes 2-byte TPID (Tag Protocol Identifier, value 0x 8100) and 2-byte TCI (Tag Control Information).
The PRI subfield in the TCI section is the 802.1p priority, also referred to as CoS priority. It is composed of 3 bits, the value range is 0-7, and 8 priorities can be represented. The highest priority is 7, and the method is applied to network management and critical network traffic, such as routing table update of a Routing Information Protocol (RIP) and an Open Shortest Path First (OSPF) protocol; priorities 6 and 5 are primarily for delay-sensitive (delay-sensitive) applications, corresponding to interactive voice and video, respectively; priority 4 to 1 is mainly used for controlled-load applications, streaming multimedia, critical traffic (SAP data) and background traffic. Priority 0 is a default value and is automatically enabled if no other priority values are set.
The IP packet relies on a ToS (Type of Service) field to identify the data priority value. The ToS is a field (1 byte in total) in the IP header of the IP packet, and is used to specify the priority of the IP packet, and the device will forward the packet with a high ToS value preferentially.
The ToS field is a single byte (8 bits) and includes three parts: three bits from 0 to 2 are used to define the IP priority (IP Precedence), toS and the last bit fixed to 0 of the packet.
The IP priority part has three bits, and the value range is 0-7 (the larger the value is, the higher the priority is). When the values are expressed by names, the 8 values are respectively route (ordinary, 000), priority (priority, 001), immediatate (quick, 010), flash (flash, 011), flash-override (quick, 100), critical (key, 101), internet control (network control, 110) and network control (network control, 111), and respectively correspond to the numbers 0 to 7.
Of the above IP priority values, 6 and 7 are generally reserved for network control data usage, such as routing; 5 recommending the voice data for use; 4 recommendation for use by video conferencing and streaming; 3 recommending the voice control data for use; 1 and 2 recommend to the data service; 0 is the default flag value. In the IP priority assignment, values of 0 to 7 may be used, or the corresponding priority names may be used.
In this embodiment, the dedicated packet queue of each packet-sending network card is an idle queue of each packet-sending network card, and the idle packet queue is independent from other packet queues. The special process monopolizes the special CPU core, and the high-priority message is sent through the special process and the special packet sending queue, so that the timely and complete transmission of the high-priority message is ensured.
And S4, controlling each CPU core to send the messages with the medium and low priority into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages.
In this embodiment, the predetermined mapping relationship between the CPU core and the packet sending queue of each network card is as follows: the CPU core 0 is bound with the number 0 packet sending queue of each network card, the CPU core 1 is bound with the number 1 packet sending queue of each network card, and the CPU core 2 is bound with the number 2 packet sending queue of each network card.
Therefore, the message with the medium-low priority received by the CPU core 0 needs to be sent to the number 0 packet sending queue of the corresponding packet sending network card (the packet sending network card for determining the message according to the destination address of the message) for packet sending; the message with medium and low priority received by the CPU core 1 needs to be sent to the number 1 packet sending queue of the corresponding packet sending network card (the packet sending network card for determining the message according to the destination address of the message) for packet sending.
As shown in fig. 3, a schematic diagram of a process of sending a message to a packet sending queue of a network card by each CPU core according to the embodiment of the present application is provided. The CPU core 0 sends the messages with the medium and low priority levels to the number 0 packet sending queue of each network card; the CPU core 1 sends the message of the middle-low priority to the number 1 packet sending queue of each network card; and the CPU core 2 sends the messages with the medium and low priority to the number 2 packet sending queue of each network card. The CPU core 3 is a special core CPU, the packet sending queue No. 3 of each network card is a special packet sending queue, and the CPU core 3 sends the high-priority message to the packet sending queue No. 3 of each network card.
The message processing method comprises the steps that firstly, when a network card receives a message, the type of the message is determined, and the message is distributed to a corresponding packet receiving queue of the network card according to the type; then, controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card; then, determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending; and finally, controlling each CPU core to send the messages with the medium and low priority levels into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages. According to the method and the device, the high-priority message is sent to the special packet sending queue for packet sending through the special process, the problem that important messages are lost due to large network transmission information amount is solved, and the integrity and timeliness of high-priority message transmission are guaranteed.
As shown in fig. 4, for a message processing apparatus 4 provided in this embodiment of the present application, the apparatus 4 includes:
a receiving module 41, configured to determine a type of a message when a network card receives the message, and distribute the message to a packet receiving queue corresponding to the network card according to the type;
the step of distributing the message to the corresponding packet receiving queue of the network card according to the type comprises the steps of A21-A22:
a21, if the type of the message is a preset type, obtaining a source address, a source port number, a protocol number, a destination address and a destination port of the message, and constructing a five-tuple corresponding to the message;
and A22, determining the corresponding packet receiving queue of the message on the network card based on the quintuple.
The determining the corresponding packet receiving queue of the message on the network card based on the quintuple comprises the following steps of B21-B23:
b21, calculating the hash value of the quintuple;
b22, performing modulus operation on the hash value to obtain a modulus operation result;
and B23, determining a corresponding packet receiving queue of the message on the network card according to the modulus obtaining result.
The calculating of the hash value of the five-tuple includes steps C21-C23:
c21, respectively calculating an initial hash value corresponding to each element in the five-tuple;
c22, acquiring the weight corresponding to each predetermined element;
and C23, calculating the hash value of the five-tuple according to the initial hash value and the weight.
The distributing the message to the corresponding packet receiving queue of the network card according to the type comprises the following steps:
and if the type of the message is not the preset type, sending the message into a specified packet receiving queue of the network card.
A receiving module 42, configured to control each CPU core to receive a message from a corresponding packet receiving queue of each network card according to a predetermined mapping relationship between the CPU core and the packet receiving queue of each network card;
the process for determining the mapping relationship between the CPU core and the packet receiving queue of each network card comprises the following steps D21-D22:
d21, determining a first number of CPU cores for receiving and sending packets and a second number of packet receiving queues for receiving and sending packets by each network card according to the total number of the CPU cores and the number of queues supported by each network card;
and D22, selecting a first number of CPU cores as a CPU core group, selecting a second number of queues from the queues of each network card as a packet receiving queue group of each network card, and establishing a mapping relation between the CPU core group and the packet receiving queue group of each network card.
The establishing of the mapping relation between the CPU core group and the packet receiving queue group of each network card comprises the following steps of E21-E24:
e21, selecting one CPU core from the CPU core group as a special CPU core, and taking the rest CPU cores in the CPU core group as an updated CPU core group;
e22, selecting one packet receiving queue from the packet receiving queue group of each network card as an appointed packet receiving queue of each network card, and taking the residual packet receiving queue in the packet receiving queue of each network card as the updated packet receiving queue group of each network card;
e23, establishing a mapping relation between the updated CPU cores in the CPU core group and the appointed packet receiving queues of the network cards one by one;
and E24, establishing a mapping relation between each CPU core in the updated CPU core group and each packet receiving queue in the packet receiving queue group updated by each network card in sequence.
A determining module 43, configured to determine the priority of each received packet, send a high-priority packet to a dedicated process corresponding to a dedicated CPU core, and send the high-priority packet to a dedicated packet sending queue of a corresponding packet sending network card through the dedicated process to send a packet;
and the sending module 44 is configured to control each CPU core to send the low-priority packet to the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to a predetermined mapping relationship between the CPU core and the packet sending queue of each network card, so as to complete packet sending processing.
Fig. 5 is a schematic structural diagram of an electronic device 5 according to a preferred embodiment of the present invention.
The electronic device 5 includes but is not limited to: memory 51, processor 52, display 53, and network interface 54. The electronic device 5 is connected to a network via a network interface 54. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a Global System for Mobile communications (GSM), wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, bluetooth (Bluetooth), wi-Fi, or a communication network.
The memory 51 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 51 may be an internal storage unit of the electronic device 5, such as a hard disk or a memory of the electronic device 5. In other embodiments, the memory 51 may also be an external storage device of the electronic device 5, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, which is equipped with the electronic device 5. Of course, the memory 51 may also include both an internal storage unit and an external storage device of the electronic device 5. In this embodiment, the memory 51 is generally used for storing an operating system installed in the electronic device 5 and various types of application software, such as a program code of the message processing program 50. Further, the memory 51 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 52 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 52 is generally used for controlling the overall operation of the electronic device 5, such as performing data interaction or communication related control and processing. In this embodiment, the processor 52 is configured to run a program code or process data stored in the memory 51, for example, a program code or the like of the message processing program 50.
The display 53 may be referred to as a display screen or display unit. The display 53 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an Organic Light-Emitting Diode (OLED) touch panel, or the like in some embodiments. The display 53 is used for displaying information processed in the electronic device 5 and for displaying a visual work interface.
The network interface 54 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), and the network interface 54 is typically used to establish a communication link between the electronic device 5 and other electronic devices.
Fig. 5 only shows the electronic device 5 with components 51-54 and message handler 50, but it should be understood that not all of the shown components are required to be implemented, and that more or fewer components may alternatively be implemented.
Optionally, the electronic device 5 may further include a user interface, the user interface may include a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface may further include a standard wired interface and a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an Organic Light-Emitting Diode (OLED) touch screen, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 5 and for displaying a visualized user interface.
The electronic device 5 may further include Radio Frequency (RF) circuitry, sensors, audio circuitry, and the like, which are not described in detail herein.
In the above embodiment, the processor 52 may implement the following steps when executing the message processing program 50 stored in the memory 51:
when a network card of the electronic device 5 receives a message, determining the type of the message, and distributing the message to a corresponding packet receiving queue of the network card according to the type;
controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card;
determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending;
and controlling each CPU core to send the messages with the medium and low priority levels into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages.
The storage device may be the memory 51 of the electronic device 5, or may be another storage device communicatively connected to the electronic device 5.
For detailed description of the above steps, please refer to the description of the flowchart of the message processing method embodiment in fig. 1.
In addition, the embodiment of the present application also provides a computer-readable storage medium, which may be non-volatile or volatile. The computer readable storage medium may be any one or any combination of hard disks, multimedia cards, SD cards, flash memory cards, SMCs, read Only Memories (ROMs), erasable Programmable Read Only Memories (EPROMs), portable compact disc read only memories (CD-ROMs), USB memories, etc. The computer readable storage medium includes a storage data area and a storage program area, the storage data area stores data created according to the use of the blockchain node, the storage program area stores a message processing program 50, and the message processing program 50 implements the following operations when being executed by a processor:
when a network card of the electronic device 5 receives a message, determining the type of the message, and distributing the message to a corresponding packet receiving queue of the network card according to the type;
controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card;
determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending;
and controlling each CPU core to send the messages with the medium and low priority into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages.
The specific implementation of the computer readable storage medium of the present application is substantially the same as the specific implementation of the above message processing method, and is not described herein again.
It should be noted that the above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments. And the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising one of 8230, and" comprising 8230does not exclude the presence of additional like elements in a process, apparatus, article, or method comprising the element.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solutions of the present application or portions thereof contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) as described above and includes several instructions for enabling a terminal device (which may be a mobile phone, a computer, an electronic apparatus, or a network device) to execute the method described in the embodiments of the present application.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are included in the scope of the present application.

Claims (10)

1. A message processing method is characterized by comprising the following steps:
when a certain network card receives a message, determining the type of the message, and distributing the message to a corresponding packet receiving queue of the network card according to the type;
controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card;
determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending;
and controlling each CPU core to send the messages with the medium and low priority into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and finishing the packet sending processing of the messages.
2. The method of claim 1, wherein the distributing the message to the corresponding packet receiving queue of the network card according to the type comprises:
if the type of the message is a preset type, acquiring a source address, a source port number, a protocol number, a destination address and a destination port of the message, and constructing a five-tuple corresponding to the message;
and determining a corresponding packet receiving queue of the message on the network card based on the five-tuple.
3. The method of claim 2, wherein the determining the corresponding packet receiving queue of the message on the network card based on the five-tuple comprises:
calculating a hash value of the five-tuple;
performing modulus on the hash value to obtain a modulus result;
and determining the corresponding packet receiving queue of the message on the network card according to the modulus obtaining result.
4. The method of claim 3, wherein said computing the hash value of the five-tuple comprises:
respectively calculating an initial hash value corresponding to each element in the quintuple;
acquiring the weight corresponding to each predetermined element;
and calculating the hash value of the quintuple according to the initial hash value and the weight.
5. The method of claim 1, wherein the distributing the message to the corresponding packet receiving queue of the network card according to the type comprises:
and if the type of the message is not the preset type, sending the message into a specified packet receiving queue of the network card.
6. The method of claim 1, wherein the determining of the mapping relationship between the CPU core and the packet receiving queue of each network card comprises:
determining a first number of CPU cores for receiving and sending packets and a second number of packet receiving queues for receiving and sending packets by each network card according to the total number of the CPU cores and the number of queues supported by each network card;
selecting a first number of CPU cores as a CPU core group, selecting a second number of queues from the queues of each network card as a packet receiving queue group of each network card, and establishing a mapping relation between the CPU core group and the packet receiving queue group of each network card.
7. The method as claimed in claim 6, wherein the establishing of the mapping relationship between the CPU core group and the packet receiving queue group of each network card comprises:
selecting one CPU core from the CPU core group as a special CPU core, and using the rest CPU cores in the CPU core group as an updated CPU core group;
selecting a packet receiving queue from the packet receiving queue group of each network card as an appointed packet receiving queue of each network card, and taking the remaining packet receiving queues in the packet receiving queues of each network card as the updated packet receiving queue group of each network card;
establishing a mapping relation between the CPU cores in the updated CPU core group and the appointed packet receiving queues of the network cards one by one;
and establishing a mapping relation between each CPU core in the updated CPU core group and each packet receiving queue in the packet receiving queue group updated by each network card in sequence.
8. A message processing apparatus, the apparatus comprising:
the receiving module is used for determining the type of a message when the message is received by a certain network card and distributing the message to a corresponding packet receiving queue of the network card according to the type;
the receiving module is used for controlling each CPU core to receive messages from the corresponding packet receiving queue of each network card according to the predetermined mapping relation between the CPU core and the packet receiving queue of each network card;
the determining module is used for determining the priority of each received message, sending the message with high priority to a special process corresponding to a special CPU core, and sending the message with high priority to a special packet sending queue of a corresponding packet sending network card through the special process for packet sending;
and the sending module is used for controlling each CPU core to send the messages with the medium and low priority levels into the corresponding packet sending queue of the corresponding packet sending network card for packet sending according to the predetermined mapping relation between the CPU core and the packet sending queue of each network card, and completing the packet sending processing of the messages.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein, the first and the second end of the pipe are connected with each other,
the memory stores a message processing program executable by the at least one processor to enable the at least one processor to perform the steps of the message processing method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that it stores a message processing program which, when executed by a processor, implements the steps of the message processing method according to any one of claims 1 to 7.
CN202211111363.3A 2022-09-13 2022-09-13 Message processing method and device, electronic equipment and storage medium Active CN115499387B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211111363.3A CN115499387B (en) 2022-09-13 2022-09-13 Message processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211111363.3A CN115499387B (en) 2022-09-13 2022-09-13 Message processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115499387A true CN115499387A (en) 2022-12-20
CN115499387B CN115499387B (en) 2024-04-09

Family

ID=84467707

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211111363.3A Active CN115499387B (en) 2022-09-13 2022-09-13 Message processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115499387B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116668375A (en) * 2023-07-31 2023-08-29 新华三技术有限公司 Message distribution method, device, network equipment and storage medium
CN117640796A (en) * 2024-01-03 2024-03-01 北京火山引擎科技有限公司 Network message processing method and device
CN117750405A (en) * 2023-12-21 2024-03-22 山东未来网络研究院(紫金山实验室工业互联网创新应用基地) Cross-region 5G private network management method
CN117750405B (en) * 2023-12-21 2024-06-04 山东未来网络研究院(紫金山实验室工业互联网创新应用基地) Cross-region 5G private network management method

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080151919A1 (en) * 2006-12-21 2008-06-26 Cisco Technology, Inc. Out of band flow control
CN102497322A (en) * 2011-12-19 2012-06-13 曙光信息产业(北京)有限公司 High-speed packet filtering device and method realized based on shunting network card and multi-core CPU (Central Processing Unit)
CN105630731A (en) * 2015-12-24 2016-06-01 曙光信息产业(北京)有限公司 Network card data processing method and device in multi-CPU (Central Processing Unit) environment
CN107634915A (en) * 2017-08-25 2018-01-26 中国科学院计算机网络信息中心 Data transmission method, device and storage medium
CN109688069A (en) * 2018-12-29 2019-04-26 杭州迪普科技股份有限公司 A kind of method, apparatus, equipment and storage medium handling network flow
CN111083075A (en) * 2019-12-20 2020-04-28 盛科网络(苏州)有限公司 Method for processing message by multi-core SoC and SoC applying same
CN114338548A (en) * 2020-10-12 2022-04-12 迈普通信技术股份有限公司 Message distribution method, device, network equipment and computer readable storage medium
CN114553780A (en) * 2020-11-11 2022-05-27 北京华为数字技术有限公司 Load balancing method and device and network card
CN114979021A (en) * 2021-02-27 2022-08-30 华为技术有限公司 Data processing method and electronic equipment

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080151919A1 (en) * 2006-12-21 2008-06-26 Cisco Technology, Inc. Out of band flow control
CN102497322A (en) * 2011-12-19 2012-06-13 曙光信息产业(北京)有限公司 High-speed packet filtering device and method realized based on shunting network card and multi-core CPU (Central Processing Unit)
CN105630731A (en) * 2015-12-24 2016-06-01 曙光信息产业(北京)有限公司 Network card data processing method and device in multi-CPU (Central Processing Unit) environment
CN107634915A (en) * 2017-08-25 2018-01-26 中国科学院计算机网络信息中心 Data transmission method, device and storage medium
CN109688069A (en) * 2018-12-29 2019-04-26 杭州迪普科技股份有限公司 A kind of method, apparatus, equipment and storage medium handling network flow
CN111083075A (en) * 2019-12-20 2020-04-28 盛科网络(苏州)有限公司 Method for processing message by multi-core SoC and SoC applying same
CN114338548A (en) * 2020-10-12 2022-04-12 迈普通信技术股份有限公司 Message distribution method, device, network equipment and computer readable storage medium
CN114553780A (en) * 2020-11-11 2022-05-27 北京华为数字技术有限公司 Load balancing method and device and network card
CN114979021A (en) * 2021-02-27 2022-08-30 华为技术有限公司 Data processing method and electronic equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116668375A (en) * 2023-07-31 2023-08-29 新华三技术有限公司 Message distribution method, device, network equipment and storage medium
CN116668375B (en) * 2023-07-31 2023-11-21 新华三技术有限公司 Message distribution method, device, network equipment and storage medium
CN117750405A (en) * 2023-12-21 2024-03-22 山东未来网络研究院(紫金山实验室工业互联网创新应用基地) Cross-region 5G private network management method
CN117750405B (en) * 2023-12-21 2024-06-04 山东未来网络研究院(紫金山实验室工业互联网创新应用基地) Cross-region 5G private network management method
CN117640796A (en) * 2024-01-03 2024-03-01 北京火山引擎科技有限公司 Network message processing method and device

Also Published As

Publication number Publication date
CN115499387B (en) 2024-04-09

Similar Documents

Publication Publication Date Title
CN115499387B (en) Message processing method and device, electronic equipment and storage medium
US7860100B2 (en) Service path selection in a service network
JP5199399B2 (en) Method and filter arrangement for storing information about messages arriving at a subscriber of the network via a serial data bus of the communication network
US20060136722A1 (en) Secure communication system and communication route selecting device
US7830895B2 (en) Packet communication apparatus with function enhancement module
US10257091B2 (en) Pipeline table identification
CN104734964A (en) Message processing method, node and system
US9853906B2 (en) Network prioritization based on node-level attributes
CN107046506B (en) Message processing method, flow classifier and service function example
EP3094053A1 (en) Predictive egress packet classification for quality of service
CN110049059A (en) A kind of outer net equipment and Intranet communication between devices method and relevant apparatus
EP2635073A1 (en) Access point selection based on number of successful connections
WO2016175768A1 (en) Map tables for hardware tables
WO2017101815A1 (en) Message processing method, device and system
CN109617806B (en) Data traffic scheduling method and device
CN111628940A (en) Flow scheduling method, device, system, switch and computer storage medium
CN110602234B (en) Block chain network node management method, device, equipment and storage medium
US20140344467A1 (en) Loadable flexible protocol profiles
JP4486031B2 (en) Semantic switch communication network, semantic switch, and semantic communication method
CN114679350A (en) SD-WAN-based link selection method, device and storage medium
EP3585013B1 (en) Data transmission method and apparatus
CN110569987A (en) Automatic operation and maintenance method, operation and maintenance equipment, storage medium and device
CN108199974A (en) Service traffics forwarding management method, device and network node
JPH01126044A (en) Multi-protocol processor
EP3131240B1 (en) Search apparatus and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant