Packet forwarding method and apparatus, NP chip, and network device

By setting up a message forwarding device in the data channel of the NP chip and using flow characteristic information to perform flow forwarding, the problem of high power consumption of pipeline processors is solved, and low-power and high-efficiency forwarding of NP chips is realized.

WO2026145185A1PCT designated stage Publication Date: 2026-07-09HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2025-12-24
Publication Date
2026-07-09

AI Technical Summary

Technical Problem

The pipelined processor consumes a lot of power to forward message headers, which in turn leads to a high power consumption of the NP chip.

Method used

By setting up a message forwarding device in the data channel, the flow characteristic information of the message is obtained and the flow forwarding is performed according to the flow table entry, thereby reducing the pipeline processing of the message and reducing power consumption.

Benefits of technology

This reduces the power consumption of the NP chip and improves the efficiency of message forwarding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025145025_09072026_PF_FP_ABST
    Figure CN2025145025_09072026_PF_FP_ABST
Patent Text Reader

Abstract

A packet forwarding method and apparatus, an NP chip, and a network device, relating to the technical field of networks. The packet forwarding apparatus is applied to an NP chip, the NP chip comprises a pipeline processor and a data path, and the packet forwarding apparatus is in the data path. The packet forwarding apparatus is used for: acquiring flow characteristic information of a first packet received by the data path; and performing flow forwarding on the first packet on the basis of the flow characteristic information of the first packet. In the present application, the packet forwarding apparatus in the data path performs flow forwarding on a packet, helping to reduce power consumption of the NP chip.
Need to check novelty before this filing date? Find Prior Art

Description

Message forwarding methods and devices, NP chips, network equipment

[0001] This application claims priority to Chinese patent application No. 202411990129.1, filed on December 31, 2024, entitled "Message Forwarding Method and Apparatus, NP Chip, Network Equipment", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of network technology, and in particular to a message forwarding method and apparatus, a network processor (NP) chip, and network equipment. Background Technology

[0003] The NP chip in a network device includes a pipeline processor (PP) and a data path (DP). The pipeline processor processes the headers of network packets received by the data path to obtain a processed header; the data path obtains the processed network packet based on the original network packet and the processed header, and then sends the processed network packet.

[0004] However, the power consumption of pipelined processors in forwarding message headers is relatively high, which leads to a higher power consumption of NP chips. Summary of the Invention

[0005] This application provides a message forwarding method and apparatus, an NP chip, and a network device. The technical solution of this application is as follows.

[0006] In a first aspect, a message forwarding device is provided, applied to an NP chip, the NP chip including a pipeline processor and a data channel, the message forwarding device being located in the data channel, the message forwarding device being used to: acquire flow characteristic information of a first message received by the data channel; and perform flow forwarding of the first message based on the flow characteristic information of the first message.

[0007] The technical solution provided in this application sets up a message forwarding device in the data channel, which performs stream forwarding of messages. The power consumption of the message forwarding device in the data channel when performing stream forwarding of messages is relatively small, which helps to reduce the power consumption of the NP chip.

[0008] Optionally, the message forwarding device is configured to: determine a first flow forwarding table entry based on the flow characteristic information of the first message; and perform flow forwarding on the first message based on the first flow forwarding table entry. Wherein, the first flow forwarding table entry matches the flow characteristic information of the first message.

[0009] Optionally, the message forwarding device is used to: obtain first control information according to the first flow forwarding table entry; and perform flow forwarding on the first message according to the first control information.

[0010] Optionally, the first flow table entry includes a mapping relationship between the flow characteristic information of the first message and the index information of the first control information. The message forwarding device is used to: determine the index information of the first control information according to the first flow table entry; and obtain the first control information according to the index information of the first control information.

[0011] The technical solution provided in this application allows the message forwarding device to determine the index information of the first control information based on the first flow table entry, and to obtain the first control information based on the index information of the first control information, which facilitates the message forwarding device to perform flow forwarding on the first message based on the first control information.

[0012] Optionally, the packet forwarding device includes a flow table matching module, a flow table data acquisition module, and a packet processing module; the flow table matching module is used to: acquire the flow characteristic information of the first packet; determine the first flow forwarding table entry based on the flow characteristic information of the first packet; and determine the index information of the first control information based on the first flow forwarding table entry; the flow table data acquisition module is used to: acquire the first control information based on the index information of the first control information; and the packet processing module is used to: perform flow forwarding on the first packet based on the first control information.

[0013] Optionally, the flow table matching module is used to: obtain flow feature information carried in at least one header of the first packet; and obtain the flow feature information of the first packet based on the flow feature information obtained from the at least one header. The flow feature information of the first packet includes the flow feature information carried in the at least one header. For example, the flow feature information of the first packet is formed by concatenating the flow feature information carried in the at least one header.

[0014] Optionally, the flow table matching module includes at least one flow feature extraction unit, which corresponds one-to-one with the at least one packet header; each of the at least one flow feature extraction units is used to extract flow feature information from the corresponding packet header.

[0015] Optionally, the at least one flow feature extraction unit is N flow feature extraction units, and the N flow feature extraction units are connected in series (that is, the N flow feature extraction units are connected in sequence), and the at least one message header is N message headers, where N is an integer greater than 1; the i-th flow feature extraction unit among the N flow feature extraction units is further configured to: splice the flow feature information extracted by the i-th flow feature extraction unit from the corresponding message header and the flow feature information output by the (i - 1)-th flow feature extraction unit, and output the spliced flow feature information, where 1 < i ≤ N and i is an integer; among them, the flow feature information of the first message is the flow feature information output by the N-th flow feature extraction unit.

[0016] Optionally, the at least one flow feature extraction unit is N flow feature extraction units, and the N flow feature extraction units are connected in parallel, and the at least one message header is N message headers, where N is an integer greater than 1; the flow table matching module further includes a splicing unit, and the splicing unit is configured to: splice the flow feature information extracted by the N flow feature extraction units from the N message headers to obtain the flow feature information of the first message.

[0017] Optionally, the flow table matching module includes a lookup unit; the lookup unit is configured to: determine the first flow table entry in the flow transfer table according to the flow feature information of the first message. That is, the lookup unit searches the flow transfer table according to the flow feature information of the first message to determine the first flow table entry.

[0018] Optionally, the first message belongs to the first flow, and the first flow table entry is a flow table entry for forwarding the first flow, and the first flow table entry is generated by the pipeline processor; after the pipeline processor generates the first flow table entry, it sends the first flow table entry to the message forwarding device; the message forwarding device is further configured to: receive the first flow table entry sent by the pipeline processor. For example, the first flow table entry includes the mapping relationship between the flow feature information of the first message and the index information of the first control information. After the pipeline processor generates the first flow table entry, it also sends the first control information to the message forwarding device, and the message forwarding device is further configured to receive the first control information sent by the pipeline processor.

[0019] Optionally, the message forwarding device includes a flow table matching module and a flow table data acquisition module. The pipeline processor sends the first flow table entry to the flow table matching module, and the pipeline processor sends the first control information to the flow table data acquisition module; correspondingly, the flow table matching module is configured to receive the first flow table entry sent by the pipeline processor, and the flow table data acquisition module is configured to receive the first control information sent by the pipeline processor.

[0020] Optionally, the first flow is an elephant flow. That is, the traffic of the first flow is relatively large.

[0021] The technical solution provided in this application generates flow table entries for large data streams, which can avoid generating flow table entries for smaller data streams, thus helping to reduce the size of the flow table.

[0022] Optionally, the first flow table entry is generated by the pipeline processor based on the header of the second message received by the data channel, and the second message belongs to the first flow; the message forwarding device is also used to: obtain the flow characteristic information of the second message received by the data channel; determine that the flow characteristic information of the second message does not hit the flow table, and send the header of the second message to the pipeline processor.

[0023] The technical solution provided in this application allows the message forwarding device to send the header of the second message to the pipeline processor when the flow characteristic information of the second message belonging to the first flow does not hit the flow table. This facilitates the pipeline processor to generate a first flow table entry based on the header of the second message, thereby enabling subsequent flow forwarding of the first-order messages based on the first flow table entry.

[0024] Optionally, the first flow table entry is generated by the pipeline processor when it determines that the number of first-order packets among the packets received by the data channel reaches a preset number. For example, for each packet belonging to the first order received by the data channel: the packet forwarding device searches the flow table based on the packet's flow characteristic information; if the flow characteristic information of the packet does not match the flow table, the packet forwarding device sends the packet header to the pipeline processor; the pipeline processor forwards the packet header, and during the forwarding process of the packet header belonging to the first order, the pipeline processor counts the number of packets belonging to the first order; the pipeline processor generates the first flow table entry when it determines that the number of first-order packets reaches a preset number.

[0025] The technical solution provided in this application generates a first flow table entry when the number of first-order messages in the data channel reaches a preset number. This avoids generating flow table entries for data streams with small traffic volumes and helps reduce the size of the flow table.

[0026] Secondly, a message forwarding method is provided, applied to a message forwarding device in an NP chip. The NP chip includes a pipeline processor and a data channel, with the message forwarding device located in the data channel. The method includes: the message forwarding device acquiring flow characteristic information of a first message received by the data channel; and the message forwarding device performing flow forwarding on the first message based on the flow characteristic information of the first message.

[0027] Optionally, the message forwarding device performs flow forwarding on the first message based on the flow characteristic information of the first message, including: the message forwarding device determines a first flow forwarding table entry in the flow forwarding table based on the flow characteristic information of the first message; the message forwarding device performs flow forwarding on the first message based on the first flow forwarding table entry.

[0028] Optionally, the message forwarding device performs flow forwarding on the first message according to the first flow table entry, including: the message forwarding device obtains first control information according to the first flow table entry; the message forwarding device performs flow forwarding on the first message according to the first control information.

[0029] Optionally, the first flow table entry includes a mapping relationship between the flow characteristic information of the first message and the index information of the first control information; the message forwarding device obtains the first control information according to the first flow table entry, including: the message forwarding device determines the index information of the first control information according to the first flow table entry; the message forwarding device obtains the first control information according to the index information of the first control information.

[0030] Optionally, the packet forwarding device includes a flow table matching module, a flow table data acquisition module, and a packet processing module; the packet forwarding device acquires the flow characteristic information of the first packet received by the data channel, including: the flow table matching module acquiring the flow characteristic information of the first packet;

[0031] The message forwarding device determines the first flow forwarding table entry in the flow forwarding table based on the flow characteristic information of the first message, including: the flow table matching module determines the first flow forwarding table entry in the flow forwarding table based on the flow characteristic information of the first message;

[0032] The message forwarding device determines the index information of the first control information based on the first flow table entry, including: the flow table matching module determines the index information of the first control information based on the first flow table entry;

[0033] The message forwarding device obtains the first control information based on the index information of the first control information, including: the flow table data acquisition module obtains the first control information based on the index information of the first control information;

[0034] The message forwarding device performs flow forwarding of the first message according to the first control information, including: the message processing module performs flow forwarding of the first message according to the first control information.

[0035] Optionally, the flow table matching module obtains the flow feature information of the first packet, including: the flow table matching module obtains the flow feature information carried in at least one packet header of the first packet; the flow table matching module obtains the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header.

[0036] Optionally, the flow table matching module includes at least one flow feature extraction unit, and the at least one flow feature extraction unit corresponds to the at least one packet header one by one; the flow table matching module obtains the flow feature information carried by at least one packet header of the first packet, including: each flow feature extraction unit in the at least one flow feature extraction unit extracts the flow feature information from the corresponding packet header.

[0037] Optionally, the at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in series, the at least one packet header is N packet headers, and N is an integer greater than 1; the flow table matching module obtains the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header, including: the i-th flow feature extraction unit among the N flow feature extraction units splices the flow feature information extracted by the i-th flow feature extraction unit from the corresponding packet header and the flow feature information output by the (i - 1)-th flow feature extraction unit, and outputs the spliced flow feature information, where 1 < i ≤ N and i is an integer; among them, the flow feature information of the first packet is the flow feature information output by the N-th flow feature extraction unit.

[0038] Optionally, the at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in parallel, the at least one packet header is N packet headers, and N is an integer greater than 1; the flow table matching module further includes a splicing unit, and the flow table matching module obtains the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header, including: the splicing unit splices the flow feature information extracted by the N flow feature extraction units from the N packet headers to obtain the flow feature information of the first packet.

[0039] Optionally, the flow table matching module includes a lookup unit; the flow table matching module determines the first flow table entry in the flow transfer table according to the flow feature information of the first packet, including: the lookup unit determines the first flow table entry in the flow transfer table according to the flow feature information of the first packet.

[0040] Optionally, the first packet belongs to the first flow, the first flow table entry is a flow table entry for forwarding the first flow, and the first flow table entry is generated by the pipeline processor; the method further includes: the packet forwarding device receives the first flow table entry sent by the pipeline processor.

[0041] Optionally, the first flow is an elephant flow.

[0042] Optionally, the first flow table entry is generated by the pipeline processor according to the packet header of the second packet received by the data channel, the second packet belongs to the first flow, and the method further includes: the packet forwarding device obtains the flow feature information of the second packet received by the data channel; the packet forwarding device determines that the flow feature information of the second packet does not match the flow transfer table, and sends the packet header of the second packet to the pipeline processor.

[0043] Optionally, the first stream table entry is generated by the pipeline processor when it determines that the number of first-order messages among the messages received by the data channel reaches a preset number.

[0044] Thirdly, an NP chip is provided, including a pipelined processor and a data channel, the data channel including message forwarding means as provided in the first aspect or any alternative to the first aspect. The NP chip may include programmable logic circuitry and / or program instructions.

[0045] Fourthly, a network device is provided, including the NP chip as provided in the third aspect.

[0046] The network equipment can be a switch, router, firewall, base station, or wireless local area network (WLAN) device. The base station can include 5G base stations, 6G base stations, etc.

[0047] This network device is a high-bandwidth network device.

[0048] Fifthly, a computer-readable storage medium is provided that stores a computer program, which, when executed, implements at least some steps of the method provided as described in the second aspect or any alternative method of the second aspect.

[0049] In a sixth aspect, a computer program product is provided, comprising a program or code that, when executed, implements at least some steps of the method provided as described in the second aspect or any alternative method of the second aspect.

[0050] The technical effects of the second to sixth aspects mentioned above can be referred to the technical effects of the first aspect and its optional implementation methods, and will not be elaborated here. Attached Figure Description

[0051] Figure 1 is a schematic diagram of an NP chip provided in an embodiment of this application;

[0052] Figure 2 is a schematic diagram of a link layer packet header provided in an embodiment of this application;

[0053] Figure 3 is a schematic diagram of an IPv4 header provided in an embodiment of this application;

[0054] Figure 4 is a schematic diagram of a TCP header provided in an embodiment of this application;

[0055] Figure 5 is a schematic diagram of another NP chip provided in an embodiment of this application;

[0056] Figure 6 is a schematic diagram of a flow table matching module provided in an embodiment of this application;

[0057] Figure 7 is a schematic diagram of another flow table matching module provided in an embodiment of this application;

[0058] Figure 8 is a flowchart of a message forwarding method provided in an embodiment of this application;

[0059] Figure 9 is a schematic diagram of a network device provided in an embodiment of this application. Detailed Implementation

[0060] The embodiments of this application will now be described in further detail with reference to the accompanying drawings.

[0061] A network processor (NP) chip is a chip in a network device used to forward packets. Typically, NP chips can use programmable forwarding logic, hardened forwarding logic, or a combination of both for packet forwarding. This forwarding logic usually only processes the packet header. For example, network devices include switches or routers. In switches, the forwarding logic in the NP chip only processes the link-layer header. In routers, the forwarding logic in the NP chip only processes the Internet Protocol (IP) header.

[0062] For example, the NP chip includes a pipeline processor (PP) and a data path (DP), with the pipeline processor communicatively connected to the data path. The pipeline processor processes the headers of network packets received by the data path to obtain processed headers. The data path buffers the network packets received by the data path, obtains processed network packets based on the processed headers of the network packets and the buffered network packets, and then sends the processed network packets.

[0063] However, during the forwarding of network packet headers, the pipelined processor needs to perform a complete pipelined processing flow on the packet header, resulting in high power consumption for the pipelined processor and consequently, high power consumption for the NP chip. Specifically, the pipelined processor includes a packet processing pipeline comprising multiple processing nodes (e.g., match-action (MA) nodes), each node performing one operation from the pipelined processing flow on the packet header. During the forwarding process, the packet header must pass through these multiple processing nodes sequentially (even if no specific operation is required on the packet header, it still needs to pass through that node), leading to high power consumption for the pipelined processor.

[0064] Furthermore, before forwarding the header of a network packet, each processing node in the packet processing pipeline needs to read the data required for forwarding that header into the memory of that pipeline processor. Since the data required for forwarding different headers by the same processing node is usually different, this necessitates continuous memory flipping (i.e., the data in the pipeline processor's memory needs to change constantly). Memory flipping also consumes power, resulting in relatively high power consumption for the pipeline processor.

[0065] Furthermore, NP chips typically include multiple packet processing engines (e.g., 2, 3, or 6). Each packet processing engine includes a pipeline processor and a data channel. The pipeline processor in each packet processing engine is used to forward the headers of network packets received by the data channel of that engine. The high power consumption of the pipeline processor leads to the high power consumption of the packet processing engine, which in turn leads to the high power consumption of the NP chip. For example, the power consumption of a single packet processing engine can typically reach the 100W level, and the power consumption of the corresponding forwarding table entry can reach 50W. When an NP chip includes multiple packet processing engines, its power consumption will be even higher.

[0066] In a current packet forwarding scheme, the pipelined processor uses a full-service forwarding method to process the packet headers of network packets. Specifically, the pipelined processor forwards the packet headers by looking up a series of service forwarding tables, such as the IP forwarding table and the media access control (MAC) forwarding table. Because the pipelined processor needs to look up a series of service forwarding tables during the packet header forwarding process, this packet forwarding method is called a full-service forwarding method. However, in this packet forwarding scheme, on the one hand, the pipelined processor itself consumes a lot of power in processing the packet headers (the pipelined processor needs to perform a complete pipelined processing flow on the packet headers during the forwarding process); on the other hand, the pipelined processor needs to look up a series of service forwarding tables during the forwarding process, and the power consumption of looking up these service forwarding tables is also high. As a result, the overall power consumption of the pipelined processor is high, and the power consumption of the NP chip is also high.

[0067] In another current packet forwarding scheme, the pipeline processor uses flow table forwarding and full-service forwarding methods to forward the packet headers of network packets. Specifically, the pipeline processor includes a flow table and a series of service forwarding tables. The flow table includes at least one flow table entry, and each flow table entry includes a mapping relationship between flow feature information and at least one forwarding operation information. Each forwarding operation information in the at least one forwarding operation information is used to indicate a forwarding operation to be performed on the packet header with the corresponding flow feature information. For any network packet received by any data channel: the pipeline processor corresponding to the data channel first looks up the flow table based on the flow feature information of the network packet; if the flow feature information of the network packet hits a flow table entry in the flow table, the pipeline processor forwards the packet header according to the flow table entry hit by the flow feature information of the network packet; if the flow feature information of the network packet does not hit a flow table entry in the flow table, the pipeline processor forwards the packet header by looking up the series of service forwarding tables. As can be seen, when the flow characteristic information of a network packet matches a flow table entry, the pipelined processor only needs to forward the packet header according to that entry, without needing to use full-service forwarding. Therefore, the pipelined processor has high performance in forwarding packet headers. However, in this packet forwarding scheme, the pipelined processor still processes the packet header, resulting in relatively high power consumption for both the pipelined processor and the NP chip. Furthermore, the flow table needs to cover various data streams, leading to a large flow table size.

[0068] This application provides a packet forwarding method and apparatus, an NP chip, and a network device. The packet forwarding apparatus is applied to an NP chip, which includes a pipeline processor and a data channel, with the packet forwarding apparatus located within the data channel. After acquiring the flow characteristic information of a first packet received by the data channel, the packet forwarding apparatus performs flow forwarding on the first packet based on the flow characteristic information. Therefore, this application provides a packet forwarding apparatus within the data channel, which performs flow forwarding of packets. Compared to packet forwarding by a pipeline processor, the power consumption of this packet forwarding apparatus is lower (it does not require executing a complete pipeline processing flow), thus helping to reduce the power consumption of the NP chip.

[0069] The message forwarding device provided in this application is applied to an NP chip. The message forwarding device of this application will be described below in conjunction with an NP chip.

[0070] Please refer to Figure 1, which shows a schematic diagram of an NP chip 10 provided in an embodiment of this application. As shown in Figure 1, a packet forwarding device 120 is applied to the NP chip 10. The NP chip 10 includes a pipeline processor 11 and a data channel 12. The pipeline processor 11 is communicatively connected to the data channel 12, and the packet forwarding device 120 is located in the data channel 12. For example, the NP chip 10 includes multiple packet processing engines (not shown in Figure 1), each packet processing engine including a pipeline processor and a data channel. In each packet processing engine, the pipeline processor and the data channel are communicatively connected. The pipeline processor 11 and the data channel 12 are in the same packet processing engine of the NP chip 10. In an optional embodiment, in at least one packet processing engine of the NP chip 10, the data channel includes the packet forwarding device 120 as provided in the embodiment of this application.

[0071] In this embodiment, the message forwarding device 120 is configured to: acquire flow characteristic information of a first message received by the data channel 12; and perform flow forwarding on the first message based on the flow characteristic information of the first message. The first message is any message received by the data channel 12. The flow characteristic information of the first message is the characteristic information of the data stream to which the first message belongs, and is used to characterize the data stream to which the first message is sent. For example, if the first message belongs to a first stream, the flow characteristic information of the first message is the characteristic information of the first stream, and is used to characterize the first stream. In some embodiments, the flow characteristic information is also called flow attribute information or flow information, and this embodiment does not limit this usage.

[0072] In an optional embodiment, the first message carries flow characteristic information, and the flow characteristic information of the first message is determined based on the flow characteristic information carried in the first message. For example, the first message includes at least one message header, each message header carrying flow characteristic information, and the message forwarding device 120 is configured to: obtain the flow characteristic information carried in the at least one message header, and obtain the flow characteristic information of the first message based on the flow characteristic information obtained from the at least one message header. In one embodiment, the at least one message header is a single message header, and the message forwarding device 120 determines the flow characteristic information of the first message from the flow characteristic information obtained from the single message header. In another embodiment, the at least one message header is multiple message headers, and the message forwarding device 120 concatenates the flow characteristic information obtained from the multiple message headers to obtain the flow characteristic information of the first message.

[0073] In an optional embodiment, the packet forwarding device 120 includes at least one flow feature template, which corresponds one-to-one with the at least one packet header. Each flow feature template is designed according to the characteristics of the corresponding packet header and is used to obtain flow feature information from the corresponding packet header. The packet forwarding device 120 is used to obtain the flow feature information carried by each packet header according to the flow feature template corresponding to each packet header in the at least one packet header. For example, the packet forwarding device 120 extracts flow feature information from each packet header according to the flow feature template corresponding to each packet header in the at least one packet header.

[0074] In this embodiment, the at least one message header includes various possible protocol layer headers, such as a link layer header, an IP layer header, and a transport layer header. The link layer header is also called the Ethernet header. The IP layer header is also called the network layer header, and it may include an Internet Protocol version 4 (IPv4) header, an Internet Protocol version 6 (IPv6) header, or a Multiprotocol Label Switching (MPLS) header. The transport layer header may include a Transmission Control Protocol (TCP) header or a User Datagram Protocol (UDP) header.

[0075] In one example, refer to Figure 2, which illustrates a schematic of a link-layer header. This link-layer header includes: a destination media access control (DMAC) field, a source media access control (SMAC) field, two virtual local area network (VLAN) tag fields, and three type fields. The DMAC field carries the DMAC address. The SMAC field carries the SMAC address. The two VLAN tag fields include VLAN tag field 1 (i.e., VLAN tag 1 in Figure 2) and VLAN tag field 2 (i.e., VLAN tag 2 in Figure 2), each of which carries one layer of VLAN tagging. The three type fields include type field 1 (i.e., type 1 in Figure 2), type field 2 (i.e., type 2 in Figure 2), and type field 3 (i.e., type 3 in Figure 2). Type field 1 is used to indicate VLAN tag field 1 (type field 1 is used to indicate that the field following type field 1 is a VLAN tag field), and type field 2 is used to indicate VLAN tag field 2 (type field 2 is used to indicate that the field following type field 2 is a VLAN tag field).

[0076] For the link-layer header shown in Figure 2, the DMAC address, SMAC address, VLAN tag 1, and VLAN tag 2 can all be used to characterize the data flow. These are all flow characteristic information. For ease of description, the flow characteristic template corresponding to the link-layer header is called the link-layer flow characteristic template. The link-layer flow characteristic template can include at least one of the following fields: DMAC address field, SMAC address field, VLAN tag field 1, and VLAN tag field 2. For example, a link-layer flow characteristic template can be designed according to two layers of VLAN tags, including VLAN tag field 1 and VLAN tag field 2. For link-layer headers that only include one layer of VLAN tags or do not include VLAN tags, when obtaining flow characteristic information from these link-layer headers according to this link-layer flow characteristic template (i.e., a link-layer flow characteristic template including two layers of VLAN tags), the values ​​of VLAN tag fields that are not present in these link-layer headers can be set to default values ​​(e.g., 0). Finally, the flow characteristic information obtained from these link-layer headers can be processed into a structure including two layers of VLAN tags. In a specific example, the link-layer flow feature template includes a DMAC field, an SMAC field, two VLAN tag fields, and three type fields. The structure of this link-layer flow feature template is the same as that in Figure 2. For a link-layer packet header that includes only one layer of VLAN tags (e.g., VLAN tag 1), during the process of the packet forwarding device 120 obtaining flow feature information from the link-layer packet header according to the link-layer flow feature template, the packet forwarding device 120 obtains the DMAC address, SMAC address, and VLAN tag 1 carried in the link-layer packet header. Furthermore, the packet forwarding device 120 sets the flow feature information obtained from the link-layer packet header to include the VLAN tag field 2, and sets the value of the VLAN tag field 2 to a default value. Thus, the flow feature information obtained by the packet forwarding device 120 from the link-layer packet header is a structure including two layers of VLAN tags. For a link-layer header that does not include VLAN tags, during the process of obtaining flow feature information from the link-layer header according to the link-layer flow feature template, the packet forwarding device 120 obtains the DMAC address and SMAC address carried in the link-layer header. Furthermore, the packet forwarding device 120 sets the flow feature information obtained from the link-layer header to include VLAN tag field 1 and VLAN tag field 2. The packet forwarding device 120 sets the values ​​of VLAN tag field 1 and VLAN tag field 2 to default values. Thus, the flow feature information obtained by the packet forwarding device 120 from the link-layer header is a structure including two layers of VLAN tags.

[0077] In one example, please refer to Figure 3, which shows a schematic diagram of an IPv4 header. This IPv4 header includes: a version field, a head length field, a type of service (TOS) field, a total length field, an identification (ID) field, a flags field, a fragment offset field, a time to live (TTL) field, a protocol field, a header checksum field, a source IP address field, and a destination IP address field. The version field carries version information. The head length field carries the length of the IPv4 header. The TOS field carries the TOS. The total length field carries the total length of the IP packet including this IPv4 header. The identification field carries the identifier of the IP packet including this IPv4 header. The fragment offset field carries the fragment offset. The TTL field carries the TTL. The protocol field carries the protocol. The header checksum field carries the checksum of this IPv4 header. The source IP address field carries the source IP address. The destination IP address field carries the destination IP address.

[0078] For the IPv4 header shown in Figure 3, version, header length, TOS, protocol, source IP address, and destination IP address can all be used to characterize a data flow. Version, header length, TOS, protocol, source IP address, and destination IP address are all flow characteristic information. For ease of description, the flow characteristic template corresponding to the IPv4 header is called the IPv4 flow characteristic template. The IPv4 flow characteristic template may include at least one of the following fields: version field, header length field, TOS field, protocol field, source IP address field, or destination IP address field. In one embodiment, the IPv4 flow characteristic template includes a version field, header length field, TOS field, protocol field, source IP address field, and destination IP address field. During the process of the packet forwarding device 120 obtaining flow characteristic information from the IPv4 header according to the IPv4 flow characteristic template, the packet forwarding device 120 obtains the version, header length, TOS, protocol, source IP address, and destination IP address from the IPv4 header. In another embodiment, the IPv4 flow feature template includes a version field, a header length field, a TOS field, a total length field, an identifier field, a flag field, a fragment offset field, a TTL field, a protocol field, a header checksum field, a source IP address field, and a destination IP address field. The structure of this IPv4 flow feature template is the same as that in Figure 3. During the process of the packet forwarding device 120 obtaining flow feature information from the IPv4 header according to this IPv4 flow feature template, the packet forwarding device 120 obtains the version, header length, TOS, protocol, source IP address, and destination IP address from the IPv4 header. Furthermore, the packet forwarding device 120 sets the values ​​of the total length field, the identifier field, the flag field, the fragment offset field, the TTL field, and the header checksum field to default values. For example, the values ​​of the total length field, the identifier field, the flag field, the fragment offset field, the TTL field, and the header checksum field are all masked as 0.

[0079] In one example, refer to Figure 4, which illustrates a schematic of a TCP header. This TCP header includes: a source port number field, a destination port number field, a request sequence number field, an acknowledgment sequence number field, a header length field, a reserved field, an urgent (URG) flag, an acknowledgment (ACK) flag, a push (PSH) flag, a reset (RST) flag, a synchronized (SYN) flag, a finish (FIN) flag, a window size field, a checksum field, and an urgent pointer field. The source port number field carries the source port number. The destination port number field carries the destination port number. The request sequence number field carries the request sequence number. The acknowledgment sequence number field carries the acknowledgment sequence number. The header length field carries the header length. The URG flag carries the URG flag. The ACK flag carries the ACK flag. The PSH flag carries the PSH flag. The RST flag carries the RST flag. The SYN flag carries the SYN flag. The FIN flag field carries the FIN flag. The window size field carries the window size. The checksum field carries the checksum. The urgent pointer field carries the urgent pointer.

[0080] For the TCP header shown in Figure 4, both the source port number and the destination port number can be used to characterize the data flow; both are flow characteristic information. For ease of description, the flow characteristic template corresponding to the TCP header is called the TCP flow characteristic template. The TCP flow characteristic template may include at least one of the following fields: a source port number field or a destination port number field. In one embodiment, the TCP flow characteristic template includes a source port number field and a destination port number field. During the process of the packet forwarding device 120 obtaining flow characteristic information from the TCP header according to the TCP flow characteristic template, the packet forwarding device 120 obtains the source port number and the destination port number from the TCP header. In another embodiment, the TCP flow feature template includes a source port number field, a destination port number field, a request sequence number field, an acknowledgment sequence number field, a header length field, a reserved field, a URG flag, an ACK flag, a PSH flag, an RST flag, a SYN flag, a FIN flag, a window size field, a checksum field, and an urgent pointer field. The structure of this TCP flow feature template is the same as that in Figure 4. During the process of the packet forwarding device 120 obtaining flow feature information from the TCP header according to the TCP flow feature template, the packet forwarding device 120 obtains the source port number and the destination port number from the TCP header. Furthermore, the packet forwarding device 120 sets the values ​​of the request sequence number field, the acknowledgment sequence number field, the header length field, the reserved field, the URG flag, the ACK flag, the PSH flag, the RST flag, the SYN flag, the FIN flag, the window size field, the checksum field, and the urgent pointer field to their default values. For example, the message forwarding device 120 masks the values ​​of the request sequence number field, the acknowledgment sequence number field, the header length field, the reserved field, the URG flag, the ACK flag, the PSH flag, the RST flag, the SYN flag, the FIN flag, the window size field, the checksum field, and the urgent pointer field to 0. It should be noted that this example uses the source and destination port numbers carried in the TCP header as flow characteristic information. Depending on the service characteristics, at least one of the URG, ACK, PSH, RST, SYN, or FIN flags can also be used as flow characteristic information; this embodiment does not limit this.

[0081] After obtaining the flow characteristic information of the first packet, the packet forwarding device 120 performs flow forwarding on the first packet based on the flow characteristic information. In a specific embodiment, the packet forwarding device 120 is configured to: determine a first flow forwarding table entry based on the flow characteristic information of the first packet; and perform flow forwarding on the first packet based on the first flow forwarding table entry. The first flow forwarding table entry matches the flow characteristic information of the first packet. For example, the first flow forwarding table entry includes the flow characteristic information of the first packet, such that the first flow forwarding table entry matches the flow characteristic information of the first packet. In a specific embodiment, the packet forwarding device 120 is configured to: search the flow forwarding table based on the flow characteristic information of the first packet to determine the flow forwarding table entry (i.e., the first flow forwarding table entry) that matches the flow characteristic information of the first packet.

[0082] After determining the first flow table entry, the message forwarding device 120 performs flow forwarding on the first message according to the first flow table entry. In a specific embodiment, the message forwarding device 120 is used to: obtain first control information according to the first flow table entry; and perform flow forwarding on the first message according to the first control information. In one embodiment, the first flow table entry includes a mapping relationship between the flow characteristic information of the first message and the index information of the first control information. The message forwarding device 120 is used to: determine the index information of the first control information according to the first flow table entry; obtain the first control information according to the index information of the first control information; and perform flow forwarding on the first message according to the first control information. For example, the first control information is stored in the memory of the NP chip 10. The message forwarding device 120 obtains the first control information from the memory of the NP chip 10 according to the index information of the first control information, and then performs flow forwarding on the first message according to the first control information.

[0083] In this embodiment, the first control information includes at least one sub-control information, each sub-control information including forwarding operation information, and some sub-control information may also include editing data. Each forwarding operation information is used to indicate a forwarding operation, which may include an editing operation. For any sub-control information including forwarding operation information and editing data, the forwarding operation information in the sub-control information is used to indicate a forwarding operation, and the editing data in the sub-control information is used to indicate the operation content of the forwarding operation; for example, the sub-control information is used to indicate editing of the message according to the editing data. The message forwarding device 120 performs flow forwarding of the first message according to the at least one sub-control information. In a specific embodiment, for each sub-control information in the at least one sub-control information: the message forwarding device 120 performs a forwarding operation on the first message according to the forwarding operation information in the sub-control information; when the sub-control information also includes editing data, the operation content of the message forwarding device 120 performing the forwarding operation on the first message includes the editing data. That is, for any sub-control information including forwarding operation information and editing data, the message forwarding device 120 edits the first message according to the sub-control information.

[0084] In an optional embodiment, the first control information includes multiple sub-control information, which are arranged in sequence. The packet forwarding device 120 performs flow forwarding on the first packet according to the sorting order of the multiple sub-control information.

[0085] As an example, the first control information includes sub-control information 1 to M, arranged sequentially, where M is a positive integer. For example, the first control information is "sub-control information 1 / sub-control information 2 / sub-control information 3 / ... / sub-control information M". Sub-control information 1 includes forwarding operation information 11 and editing data 12, sub-control information 2 includes forwarding operation information 21 and editing data 22, sub-control information 3 includes forwarding operation information 31, and so on. Sub-control information M includes forwarding operation information M1 and editing data M2. This is illustrated by taking forwarding operation information 11 as an indication of forwarding operation 11, forwarding operation information 21 as an indication of forwarding operation 21, forwarding operation information 31 as an indication of forwarding operation 31, and so on, with forwarding operation information M1 indicating forwarding operation M1. The message forwarding device 120 performs flow forwarding on the first message according to the first control information, including: First, the message forwarding device 120 performs forwarding operation 11 on the first message according to forwarding operation information 11, the operation content of forwarding operation 11 including editing data 12; then, the message forwarding device 120 performs forwarding operation 21 on the first message according to forwarding operation information 21 and editing data 22, the operation content of forwarding operation 21 including editing data 22; then, the message forwarding device 120 performs forwarding operation 31 on the first message according to forwarding operation information 31; and so on; finally, the message forwarding device 120 performs forwarding operation M1 on the first message according to forwarding operation information M1 and editing data M2, the operation content of forwarding operation M1 including editing data M2.

[0086] In a specific example, M equals 4, sub-control information M is sub-control information 4, forwarding operation information M1 is forwarding operation information 41, and edit data M2 is edit data 42. Forwarding operation information 11 is deletion operation information, used to indicate a deletion operation. Edit data 12 is the length x1 to be deleted. Sub-control information 1, including forwarding operation information 11 and edit data 12, is used to indicate the deletion of content of length x1 from the message; for example, sub-control information 1 indicates the deletion of content of length x1 starting from the beginning of the message header. Forwarding operation information 21 is addition operation information, used to indicate an addition operation. Edit data 22 is the content to be added. Sub-control information 2, including forwarding operation information 21 and edit data 22, is used to indicate the addition of edit data 22 to the message; for example, sub-control information 2 indicates the addition of edit data 22 starting from the beginning of the message header. Forwarding operation information 31 is an IPv4 TTL-- enable flag, used to instruct the execution of IPv4 TTL-- on IPv4 packets with IPv4 TTL-- enabled. Forwarding operation information 41 is IPv4 TOS replacement operation information, used to instruct the IPv4 TOS replacement operation. Editing data 42 is the IPv4 TOS value to be replaced. Sub-control information 4, including forwarding operation information 41 and editing data 42, is used to instruct the replacement of the TOS value of the IPv4 packet with editing data 42. Taking an IPv4 packet as an example, the first packet includes an Ethernet header and an IPv4 header. First, according to sub-control information 1, the packet forwarding device 120 deletes content of length x1 from the first packet, starting from the beginning of the header. Then, according to sub-control information 2, the packet forwarding device 120 adds editing data 22 to the first packet, starting from the beginning of the header. Next, according to sub-control information 3, the packet forwarding device 120 checks whether IPv4 TTL-- is enabled in the first packet; if IPv4 TTL-- is enabled in the first packet, the packet forwarding device 120 performs IPv4 TTL-- on the first packet (that is, decrements the TTL in the IPv4 header of the first packet by 1); if IPv4 TTL-- is not enabled in the first packet, the packet forwarding device 120 does not perform IPv4 TTL-- on the first packet, and the packet forwarding device 120 skips sub-control information 3. Finally, according to sub-control information 4, the packet forwarding device 120 replaces the TOS value in the IPv4 header of the first packet with edit data 42 (that is, the IPv4 TOS value to be replaced).After performing IPv4 TTL-- on the first packet and replacing the TOS value in the IPv4 header of the first packet with edit data 42, the packet forwarding device 120 recalculates the checksum of the IPv4 header of the first packet and updates the header checksum in the IPv4 header with the recalculated checksum. As an example, both the content of length x1 and the edit data 12 are Ethernet headers. For example, the content of length x1 is called the first Ethernet header, and the edit data 12 is called the second Ethernet header. That is, the packet forwarding device 120 deletes the Ethernet header (i.e., the first Ethernet header) of the first packet according to the sub-control information 1, and then adds the second Ethernet header to the first packet.

[0087] For IPv4 TOS replacement operations, this application embodiment illustrates an example where the sub-control information includes IPv4 TOS replacement operation information and the IPv4 TOS value to be replaced. In some embodiments, the sub-control information only includes the IPv4 TOS value to be replaced. This IPv4 TOS value serves both as the content to be replaced and as an indication of the IPv4 TOS replacement operation. That is, for a replacement operation, the sub-control information may only include the parameter value to be replaced, and this parameter value is used to indicate the replacement operation. This application embodiment does not limit this approach.

[0088] In an optional embodiment, the first control information includes information about the output port of the first message (e.g., the port number of the output port). The message forwarding device 120 performs flow forwarding of the first message according to the first control information, and further includes: the message forwarding device 120 determines the output port of the first message according to the information about the output port of the first message, and the message forwarding device 120 sends the first message through the output port of the first message.

[0089] In an optional embodiment, please refer to Figure 5, which shows a schematic diagram of another NP chip 10 provided in this application embodiment. As shown in Figure 5, the packet forwarding device 120 includes a flow table matching module 121, a flow table data acquisition module 122, and a packet processing module 123. The flow table matching module 121, the flow table data acquisition module 122, and the packet processing module 123 are connected in sequence. The flow table matching module 121 is used to: acquire the flow characteristic information of a first packet; determine a first flow forwarding table entry based on the flow characteristic information of the first packet; and determine the index information of first control information based on the first flow forwarding table entry. The flow table data acquisition module 122 is used to acquire the first control information based on the index information of the first control information. The packet processing module 123 is used to: perform flow forwarding on the first packet based on the first control information. During the flow forwarding process of the first packet, the packet processing module 123 can edit the first packet; therefore, the packet processing module 123 can also be called an editor module.

[0090] In a specific embodiment, the first message includes at least one message header, each of which carries flow characteristic information. The flow table matching module 121 is used to: obtain the flow characteristic information carried by the at least one message header; obtain the flow characteristic information of the first message based on the flow characteristic information obtained from the at least one message header; and search the flow forwarding table according to the flow characteristic information of the first message to determine the first flow forwarding table entry. In one embodiment, the at least one message header is a single message header, and the flow table matching module 121 determines the flow characteristic information of the first message from the flow characteristic information obtained from the single message header. In another embodiment, the at least one message header is multiple message headers, and the flow table matching module 121 concatenates the flow characteristic information obtained from the multiple message headers to obtain the flow characteristic information of the first message.

[0091] In an optional embodiment, the flow table matching module 121 is used to extract flow feature information from each of the at least one packet header. For example, the flow table matching module 121 includes at least one flow feature extraction unit, which corresponds one-to-one with the at least one packet header, and each flow feature extraction unit is used to extract flow feature information from the corresponding packet header. In a specific embodiment, the at least one flow feature extraction unit corresponds one-to-one with the at least one flow feature template, and each flow feature extraction unit is used to extract flow feature information from the packet header corresponding to each flow feature extraction unit according to the flow feature template corresponding to each flow feature extraction unit. In one embodiment, the at least one flow feature extraction unit includes a flow feature extraction unit corresponding to a link layer packet header, a flow feature extraction unit corresponding to an IPv4 header, and a flow feature extraction unit corresponding to a TCP header. For ease of description, the flow feature extraction unit corresponding to the link layer packet header is referred to as a link layer flow feature extraction unit, the flow feature extraction unit corresponding to the IPv4 header is referred to as an IPv4 flow feature extraction unit, and the flow feature extraction unit corresponding to the TCP header is referred to as a TCP flow feature extraction unit. The aforementioned at least one flow feature template includes a link-layer flow feature template, an IPv4 flow feature template, and a TCP flow feature template. The link-layer flow feature extraction unit corresponds to the link-layer flow feature template, the IPv4 flow feature extraction unit corresponds to the IPv4 flow feature template, and the TCP flow feature extraction unit corresponds to the TCP flow feature template. Taking a first packet including a link-layer header, an IPv4 header, and a TCP header as an example, the link-layer flow feature extraction unit is used to extract flow feature information from the link-layer header of the first packet according to the link-layer flow feature template. The IPv4 flow feature extraction unit is used to extract flow feature information from the IPv4 header of the first packet according to the IPv4 flow feature template; the TCP flow feature extraction unit is used to extract flow feature information from the TCP header of the first packet according to the TCP flow feature template. The implementation process of any flow feature extraction unit extracting flow feature information from the corresponding packet header according to the corresponding flow feature template can be referred to the implementation process of the packet forwarding device 120 extracting flow feature information from the corresponding packet header according to the corresponding flow feature template mentioned above, and will not be repeated here.

[0092] In one embodiment, please refer to FIG. 6, which shows a schematic diagram of a flow table matching module 121 provided by an embodiment of the present application. The flow table matching module 12 includes N flow feature extraction units, and the N flow feature extraction units are connected in series (that is, the N flow feature extraction units are connected in sequence), where N is an integer greater than 1. FIG. 6 illustrates the example where the N flow feature extraction units are flow feature extraction units 1 to N. The first packet includes N packet headers, and the N packet headers correspond to the N flow feature extraction units one by one. Each of the N flow feature extraction units is used to extract flow feature information from the packet header corresponding to each flow feature extraction unit; the i-th flow feature extraction unit among the N flow feature extraction units is further used to: splice the flow feature information extracted by the i-th flow feature extraction unit from the packet header corresponding to the i-th flow feature extraction unit and the flow feature information output by the (i - 1)-th flow feature extraction unit, and output the spliced flow feature information, where 1 < i ≤ N and i is an integer. Among them, the flow feature information of the first packet is the flow feature information output by the N-th flow feature extraction unit.

[0093] In a specific embodiment, as shown in Figure 6, the first flow feature extraction unit (e.g., flow feature extraction unit 1 in Figure 6) among the N flow feature extraction units is used to: extract flow feature information from the packet header corresponding to the first flow feature extraction unit, and output the extracted flow feature information to the second flow feature extraction unit (e.g., flow feature extraction unit 2 in Figure 6) among the N flow feature extraction units. The second flow feature extraction unit is used to: extract flow feature information from the packet header corresponding to the second flow feature extraction unit, concatenate the flow feature information output by the first flow feature extraction unit to the second flow feature extraction unit and the flow feature information extracted by the second flow feature extraction unit from the packet header corresponding to the second flow feature extraction unit, and output the concatenated flow feature information to the third flow feature extraction unit (e.g., flow feature extraction unit 3 in Figure 6) among the N flow feature extraction units. The third flow feature extraction unit is used to: extract flow feature information from the packet header corresponding to the third flow feature extraction unit; concatenate the flow feature information output by the second flow feature extraction unit to the third flow feature extraction unit and the flow feature information extracted by the third flow feature extraction unit from the packet header corresponding to the third flow feature extraction unit; and output the concatenated flow feature information to the fourth flow feature extraction unit among the N flow feature extraction units. This process continues until the Nth flow feature extraction unit (e.g., flow feature extraction unit N in Figure 6) outputs the concatenated flow feature information. In other words, the first flow feature extraction unit among the N flow feature extraction units is used to: extract flow feature information from the packet header corresponding to the first flow feature extraction unit and output the extracted flow feature information to the second flow feature extraction unit among the N flow feature extraction units. Each flow feature extraction unit other than the first flow feature extraction unit is used to: extract flow feature information from the packet header corresponding to each flow feature extraction unit, concatenate the flow feature information output by the previous flow feature extraction unit and the flow feature information extracted by each flow feature extraction unit from the corresponding packet header, and output the concatenated flow feature information.

[0094] In another embodiment, please refer to Figure 7, which shows a schematic diagram of another flow table matching module 121 provided in this application embodiment. The flow table matching module 12 includes a splicing unit 1211 and N flow feature extraction units. The N flow feature extraction units are connected in parallel and are respectively connected to the splicing unit 1211, where N is an integer greater than 1. Figure 7 illustrates this using the example of flow feature extraction units 1 to N. The first message includes N message headers, which correspond one-to-one with the N flow feature extraction units. Each of the N flow feature extraction units is used to: extract flow feature information from the message header corresponding to each flow feature extraction unit and output the flow feature information to the splicing unit 1211. The splicing unit 1211 is used to: splice the flow feature information extracted from the N message headers by the N flow feature extraction units to obtain the flow feature information of the first message.

[0095] It should be noted that the splicing rules of the flow feature extraction unit for splicing flow feature information, and the splicing rules of the splicing unit 1211 for splicing flow feature information, can be flexibly defined according to the actual situation. This application embodiment does not limit the splicing rules.

[0096] In an optional embodiment, the flow table matching module 121 further includes a parsing unit (not shown in Figures 6 and 7), which is connected to the aforementioned N flow feature extraction units. The parsing unit is used to parse the first packet to determine the aforementioned N packet headers of the first packet. Each of the N flow feature extraction units extracts flow feature information from the corresponding packet header parsed by the parsing unit.

[0097] After obtaining the flow characteristic information of the first packet, the flow table matching module 121 determines the first flow forwarding table entry in the flow forwarding table based on the flow characteristic information of the first packet. In a specific embodiment, as shown in FIG6 or FIG7, the flow table matching module 121 includes a lookup unit 1212, which is used to: determine the first flow forwarding table entry in the flow forwarding table based on the flow characteristic information of the first packet. For example, the lookup unit 1212 is used to search the flow forwarding table based on the flow characteristic information of the first packet to determine the first flow forwarding table entry in the flow forwarding table.

[0098] In this embodiment, the maintenance of the flow table (e.g., adding, deleting, and updating flow table entries) can be performed by the pipeline processor 11. The data channel 12 can provide an interface to the pipeline processor 11 for maintaining the flow table, so that the pipeline processor 11 can maintain the flow table. In an optional embodiment, the first message belongs to the first flow, and the first flow table entry is a forwarding entry used to forward the first flow. The first flow table entry is generated by the pipeline processor 11. After generating the first flow table entry, the pipeline processor 11 sends the first flow table entry to the message forwarding device 120. The message forwarding device 120 is also used to receive the first flow table entry sent by the pipeline processor 11. After receiving the first flow table entry, the message forwarding device 120 stores the first flow table entry. For example, the message forwarding device 120 stores the first flow table entry in the memory of the NP chip 10. In an optional embodiment, the first flow table entry includes a mapping relationship between the flow characteristic information of the first message and the index information of the first control information. During the process of generating the first flow table entry, the pipeline processor 11 also generates the first control information and sends the first control information to the message forwarding device 120. The message forwarding device 120 is also used to receive the first control information sent by the pipeline processor 11. After receiving the first control information, the message forwarding device 120 stores the first control information. For example, the message forwarding device 120 stores the first control information in the memory of the NP chip 10.

[0099] In an optional embodiment, the first flow table entry is generated by the pipeline processor 11 based on the header of the second message received by the data channel 12, and the second message belongs to the first flow. The message forwarding device 120 is further configured to: obtain the flow characteristic information of the second message received by the data channel 12; determine that the flow characteristic information of the second message does not match the flow table, and send the header of the second message to the pipeline processor 11.

[0100] In a specific embodiment, after data channel 12 receives the second message, message forwarding device 120 obtains the flow characteristic information of the second message; message forwarding device 120 searches the flow table based on the flow characteristic information of the second message, and determines that there is no flow table entry matching the flow characteristic information of the second message, thereby determining that the flow characteristic information of the second message does not match the flow table; message forwarding device 120 sends the message header of the second message to pipeline processor 11. After receiving the message header of the second message, pipeline processor 11 generates a first flow table entry based on the message header of the second message, and sends the first flow table entry to message forwarding device 120. Message forwarding device 120 receives the first flow table entry and stores the first flow table entry. For example, the pipeline processor 11 generates a first flow table entry and first control information based on the header of the second message. The first flow table entry includes a mapping relationship between the flow characteristic information of the second message (both the second message and the first message belong to the first flow, and the flow characteristic information of the second message is the same as that of the first message) and the index information of the first control information. The pipeline processor 11 sends the first flow table entry and the first control information to the message forwarding device 120. The message forwarding device 120 receives the first flow table entry and the first control information, and stores the first flow table entry and the first control information.

[0101] In a specific embodiment, as shown in FIG5, the packet forwarding device 120 includes a flow table matching module 121 and a flow table data acquisition module 122, which are respectively connected to the pipeline processor 11. After the data channel 12 receives the second packet, the flow table matching module 121 acquires the flow feature information of the second packet; the flow table matching module 121 searches the flow table according to the flow feature information of the second packet, determines that there is no flow table entry matching the flow feature information of the second packet in the flow forwarding table, and thus determines that the flow feature information of the second packet does not match the flow table, and the flow table matching module 121 sends the packet header of the second packet to the pipeline processor 11. After the pipeline processor 11 generates the first flow table entry and the first control information, the pipeline processor 11 sends the first flow table entry to the flow table matching module 121 and sends the first control information to the flow table data acquisition module 122. Correspondingly, the flow table matching module 121 receives the first flow table entry sent by the pipeline processor 11 and stores the first flow table entry; the flow table data acquisition module 122 receives the first control information sent by the pipeline processor 11 and stores the first control information.

[0102] In a specific embodiment, after receiving the header of the second message, the pipeline processor 11 obtains the feature information carried in the header of the second message. Based on the feature information obtained from the header of the second message, the pipeline processor 11 performs full-service forwarding of the second message by looking up a series of service forwarding tables. Based on the feature information obtained from the header of the second message and the control information (including forwarding operation information, edit data, etc.) obtained by looking up the series of service forwarding tables using the feature information obtained from the header of the second message, the pipeline processor 11 generates a first forwarding table entry and first control information. For example, at least one header of the second message carries feature information including flow feature information; the pipeline processor 11 obtains the flow feature information of the second message based on the flow feature information obtained from the feature information obtained from the at least one header; the pipeline processor 11 obtains first control information based on control information obtained by searching the service forwarding table according to the feature information obtained from the at least one header; the pipeline processor 11 generates index information of the first control information; the pipeline processor 11 generates a first flow forwarding table entry based on the flow feature information of the second message and the index information of the first control information. In one embodiment, the at least one header is a single header, and the pipeline processor 11 determines the flow feature information of the second message from the feature information obtained from the single header as the flow feature information of the second message; the pipeline processor 11 determines the control information obtained by searching the service forwarding table according to the feature information obtained from the single header as the first control information. In another embodiment, the at least one message header is multiple message headers. The pipeline processor 11 concatenates the flow feature information obtained from the feature information obtained from the multiple message headers to obtain the flow feature information of the second message. The pipeline processor 11 concatenates the control information obtained by searching the service forwarding table based on the feature information obtained from the multiple message headers to obtain the first control information.

[0103] It should be noted that, as shown in Figure 5, the pipeline processor 11 is also connected to the message processing module 123. During the process of performing full-service forwarding of the second message by looking up a series of service forwarding tables, the pipeline processor 11 can obtain control information. The pipeline processor 11 can send control information to the message processing module 123. The message processing module 123 performs forwarding processing on the second message according to the control information sent by the pipeline processor 11. For example, the message processing module 123 edits the second message according to the control information sent by the pipeline processor 11, and then sends the second message through its output port.

[0104] In an optional embodiment, the first stream is an elephant stream. The first stream has a large flow rate. In this embodiment, the pipeline processor 11 generates flow table entries for the elephant stream, which avoids generating flow table entries for smaller data streams, thus helping to reduce the size of the flow table.

[0105] In an optional embodiment, the first flow table entry is generated by the pipeline processor 11 when it determines that the number of first-order packets among the packets received by the data channel 12 reaches a preset number. Specifically, for each packet belonging to the first order received by the data channel 12: the packet forwarding device 120 searches the flow table based on the packet's flow characteristic information; if the flow characteristic information of the packet does not match the flow table, the packet forwarding device 120 sends the packet header to the pipeline processor 11. The pipeline processor 11 forwards the packet header, and during this forwarding process, it counts the number of first-order packets. When the number of first-order packets reaches a preset number, the pipeline processor 11 generates the first flow table entry. The aforementioned first message can be a message belonging to the first-order category received by the data channel 12 when the pipeline processor 11 determines that the number of messages belonging to the first-order category has reached a preset number (or thereafter). In this embodiment, the pipeline processor 11 generates a first flow table entry when the number of messages belonging to the first-order category among the messages received by the data channel 12 reaches a preset number. This avoids generating flow table entries for data streams with small traffic volumes and helps to reduce the size of the flow table.

[0106] It should be noted that, in this embodiment, the flow table is a key-value table, where the key is flow characteristic information and the value is the index information of control information. The flow characteristic information in the flow table includes flow characteristic information carried by the packet, and may also include flow characteristic information of the packet determined by other means, such as the source port (i.e., the ingress port) of the packet. Control information may include various possible control information used for packet forwarding. This includes, but is not limited to, control information for modifying packets, control information for telemetry of the data stream, and control information for ensuring the quality of service (QoS) of the data stream. Control information for telemetry of the data stream includes, for example, control information for counting packets in the data stream and control information for copying packets in the data stream. Control information used to ensure the QoS of data streams includes control information for dropping packets of a data stream, control information for passing packets of a data stream, control information for delaying packets of a data stream, and control information for scheduling packets of a data stream.

[0107] In summary, the technical solution provided in this application embodiment sets up a message forwarding device in the data channel of the NP chip, and the message forwarding device performs flow forwarding of messages. Compared with the pipeline processor in the NP chip performing message forwarding processing, the power consumption of the message forwarding device performing flow forwarding of messages is smaller (no need to perform a complete pipeline processing flow), which helps to reduce the power consumption of the NP chip.

[0108] The above is a description of the device embodiments of this application. The method embodiments of this application are described below.

[0109] Please refer to Figure 8, which shows a flowchart of a message forwarding method provided in an embodiment of this application. This message forwarding method is applied to a message forwarding device in an NP chip, which includes a pipeline processor and a data channel, and the message forwarding device is located in the data channel. For example, the NP chip is shown in Figure 1 or Figure 5, and the message forwarding device is message forwarding device 120.

[0110] Referring to Figure 8, the message forwarding method includes the following steps S801 to S802.

[0111] S801. The message forwarding device acquires the flow characteristic information of the first message received by the data channel.

[0112] Here, the first message is any message received by the data channel. The flow characteristic information of the first message is the characteristic information of the data stream to which the first message belongs. The flow characteristic information of the first message is used to characterize the data stream to which the first message is sent. For example, if the first message belongs to the first stream, the flow characteristic information of the first message is the characteristic information of the first stream, and the flow characteristic information of the first message is used to characterize the first stream.

[0113] In optional embodiments, the first message carries flow characteristic information, and the flow characteristic information of the first message is determined based on the flow characteristic information carried in the first message. For example, the first message includes at least one message header, each of the at least one message header carrying flow characteristic information. The message forwarding device obtains the flow characteristic information carried in the at least one message header, and the message forwarding device obtains the flow characteristic information of the first message based on the flow characteristic information obtained from the at least one message header. In one embodiment, the at least one message header is a single message header, and the message forwarding device determines the flow characteristic information of the first message from the flow characteristic information obtained from the single message header. In another embodiment, the at least one message header is multiple message headers, and the message forwarding device concatenates the flow characteristic information obtained from the multiple message headers to obtain the flow characteristic information of the first message.

[0114] In an optional embodiment, the packet forwarding device includes at least one flow feature template, which corresponds one-to-one with the at least one packet header. The packet forwarding device obtains the flow feature information carried in each packet header based on the flow feature template corresponding to each packet header in the at least one packet header. For example, the packet forwarding device extracts flow feature information from each packet header based on the flow feature template corresponding to each packet header in the at least one packet header.

[0115] In an optional embodiment, the packet forwarding device includes a flow table matching module, which obtains flow feature information of a first packet. Specifically, in a specific embodiment, the first packet includes at least one packet header, and the flow table matching module obtains the flow feature information carried in the at least one packet header. The flow table matching module obtains the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header. For example, the flow table matching module includes at least one flow feature extraction unit, which corresponds one-to-one with the at least one packet header. Each of the at least one flow feature extraction units extracts flow feature information from the corresponding packet header. In a specific embodiment, each of the at least one flow feature extraction unit corresponds one-to-one with at least one flow feature template, and each of the at least one flow feature extraction units extracts flow feature information from the packet header corresponding to each flow feature extraction unit according to the flow feature template corresponding to each flow feature extraction unit.

[0116] In one embodiment, the at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in series, the at least one message header is N message headers, and N is an integer greater than 1. Each of the N flow feature extraction units extracts flow feature information from the corresponding message header. The i-th flow feature extraction unit among the N flow feature extraction units splices the flow feature information extracted by the i-th flow feature extraction unit from the message header corresponding to the i-th flow feature extraction unit and the flow feature information output by the (i - 1)-th flow feature extraction unit, and outputs the spliced flow feature information, where 1 < i ≤ N and i is an integer; among them, the flow feature information of the first message is the flow feature information output by the N-th flow feature extraction unit. In a specific embodiment, the first flow feature extraction unit among the N flow feature extraction units extracts flow feature information from the message header corresponding to the first flow feature extraction unit, and outputs the extracted flow feature information to the second flow feature extraction unit among the N flow feature extraction units. The second flow feature extraction unit extracts flow feature information from the message header corresponding to the second flow feature extraction unit, splices the flow feature information output by the first flow feature extraction unit to the second flow feature extraction unit and the flow feature information extracted by the second flow feature extraction unit from the message header corresponding to the second flow feature extraction unit, and outputs the spliced flow feature information to the third flow feature extraction unit among the N flow feature extraction units. The third flow feature extraction unit extracts flow feature information from the message header corresponding to the third flow feature extraction unit, splices the flow feature information output by the second flow feature extraction unit to the third flow feature extraction unit and the flow feature information extracted by the third flow feature extraction unit from the message header corresponding to the third flow feature extraction unit, and outputs the spliced flow feature information to the fourth flow feature extraction unit among the N flow feature extraction units. And so on, until the N-th flow feature extraction unit among the N flow feature extraction units outputs the spliced flow feature information.

[0117] In another embodiment, the at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in parallel, the at least one message header is N message headers, and N is an integer greater than 1. The flow table matching module further includes a splicing unit, and the N flow feature extraction units are respectively connected to the splicing unit. Each of the N flow feature extraction units extracts flow feature information from the corresponding message header, and outputs the flow feature information to the splicing unit. The splicing unit splices the flow feature information extracted by the N flow feature extraction units from the N message headers to obtain the flow feature information of the first message.

[0118] S802. The message forwarding device performs flow forwarding on the first message according to the flow feature information of the first message.

[0119] The message forwarding device determines a first flow forwarding table entry based on the flow characteristic information of the first message; the message forwarding device then performs flow forwarding on the first message based on the first flow forwarding table entry. Specifically, the first flow forwarding table entry matches the flow characteristic information of the first message. For example, the first flow forwarding table entry includes the flow characteristic information of the first message, ensuring a match between the first flow forwarding table entry and the flow characteristic information of the first message.

[0120] In an optional embodiment, the packet forwarding device obtains first control information based on a first flow forwarding table entry, and then performs flow forwarding on the first packet based on the first control information. In one embodiment, the first flow forwarding table entry includes a mapping relationship between flow characteristic information of the first packet and index information of the first control information. The packet forwarding device determines the index information of the first control information based on the first flow forwarding table entry, obtains the first control information based on the index information, and then performs flow forwarding on the first packet based on the first control information. For example, the first control information is stored in the memory of the NP chip. The packet forwarding device obtains the first control information from the memory of the NP chip based on the index information of the first control information, and then performs flow forwarding on the first packet based on the first control information.

[0121] In an optional embodiment, the packet forwarding device includes a flow table matching module, a flow table data acquisition module, and a packet processing module, which are connected sequentially. The flow table matching module acquires the flow characteristic information of a first packet. The flow table matching module determines a first flow forwarding entry in the flow forwarding table based on the flow characteristic information of the first packet. The flow table matching module determines the index information of first control information based on the first flow forwarding entry. The flow table data acquisition module acquires the first control information based on the index information of the first control information. The packet processing module performs flow forwarding on the first packet based on the first control information. In an optional embodiment, the flow table matching module includes a lookup unit; this lookup unit determines the first flow forwarding entry in the flow forwarding table based on the flow characteristic information of the first packet.

[0122] In an optional embodiment, the first message belongs to the first flow, and the first flow forwarding table entry is a forwarding table entry used for forwarding the first flow. This first flow forwarding table entry is generated by the pipeline processor. After generating the first flow forwarding table entry, the pipeline processor sends it to the message forwarding device. Correspondingly, the message forwarding device receives the first flow forwarding table entry sent by the pipeline processor. After receiving the first flow forwarding table entry, the message forwarding device stores it. Therefore, after a subsequent data channel receives the first message, the message forwarding device can determine the first flow forwarding table entry in the flow forwarding table based on the flow characteristic information of the first message.

[0123] In an optional embodiment, the first flow table entry is generated by the pipeline processor based on the header of the second message received by the data channel. The second message belongs to the first flow and precedes the first message. After the data channel receives the second message, the message forwarding device obtains the flow characteristic information of the second message. The message forwarding device searches the flow table based on the flow characteristic information of the second message. If it determines that the flow characteristic information of the second message does not match the flow table, the message forwarding device sends the header of the second message to the pipeline processor. After receiving the header of the second message, the pipeline processor generates the first flow table entry based on the header of the second message.

[0124] In an optional embodiment, the first stream is an "elephant stream." The first stream has a large flow rate. In this embodiment, the pipeline processor generates flow table entries for the elephant stream, which avoids generating flow table entries for smaller data streams, thus helping to reduce the size of the flow table.

[0125] In an optional embodiment, the first flow table entry is generated by the pipeline processor when it determines that the number of first-order packets among the packets received by the data channel reaches a preset number. Generating the first flow table entry when the number of first-order packets among the packets received by the data channel reaches the preset number helps reduce the size of the flow table.

[0126] For a detailed introduction to the message forwarding method, please refer to the aforementioned description of the message forwarding device embodiment; it will not be repeated here.

[0127] In summary, the technical solution provided in this application embodiment sets up a message forwarding device in the data channel of the NP chip, and the message forwarding device performs flow forwarding of messages. Compared with the pipeline processor in the NP chip performing message forwarding processing, the power consumption of the message forwarding device performing flow forwarding of messages is smaller (no need to perform a complete pipeline processing flow), which helps to reduce the power consumption of the NP chip.

[0128] Based on the same inventive concept, this application provides an NP chip, which includes a pipeline processor and a data channel. The data channel includes the packet forwarding device provided in the above embodiments. For example, the NP chip includes multiple packet processing engines, each packet processing engine including a pipeline processor and a data channel. The data channel in at least one packet processing engine includes the packet forwarding device provided in the above embodiments.

[0129] The NP chip may include programmable logic circuits and / or program instructions.

[0130] For example, the NP chip is shown in Figure 1 or Figure 5.

[0131] Based on the same inventive concept, embodiments of this application provide a network device including the aforementioned NP chip. This network device can be a switch, router, firewall, base station, or wireless local area network (WLAN) device. The base station can include 5G base stations, 6G base stations, etc. Furthermore, this network device is a high-bandwidth network device.

[0132] As an example, please refer to Figure 9, which shows a schematic diagram of a network device 900 provided in an embodiment of this application. The network device 900 includes a processor 902, a memory 904, an NP chip 906, a communication interface 908, and a bus 910. The processor 902, memory 904, NP chip 906, and communication interface 908 are communicatively connected via the bus 910. The connection method between the processor 902, memory 904, NP chip 906, and communication interface 908 shown in Figure 9 is only an example; the processor 902, memory 904, NP chip 906, and communication interface 908 can also be connected using connection methods other than the bus 910.

[0133] The memory 904 stores the computer program 9042, which may include instructions and data. The memory 904 can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), flash memory, optical storage, and registers.

[0134] The processor 902 can be a general-purpose processor, which performs specific steps and / or operations by reading and executing a computer program (e.g., computer program 9042) stored in memory (e.g., memory 904). The general-purpose processor may use data stored in memory (e.g., memory 904) during the execution of these steps and / or operations. The general-purpose processor can be a central processing unit (CPU). Alternatively, the processor 902 can be a special-purpose processor, which is specifically designed to perform specific steps and / or operations. A special-purpose processor can be a digital signal processor (DSP), an ASIC, or an FPGA, etc. The processor 902 can be a combination of multiple processors, such as a multi-core processor.

[0135] The NP chip 906, also known as a forwarding chip, network chip, or network forwarding chip, is primarily used for packet forwarding. In this embodiment, the NP chip 906 includes a pipeline processor and a data channel. This data channel includes the packet forwarding device provided in the above embodiments to perform flow forwarding of packets. The NP chip 906 can be the NP chip 10 described in the foregoing embodiments.

[0136] The communication interface 908 may include input / output (I / O) interfaces, physical interfaces, and logical interfaces for interconnecting devices within the network device 900, as well as interfaces for interconnecting the network device 900 with other devices. Physical interfaces may be POS interfaces, gigabit Ethernet (GE) interfaces, asynchronous transfer mode (ATM) interfaces, etc., used for interconnecting the network device 900 with other devices. Logical interfaces are internal interfaces of the network device 900, used for interconnecting devices within the network device 900. It is easy to understand that the communication interface 908 can be used for communication between the network device 900 and other devices; for example, the communication interface 908 is used for sending and receiving messages between the network device 900 and other devices.

[0137] Bus 910 can be of any type, used to interconnect processor 902, memory 904, NP chip 906, and communication interface 908. For example, bus 910 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Bus 910 can be categorized as an address bus, data bus, control bus, etc. For ease of representation, only one thick line is used in Figure 9, but this does not indicate that there is only one bus or one type of bus.

[0138] The aforementioned devices in network device 900 can be disposed on separate chips, or at least partially or entirely on the same chip. Whether to dispose of the devices independently on different chips or integrate them on one or more chips often depends on the product design requirements. This application does not limit the specific implementation of the aforementioned devices.

[0139] The network device 900 shown in Figure 9 is merely an example. In the implementation process, the network device 900 may also include other components, which will not be listed one by one in this article.

[0140] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium storing a computer program. When the computer program is executed (e.g., executed by a message forwarding device), it implements all or part of the steps of the message forwarding method provided in the method embodiment shown in FIG8.

[0141] Based on the same inventive concept, this application provides a computer program product, which includes a program or code. When the program or code is executed (e.g., executed by a message forwarding device), it implements all or part of the steps of the message forwarding method provided in the method embodiment shown in FIG8.

[0142] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented entirely or partially as a computer program product, which includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium, or a semiconductor medium (e.g., solid-state drive), etc.

[0143] It should be understood that the term "at least one" in this application refers to one or more, and "multiple" refers to two or more. The term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Furthermore, for clarity, this application uses terms such as "first," "second," and "third" to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first," "second," and "third" do not limit the quantity or order of execution.

[0144] The different types of embodiments, such as the method embodiments and device embodiments provided in this application, can be referenced to each other. The order of operations in the method embodiments can be adjusted appropriately, and the operations can be added or removed in response to the situation. Any variations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and therefore will not be described in detail.

[0145] In the corresponding embodiments provided in this application, it should be understood that the disclosed devices, etc., can be implemented through other configurations. For example, the device embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed between devices or modules may be through some interfaces, or indirect coupling or communication connection between devices or modules, which may be electrical or other forms. Modules described as separate components may or may not be physically separate, and components described as modules may or may not be physical modules; they may be located in one place or distributed across multiple network nodes. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0146] The above description is merely an exemplary embodiment of this application, but the scope of protection of this application is not limited thereto. Any equivalent modifications or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A message forwarding device, characterized in that, Applied to a network processor NP chip, the NP chip includes a pipeline processor and a data channel, and the packet forwarding device is in the data channel. The packet forwarding device is configured to: Obtain the flow feature information of the first packet received by the data channel; Perform flow forwarding on the first packet according to the flow feature information of the first packet.

2. The message forwarding device according to claim 1, characterized in that, The packet forwarding device is configured to: Determine the first flow forwarding entry in the flow forwarding table according to the flow feature information of the first packet; Perform flow forwarding on the first packet according to the first flow forwarding entry.

3. The message forwarding device according to claim 2, characterized in that, The packet forwarding device is configured to: Obtain the first control information according to the first flow forwarding entry; Perform flow forwarding on the first packet according to the first control information.

4. The message forwarding device according to claim 3, characterized in that, The first flow forwarding entry includes the mapping relationship between the flow feature information of the first packet and the index information of the first control information. The packet forwarding device is configured to: Determine the index information of the first control information according to the first flow forwarding entry; Obtain the first control information according to the index information of the first control information.

5. The message forwarding device according to claim 4, characterized in that, The packet forwarding device includes a flow table matching module, a flow table data acquisition module, and a packet processing module; The flow table matching module is configured to: obtain the flow feature information of the first packet; determine the first flow forwarding entry in the flow forwarding table according to the flow feature information of the first packet; determine the index information of the first control information according to the first flow forwarding entry; The flow table data acquisition module is configured to: obtain the first control information according to the index information of the first control information; The packet processing module is configured to: perform flow forwarding on the first packet according to the first control information.

6. The message forwarding device according to claim 5, characterized in that, The flow table matching module is configured to: Obtain the flow feature information carried by at least one packet header of the first packet; Obtain the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header.

7. The message forwarding device according to claim 6, characterized in that, The flow table matching module includes at least one flow feature extraction unit, and the at least one flow feature extraction unit corresponds to the at least one packet header one by one; Each flow feature extraction unit in the at least one flow feature extraction unit is configured to: extract flow feature information from the corresponding packet header.

8. The message forwarding device according to claim 7, characterized in that, The at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in series, the at least one packet header is N packet headers, and N is an integer greater than 1; The i-th flow feature extraction unit in the N flow feature extraction units is further configured to: splice the flow feature information extracted by the i-th flow feature extraction unit from the corresponding packet header and the flow feature information output by the (i - 1)-th flow feature extraction unit, and output the spliced flow feature information, where 1 < i ≤ N and i is an integer; Wherein, the flow feature information of the first packet is the flow feature information output by the N-th flow feature extraction unit.

9. The message forwarding device according to claim 7, characterized in that, The at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in parallel, the at least one packet header is N packet headers, and N is an integer greater than 1; The flow table matching module further includes a splicing unit, which is used to splice the flow feature information extracted from the N packet headers by the N flow feature extraction units to obtain the flow feature information of the first packet.

10. The message forwarding apparatus according to any one of claims 5 to 9, characterized in that, The flow table matching module includes a lookup unit; the lookup unit is used to: determine the first flow table entry in the flow table based on the flow feature information of the first message.

11. The message forwarding apparatus according to any one of claims 2 to 10, characterized in that, The first message belongs to the first stream, the first stream forwarding table entry is a forwarding table entry used to forward the first stream, and the first stream forwarding table entry is generated by the pipeline processor; The message forwarding device is further configured to: receive the first stream forwarding table entry sent by the pipeline processor.

12. The message forwarding apparatus according to claim 11, characterized in that, The first stream is the elephant stream.

13. The message forwarding device according to claim 12, characterized in that, The first stream forwarding table entry is generated by the pipeline processor based on the header of the second message received by the data channel, and the second message belongs to the first stream; The message forwarding device is also used for: Obtain the flow characteristic information of the second message received by the data channel; If it is determined that the flow feature information of the second message does not match the flow table, the header of the second message is sent to the pipeline processor.

14. The message forwarding apparatus according to claim 12 or 13, characterized in that, The first stream forwarding table entry is generated by the pipeline processor when it determines that the number of packets belonging to the first stream among the packets received by the data channel reaches a preset number.

15. A message forwarding method, characterized in that, A packet forwarding device applied in a network processor NP chip, the NP chip including a pipeline processor and a data channel, the packet forwarding device being located in the data channel, the method comprising: The message forwarding device acquires the flow characteristic information of the first message received by the data channel; The message forwarding device performs flow forwarding on the first message based on the flow characteristic information of the first message.

16. The method according to claim 15, characterized in that, The message forwarding device performs flow forwarding on the first message based on the flow characteristic information of the first message, including: The message forwarding device determines the first flow forwarding table entry in the flow forwarding table based on the flow characteristic information of the first message; The message forwarding device performs flow forwarding on the first message according to the first flow table entry.

17. The method according to claim 16, characterized in that, The message forwarding device performs flow forwarding on the first message according to the first flow forwarding table entry, including: The message forwarding device obtains the first control information based on the first forwarding table entry; The message forwarding device performs flow forwarding of the first message according to the first control information.

18. The method according to claim 17, characterized in that, The first flow table entry includes the mapping relationship between the flow feature information of the first message and the index information of the first control information; The message forwarding device obtains first control information based on the first forwarding table entry, including: The message forwarding device determines the index information of the first control information based on the first forwarding table entry; The message forwarding device obtains the first control information based on the index information of the first control information.

19. The method according to claim 18, characterized in that, The packet forwarding device includes a flow table matching module, a flow table data acquisition module, and a packet processing module; The message forwarding device obtains the flow characteristic information of the first message received by the data channel, including: the flow table matching module obtains the flow characteristic information of the first message; The packet forwarding device determines a first forwarding table entry in the forwarding table according to the flow feature information of the first packet, including: the flow table matching module determines the first forwarding table entry in the forwarding table according to the flow feature information of the first packet; The packet forwarding device determines index information of the first control information according to the first forwarding table entry, including: the flow table matching module determines index information of the first control information according to the first forwarding table entry; The packet forwarding device obtains the first control information according to the index information of the first control information, including: the flow table data acquisition module obtains the first control information according to the index information of the first control information; The packet forwarding device performs flow forwarding on the first packet according to the first control information, including: the packet processing module performs flow forwarding on the first packet according to the first control information.

20. The method according to claim 19, characterized in that, The flow table matching module obtains the flow feature information of the first packet, including: The flow table matching module obtains the flow feature information carried by at least one packet header of the first packet; The flow table matching module obtains the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header.

21. The method according to claim 20, characterized in that, The flow table matching module includes at least one flow feature extraction unit, and the at least one flow feature extraction unit corresponds to the at least one packet header one by one; The flow table matching module obtains the flow feature information carried by at least one packet header of the first packet, including: Each flow feature extraction unit in the at least one flow feature extraction unit extracts flow feature information from the corresponding packet header.

22. The method according to claim 21, characterized in that, The at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in series, the at least one packet header is N packet headers, and N is an integer greater than 1; The flow table matching module obtains the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header, including: the i-th flow feature extraction unit among the N flow feature extraction units splices the flow feature information extracted by the i-th flow feature extraction unit from the corresponding packet header and the flow feature information output by the (i - 1)-th flow feature extraction unit, and outputs the spliced flow feature information, where 1 < i ≤ N and i is an integer; wherein, the flow feature information of the first packet is the flow feature information output by the N-th flow feature extraction unit.

23. The method according to claim 21, characterized in that, The at least one flow feature extraction unit is N flow feature extraction units, the N flow feature extraction units are connected in parallel, the at least one packet header is N packet headers, and N is an integer greater than 1; The flow table matching module further includes a splicing unit. The flow table matching module obtains the flow feature information of the first packet based on the flow feature information obtained from the at least one packet header, including: the splicing unit splices the flow feature information extracted by the N flow feature extraction units from the N packet headers to obtain the flow feature information of the first packet.

24. The method according to any one of claims 19 to 23, characterized in that, The flow table matching module includes a lookup unit; The flow table matching module determines the first flow table entry in the flow table based on the flow feature information of the first message, including: the lookup unit determines the first flow table entry in the flow table based on the flow feature information of the first message.

25. The method according to any one of claims 16 to 24, characterized in that, The first message belongs to the first stream, the first stream forwarding table entry is a forwarding table entry used to forward the first stream, and the first stream forwarding table entry is generated by the pipeline processor; The method further includes: the message forwarding device receiving the first stream forwarding table entry sent by the pipeline processor.

26. The method according to claim 25, characterized in that, The first stream is the elephant stream.

27. The method according to claim 16, characterized in that, The first stream forwarding table entry is generated by the pipeline processor based on the header of the second message received by the data channel, wherein the second message belongs to the first stream, and the method further includes: The message forwarding device acquires the flow characteristic information of the second message received by the data channel; The message forwarding device determines that the flow feature information of the second message does not match the flow forwarding table, and sends the message header of the second message to the pipeline processor.

28. The method according to claim 26 or 27, characterized in that, The first stream table entry is generated by the pipeline processor when it determines that the number of packets belonging to the first stream among the packets received by the data channel reaches a preset number.

29. A network processor NP chip, characterized in that, It includes a pipeline processor and a data channel, the data channel including a message forwarding device as described in any one of claims 1 to 14.

30. A network device, characterized in that, Includes the NP chip as described in claim 29.