Message forwarding method and related equipment

By introducing acceleration table entries into network devices and using multiple CPU cores to cooperate to forward data packets, the problem of insufficient improvement in data packet forwarding performance in the existing technology is solved, and more efficient data packet forwarding is achieved.

CN119728541AActive Publication Date: 2025-03-28HONOR DEVICE CO LTD

Patent Information

Application Number
CN202311223395.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-20
Publication Date
2025-03-28
Estimated Expiration
2043-09-20

AI Technical Summary

Technical Problem

In network devices with multi-CPU cores, the prior art has led to less obvious improvement in data packet forwarding performance, mainly because the forwarding of data packets is still completed on a single CPU core, and the advantages of multiple CPU cores have not been fully utilized.

Method used

By introducing acceleration table entries into the network device, it is selected to use the network protocol stack or CPU core scheduling to forward data packets based on whether the acceleration table entries corresponding to the data packets are matched. When matching the accelerator entry, multiple CPU cores cooperate to complete the forwarding of data packets, realizing the full utilization of CPU resources.

Benefits of technology

By reducing the forwarding path of data packets, the forwarding efficiency of data packets is improved and the overall performance of network devices is improved, especially in the scenario of forwarding large-traffic data packets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728541A_ABST
    Figure CN119728541A_ABST
Patent Text Reader

Abstract

The invention provides a message forwarding method and related equipment, and relates to the technical field of communication, and the message forwarding method comprises the steps: receiving a to-be-forwarded data message; under the condition that an acceleration table entry corresponding to the data message is matched, a target CPU core to be scheduled is determined, and the acceleration table entry comprises message forwarding information of the data message; and adding the data message and the message forwarding information corresponding to the data message into a queue of the target CPU core, and executing forwarding processing on the data message by the target CPU core. According to the method, the two CPU cores are matched to complete forwarding of one data message, CPU core resources are fully utilized, forwarding of the data message does not pass through a network protocol stack, and the forwarding efficiency of the data message is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of communication technology, and in particular to a message forwarding method and related equipment. Background Art

[0002] Under the existing message forwarding mechanism of Linux, the forwarding process of data messages generally includes: the network card driver receives the data message; the network card driver transmits the received data message to the network protocol stack for processing; the network protocol stack transmits the processed data message to the network card driver, and the network card driver drives the network card to forward the data message. That is, all data messages to be forwarded need to be processed by the network protocol stack, which may cause the central processing unit (CPU) to be busy processing the forwarding of data messages in the scenario of large-volume data message forwarding, resulting in poor data message forwarding performance.

[0003] In order to solve this problem, most routing equipment manufacturers will try to adopt software / hardware acceleration solutions to improve the forwarding performance of data packets by shortening the forwarding path of data packets. The data packet forwarding of the existing software / hardware acceleration solutions is still completed on one CPU core. For CPUs with multiple CPU cores, the advantages of multiple CPU cores are not brought into play, and the forwarding performance of data packets is not significantly improved. Summary of the invention

[0004] In view of the above, it is necessary to provide a message forwarding method and related equipment, which can solve the problem that data message forwarding is completed on a single CPU core, resulting in no obvious improvement in data message forwarding performance.

[0005] In the first aspect, the present application provides a message forwarding method, which is applied to a network device, wherein the CPU of the network device has multiple CPU cores, and the message forwarding method includes: receiving a data message to be forwarded; when an acceleration table entry corresponding to the data message is matched, determining a target CPU core to be scheduled, the acceleration table entry including message forwarding information of the data message; adding the data message and the message forwarding information corresponding to the data message to a queue of the target CPU core, and the target CPU core performs forwarding processing on the data message.

[0006] By adopting the above technical scheme, whether to use the network protocol stack to forward the data message or to use the CPU core scheduling method to forward the data message is selected based on whether the acceleration table item corresponding to the data message is matched. When the acceleration table item corresponding to the data message is matched, the CPU core scheduling method is used to forward the data message, and the two CPU cores cooperate to complete the forwarding of a data message, thereby fully utilizing the CPU core resources. Moreover, since the acceleration table item contains the message forwarding information, the target CPU core can perform message forwarding processing based on the message forwarding information, so that the forwarding of the data message can go through the network protocol stack, thereby further improving the forwarding efficiency of the data message.

[0007] In one possible implementation, after receiving the data packet to be forwarded, it also includes: when no acceleration table entry corresponding to the data packet is matched, the current CPU core executes forwarding processing of the data packet, wherein the forwarding processing of the data packet executed by the current CPU core includes processing the data packet using the network protocol stack, and sending the processed data packet through the network card driver.

[0008] By adopting the above technical solution, when the acceleration table entry corresponding to the data packet is not matched, the forwarding processing of the data packet cannot be realized through the target CPU core because there is no acceleration table entry containing the packet forwarding information. The forwarding of the data packet is executed on the current CPU core, that is, the data packet is processed by the network protocol stack, and the data packet processed by the network protocol stack is sent out through the network card driver to realize the smooth forwarding of the data packet.

[0009] In one possible implementation, the message forwarding method also includes: extracting entry device information, five-tuple information and message forwarding information from the data message processed by the network protocol stack; and constructing an acceleration table entry corresponding to the data message based on the entry device information, five-tuple information and message forwarding information.

[0010] By adopting the above technical solution, the acceleration table entry corresponding to the data packet is constructed by extracting the entry device information, five-tuple information and message forwarding information from the data packet processed by the network protocol stack, so that the data packets subsequently forwarded by the data flow can be processed without the network protocol stack, thereby improving the forwarding efficiency of the data packet.

[0011] In one possible implementation, an acceleration table entry corresponding to a data message is constructed based on ingress device information, five-tuple information, and message forwarding information, including: calculating a message hash value of the data message based on the five-tuple information; determining whether a network device has stored an acceleration table entry corresponding to the data message based on the message hash value; and in a case where the network device does not store an acceleration table entry corresponding to the data message, constructing an acceleration table entry corresponding to the data message based on the ingress device information, five-tuple information, and message forwarding information.

[0012] By adopting the above technical solution, the quintuple information is used as the identity of the data message, and the acceleration table item uses the message hash value calculated based on the quintuple information as the identifier, which can be easily distinguished from other acceleration table items. Before constructing the acceleration table item corresponding to the data message, by querying whether the network device has stored the corresponding acceleration table item, the repeated creation of the acceleration table item can be avoided, thereby saving the storage space of the network device.

[0013] In one possible implementation, after receiving the data packet to be forwarded, it also includes: extracting quintuple information from the data packet, and calculating the message hash value of the data packet based on the quintuple information; comparing the message hash value of the data packet with the message hash value of each currently stored acceleration table entry record to obtain an acceleration table entry that matches the data packet.

[0014] By adopting the above technical solution, the acceleration table entry uses the message hash value calculated based on the five-tuple information of the corresponding data message as an identifier to distinguish it from other acceleration table entries. By comparing the message hash value of the forwarded data message with the message hash value of each acceleration table entry currently stored in the network device, it is possible to determine whether the network device stores the acceleration table entry corresponding to the data message, and then, based on the comparison result, it can be selected whether to use the network protocol stack to forward the data message or to use the CPU core scheduling method to forward the data message.

[0015] In one possible implementation, determining a target CPU core to be scheduled includes: determining a pre-scheduled CPU core based on a pre-configured static scheduling policy; when a state of the pre-scheduled CPU core does not meet a preset condition, determining the pre-scheduled CPU core as a target CPU core, the preset condition including that the pre-scheduled CPU core has the highest utilization rate among multiple CPU cores; when the state of the pre-scheduled CPU core meets the preset condition, obtaining an application type to which a data packet belongs and a utilization rate of each CPU core among the multiple CPU cores, and determining the target CPU core based on the application type to which the data packet belongs, the utilization rate of each CPU core and the pre-configured dynamic scheduling policy.

[0016] By adopting the above technical scheme, the target CPU core to be scheduled can be determined based on the pre-configured static scheduling policy. It can also be reselected when the target CPU core to be scheduled determined based on the static scheduling policy is busy and other CPU cores are relatively idle (for example, with the highest CPU usage rate). This can solve the problem that the static scheduling policy cannot be modified after being preset in the network device. In some scenarios, the static scheduling policy may not be the optimal scheduling policy. After identifying the application type of the data flow, the target CPU core is re-determined based on the application type to which the data packet belongs, the usage rate of each CPU core and the pre-configured dynamic scheduling policy to achieve the best packet forwarding performance.

[0017] In one possible implementation, the static scheduling strategy includes any one of the following: determining the pre-scheduled CPU core based on the message type of the data message and the binding relationship between the CPU core; determining the pre-scheduled CPU core based on the message priority of the data message and the binding relationship between the CPU core; determining the pre-scheduled CPU core based on the CPU core identifier recorded in the acceleration table entry.

[0018] By adopting the above technical scheme, the CPU core can be scheduled according to the message type of the data message and the binding relationship between the CPU core, so that the specified type of message is bound to the specified CPU core. For example, a certain type of message is forwarded more frequently and can be bound to the CPU core with stronger computing power. Or the CPU core can be scheduled according to the priority of the data message and the binding relationship between the CPU core, so that the data message with higher priority is bound to the CPU core with stronger computing power, and the data message with lower priority is bound to the CPU core with weaker computing power. Or the CPU core can be scheduled according to the CPU core identifier (CPU_ID) recorded in the acceleration table item corresponding to the data message. For example, the acceleration table item records the identity identifier of the CPU core with the least number of acceleration table items at the time of creation. The CPU core can be scheduled according to the CPU_ID recorded in the acceleration table item corresponding to the data message, so that it can be scheduled to the CPU core with a smaller number of acceleration table items each time, thereby achieving load balancing of the CPU cores.

[0019] In one possible implementation, determining the target CPU core to be scheduled includes: determining the target CPU core to be scheduled based on a preconfigured static scheduling policy, the static scheduling policy including determining the target CPU core based on the message type of the data message and the binding relationship between the CPU core, determining the target CPU core based on the message priority of the data message and the binding relationship between the CPU core, or determining the target CPU core based on the CPU core identifier recorded in the acceleration table item.

[0020] By adopting the above technical solution, the CPU core can be scheduled according to the message type of the data message and the binding relationship between the CPU core, or according to the priority of the data message and the binding relationship between the CPU core, or according to the CPU core identifier (CPU_ID) recorded in the acceleration table item corresponding to the data message, thereby improving the forwarding efficiency of the data message.

[0021] In a possible implementation, the CPU core identifier recorded in the acceleration table entry is the identifier of the CPU core with the least number of acceleration table entries in the queue when the acceleration table entry is created.

[0022] By adopting the above technical solution, during the acceleration table entry creation process, the identity of the CPU core with the least number of acceleration table entries at the time of acceleration table entry creation is recorded, and the CPU core is subsequently scheduled according to the CPU_ID recorded in the acceleration table entry corresponding to the data message. This can achieve scheduling to the CPU core with a smaller number of acceleration table entries each time, thereby achieving load balancing of the CPU cores.

[0023] In one possible implementation, the target CPU core performs forwarding processing of the data packet, including: switching the forwarding processing of the data packet from the current CPU core to the target CPU core, triggering the poll callback of the target CPU core; reading the data packet and the message forwarding information of the data packet from the queue of the target CPU core; determining the output interface device and output interface of the data packet based on the message forwarding information of the data packet, and updating the data packet; calling the output interface of the output interface device to send out the updated data packet.

[0024] By adopting the above technical solution, after executing the CPU core switching, the poll callback of the target CPU core is triggered to read the data packet and the message forwarding information of the data packet from the queue of the target CPU core. The target CPU core can determine the output interface device and output interface of the data packet based on the message forwarding information of the data packet, and update the relevant information of the protocol layer contained in the message forwarding information to the data packet, and then call the output interface to send the updated data packet out, thereby executing the forwarding processing of the data packet on the target CPU core, without the need to process the data packet through the network protocol stack, thereby improving the forwarding efficiency of the data packet.

[0025] In one possible implementation, the message forwarding information includes output interface device information, an output interface operation set, and relevant information of a specified protocol layer, the specified protocol layer includes a network layer and a transport layer, and the output interface device and output interface of the data message are determined based on the message forwarding information of the data message, and the data message is updated, including: determining the output interface device of the data message based on the output interface device information; determining the output interface of the data message based on the output interface operation set; and updating the relevant information of the protocol layer to the data message.

[0026] By adopting the above technical solution, the message forwarding information includes the output interface device information, the output interface operation set and the related information of the network layer and the transport layer. The target CPU core can determine the output interface device of the data message based on the output interface device information, determine the output interface of the data message based on the output interface operation set, and update the related information of the network layer and the transport layer to the data message, thereby realizing the message processing of the simulated network protocol stack, so that the forwarding of the data message can go through the network protocol stack, thereby improving the forwarding efficiency of the data message.

[0027] In a possible implementation, the network device includes one of a router, a switch, a forwarder, a virtual switch, a virtual router, and a virtual forwarder.

[0028] By adopting the above technical solution, the network device includes but is not limited to any one of a router, a switch, a repeater, a virtual switch, a virtual router, and a virtual repeater.

[0029] In a second aspect, the present application provides a network device, which includes a memory and a processor; the memory is used to store program instructions; the processor is used to read the program instructions stored in the memory to implement the above-mentioned message forwarding method.

[0030] In a third aspect, the present application provides a computer-readable storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the above-mentioned message forwarding method is implemented.

[0031] In a fourth aspect, the present application provides a chip coupled to a memory in a network device, and the chip is used to control the network device to execute the above-mentioned message forwarding method.

[0032] In addition, the technical effects brought about by the second to fourth aspects can be found in the descriptions related to the methods of each design in the above method part, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 A flow chart for performing data packet forwarding for an existing network device;

[0034] Figure 2A software architecture diagram of a network device performing data message forwarding provided in an embodiment of the present application;

[0035] Figure 3 A flowchart of creating an acceleration table entry for a network device according to an embodiment of the present application;

[0036] Figure 4 A flowchart of a network device performing acceleration table entry matching provided in an embodiment of the present application;

[0037] Figure 5 A flowchart of initializing a CPU core of a network device provided in an embodiment of the present application;

[0038] Figure 6 A flowchart of CPU core scheduling for a network device provided in an embodiment of the present application;

[0039] Figure 7 An overall flow chart of CPU core initialization and scheduling for a network device provided in an embodiment of the present application;

[0040] Figure 8 A schematic diagram of the software architecture of the Netfilter framework provided in one embodiment of the present application;

[0041] Fig. 9 An interactive flow chart of a network device implementing data message forwarding according to an embodiment of the present application;

[0042] Fig.10 An interactive flow chart of a network device implementing data message forwarding according to another embodiment of the present application;

[0043] Fig.11 This is a flow chart of CPU core scheduling by a soft acceleration module provided in an embodiment of the present application;

[0044] Fig.12 is a flow chart of a message forwarding method provided by an embodiment of the present application;

[0045] Fig.13 This is a hardware architecture diagram of a network device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0046] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0047] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, words such as "exemplary", "or", "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "or", "for example" is intended to present related concepts in a concrete way.

[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field of the present application. The terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. It should be understood that, unless otherwise specified in the present application, " / " means or. For example, A / B can represent A or B. "And / or" in the present application is only a kind of association relationship describing associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, a, b and c seven situations. It should be understood that the order of the steps shown in the flowchart of this article can be changed, and some can also be omitted.

[0049] See also Figure 1 , illustrating the processing flow of data packet forwarding by a network device. For example, the network device in the embodiment of the present application may refer to a device that performs data / route forwarding functions, such as a router, a switch, a forwarder, etc. The router, switch, forwarder, etc. may be a physical device or a virtual device based on virtualization technology (such as a virtual switch, a virtual router, a virtual forwarder). The embodiment of the present application does not impose any special restrictions on the specific form of the network device. The network device may be deployed with operating system, Operating system, etc.

[0050] Deployment with network equipment Taking the operating system as an example, the message forwarding process of the network device is briefly described. The message forwarding process may include:

[0051] (1) The network card at the hardware layer receives the data message and sends the data message to the network card driver;

[0052] (2) The network card driver at the kernel layer calls the interface function netif_rx to send the data message to the network protocol stack (at the kernel layer) for processing. For example, the network protocol stack processes the data message according to the requirements of the network protocol;

[0053] (3) The network protocol stack sends the processed data message to the network card driver;

[0054] (4) The network card driver calls the interface function node-xmit to send the data message processed by the network protocol stack to the network card for transmission through the network card.

[0055] In the above-mentioned data message forwarding process, the data message forwarding process is generally processed by a CPU core in the CPU. Since the forwarding of data messages needs to be processed by the network protocol stack, it may cause the CPU core to be busy processing the forwarding of data messages in a large-volume data message forwarding scenario, and the utilization rate may reach 100%, which may lead to poor data message forwarding performance, while the utilization rate of other CPU cores may be relatively low, and even the utilization rate of a certain CPU core may be 0%. For a network device with multiple CPU cores, the CPU resources are not maximized. The embodiment of the present application takes the network protocol stack as the transmission control protocol / internet protocol (TCP / IP) protocol stack as an example for explanation.

[0056] In view of this, the message forwarding method provided in the embodiment of the present application can solve the problem that when the CPU has multiple CPU cores, the CPU resources cannot be maximized, resulting in poor data message forwarding performance.

[0057] like Figure 2 As shown, a soft acceleration module 20 is configured between the network card driver and the network protocol stack, and the soft acceleration module 20 is used to implement the switching of the CPU core to maximize the use of CPU resources. Specifically, after the network card driver receives the data message, it sends the data message to the soft acceleration module 20, and the soft acceleration module 20 determines whether to schedule the data message or forward it to the network protocol stack for processing. If the soft acceleration module 20 determines to schedule the data message, the soft acceleration module 20 schedules the data message to another CPU core, and the subsequent processing of the data message (processing the data message according to the requirements of the network protocol) and forwarding will be performed on the CPU core after scheduling, that is, the forwarding process of the data message involves two CPU cores. If the soft acceleration module 20 determines to forward the data message to the network protocol stack for processing, it will not involve the switching of the CPU core, that is, the forwarding process of the data message only involves one CPU core.

[0058] For example, the soft acceleration module 20 can match the acceleration table entry for the data message, and determine whether to schedule the data message or forward it to the network protocol stack for processing according to the matching result. If the soft acceleration module 20 matches the acceleration table entry corresponding to the data message, the soft acceleration module 20 schedules the CPU core according to the pre-configured scheduling strategy, and the subsequent processing and forwarding of the data message are performed on the CPU core after scheduling; if the soft acceleration module 20 does not match the acceleration table entry corresponding to the data message, the soft acceleration module 20 forwards the data message to the network protocol stack for processing.

[0059] In some embodiments, the soft acceleration module 20 may include an acceleration entry generation module 201, an acceleration entry matching module 202, and a forwarding scheduling module 203. The module referred to in the embodiments of the present application may refer to a series of computer program instruction segments that can perform specific functions, or may be a functional module formed by the cooperation of computer program instruction segments and hardware. The division of modules is a logical function division, and there may be other division methods in actual implementation, which is not limited in the present application.

[0060] The acceleration table entry generation module 201 is used to create an acceleration table entry corresponding to the data packet based on the relevant information of the data packet. The relevant information of the data packet may include the five-tuple information of the data packet (source IP address, destination IP address, source port number, destination port number and transmission protocol), the ingress device information of the data packet, and the outgoing interface device information set of the data packet. The outgoing interface device information set of the data packet may include the outgoing interface device information of the data packet, the forwarding direction of the data packet, the outgoing interface operation set of the data packet, relevant information of the protocol layer, etc.

[0061] For example, the protocol layer may include the network layer (L2 layer in the TCP / IP reference model) and the transport layer (L3 layer in the TCP / IP reference model), and the relevant information of the protocol layer may include connection tracking record information, IP information, etc. The TCP / IP reference model refers to an abstract layered model customized for the TCP / IP protocol stack.

[0062] The acceleration table item matching module 202 is used to match the acceleration table item for the data message. If the acceleration table item matching module 202 matches the acceleration table item corresponding to the data message, the data message is sent to the forwarding scheduling module 203 for scheduling. If the acceleration table item matching module 202 does not match the acceleration table item corresponding to the data message, the data message is sent to the network protocol stack for processing. The forwarding scheduling module 203 is used to schedule the CPU core according to the pre-configured scheduling strategy, so that the subsequent processing and forwarding of the data message are performed on the CPU core after scheduling.

[0063] When the network device is forwarding data streams, the data streams are forwarded according to individual data packets. The network card driver sends the received data packet to the acceleration table item matching module 202. If the currently received data packet is the first data packet in the data stream, since the acceleration table item generation module 201 creates the acceleration table item based on the relevant information of the data packet processed by the network protocol stack, that is, when the acceleration table item matching module 202 receives the first data packet in the data stream, the acceleration table item of the data packet has not been created in time, and the acceleration table item matching module 202 cannot match the acceleration table item corresponding to the data packet. The acceleration table item matching module 202 sends the data packet to the network protocol stack for processing. After being processed by the network protocol stack, the data packet is sent to the acceleration table item generation module 201. At this time, the acceleration table item generation module 201 creates the corresponding acceleration table item based on the relevant information of the data packet, and sends the data packet processed by the network protocol stack to the network card driver. The network card driver can drive the network card to send the data packet out.

[0064] If the data packet received by the acceleration table entry matching module 202 is not the first data packet of the data stream, since the acceleration table entry generation module 201 has created an acceleration table entry corresponding to the data packet, the acceleration table entry matching module 202 can match the acceleration table entry corresponding to the data packet. The acceleration table entry matching module 202 sends the data packet to the forwarding scheduling module 203. The forwarding scheduling module 203 schedules the CPU core according to the pre-configured scheduling strategy, so that the subsequent processing and forwarding of the data packet are performed on the scheduled CPU core. After the data packet is processed by the forwarding scheduling module 203, it is sent to the network card driver, and the network card driver can drive the network card to send the data packet out.

[0065] The following combination Figure 3 , Figure 4 , Figure 5 and Figure 6 The functions of the acceleration table entry generation module 201, the acceleration table entry matching module 202 and the forwarding scheduling module 203 are introduced.

[0066] like Figure 3 As shown, the process of the acceleration table entry generation module 201 creating the acceleration table entry is illustrated.

[0067] S301, marking the message type of the data message processed by the network protocol stack.

[0068] When the network device forwards the data stream, the data stream is forwarded according to individual data packets, and the data packets are transmitted between different protocol layers in the kernel in the form of SKB. The data packets processed by the network protocol stack may refer to the data packets of a certain data stream that are processed by the network protocol stack and passed to the acceleration table entry generation module 201. The embodiment of the present application is described by taking the network device processing the first data stream as an example.

[0069] For network devices, they can connect to one or more terminal devices (mobile phones, tablets, laptops, etc.), and then forward data streams for one or more terminal devices. Different terminal devices may have different data volumes, and different services under the same terminal may also have different data streams.

[0070] The network protocol stack can send the processed data packet of the first data stream to the acceleration table entry generation module 201. The acceleration table entry generation module 201 can mark the packet type for the data packet according to the network type to which the first data stream belongs. The network type may include Ethernet, wireless LAN (2.4GHz band or 5GHz band), etc.

[0071] In the Linux system, data packets are processed through a socket buffer (SKB), and data transmission and interactive data packets between different protocol layers in the kernel are implemented based on the SKB. For example, a field can be added to the SKB or a certain existing field can be specified to identify the message type of the data packet, and the acceleration entry generation module 201 can call the xmit interface of the Ethernet driver or the wireless fidelity (Wi-Fi) driver to assign a value to the field to realize marking the message type of the data packet.

[0072] For example, the first form of assignment is performed on the field, indicating that the message type of the data message is an Ethernet message. The second form of assignment is performed on the field, indicating that the message type of the data message is a 2.4G Wi-Fi message. The third form of assignment is performed on the field, indicating that the message type of the data message is a 5G Wi-Fi message.

[0073] S302: Determine whether the number of acceleration table entries currently stored in the preset storage area is greater than or equal to a preset upper limit value.

[0074] In some embodiments, the preset storage area may be a storage area in the network device for storing acceleration table items. For network devices, storage resources are limited, and the storage space allocated to the acceleration table items also has a capacity upper limit, that is, the number of acceleration table items that can be stored in the preset storage area is also limited. The preset upper limit value can be set according to the storage capacity of the preset storage area, and the specific value of the preset upper limit value is not limited in the embodiment of the present application.

[0075] If the number of acceleration table entries currently stored in the preset storage area is greater than or equal to the preset upper limit value, it indicates that the remaining capacity of the preset storage area for storing acceleration table entries is insufficient and may not be able to store the newly created acceleration table entry, the process ends, and the acceleration table entry generation module 201 exits the acceleration table entry creation process. If the number of acceleration table entries currently stored in the preset storage area is less than the preset upper limit value, it indicates that the remaining capacity of the preset storage area for storing acceleration table entries is relatively sufficient, and the acceleration table entry generation module 201 can continue to execute step S303.

[0076] S303: If the number of acceleration table entries is less than a preset upper limit, obtain relevant information of the data message, the relevant information including quintuple information, ingress device information, and egress interface device information set.

[0077] In some embodiments, the outbound interface device information set may include message forwarding information, for example, the outbound interface device information set includes outbound interface device information, forwarding direction, outbound interface operation set, relevant information of the protocol layer, etc. If the number of acceleration table entries is less than the preset upper limit value, the acceleration table entry generation module 201 may extract the five-tuple information, the ingress device information, and the outbound interface device information set from the SKB.

[0078] For example, the code for the five-tuple information may include:

[0079] struct fp_tuple{

[0080] u16 type;

[0081] u8 proto;

[0082] u8 resv;

[0083] u16 port_src;

[0084] u16 port_dst;

[0085] }.

[0086] The code of the outgoing interface device information set may include:

[0087] struct fp_dst{

[0088] u32 dir; / / Forwarding direction

[0089] struct net-device*dev; / / Output interface device

[0090] struct fp_dec_ops*ops; / / Output interface operation set

[0091] void*data; / / Key information of L2 and L3 layers

[0092] atomic_t refcnt; / / reference count

[0093] struct rcu_head rcu;

[0094] }.

[0095] S304, calculating a message hash value based on the five-tuple information of the data message.

[0096] After obtaining the relevant information of the data message, a message hash value corresponding to the data message can be calculated based on the five-tuple information in the relevant information. The message hash value can be used as a unique identifier of the acceleration table entry corresponding to the data message.

[0097] S305: Search the global acceleration node based on the message hash value to see whether there is an acceleration table entry corresponding to the data message.

[0098] A global acceleration node may refer to a global node for managing the accelerated forwarding of all data flows in a network device. After calculating the message hash value of a data message, the calculated message hash value may be compared with the message hash values ​​stored in each acceleration table item in the global acceleration node to determine whether there is an acceleration table item corresponding to the data message. For example, if it is determined through comparison that the message hash values ​​stored in each acceleration table item in the global acceleration node are not the same as the message hash value of the calculated data message, it indicates that there is no acceleration table item corresponding to the data message in the global acceleration node. If it is determined through comparison that there is an acceleration table item in the global acceleration node that stores the same message hash value as the calculated data message, it indicates that there is an acceleration table item corresponding to the data message in the global acceleration node.

[0099] If it is determined that there is an acceleration table entry corresponding to the data message in the global acceleration node, in order to avoid duplicate acceleration table entries, the acceleration table entry generation module 201 exits the acceleration table entry creation process, and the process ends. If it is determined that there is no acceleration table entry corresponding to the data message in the global acceleration node, that is, it is necessary to create an acceleration table entry corresponding to the data message, the acceleration table entry generation module 201 can continue to execute step S306.

[0100] S306: If the acceleration table entry corresponding to the data message does not exist in the global acceleration node, an acceleration table entry corresponding to the data message is created based on relevant information of the data message.

[0101] If the acceleration table entry corresponding to the data message does not exist in the global acceleration node, the acceleration table entry generation module 201 may create an acceleration table entry corresponding to the data message based on relevant information of the data message.

[0102] The code for the acceleration table entry may include:

[0103] struct fp_fwd_node{

[0104] struct net_device* in_dev; / / Entry device information

[0105] struct fp_tuple tuple; / / quintuple information

[0106] struct fp_dst_rcu*dst; / / Output interface device information set

[0107] struct hlist_node hlist; / / Hash pointer mounted to the global acceleration node

[0108] }.

[0109] In some embodiments, in order to save storage resources of a preset storage area, the network device may delete the acceleration table entry corresponding to the data flow after the receiver of the data flow is disconnected from the network device.

[0110] S307: Insert the acceleration table entry corresponding to the data message into the global acceleration node.

[0111] After the acceleration table entry corresponding to the data message is created, the acceleration table entry may be inserted into the global acceleration node to perform global acceleration management.

[0112] In some embodiments, when creating acceleration table entries, the current number of acceleration table entries for each CPU core can also be obtained, and the unique identity CPU_ID of the CPU core with the least number of current acceleration table entries is recorded in the created acceleration table entry, so that the CPU core scheduling can be performed based on the CPU_ID recorded in the acceleration table entry to achieve load balancing of the CPU cores.

[0113] like Figure 4 As shown, the process of the acceleration table entry matching module 202 performing the acceleration table entry matching is illustrated.

[0114] S401, receiving a data message sent by a network card driver, and obtaining a message type of the data message.

[0115] The data stream is forwarded according to individual data packets, and the data packets under the same data stream have the same message type. The message type of the data packet can be marked in the process of creating the acceleration table entry. Taking the forwarding of the first data stream as an example, if the data packet sent by the network card driver received by the acceleration table entry matching module 202 is the first data packet of the first data stream, since the acceleration table entry of the data packet has not been created in time, the message type of the data packet has not been marked, that is, the acceleration table entry matching module 202 cannot obtain the message type of the data packet, and the acceleration table entry matching module 202 can directly forward the data packet to the network protocol stack for processing, so that the acceleration table entry generation module 201 can mark the message type based on the data packet processed by the network protocol stack, and create the acceleration table entry.

[0116] If the data packet sent by the network card driver received by the acceleration table entry matching module 202 is the i-th data packet of the first data stream, i is a positive integer greater than 1, since the acceleration table entry generation module 201 has marked the message type of the first data packet of the first data stream, the acceleration table entry matching module 202 can obtain the message type of the i-th data packet received subsequently.

[0117] S402: Determine an operation interface corresponding to the data message based on the message type of the data message.

[0118] In some embodiments, after obtaining the message type of the data message, the acceleration table entry matching module 202 can determine the operation interface corresponding to the data message based on the message type of the data message, so that the operation interface can be called later to extract the five-tuple information of the data message. For example, if the message type of the data message is an Ethernet message, the operation interface corresponding to the data message is an Ethernet driver operation interface, and if the message type of the data message is a 2.4G Wi-Fi message, the operation interface corresponding to the data message is a Wi-Fi driver operation interface.

[0119] S403: Extract quintuple information of the data message based on the operation interface corresponding to the data message.

[0120] After determining the operation interface corresponding to the data message, the acceleration table entry matching module 202 may call the operation interface corresponding to the data message to extract the five-tuple information of the data message.

[0121] S404: Determine whether there is an acceleration table entry corresponding to the data message in the global acceleration node based on the quintuple information of the data message.

[0122] In some embodiments, after obtaining the five-tuple information of the data message, the acceleration table item matching module 202 can calculate the message hash value corresponding to the data message based on the five-tuple information, and then compare the calculated message hash value with the message hash value stored in each acceleration table item in the global acceleration node to determine whether there is an acceleration table item corresponding to the data message in the global acceleration node. For example, if the comparison determines that the message hash values ​​stored in each acceleration table item in the global acceleration node are different from the calculated message hash value, it indicates that there is no acceleration table item corresponding to the data message in the global acceleration node. If the comparison determines that there is an acceleration table item in the global acceleration node that stores the same message hash value as the calculated message hash value, it indicates that there is an acceleration table item corresponding to the data message in the global acceleration node.

[0123] If it is determined that there is an acceleration table entry corresponding to the data message in the global acceleration node, the acceleration table entry matching module 202 can continue to execute step S405. If it is determined that there is no acceleration table entry corresponding to the data message in the global acceleration node, indicating that the acceleration table entry corresponding to the data message is not matched, step S407 is executed, and the acceleration table entry matching module 202 forwards the data message to the network protocol stack for processing.

[0124] S405: Update the forwarding status of the entry corresponding to the data message in the forwarding table.

[0125] In network devices, the forwarding table can also be called the forwarding information base (FIB). Network devices forward data by using the FIB table. The table entries in the FIB specify the destination to which the data message is to go, the outgoing interface to be passed, the next hop IP address and other information. The acceleration table entry matching module 202 updates the forwarding state of the table entry corresponding to the data message in the forwarding table, indicating that the data message enters the forwarding state. After being processed by the forwarding scheduling module 203, the network card driver drives the network card to forward.

[0126] S406 , sending the data message and the key information of the corresponding acceleration table entry to the forwarding scheduling module 203 .

[0127] In some embodiments, before sending the data message and the corresponding acceleration table entry to the forwarding scheduling module 203, the acceleration table entry matching module 202 can also determine whether the acceleration state of the data flow in the soft acceleration module 20 is normal. If the acceleration state is normal, it indicates that the forwarding acceleration of the data flow is achieved through the soft acceleration module 20. The acceleration table entry matching module 202 sends the key information of the data message and the corresponding acceleration table entry to the forwarding scheduling module 203. If the acceleration state is abnormal, it indicates that the forwarding acceleration of the data flow is not achieved through the soft acceleration module 20. It is not meaningful to send the data message to the forwarding scheduling module 203 for scheduling and processing, and it may even cause a large delay in the forwarding of the data message. The acceleration table entry matching module 202 can forward the data message to the network protocol stack for processing. The key information of the acceleration table entry can refer to the output interface device information, the output interface operation set, and the key information of the L2 and L3 layers recorded in the acceleration table entry.

[0128] In some embodiments, whether the acceleration state of the data flow in the soft acceleration module 20 is normal can be determined by obtaining the time difference between the timestamp of the previous data message of the current data message input to the acceleration table entry matching module 202 and the timestamp output from the forwarding scheduling module. If the time difference is greater than the preset time, it indicates that the acceleration state is abnormal, and the acceleration table entry matching module 202 can forward the data message to the network protocol stack for processing. If the time difference is less than or equal to the preset time, it indicates that the acceleration state is normal, and the acceleration table entry matching module 202 can send the key information of the data message and the corresponding acceleration table entry to the forwarding scheduling module 203, so that the forwarding scheduling module 203 can schedule and process the data message later.

[0129] S407: forward the data message to the network protocol stack.

[0130] like Figure 5 As shown, the process of initializing each CPU core by the forwarding scheduling module 203 is illustrated.

[0131] S501, creating a corresponding number of virtual network cards according to the number of CPU cores included in the CPU, and initializing a queue for each CPU core.

[0132] In some embodiments, one CPU core may correspond to one virtual network card, and the CPU core may process data packets according to the requirements of the network protocol through the corresponding virtual network card.

[0133] The queue of the CPU core can be used to store data packets to be forwarded and key information of acceleration entries. For example, the key information may include outbound interface device information, outbound interface operation set, and key information of L2 and L3 layers.

[0134] S502: Register a poll callback function for each CPU core.

[0135] The poll callback function may be a do_pull function that supports a new application program interface (NAPI). NAPI combines the advantages of an interrupt mode and a polling mode. Under light load conditions, the processing mode is close to an interrupt mode, and under heavy load conditions, the processing mode is close to a polling mode.

[0136] By registering a poll callback function for each CPU core, after the data packet and some key information in the acceleration table entry are stored in the queue of a CPU core, the CPU core can read the data packet and some key information in the acceleration table entry from its own queue by triggering the poll callback.

[0137] S503: Configure a scheduling policy for CPU core scheduling.

[0138] In some embodiments, the scheduling policy may include a static scheduling policy and a dynamic scheduling policy.

[0139] For example, static scheduling policies may include the following three types: scheduling policies based on message type and corresponding CPU core binding, scheduling policies based on message priority and corresponding CPU core binding, and scheduling policies based on CPU_ID of CPU core recorded in acceleration table entry. This application does not limit the specific policy content defined by static scheduling policies, and the policy content can be set and adjusted according to actual needs.

[0140] The scheduling strategy based on the binding of the message type and the corresponding CPU core may refer to: scheduling the CPU core according to the binding relationship between the message type of the data message and the CPU core. For example, the message types include Ethernet messages, 2.4G Wi-Fi messages, and 5G Wi-Fi messages. The Ethernet messages, 2.4G Wi-Fi messages, and 5G Wi-Fi messages are respectively bound to different CPU cores. After the acceleration table matching module 202 parses the message type of the data message, the forwarding scheduling module 203 can read the binding relationship between the message type and the CPU core, and schedule the CPU core according to the binding relationship, and then the CPU core after scheduling can execute the data message packet processing flow.

[0141] For example, the CPU of the network device includes four CPU cores, and it is pre-set that the packet sending process of Ethernet packets is executed on the second CPU core, the packet sending process of 2.4G Wi-Fi packets is executed on the third CPU core, and the packet sending process of 5G Wi-Fi packets is executed on the fourth CPU core. Assuming that before the forwarding scheduling module 203 performs CPU core scheduling, the processes such as receiving data packets and matching acceleration table items are executed on the first CPU core, the forwarding scheduling module 203 can switch the packet sending process of Ethernet packets from the first CPU core to the second CPU core, switch the packet sending process of 2.4G Wi-Fi packets from the first CPU core to the third CPU core, and switch the packet sending process of 5G Wi-Fi packets from the first CPU core to the fourth CPU core.

[0142] For example, the following code can be used to set the packet sending process of 2.4G Wi-Fi packets (WLAN0) to be executed on the third CPU core (CPU 2), and the packet sending process of 5G Wi-Fi packets (WLAN1) to be executed on the fourth CPU core (CPU 3):

[0143] / #cat / proc / fc / ctr1 / smp_dispatch_wifi_tx

[0144] WLAN0–Mode:1(IPI dispatch)CPU:2

[0145] WLAN1–Mode:1(IPI dispatch)CPU:3.

[0146] The scheduling strategy based on the message priority and the corresponding CPU core binding may refer to: scheduling the CPU core according to the priority of the data message and the binding relationship between the CPU core. The priority of the data message can be distinguished according to the differentiated services code point (DSCP) value in the data message. The IP header of each data message includes a byte (1 byte includes 8 bits) for identifying the service category (type of service, TOS), and the 6-bit encoding value in the byte is used to represent the priority of the data message, that is, the DSCP value ranges from 0 to 63. The larger the DSCP value, the higher the priority of the data message. In addition to the service category (TOS), the IP header of the data message generally also includes the version (Version), header length (Header Length), total length (Total Length), ID identifier, flag (Flag), fragmentation offset (Fragmentation offset), time to live (Time to live, TTL), protocol (Protocol), frame check sequence (frame check sequence, FCS), source IP address (source ip address, IP-SA), destination IP address (Destination ip address, IP-DA), the IP header of the data message can be shown in Table 1 below.

[0147] Table 1

[0148]

[0149] Based on the performance differences of different CPU cores, data packets of different priorities can be sent to different CPU cores for processing according to the message priority, and data packets with high priority can be sent to CPU cores with stronger performance. Assuming that the CPU of the network device includes four CPU cores, and the processing capabilities of each CPU core are: the first CPU core> the second CPU core> the third CPU core> the fourth CPU core, by constructing the binding relationship between the DSCP value and the CPU core as shown in Table 2 below, the CPU core can be scheduled according to the binding relationship between the data packet priority and the CPU core.

[0150] Table 2

[0151] DSCP value Corresponding CPU core 0~15 Fourth CPU core (CPU 3) 16~31 Third CPU core (CPU 2) 32~47 Second CPU core (CPU 1) 48~63 First CPU core (CPU 0)

[0152] The forwarding scheduling module 203 can parse the DSCP value of the SKB (data packets are transmitted between different protocol layers in the kernel in the form of SKB) and schedule the CPU core based on the DSCP value to improve the packet forwarding performance.

[0153] The scheduling strategy based on the CPU_ID of the CPU core recorded in the acceleration table entry may refer to: scheduling the CPU core according to the CPU_ID recorded in the acceleration table entry corresponding to the data message. When creating the acceleration table entry corresponding to the data message, the acceleration table entry records the identity (CPU_ID) of the CPU core with the least number of current acceleration table entries. When scheduling the CPU core, the CPU core can be scheduled according to the CPU_ID recorded in the acceleration table entry corresponding to the data message, so that each time it is scheduled to the CPU core with a smaller number of acceleration table entries, so as to achieve load balancing of the CPU core.

[0154] For example, if the CPU_ID of the acceleration table entry record corresponding to a data message is the second CPU core, the packet sending process of the data message can be switched from the current CPU core to the second CPU core for execution.

[0155] Since the static scheduling policy cannot be modified during the operation of the network device after being preset to the network device, in some scenarios, the static scheduling policy may not be the best scheduling policy. After the service type of the data flow is identified, the static scheduling policy can be dynamically adjusted based on the identification result to achieve the best message forwarding performance. That is, the dynamic scheduling policy can refer to a policy that dynamically adjusts the static scheduling policy based on the service type identification result of the data flow.

[0156] As shown in Table 3 below, taking the service type of the data flow as the application type as an example, the rules for dynamically adjusting the static scheduling strategy based on the application type corresponding to the data flow are illustrated. Different application types can set the same / different dynamic scheduling strategies.

[0157] Table 3

[0158]

[0159]

[0160] It can be seen from the content of Table 3 that, during the CPU core scheduling process, the forwarding scheduling module 203 can determine whether to adjust the static scheduling strategy according to the application type of the data flow and the status of the pre-scheduled CPU core.

[0161] For example, if the application type of the data stream is a game, and the pre-scheduled CPU core determined based on the static scheduling policy has the highest usage rate among all CPU cores, the forwarding scheduling module 203 may first determine the corresponding dynamic scheduling policy based on the application type corresponding to the data stream, and then select a new CPU core as the final CPU core to be scheduled based on the corresponding dynamic scheduling policy. If the pre-scheduled CPU core determined based on the static scheduling policy does not have the highest usage rate among all CPU cores, the forwarding scheduling module 203 uses the pre-scheduled CPU core as the final CPU core to be scheduled.

[0162] In some embodiments, the condition for triggering the dynamic scheduling policy may also be set to be that the usage rate of the pre-scheduled CPU core is greater than a threshold and has the highest usage rate among all CPU cores.

[0163] like Figure 6 As shown, it illustrates the process of the forwarding scheduling module 203 performing CPU core scheduling according to the pre-configured scheduling strategy (static scheduling strategy and dynamic scheduling strategy).

[0164] S601, obtaining key information of a data message and a corresponding acceleration table entry.

[0165] In some embodiments, the forwarding scheduling module 203 can obtain the key information of the data message and the corresponding acceleration table entry by receiving the data message and the key information of the corresponding acceleration table entry sent by the acceleration table entry matching module 202. The data message is transmitted between different protocol layers in the kernel in the form of SKB, that is, the forwarding scheduling module 203 actually obtains the key information of the SKB to be forwarded and the acceleration table entry corresponding to the SKB.

[0166] S602: Determine a target CPU core to be scheduled based on a pre-configured scheduling policy.

[0167] In some embodiments, the forwarding scheduling module 203 may determine the target CPU core to be scheduled based on the static scheduling policy and the dynamic scheduling policy, so that subsequent processing and forwarding of the data message are performed on the target CPU core.

[0168] For example, if the state of the pre-scheduled CPU core determined based on the static scheduling policy does not meet the preset conditions, the pre-scheduled CPU core is used as the final CPU core to be scheduled (i.e., the target CPU core); if the state of the pre-scheduled CPU core determined based on the static scheduling policy meets the preset conditions, a CPU core is reselected based on the dynamic scheduling policy as the final CPU core to be scheduled (i.e., the target CPU core). The preset conditions may refer to the conditions that trigger the dynamic scheduling policy, such as the pre-scheduled CPU core having the highest utilization rate among all CPU cores, or the utilization rate of the pre-scheduled CPU core is greater than a threshold and has the highest utilization rate among all CPU cores.

[0169] S603, adding the key information of the data message and the corresponding acceleration table entry to the queue of the target CPU core.

[0170] After determining the target CPU core to be scheduled, the data message and the key information of the corresponding acceleration table entry can be added to the queue of the target CPU core, that is, the data message and the key information of the corresponding acceleration table entry are added to the queue of the target CPU core as a queue element. The queue elements in the queue can be read according to the first-in-first-out rule.

[0171] S604, switching the CPU core, triggering the poll callback of the target CPU core, and reading the data message and the key information of the corresponding acceleration table entry from the queue of the target CPU core.

[0172] In some embodiments, for a CPU with multiple CPU cores, the Linux system provides a symmetric multiprocessing (SMP) scheduling mechanism to migrate tasks to a suitable CPU core for execution. The SMP scheduling mechanism can be used to switch CPU cores, from the current CPU core to the target CPU core. The CPU core switching can trigger a NAPI soft interrupt, which can then trigger the target CPU core to call the poll callback function, so that the target CPU core reads the data message and the corresponding key information of the acceleration table entry from its own queue.

[0173] In some embodiments, before switching the CPU core, the process is executed on the current CPU core, for example, steps S601 to S603 are executed on the current CPU core. After switching the CPU core, the process is transferred to the target CPU core for execution, for example, the reading of the data message and the corresponding key information of the acceleration table item in step S604 and the following steps S605 and S606 are executed on the target CPU core.

[0174] S605, determining the outbound interface device and outbound interface of the data message based on the key information of the acceleration table entry, and updating the key information of the L2 and L3 layers to the data message.

[0175] In some embodiments, the key information of the acceleration table entry includes the output interface device information, the output interface operation set, and the key information of the L2 and L3 layers. The output interface device of the data packet can be determined based on the output interface device information, and the output interface of the data packet can be determined based on the output interface operation set. The output interface can be a packet sending function driven by a network card, such as a packet sending function driven by an Ethernet driver, or a packet sending function driven by a Wi-Fi driver.

[0176] Since the data packet has not been processed by the network protocol stack, the key information of the L2 and L3 layers of the data packet has not been updated by the network protocol stack. The key information of the L2 and L3 layers recorded in the acceleration table entry is the information updated by the previous data packet through the network protocol stack. By updating the key information of the L2 and L3 layers recorded in the acceleration table entry to the data packet, it is possible to simulate the processing of the data packet through the network protocol stack.

[0177] S606, calling the outbound interface of the outbound interface device to send the data message out through the network card.

[0178] After determining the output interface device and output interface of the data message, the output interface of the output interface device can be called to send the data message that completes the update of the key information of the L2 and L3 layers through the network card.

[0179] For example, the network card driver includes an Ethernet driver and a Wi-Fi driver. The terminal device accesses the network device wirelessly. For the data message forwarded from the network device to the terminal device, on the network device side, the Ethernet driver receives the data message, and the Wi-Fi driver drives the network card to send the data message out; for the data message forwarded from the network device to the server, on the network device side, the Wi-Fi driver receives the data message (the source of the data message is the terminal device), and the Ethernet driver drives the network card to send the data message out; for the data message forwarded from the network device to other network devices (the network device and other network devices are connected by wire), on the network device side, the Ethernet driver receives the data message, and the Ethernet driver drives the network card to send the data message out. The network card may include a first hardware module (driven by the Ethernet driver) that can realize the transmission and reception of Ethernet data messages and a second hardware module (driven by the Wi-Fi driver) that can realize the transmission and reception of Wi-Fi data messages.

[0180] The forwarding scheduling module 203 schedules the CPU cores to achieve the forwarding of data messages by utilizing the cooperation of two CPU cores, thereby improving the forwarding performance of data messages of the network device.

[0181] See also Figure 7 , illustrating the overall process of the forwarding scheduling module 203 implementing the initialization of the CPU core and the scheduling of the CPU core.

[0182] CPU core initialization:

[0183] (1) Obtain the CPU cores included in the CPU, create a virtual network card for each CPU core, and initialize the queue of each CPU core.

[0184] After the queue of each CPU core is initialized, the queue elements it contains are empty.

[0185] (2) Register a poll callback function for each CPU core.

[0186] (3) Configuring a scheduling strategy for CPU core scheduling, the scheduling strategy may include a static scheduling strategy and a dynamic scheduling strategy. The static scheduling strategy may include determining the CPU core to be scheduled based on the binding relationship between the message type of the data message and the CPU core; determining the CPU core to be scheduled based on the message priority of the data message and the binding relationship between the CPU core; and determining the CPU core to be scheduled based on the CPU core identifier recorded in the acceleration table entry.

[0187] CPU core scheduling:

[0188] (1) Receive the data message to be forwarded and the key information of the corresponding acceleration table entry.

[0189] (2) Scheduling strategy selection, such as choosing to use a static scheduling strategy or a dynamic scheduling strategy.

[0190] (3) Determine the target CPU core to be scheduled based on the selected scheduling strategy.

[0191] (4) Add the data message to be forwarded and the key information of the corresponding acceleration table entry to the queue of the target CPU core.

[0192] Since the network device may forward multiple data streams in parallel, that is, data packets of multiple data streams may be added to the queue of the target CPU core, Figure 7 It shows that the queue includes N queue elements (queue element 1 to queue element N), N is a positive integer, and the queue elements in the queue can be read according to the first-in-first-out strategy.

[0193] (5) SMP switches CPU cores, triggering soft interrupts.

[0194] When SMP switches CPU cores, a soft interrupt can be triggered, which can further trigger the poll callback of the target CPU core.

[0195] (6) Trigger the poll callback of the target CPU core.

[0196] (7) The target CPU core reads the data message to be forwarded and the key information of the corresponding acceleration table entry from its own queue.

[0197] (8) The target CPU core determines the output interface device and output interface of the data message based on the key information of the acceleration table entry.

[0198] (9) The target CPU core obtains the key information of the L2 and L3 layers from the key information of the acceleration table entry, and updates the key information of the L2 and L3 layers to the data message to be forwarded.

[0199] (10) The target CPU core calls the output interface of the output interface device to send the updated data message through the network card.

[0200] In some embodiments, in order to implement the scheduling of CPU cores based on dynamic scheduling strategies, an intelligent recognition module for identifying business types can be set at the kernel layer of the network device. The intelligent recognition module can identify the business type corresponding to the data stream based on the input data stream. Taking the business type of the data stream as the application type as an example, the corresponding application name can be identified based on the input data stream, and then the application type is determined based on the application name. For example, the application type can include game class, live broadcast class (game live broadcast or other live broadcast), application market class, download class, video class, short video class, news class, social chat class, e-commerce shopping class, online class class, etc., and the application type can be divided according to actual needs, and the embodiments of the present application are not limited to this.

[0201] For example, as shown in Table 4 below, the following application types can be identified by the intelligent identification module. The application types listed in Table 4 do not limit the intelligent identification module, and the intelligent identification module can also identify data streams of other application types not listed in Table 4.

[0202] Table 4

[0203]

[0204] Different applications usually use different protocols, and different application protocols have their own characteristics. These characteristics may be specific ports, specific strings, or specific bit sequences. The characteristics that can identify the protocol are called signatures. The intelligent identification module can determine the application by matching the signatures in the data message. The data messages exchanged between different applications usually also include specific fields that can be distinguished from other applications. The intelligent identification module can also determine the application by matching specific fields in the data message.

[0205] In some embodiments, the intelligent identification module can be deployed in the network protocol stack. Taking the deployment of the Linux system in the network device as an example, the Netfilter framework is a management mechanism introduced by the Linux system to provide a complete set of detection point (HOOK) functions, so that the kernel can check, modify and discard data packets entering and leaving the network interface. The network layer generally includes five HOOK points: Pre-Routing node, Local_IN node, Forward node, Local_OUT node, Post-Routing node. The data stream forwarded by the network device generally passes through the Pre-Routing node, Forward node and Post-Routing node. The intelligent identification module can work in the FORWARD node. The intelligent identification module can identify and record the business type corresponding to each data stream in units of data streams.

[0206] like Figure 8 The figure shows the working position of the intelligent identification module in the Netfilter framework. The intelligent identification module is set at the FORWARD node.

[0207] When a data message is transmitted from the data link layer, if the data message is to access the network device itself, the data message passes through the PRE_ROUTING node and the LOCAL_IN node to reach the transport layer and the application layer. When the data message is sent out from the network device, the data message is sent out through the LOCAL_OUT node and the POST_ROUTING node. When the data message is transmitted from the data link layer, if the data message needs to be forwarded, the data message is sent out through the PRE_ROUTING node, the FORWARD node, and the POST_ROUTING node.

[0208] The intelligent identification module located at the FORWARD node can obtain the five-tuple information of the data message and save the five-tuple information of the data message into the memory. At the same time, the intelligent identification module can also determine the application type of the data flow by matching specific fields in the data message and save the mapping relationship between the five-tuple information and the application type in the memory.

[0209] See also Fig. 9 and Fig.10 , illustrating the interaction process of internal functional components in network devices to implement data message forwarding.

[0210] If the data packet is the first data packet of a data flow, the interaction process includes the following processes:

[0211] 901, the network card driver receives the data message.

[0212] 902 , the network card driver sends the data message to the soft acceleration module 20 .

[0213] 903, the soft acceleration module 20 sends the data message to the network protocol stack.

[0214] For the first data packet of the data flow, since the acceleration table entry has not been created yet, the soft acceleration module 20 will forward the data packet to the network protocol stack for processing.

[0215] 904, the network protocol stack processes the data message and calls the intelligent identification module to identify the application type of the data stream.

[0216] In some embodiments, during the process of processing data packets, the FORWARD hook node located in the network layer of the network protocol stack can call the intelligent identification module to identify the application type of the data flow, and construct a mapping relationship between the five-tuple information of the data flow and the application type. The mapping relationship can be stored in the memory, and the mapping relationship between multiple five-tuple information and their corresponding application types can be saved by constructing a mapping relationship table.

[0217] 905 , the network protocol stack sends the processed data message to the soft acceleration module 20 .

[0218] 906 , the soft acceleration module 20 creates an acceleration table entry based on the relevant information of the processed data message.

[0219] The relevant information may include the five-tuple information of the data packet (source IP address, destination IP address, source port number, destination port number and transmission protocol), the ingress device information of the data packet, and the outgoing interface device information set of the data packet. The outgoing interface device information set of the data packet may include the outgoing interface device information of the data packet, the forwarding direction of the data packet, the outgoing interface operation set of the data packet, relevant information of the protocol layer, etc.

[0220] 907, the soft acceleration module 20 forwards the data message processed by the network protocol stack to the network card driver.

[0221] In some embodiments, process 906 and process 907 may be performed in parallel.

[0222] 908. The network card driver drives the network card to send out the data message processed by the network protocol stack.

[0223] If the data packet is not the first data packet of the data flow, the interaction process includes the following processes:

[0224] 101. The network card driver receives a data message.

[0225] 102 , the network card driver sends the data message to the soft acceleration module 20 .

[0226] 103, the soft acceleration module 20 determines the application type to which the data flow belongs based on the five-tuple information of the data message, and determines the target CPU core to be scheduled based on the static scheduling strategy, the utilization rate of each CPU core and the application type to which the data flow belongs.

[0227] 104 , the soft acceleration module 20 executes CPU core scheduling to schedule to a target CPU core.

[0228] 105, the soft acceleration module 20 processes the data message.

[0229] For example, processing the data message may include determining an outbound interface device and an outbound interface of the data message based on key information of the acceleration table entry, and updating key information of the L2 and L3 layers to the data message.

[0230] 106. The soft acceleration module 20 sends the processed data message to the network card driver.

[0231] 107. The network card driver drives the network card to send out the processed data message.

[0232] In some embodiments, before executing CPU core scheduling, the process is executed on the current CPU core, for example, processes 101 to 103 are executed on the current CPU core, and after executing CPU core scheduling, the process is transferred to the target CPU core for execution, for example, processes 105 to 107 are executed on the target CPU core.

[0233] In order to further understand the scheduling logic involved in the CPU core scheduling performed by the soft acceleration module 20 of the present application, the following is combined with Fig.11 The process of CPU core scheduling performed by the soft acceleration module 20 during the process of forwarding a certain data flow by the network device is described in detail.

[0234] S111, obtaining quintuple information of the data message, and searching for the application type to which the data flow belongs based on the quintuple information of the data message.

[0235] In some embodiments, after obtaining the quintuple information of the data message, the soft acceleration module 20 may compare the obtained quintuple information with the mapping relationship table between the quintuple information and the application type stored in the memory to find the application type to which the data flow belongs.

[0236] In some embodiments, if the application type to which the data stream belongs is found, step S112 may be executed; if the application type to which the data stream belongs is not found, step S116 may be executed.

[0237] S112, obtaining the usage rate of each CPU core.

[0238] For example, the soft acceleration module 20 may obtain the usage rate of each CPU core through the system status statistics interface / proc / stat.

[0239] S113, determining whether it is necessary to reset the target CPU core according to the application type to which the data flow belongs and the usage rate of each CPU core.

[0240] In some embodiments, the target CPU core may refer to the CPU core to be ultimately scheduled. For example, if the usage of each CPU core changes, it may be necessary to reset the target CPU core based on the application type to which the data flow belongs and the usage of each CPU core. If it is determined that the target CPU core needs to be reset, step S114 may be executed, and if it is determined that the target CPU core does not need to be reset, step S116 may be executed.

[0241] For example, the CPU core determined based on the application type to which the data flow belongs and the usage rate of each CPU core can be compared with the CPU core set last time. If they are different, it is determined that the target CPU core needs to be reset; if they are the same, it is determined that the target CPU core does not need to be reset.

[0242] S114, determining whether the duration from the current time to the last time the target CPU core was set is greater than a preset duration.

[0243] After determining that the target CPU core needs to be reset, the duration from the current time to the last time the target CPU core was set can be calculated and compared with the preset duration. If it is greater than the preset duration, step S115 can be executed. If it is not greater than the preset duration, step S116 can be executed. The embodiment of the present application can avoid frequent setting of the target CPU core through step S114. The preset duration can be set according to actual needs, and the embodiment of the present application does not limit this. For example, the preset duration is 10s.

[0244] S115, resetting the target CPU core according to the application type to which the data flow belongs and the usage rate of each CPU core.

[0245] After determining that the duration between the current time and the last time the target CPU core was set is greater than the preset duration, the target CPU core may be reset according to the application type to which the data flow belongs and the usage rate of each CPU core.

[0246] S116: The last scheduled CPU core is used as the target CPU core.

[0247] The last scheduled CPU core may refer to the CPU core scheduled for forwarding the last data packet of the current data packet. The last scheduled CPU core may be the target CPU core determined based on the application type to which the data flow belongs and the utilization rate of each CPU core, or the target CPU core determined based on the static scheduling policy.

[0248] S117, executing CPU core switching to switch the forwarding process of the data message from the current CPU core to the target CPU core for execution.

[0249] After resetting the target CPU core, or taking the last scheduled CPU core as the target CPU core, CPU core switching may be performed to switch the forwarding process of the data message from the current CPU core to the target CPU core for execution.

[0250] See also Fig.12 As shown, a message forwarding method is provided in an embodiment of the present application. The message forwarding method can be applied to a network device, and the CPU of the network device includes multiple CPU cores. The message forwarding method includes:

[0251] S121, receiving a data message to be forwarded.

[0252] In some embodiments, the data packet to be forwarded may be received by a network card driver.

[0253] S122, determining whether an acceleration table entry corresponding to the data message is matched.

[0254] In some embodiments, the five-tuple information of the forwarded data message can be obtained, and based on the five-tuple information of the data message to be forwarded, it is searched whether the network device stores an acceleration table entry corresponding to the data message. For example, after obtaining the five-tuple information of the data message, a message hash value corresponding to the data message can be calculated based on the five-tuple information, and then the calculated message hash value is compared with the message hash values ​​stored in each acceleration table entry stored in the network device to determine whether the acceleration table entry corresponding to the data message is matched.

[0255] S123: When no acceleration table entry corresponding to the data message is matched, forwarding processing of the data message is performed on the current CPU core.

[0256] In the case where no acceleration table entry corresponding to the data message is matched, it indicates that the data message to be forwarded may be the first data message of the data flow, and the network device has not yet created the corresponding acceleration table entry. In this case, the network protocol stack can be used to process the data message without switching the CPU core. That is, executing the forwarding processing of the data message on the current CPU core may include: using the network protocol stack to process the data message, and sending the processed data message through the network card driver.

[0257] In some embodiments, after the data packet is processed by the network protocol stack, relevant information can be extracted from the data packet. The relevant information may include entry device information, five-tuple information, and packet forwarding information, etc., and then a corresponding acceleration table entry is created based on the relevant information of the data packet, so that subsequent data packet forwarding of the data flow can be processed without the network protocol stack, thereby improving the packet forwarding efficiency.

[0258] S124, when an acceleration table entry corresponding to the data message is matched, determining a target CPU core to be scheduled, the acceleration table entry including message forwarding information of the data message.

[0259] When an acceleration table entry corresponding to a data message is matched, it indicates that the data message can be forwarded in the form of CPU scheduling, and the data message does not need to be processed by the network protocol stack. The target CPU core to be scheduled can be determined based on a static scheduling strategy or a dynamic scheduling strategy.

[0260] S125, adding the data message and the message forwarding information corresponding to the data message to the queue of the target CPU core.

[0261] After the target CPU core is determined, the data message and the message forwarding information corresponding to the data message may be added to the queue of the target CPU core to facilitate the subsequent forwarding of the data message by the target CPU core.

[0262] S126, the target CPU core executes forwarding processing of the data message.

[0263] After the data message and the message forwarding information corresponding to the data message are added to the queue of the target CPU core, the CPU core can be switched to switch the forwarding processing of the data message from the current CPU core to the target CPU core, that is, the subsequent forwarding process of the data message is completed by the target CPU core.

[0264] For example, by executing CPU core switching, the poll callback of the target CPU core can be triggered, and the data packet and the message forwarding information of the data packet can be read from the queue of the target CPU core. Then, based on the message forwarding information of the data packet, the output interface device and output interface of the data packet can be determined, and the data packet can be updated. Finally, the output interface is called to send the updated data packet.

[0265] Fig.13 The above is a schematic diagram of a network device in an embodiment of the present application. The network device 100 includes a processor 1001, a memory 1002 coupled to the processor 1001, and a transceiver 1003. The processor 1001 can be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP. The processor 1001 can also be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The above-mentioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The processor 1001 can refer to one processor or include multiple processors. The transceiver 1003 is used to receive a data message to be forwarded and send the message to the processor 1001 for subsequent operation processing. The memory 1002 may include a volatile memory, such as a random-access memory (RAM); the memory may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory (English: flash memory), a hard disk drive (HDD) or a solid-state drive (SSD); the memory 1002 may also include a combination of the above-mentioned types of memory. One or more computer programs 1004 are stored in the memory 1002. The one or more computer programs 1004 are configured to be executed by the processor 1001. The one or more computer programs 1004 include instructions, and the above instructions can be used to implement the execution of the following in the network device 100: Fig.12 The message forwarding method.

[0266] This embodiment further provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on a network device, the network device executes the above-mentioned related method steps to implement the message forwarding method in the above-mentioned embodiment.

[0267] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement the message forwarding method in the above-mentioned embodiment.

[0268] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer execution instructions, and when the device is running, the processor can execute the computer execution instructions stored in the memory so that the chip executes the message forwarding method in the above-mentioned method embodiments.

[0269] Among them, the network device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.

[0270] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0271] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are schematic. For example, the division of the modules or units is a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0273] In addition, each functional unit in each embodiment of the present application 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0274] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks or optical disks.

[0275] The above description is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application.

Claims

1. A message forwarding method, applied to a network device, characterized in that: The central processing unit (CPU) of the network device has multiple CPU cores, and the method includes: Receive data packets to be forwarded; In the case where an acceleration table entry corresponding to the data message is matched, determining a target CPU core to be scheduled, the acceleration table entry including message forwarding information of the data message; The data message and the message forwarding information corresponding to the data message are added to the queue of the target CPU core, and the target CPU core performs forwarding processing on the data message.

2. The method according to claim 1, characterized in that After receiving the data message to be forwarded, the method further includes: In the case where the acceleration table entry corresponding to the data packet is not matched, the forwarding processing of the data packet is performed by the current CPU core, wherein the forwarding processing of the data packet performed by the current CPU core includes processing the data packet using the network protocol stack, and sending the processed data packet through the network card driver.

3. The method according to claim 2, characterized in that The method further comprises: Extracting ingress device information, five-tuple information and the message forwarding information from the data message processed by the network protocol stack; An acceleration table entry corresponding to the data message is constructed based on the ingress device information, the five-tuple information and the message forwarding information.

4. The method according to claim 3, characterized in that The constructing an acceleration table entry corresponding to the data message based on the ingress device information, the five-tuple information and the message forwarding information includes: Calculate a message hash value of the data message based on the five-tuple information; Determine, based on the message hash value, whether the network device has stored an acceleration table entry corresponding to the data message; In a case where the network device does not store an acceleration table entry corresponding to the data message, an acceleration table entry corresponding to the data message is constructed based on the ingress device information, the five-tuple information and the message forwarding information.

5. The method according to claim 1, characterized in that After receiving the data message to be forwarded, the method further includes: Extracting five-tuple information from the data message, and calculating a message hash value of the data message based on the five-tuple information; The message hash value of the data message is compared with the message hash value of each currently stored acceleration table entry record to obtain an acceleration table entry matching the data message.

6. The method according to claim 1, characterized in that The determining of the target CPU core to be scheduled includes: Determine the pre-scheduled CPU core based on a pre-configured static scheduling policy; In a case where the state of the pre-scheduled CPU core does not meet a preset condition, determining the pre-scheduled CPU core as the target CPU core, wherein the preset condition includes that the pre-scheduled CPU core has the highest usage rate among the multiple CPU cores; When the state of the pre-scheduled CPU core meets the preset condition, the application type to which the data packet belongs and the usage rate of each CPU core among the multiple CPU cores are obtained, and the target CPU core is determined based on the application type to which the data packet belongs, the usage rate of each CPU core and the pre-configured dynamic scheduling strategy.

7. The method according to claim 6, characterized in that The static scheduling strategy includes any one of the following: Determining the pre-scheduled CPU core based on the binding relationship between the message type of the data message and the CPU core; Determining the pre-scheduled CPU core based on the message priority of the data message and the binding relationship between the CPU core; The pre-scheduled CPU core is determined based on the CPU core identifier recorded in the acceleration table entry.

8. The method according to claim 1, characterized in that The determining of the target CPU core to be scheduled includes: The target CPU core to be scheduled is determined based on a pre-configured static scheduling policy, wherein the static scheduling policy includes determining the target CPU core based on a message type of a data message and a binding relationship between a CPU core, determining the target CPU core based on a message priority of a data message and a binding relationship between a CPU core, or determining the target CPU core based on a CPU core identifier recorded in an acceleration table entry.

9. The method according to claim 7 or 8, characterized in that The CPU core identifier recorded in the acceleration table entry is the identifier of the CPU core with the least number of acceleration table entries in the queue when the acceleration table entry is created.

10. The method according to claim 1, characterized in that The target CPU core performs forwarding processing on the data message, including: Switch the forwarding process of the data message from the current CPU core to the target CPU core, triggering the poll callback of the target CPU core; Read the data message and message forwarding information of the data message from the queue of the target CPU core; Determining an outbound interface device and an outbound interface of the data message based on the message forwarding information of the data message, and updating the data message; The output interface of the output interface device is called to send out the updated data message.

11. The method according to claim 10, characterized in that The message forwarding information includes outbound interface device information, an outbound interface operation set, and related information of a specified protocol layer, wherein the specified protocol layer includes a network layer and a transport layer, and the determining of an outbound interface device and an outbound interface of a data message based on the message forwarding information of the data message, and updating the data message, comprises: Determine the outbound interface device of the data message based on the outbound interface device information; Determining an outbound interface of the data message based on the outbound interface operation set; The relevant information of the protocol layer is updated to the data message.

12. The method according to any one of claims 1 to 11, characterized in that The network device includes one of a router, a switch, a forwarder, a virtual switch, a virtual router, and a virtual forwarder.

13. A network device, characterized in that: The network device memory and processor; The memory is used to store program instructions; The processor is used to read the program instructions stored in the memory to implement the message forwarding method as described in any one of claims 1 to 12.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the message forwarding method according to any one of claims 1 to 12 is implemented.

15. A chip coupled to a memory in a network device, characterized in that: The chip is used to control the network device to execute the message forwarding method as described in any one of claims 1 to 12.

Citation Information

Patent Citations

  • Message sending method and device, electronic equipment and computer readable storage medium

    CN110177047A

  • Firewall system of user mode pipeline architecture

    CN111614631A

  • Method and system for multi-core parallel rapid data packet forwarding of network communication equipment

    CN112929278A

  • Method and device for optimizing data packet forwarding of multi-core CPU and storage medium

    CN116136793A

  • Multi-core communication acceleration using hardware queue device

    US20170192921A1

Cited By

  • High-concurrency network connection load balancing method based on operating system

    CN120407205A