Message processing method, device and chip

By performing FEC encoding and decoding in the target hardware engine of the network device, the problem of excessive CPU computing burden in the prior art is solved, and the throughput and efficiency of message transmission is improved.

CN112564855BActive Publication Date: 2025-01-03HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911205835.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2019-09-10
Filing Date
2019-11-29
Publication Date
2025-01-03
Estimated Expiration
2039-11-29

AI Technical Summary

Technical Problem

When performing forward error correction (FEC) encoding and decoding, existing network devices have too much computing burden and are difficult to meet the requirements of fast encoding and decoding, resulting in insufficient throughput during message transmission.

Method used

By directly performing FEC encoding and decoding in the target hardware engine of the network device, the burden on the central processor (CPU) is reduced, encoding and decoding efficiency is improved, and network devices can meet the transmission requirements of large throughput.

Benefits of technology

It realizes improving the encoding and decoding efficiency of network devices during message transmission, meeting the requirements of large throughput, and reducing CPU overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112564855B_ABST
    Figure CN112564855B_ABST
Patent Text Reader

Abstract

The present application discloses a message processing method, device and chip, belonging to the field of data processing technology. The method performs FEC encoding on M original messages in a first data stream directly in a target hardware engine of a network device without performing FEC encoding in a CPU, thereby reducing CPU overhead and improving the encoding efficiency of the network device, thereby making it easier for the network device to meet the requirement of high throughput during message transmission.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority to Chinese patent application No. 201910854367.2, filed on September 10, 2019, and entitled “FEC acceleration method, device, system and FEC hardware accelerator”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of data processing technology, and in particular to a message processing method, device and chip. Background Art

[0003] When data streams are transmitted between two network devices, packet loss often occurs. Currently, forward error correction (FEC) encoding and decoding technology can be used to solve the packet loss problem that occurs during data stream transmission.

[0004] Specifically, the first-level network device performs FEC encoding on the original message in the data stream to obtain a redundant message of the original message. The first-level network device adds an FEC message header to the original message and the redundant message respectively, and sends the original message and the redundant message carrying the FEC message header to the second-level network device. When the original message is lost during the transmission process, the second-level network device restores the lost original message based on the original message and the redundant message that have not been lost, and recombines the original message that has not been lost and the restored original message into the original data stream. The second-level network device outputs the data stream. Therefore, the loss of messages during the data stream transmission process can be avoided.

[0005] The FEC encoding process and the original message recovery process in the above message transmission process require a lot of calculations, which are completed by the central processing units (CPU) of the network equipment. However, the CPU's own computing power and computing speed are limited. If the requirements for fast encoding and decoding are to be met, it is difficult to meet the high throughput requirements in the message transmission process. Summary of the invention

[0006] The present application provides a message processing method, device and chip, so that network equipment can quickly encode and decode messages while meeting the requirements of high throughput in the process of transmitting messages.

[0007] In a first aspect, a message processing method is provided, which is applied to a network device including a processor and a target hardware engine, and the method includes:

[0008] The processor generates a first encoding task according to M original messages in a first data stream to be processed, where M is a positive integer, and the first encoding task is used to instruct encoding of the M original messages;

[0009] The target hardware engine performs forward error correction (FEC) encoding on the M original messages according to the first encoding task to obtain R redundant messages, where R is a positive integer.

[0010] This method performs FEC encoding on the M original messages in the first data stream directly in the target hardware engine of the network device without performing FEC encoding in the processor. Therefore, it can reduce the CPU overhead and improve the encoding efficiency of the network device, thereby making it easier for the network device to meet the requirements of high throughput during message transmission.

[0011] In a possible implementation, after the processor generates the first encoding task according to the M original messages in the first data stream to be processed, the method further includes:

[0012] The processor stores the first encoding task in a first target sending queue, where the first target sending queue is used to store encoding tasks of the to-be-processed data stream of the network device, where the to-be-processed data stream of the network device includes the first data stream;

[0013] The target hardware engine reads the first encoding task from the first target sending queue.

[0014] In a possible implementation, the processor storing the first encoding task in a first target sending queue includes:

[0015] The processor adds the first encoding task to the first target sending queue according to the priority of the first data stream, and the priority of the first target sending queue is equal to the priority of the first data stream.

[0016] In a possible implementation, the target hardware engine reading the first encoding task from the first target sending queue includes:

[0017] The target hardware engine sequentially queries whether there is an encoding task in each sending queue according to the order of priority of each sending queue, and each queue in the sending queue corresponds to a priority;

[0018] In each of the sending queues, when there is no encoding task in a queue with a higher priority than the first target sending queue, the target hardware engine reads the first encoding task from the first target sending queue.

[0019] In a possible implementation, the first target sending queue is located in any one of the memory of the network device, the processor, and the target hardware engine.

[0020] In a possible implementation, before the processor generates the first encoding task according to the M original messages in the stored first data stream to be processed, the method further includes:

[0021] The network device stores the received original message in the first data stream into a memory of the network device;

[0022] If the amount of uncoded original messages of the first data stream in the memory of the network device is equal to or greater than M, the processor obtains the M original messages from the uncoded original messages of the first data stream.

[0023] In one possible implementation, the first encoding task includes the storage address of the M original messages, or the first encoding task includes the storage address of the M original messages and the priority of the first data stream, or the first encoding task includes the M original messages, or the first encoding task includes the M original messages and the priority of the first data stream.

[0024] In a second aspect, a message processing method is provided, which is applied to a network device including a processor and a target hardware engine, and the method includes:

[0025] The processor obtains a first group of FEC messages from the received first data stream, wherein all FEC messages in the first group of FEC messages have the same FEC message header, and the FEC message header includes an original message amount M of FEC encoding;

[0026] When the number of original messages in the first group of FEC messages is less than the original message amount M, the processor generates a first decoding task according to the first group of FEC messages, where the first decoding task is used to instruct decoding of the first group of FEC messages;

[0027] The target hardware engine performs FEC decoding on the original messages in the first group of FEC messages and the redundant messages of the original messages according to the first decoding task to obtain the lost original messages in the first group of FEC messages.

[0028] This method directly performs FEC decoding on the FEC messages that are not lost in the first group of FEC messages in the target hardware engine of the network device without performing FEC decoding in the CPU. Therefore, it can reduce the CPU overhead and improve the decoding efficiency of the network device, thereby making it easier for the network device to meet the requirements of high throughput during the message transmission process.

[0029] In a possible implementation, after the processor generates the first decoding task according to the first group of FEC messages, the method further includes:

[0030] The processor stores the first decoding task in a second target sending queue, where the second target sending queue is used to store decoding tasks of a to-be-processed data stream of the network device, where the to-be-processed data stream of the network device includes the first data stream;

[0031] The target hardware engine reads the first decoding task from the second target sending queue.

[0032] In a possible implementation, the processor storing the first decoding task in the second target sending queue includes:

[0033] According to the priority of the first data stream, the processor adds the first decoding task to the second target sending queue, and the priority of the second target sending queue is equal to the priority of the first data stream.

[0034] In a possible implementation, the target hardware engine reading the first decoding task from the second target sending queue includes:

[0035] The target hardware engine sequentially queries whether there are decoding tasks in each sending queue according to the priority of each sending queue, and each queue in the sending queue corresponds to a priority;

[0036] In each of the sending queues, when there are no other decoding tasks in a queue with a higher priority than the second target sending queue, the target hardware engine reads the first decoding task from the second target sending queue.

[0037] In a possible implementation, the second target sending queue is located in any one of the memory of the network device, the processor, and the target hardware engine.

[0038] In one possible implementation, the first decoding task includes the storage address of the first group of FEC messages, or the first decoding task includes the storage address of the first group of FEC messages and the priority of the first data stream, or the first decoding task includes the first group of FEC messages, or the first decoding task includes the first group of FEC messages and the priority of the first data stream.

[0039] In a third aspect, a message processing device is provided, which is used to execute the message processing method. Specifically, the device includes a functional module for executing the message processing method provided by the first aspect or any optional manner of the first aspect.

[0040] In a fourth aspect, a message processing device is provided, which is used to execute the message processing method. Specifically, the device includes a functional module for executing the message processing method provided by the second aspect or any optional manner of the second aspect.

[0041] In a fifth aspect, a chip is provided, comprising a processor and a target hardware engine, wherein the processor is used to implement the processor provided by the first aspect or any optional method of the first aspect, and the target hardware engine is used to implement the target hardware engine provided by the first aspect or any optional method of the first aspect.

[0042] In a sixth aspect, a chip is provided, comprising a processor and a target hardware engine, wherein the processor is used to implement the processor provided by the second aspect or any optional method of the second aspect, and the target hardware engine is used to implement the target hardware engine provided by the second aspect or any optional method of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0044] Figure 1 It is a schematic diagram of an FEC encoding calculation process provided in an embodiment of the present application;

[0045] Figure 2 It is a schematic diagram of an FEC decoding calculation process provided by an embodiment of the present application;

[0046] Figure 3 is a schematic diagram of a message transmission system provided in an embodiment of the present application;

[0047] Figure 4 It is a structural schematic diagram of a message processing device provided in an embodiment of the present application;

[0048] Figure 5 It is a structural schematic diagram of a message processing device provided in an embodiment of the present application;

[0049] Figure 6 is a schematic diagram of a target hardware engine provided in an embodiment of the present application;

[0050] Figure 7 It is a flow chart of a message processing method provided by an embodiment of the present application;

[0051] Figure 8 It is a flow chart of a message processing method provided by an embodiment of the present application;

[0052] Fig. 9 It is a schematic diagram of an internal interaction process of a network device provided in an embodiment of the present application;

[0053] Fig.10 It is a schematic diagram of an FEC message provided in an embodiment of the present application;

[0054] Fig.11 This is a flowchart of FEC encoding provided by an embodiment of the present application;

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

[0056] Fig.13 This is a flowchart of FEC decoding provided in an embodiment of the present application. DETAILED DESCRIPTION

[0057] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0058] In order to facilitate understanding of the implementation process of this application, Figure 1 A schematic diagram of an FEC encoding calculation process provided by an embodiment of the present application is shown, and FEC encoding is introduced as follows: the parameters used in the FEC encoding process are encoding parameters, and the encoding parameters include the original message amount M, the redundant message amount R, and the target size L, wherein M and R are both positive integers, L is a value greater than 0, the original message amount M is the number of original messages to be encoded, and the redundant message amount R is the number of redundant messages obtained after FEC encoding of the M original messages. Since the sizes of the M original messages are different, the first network device, in the process of encoding the M original messages to generate redundant messages, first performs padding processing based on the M original messages to obtain M equal-length messages, each equal-length message is a message after the original message is padded, and the size of each equal-length message and the size of the redundant message are both the target size L, and the target size L can be the size of the largest original message among the M original messages. At this time, the largest message among the M original messages does not need to be padded and can be regarded as an equal-length message. Then, the first network device may first form an M*L matrix to be encoded by combining M equal-length messages, where each row of the matrix to be encoded is a message of equal length, for example: Figure 1In the example, M=4, and there are 4 equal-length messages M0-M3, then the matrix to be encoded is composed of equal-length messages M0-M3; the first network device constructs a (M+R)*M generating matrix, and the generating matrix is ​​composed of a first sub-matrix and a second sub-matrix, wherein the first sub-matrix is ​​an M*M unit matrix, and the second sub-matrix is ​​an R*M Cauchy matrix.

[0059] Among them, the element in the i-th row and j-th column of the second submatrix is

[0060] x i-1 and i-1 and are both Galois fields (GF) (2 w ), where and are integers greater than or equal to 0, and w can be 8, for example, Figure 1 The network device multiplies the generator matrix and the matrix to be encoded to obtain a coding matrix of (M+R)*L, where the coding matrix includes the matrix to be encoded and a check matrix of R*L, where each row of the check matrix is ​​a redundant message, for example Figure 1 In R=2, the redundant messages are R0 and R1.

[0061] After the first network device obtains the R redundant messages, it adds the same FEC message header to the M original messages and the R redundant messages, thereby encapsulating the M original messages and the R redundant messages into a group of FEC messages, and sends this group of FEC messages to the second network device. When any equal-length message in the encoding matrix is ​​lost during the transmission of this group of FEC messages, the second network device can also recover any lost equal-length message through the decoding process. Figure 2 A schematic diagram of an FEC decoding calculation process provided by an embodiment of the present application is shown, and FEC decoding is introduced as follows: when equal-length messages M2 and M3 in the coding matrix are lost, the second network device can form a recovery matrix with non-lost equal-length messages M0, M1 and redundant messages R0, R1; construct a target check matrix, wherein the target check matrix includes a third sub-matrix and a second sub-matrix, because 2 equal-length messages are lost, the third sub-matrix is ​​a 2*M unit matrix; the second network device multiplies the inverse matrix of the target check matrix by the recovery matrix to obtain the matrix to be encoded, and the second network device can obtain the lost equal-length messages M2 and M3 from the matrix to be encoded.

[0062] Figure 3 is a schematic diagram of a message transmission system provided in an embodiment of the present application, see Figure 3, a first terminal 301, a first network device 302, a second network device 303 and a second terminal 304, wherein the first terminal 301 is used to generate a data stream and send the data stream to the first network device 302, the first network device 302 can perform FEC encoding on the message in the data stream and send the encoded stream composed of FEC messages to the second network device 303, the second network device 303 decodes the FEC messages that are not lost in the encoded stream, restores the lost original messages, and combines the restored original messages and the original messages that are not lost into the original data stream, and sends the data stream to the second terminal 304, wherein the first terminal 301 and the second terminal 304 can be mobile phones, laptops, etc., the first network device 302 and the second network device 303 can be computer devices such as routers and switches, the data stream can be a video stream, or a text stream composed of text data, and the embodiment of the present application does not specifically limit the type of data stream.

[0063] In the schematic diagram taking the video stream as an example, when the first terminal 301 and multiple second terminals 302 conduct a video conversation, the first terminal 301 sends the original message used to constitute the video to the first network device 302 to form a video stream (that is, a data stream). The first network device 302 performs FEC encoding on the original message in the video stream to obtain redundant messages, and encapsulates the original message and the redundant message into an FEC message to obtain a coded stream, and sends the coded stream to the second network device 303. After obtaining each group of FEC messages in the coded stream, the second network device 303 determines whether each group of FEC messages is missing according to the FEC message header of each group of FEC messages. If lost, a group of FEC messages of the lost original message is decoded to restore the lost original message, and the restored original message and the non-lost original message are combined into a video stream and sent to multiple second terminals 304. After each second terminal 304 receives the video stream, it plays the video, thereby realizing a video conversation between multiple terminals.

[0064] In some possible implementations, the first terminal 301 may also have the function of the first network device, see Figure 4 The structure diagram of a message processing device provided in an embodiment of the present application is shown, and the device 400 includes:

[0065] The processor 401 is configured to generate a first encoding task according to M original messages in a first data stream to be processed, where M is a positive integer, and the first encoding task is used to instruct encoding of the M original messages;

[0066] The target hardware engine 402 is used to perform forward error correction FEC encoding on the M original messages according to the first encoding task to obtain R redundant messages, where R is a positive integer.

[0067] Optionally, the processor 401 is further configured to store the first encoding task in a first target sending queue, where the first target sending queue is used to store encoding tasks of a data stream to be processed by the device, where the data stream to be processed by the device includes the first data stream;

[0068] The target hardware engine is further configured to read the first encoding task from the first target sending queue.

[0069] Optionally, the processor 401 is used to add the first encoding task to the first target sending queue according to the priority of the first data stream, and the priority of the first target sending queue is equal to the priority of the first data stream.

[0070] Optionally, the target hardware engine 402 is used to:

[0071] The target hardware engine sequentially queries whether there are encoding tasks in each sending queue according to the order of priority of each sending queue, and each queue in the sending queue corresponds to a priority;

[0072] In each of the sending queues, when there is no encoding task in a queue with a higher priority than the first target sending queue, the first encoding task is read from the first target sending queue.

[0073] Optionally, the apparatus 400 further includes a memory 403, and the first target sending queue is located in any one of the memory of the network device, the processor, and the target hardware engine.

[0074] Optionally, the device 400 further includes a memory 403;

[0075] The memory 403 is used to store the original message received in the first data stream;

[0076] The processor 401 is also used to obtain the M original messages from the unencoded original messages of the first data stream if the message amount of the unencoded original messages of the first data stream in the memory is greater than or equal to M, and execute the step of generating a coding task based on the M original messages in the stored first data stream to be processed.

[0077] The processor 401 may be a general-purpose processor, such as a CPU, or a network processor (NP), or a combination of a CPU and a NP. The processor may also include a hardware chip, which may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0078] The memory 403 may include a volatile memory, such as a random-access memory (RAM); the memory may also include a non-volatile memory, such as a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or any combination thereof.

[0079] Optionally, the first encoding task includes the storage addresses of the M original messages, or the first encoding task includes the storage addresses of the M original messages and the priority of the first data stream, or the first encoding task includes the M original messages, or the first encoding task includes the M original messages and the priority of the first data stream.

[0080] In some possible implementations, Figure 4 The functions of the message processing device shown can also be implemented by a chip, which may include Figure 4 The processor 401 and Figure 4 The target hardware engine 402 in.

[0081] In some possible implementations, the second terminal 304 may also have the function of the second network device 303, see Figure 5 5 is a schematic diagram of the structure of a message processing device provided in an embodiment of the present application, wherein the device 500 includes a processor 501 and a target hardware engine 502;

[0082] The processor 501 is configured to obtain a first group of FEC messages from a received first data stream, wherein all FEC messages in the first group of FEC messages have the same FEC message header, and the FEC message header includes an original message amount M of FEC encoding;

[0083] When the number of original messages in the first group of FEC messages is less than the original message amount M, generating a first decoding task according to the first group of FEC messages, the first decoding task being used to instruct decoding of the first group of FEC messages;

[0084] The target hardware engine 502 is used to perform FEC decoding on the original messages in the first group of FEC messages and the redundant messages of the original messages according to the first decoding task, so as to obtain the lost original messages in the first group of FEC messages.

[0085] Optionally, the processor 501 is further configured to store the first decoding task in a second target sending queue, where the second target sending queue is used to store decoding tasks of a data stream to be processed by the device, where the data stream to be processed by the device includes the first data stream;

[0086] The target hardware engine 502 is further configured to read the first decoding task from the second target sending queue.

[0087] Optionally, the processor 501 is used to add the first decoding task to the second target sending queue according to the priority of the first data stream, and the priority of the second target sending queue is equal to the priority of the first data stream.

[0088] Optionally, the target hardware engine 502 is used to:

[0089] According to the priority of each sending queue, query in turn whether there is a decoding task in each sending queue, each queue in the sending queue corresponds to a priority;

[0090] In each of the sending queues, when there are no other decoding tasks in a queue with a higher priority than the second target sending queue, the first decoding task is read from the second target sending queue.

[0091] Optionally, the device further includes a memory, and the second target sending queue is located in any one of the memory, the processor, and the target hardware engine.

[0092] Optionally, the first decoding task includes the storage address of the FEC messages that are not lost in the first group of FEC messages, or the storage address of the FEC messages that are not lost in the first group of FEC messages and the priority of the first data stream, or the first decoding task includes the first group of FEC messages, or the first decoding task includes the first group of FEC messages and the priority of the first data stream.

[0093] In some possible implementations, Figure 5 The functions of the message processing device shown can also be implemented by a chip, which may include Figure 5 The processor 501 and Figure 5 The target hardware engine 502 in.

[0094] For the sake of convenience, the first network device 302 and the second network device 303 are both recorded as computing devices, and the computing devices can include a target hardware engine, which is used to perform encoding and decoding calculations. Figure 6 The target hardware engine 600 includes a controller 601, a cache unit 602, a data processing unit 603, a matrix generator 604 and a codec unit 605. Among them, the controller 601 is used to receive the encoding and decoding parameters sent by the CPU of the computing device and the storage address of the message to be encoded and decoded, and determine the corresponding data processing strategy, the model parameters of the encoding and decoding model and the model parameters of the matrix model according to the encoding and decoding parameters; wherein the encoding and decoding parameters include encoding parameters or decoding parameters, and the decoding parameters may be the content in the FEC message header; the message to be encoded and decoded may be M original messages, or FEC messages that have not been lost; the encoding and decoding model may include an encoding model or a decoding model, the model parameters of the encoding model are the original message amount M and the target size L, the model parameters of the decoding model include the message amount F of the lost original FEC message and the target size L, F is greater than 0 and less than or equal to R; the model parameters of the matrix model include the model parameters of the generated matrix or the model parameters of the target check matrix, the model parameters of the generated matrix include the original message amount M, the redundant message amount R and the target size L, and the model parameters of the target check matrix include the message amount F of the lost original FEC message, the redundant message amount R and the target size L.

[0095] The controller 601 is further configured to obtain the message to be encoded and decoded from the memory of the computing device according to the storage address of the received message to be encoded and decoded, and store the message to be encoded and decoded in the cache unit 602. The controller 601 is further configured to send the model parameters of the encoding and decoding model and the data processing strategy to the data processing unit 603, so that the data processing unit 603 generates a matrix to be encoded or a recovery matrix based on the message to be encoded and decoded according to the model parameters of the encoding and decoding model and the data processing strategy, and sends the matrix to be encoded or the recovery matrix to the encoding and decoding unit 605.

[0096] The controller 601 is further configured to send the model parameters of the matrix model to the matrix generator 604 , so that the matrix generator 604 constructs a generator matrix or a target check matrix according to the model parameters of the matrix model, and sends the generator matrix or the target check matrix to the encoding and decoding unit 605 .

[0097] The encoding and decoding unit 605 is used to perform encoding and decoding calculations on the received matrix to be encoded or the recovery matrix and the corresponding generation matrix or the target check matrix to obtain redundant messages or lost original FEC messages (see Figure 1 and Figure 2 The encoding and decoding calculation process shown in FIG. 6 ) sends the redundant message or the lost original FEC message to the cache unit 602, and the cache unit 602 sends the redundant message or the recovered message to the memory or processor of the computing device.

[0098] The codec unit 605 in the target hardware engine can reuse the FEC encoding logic and the FEC decoding logic. When FEC encoding is required, the codec unit 605 performs FEC encoding on the generation matrix and the matrix to be encoded according to the FEC encoding logic; when FEC decoding is required, the codec unit 605 performs FEC decoding on the target check matrix and the recovery matrix according to the FEC decoding logic. In some possible implementations, the codec unit 605 may include a coding subunit and a decoding subunit, wherein the coding subunit may perform FEC encoding on the generation matrix and the matrix to be encoded according to the FEC encoding logic, and the decoding subunit may perform FEC decoding on the target check matrix and the recovery matrix according to the FEC decoding logic.

[0099] To further explain the encoding and decoding process of computing devices, see Figure 7The flowchart of a message processing method provided by an embodiment of the present application is shown, the computing device receives a message in a data stream through a gigabit Ethernet (GE) network port or a ten-gigabit Ethernet (GXE) network port, the GE / GXE network port sends the received message to a packet parsing hardware engine (packet parse engine, PPE), the PPE stores the message in a memory, and performs a preliminary analysis on the message to obtain a descriptor of the message, and sends a notification message carrying the storage address of the message to a network processing (network processer, NP) engine through a diversion; the NP engine can perform a deep analysis on the message in the memory to determine whether it needs to be encoded, and when the message needs to be encoded, the NP engine can also forward the notification message to the CPU; the CPU protocol stack sends a user datagram protocol (user datagram The target hardware engine sends a coding task to the target hardware engine through the FEC software interface; the target hardware engine obtains the coding message from the memory according to the storage address of the coding message carried in the coding task, generates redundant messages, and stores the redundant messages in the memory. After the storage is completed, the target hardware engine reports the coding task completion information to the FEC software interface in the CPU; the FEC software interface obtains the coding message and the redundant message from the memory according to the storage address of the coding message and the storage address of the redundant message carried in the coding task completion information, adds the FEC message header to the obtained coding message and the redundant message, and generates the FEC message; the FEC software interface sends the FEC message to the traffic management (TM) engine to form the coded coding stream (that is, the data stream); the TM engine manages the coding stream according to the needs of the CPU or other hardware engines, such as the quality of service (quality of The TM engine sends the managed coded stream to the PPE; the PPE forwards the managed coded stream to the GE / GXE network port, and the GE / GXE network port outputs the managed coded stream. It should be noted that in some possible implementations, the computing device does not include the NP engine, PPE, and TM engine, and the work of the NP engine, PPE, and TM engine can all be completed by one processor or the CPU. Alternatively, the work of the NP engine, PPE, TM engine, and CPU can be completed by one processor.

[0100] The above is a description of the encoding process of the computing device. The decoding process of the computing device is described as follows: when the message stored in the memory of the computing device is an FEC message, if the original message in a group of FEC messages with the same message header is lost, the CPU issues a decoding task to the target hardware engine through the FEC software interface; the target hardware engine obtains a group of FEC messages from the memory according to the storage address of the group of FEC messages carried in the decoding task, and restores the lost original message according to the group of FEC messages, and stores the restored original message in the memory. After the storage is completed, the target hardware engine reports the decoding task completion information to the FEC software interface in the CPU; the FEC software interface obtains the original message that is not lost in a group of FEC messages and the restored original message from the memory according to the storage address of the original message that is not lost in a group of FEC messages carried in the decoding task completion information and the storage address of the restored original message, and the obtained original message is combined into a data stream for output. Among them, the CPU outputs the data stream and the outputs the coded stream in the same way. Here, the embodiment of the present application does not repeat the way the CPU outputs the data stream.

[0101] In some possible implementations, the protocol stack, UDP agent, and FEC software interface may not be deployed in the CPU, but in the NP engine. In this case, in the encoding and decoding process, the NP engine, the target hardware engine, and the memory need to interact with each other, without the need for the CPU to interact with the target hardware engine and the memory. In some possible implementations, after the target hardware engine obtains the encoding matrix or the matrix to be encoded through encoding and decoding, the original message and the redundant message in the encoding matrix can be directly encapsulated into FEC messages and output to the network device, or the original message can be directly obtained from the matrix to be encoded and output to the network device. In some possible implementations, the target hardware engine can also directly send the encoding matrix or the matrix to be encoded to the FEC software interface, and the FEC software interface encapsulates the original message and the redundant message in the encoding matrix into FEC messages and outputs the network device, or the FEC software interface obtains the original message from the matrix to be encoded and outputs the network device.

[0102] In summary, the encoding process of the network device is summarized as follows: after the network device obtains any data stream, it can store the any data stream in the memory. If the message in the any data stream is a message to be encoded, the processor in the network device can generate a coding task for instructing the encoding of multiple messages to be encoded, and the processor can send the coding task to the memory; the target hardware engine in the network device reads the coding task in the memory, and performs FEC encoding on the multiple messages to be encoded stored in the memory according to the coding task to obtain redundant messages of the multiple messages to be encoded, and the target hardware engine stores the redundant messages in the memory; then, the processor can obtain the multiple messages to be encoded and the redundant messages of the multiple messages to be encoded from the memory, and encapsulate the obtained messages into FEC messages. To further illustrate this processing process, refer to FIG. Figure 8 The flowchart of a message processing method provided by an embodiment of the present application is shown, wherein the first network device may include a processor and a target hardware engine, and the process of the method may include the following steps 801-812:

[0103] 801. A first network device obtains M original messages in a first data stream to be processed.

[0104] The first network device may obtain multiple data streams. The first data stream is any data stream among the multiple data streams, and the first data stream may include multiple messages. The data stream may be a video data stream, an audio data stream, or a text data stream, etc. The embodiment of the present application does not specifically limit the type of the first data stream.

[0105] The M original messages are any M consecutive original messages in the first data stream. The first network device can encode the M original messages each time. When one encoding is completed, another M original messages in the first data stream are encoded. In some possible implementation methods, this step 801 can be implemented through the process shown in steps 8011-8012.

[0106] Step 8011: The first network device stores the original message in the received first data stream into the memory of the first network device.

[0107] After receiving an original message in the first data stream, the GE / GXE network port of the first network device sends the original message to the PPE. After receiving the original message, the PPE stores the original message in the memory and records the storage address of the original message.

[0108] Step 8012: If the amount of uncoded original messages of the first data stream in the memory is equal to or greater than M, the processor obtains M original messages from the uncoded original messages of the first data stream.

[0109] The processor may include at least one of a CPU and an NP engine in the first network device. Since the first network device encodes the next group of M unencoded original messages after each encoding, for the original messages in the first data stream, when M original messages are newly cached in the memory of the first network device, the newly cached M original messages can be used as the next M original messages to be encoded in the first data stream.

[0110] In some possible implementations, the first network device may also set a preset duration. For the original message in the first data stream, the first network device uses the original message newly stored in the preset duration as the original message to be encoded next time after each preset duration. In some possible implementations, the size of M may change each time encoding occurs. For example, after a preset duration, the first network device obtains 5 original messages, and M is equal to 5 at this time. After the next preset duration, the first network device obtains 4 original messages, and M is equal to 4 at this time. The embodiment of the present application does not specifically limit the preset duration.

[0111] After the PPE stores an original message in the memory, the PPE sends a storage completion message corresponding to the original message to the NP engine. The storage completion message may carry the flow identifier of the first data flow and the storage address of the original message. The flow identifier may be the name or number of the first data flow, which is used to indicate the data flow to which the original message belongs. In some possible implementations, the first network device sets a corresponding priority for each received data flow according to business requirements. The first network device may preferentially process data flows with high priorities. Accordingly, the storage completion message may also carry the priority corresponding to the first data flow, so that each module in the first network device may process the original message in the corresponding data flow according to the priority. The user may configure a priority information table on the first network device. The priority information table includes multiple priorities from high to low, and each priority corresponds to a business type. When the first network device receives the first data flow, it may determine the business type of the first data flow according to the data carried by the original message in the first data flow, and determine the priority corresponding to the business type of the first data flow from the priority information table, so that the first network device may set the corresponding priority for the first data flow.

[0112] When the NP engine receives the storage completion message, it can send the storage completion message to the protocol stack. Therefore, the UDP agent can collect each storage completion message from the protocol stack. Whenever the number of new storage completion messages collected by the UDP agent is M, the newly collected M storage completion messages can indicate that M new messages to be encoded are stored in the memory. Therefore, the UDP agent can use the M original messages corresponding to the M storage completion messages as the M original messages to be encoded.

[0113] 802. The processor generates a first encoding task according to M original messages in a first data stream to be processed, where M is a positive integer and the first encoding task is used to instruct encoding of the M original messages.

[0114] This step 802 can be executed by the FEC software interface in the processor of the first network device. Whenever the UDP agent collects M storage completion messages, the UDP agent can send the collected M storage completion messages to the FEC software interface in the processor. When the FEC software interface receives M storage completion messages, this step 802 can be executed.

[0115] The FEC software interface can obtain the storage addresses of the M original messages from the M storage completion messages, wherein the storage addresses of the M original messages include the storage address of each message in the M original messages; the FEC software interface can generate the encoding task according to the storage addresses of the M original messages and the encoding parameters, and the encoding task can include the storage addresses of the M original messages and the encoding parameters, so that the target hardware engine can obtain the M original messages from the memory according to the storage addresses, and encode the obtained M original messages according to the encoding parameters. In some possible implementations, the first encoding task may not include the storage addresses of the M original messages, but include the M original messages, so that the target hardware engine can directly obtain the M original messages from the first encoding task; when the first data stream has a priority, the first encoding task may also include the priority of the first data stream, and the encoding task may also carry an encoding identifier for indicating that each message is to be encoded. The embodiment of the present application does not specifically limit the representation method of the encoding identifier.

[0116] The encoding parameter may be a preset encoding parameter of the first network device, and the first network device may use the encoding parameter each time encoding is performed. Of course, the first network device may also appropriately adjust the encoding parameter according to the message transmission situation. When the first network device performs encoding each time according to the same encoding parameter, the first message volume may be the original message volume M in the encoding parameter. The first network device may also dynamically modify the original message volume M in the encoding parameter according to the current CPU overhead or the current computing power of the target hardware engine. For example, when the CPU overhead is small or the target hardware engine currently still has sufficient computing power, the first network device may appropriately increase the original message volume, that is, increase the messages to be encoded once. Otherwise, the original message volume may be appropriately reduced, that is, reduce the messages to be encoded once.

[0117] The first network device can also dynamically adjust the redundant message amount R in the model parameters according to the current network packet loss rate. For example, when the network packet loss rate is high, the redundant message amount R can be appropriately increased, that is, the message amount of redundant messages generated by a coding process is increased, so that all lost messages can be recovered later. When the network packet loss rate is low, the redundant message amount R can be appropriately reduced, that is, the message amount of redundant messages generated by a coding process is reduced to improve the coding efficiency.

[0118] Since the first network device can perform the above-mentioned dynamic adjustment on the coding parameters, the coding efficiency of the first network device can be improved by adjusting the coding parameters.

[0119] 803. The processor stores the first encoding task in a first target sending queue, where the first target sending queue is used to store encoding tasks of a to-be-processed data stream of a first network device, where the to-be-processed data stream of the first network device includes the first data stream.

[0120] This step 803 can be performed by the FEC software interface in the processor. The first network device can preset multiple sending queues, each sending queue is used to store the encoding task of the data stream to be processed by the first network device, and the first target sending queue can be any queue in the multiple sending queues. The multiple sending queues can be located in any one of the memory, processor and target hardware engine of the first network device.

[0121] In some possible implementations, the first network device may set a priority for each sending queue, and each sending queue is used to store encoding tasks of data streams with the same priority. Fig. 9 The schematic diagram of an internal interaction process of a network device provided in an embodiment of the present application is shown. Fig. 9There is a sending queue A with a priority of A and a sending queue B with a priority of B in the memory, where priority A is higher than priority B. At this time, encoding tasks 3, 5 and 6 are stored in sending queue A, and encoding tasks 1, 2 and 4 are stored in sending queue B, where encoding tasks 3, 5 and 6 are respectively encoding tasks with a priority of A, and encoding tasks 1, 2 and 4 are respectively encoding tasks with a priority of B.

[0122] In some possible implementations, this step 803 may include: the processor adds the first encoding task to the first target sending queue according to the priority of the first data stream, and the priority of the first target sending queue is equal to the priority of the first data stream. Specifically, after the FEC software interface generates a first encoding task, the FEC software interface can determine the first target sending queue corresponding to the priority of the first data stream in the memory according to the priority of the first data stream. When the number of encoding tasks in the first target sending queue is less than the first target number, the FEC software interface adds the first encoding task to the first target sending queue, wherein the first target number is the maximum number of encoding tasks that can be stored in the first target sending queue. When the number of encoding tasks in the first target sending queue is equal to the first target number, the FEC software interface queries whether the number of encoding tasks in the first target sending queue is less than the first target number at intervals of a first preset duration. Once it is less than the first target number, the first encoding task is added to the first target sending queue. The embodiment of the present application does not specifically limit the first preset duration. The target hardware engine may query the first target sending queue whenever the codec unit is idle.

[0123] 804. The target hardware engine reads the first encoding task from the first target sending queue.

[0124] The target hardware engine can first poll each sending queue in the memory according to the priority level to determine whether the target hardware engine wants to send from the first target sending queue. In some possible implementations, the target hardware engine queries each sending queue in order of priority to see whether there is an encoding task, and each queue in each sending queue corresponds to a priority; in each sending queue, when there is no encoding task in a queue with a higher priority than the first target sending queue, the target hardware engine reads the first encoding task from the first target sending queue.

[0125] The process of the target hardware engine polling each sending queue can be: the target hardware engine queries the first sending queue with the highest priority among the various sending queues. When there is an encoding task in the first sending queue, the target hardware engine obtains an encoding task from the head of the first sending queue, and executes the following step 805 according to the encoding task; every second preset time period, the target hardware engine queries the first sending queue again, and when there is still an encoding task in the first sending queue, a new encoding task is obtained from the head of the first sending queue again; until there is no encoding task stored in the first sending queue, the target hardware engine queries whether there is an encoding task in the second sending queue corresponding to the second priority among the multiple sending queues. When there is an encoding task, the encoding task is obtained from the second sending queue, and the following step 805 is executed, wherein the second priority is the priority second only to the highest priority; when there is no encoding task in the second sending queue, the sending queue second only to the second priority is queried according to the priority, and so on.

[0126] When the encoding task at the head of a sending queue is acquired by the target hardware engine, the next encoding task in the sending queue becomes the head of the sending queue, so that the target hardware engine can acquire the next encoding task from the head of the sending queue next time.

[0127] 805. The target hardware engine obtains the M original messages from the memory according to the storage addresses of the M original messages in the first encoding task.

[0128] When the controller in the target hardware engine obtains the first encoding task, the storage address of the M original messages can be obtained from the first encoding task. The target hardware engine can send a first message acquisition request to the memory, and the first message acquisition request carries the storage address of the M original messages. When the memory receives the first message acquisition request, it sends the M original messages stored in the storage address to the target hardware engine. After receiving the M original messages, the target hardware engine caches the M first messages in the cache unit so that the data processing unit processes the M original messages. Of course, if the first encoding task directly carries the M original messages, the target hardware engine can directly obtain the M original messages from the first encoding task without obtaining the M original messages from the memory.

[0129] 806. The target hardware engine performs forward error correction (FEC) encoding on the M original messages according to the first encoding task to obtain R redundant messages, where R is a positive integer.

[0130] When the target hardware engine obtains the M original messages, it can perform forward error correction FEC encoding on the M original messages according to the encoding parameters in the first encoding task. In one possible manner, the data processing unit in the target hardware engine can fill the M original messages according to the original message quantity M in the encoding parameters to obtain M equal-length messages; the data processing unit organizes the M equal-length messages into a matrix to be encoded, wherein one row of the matrix to be encoded is an equal-length message; the data processing unit sends the matrix to be encoded to the encoding and decoding unit; the encoding and decoding matrix unit multiplies the corresponding generation matrix with the matrix to be encoded to obtain R redundant messages, so as to implement this step 806. Figure 1 The process of multiplying the generated matrix and the matrix to be encoded is introduced in the embodiment of the present application, and this process is not repeated here.

[0131] The generation matrix can be generated by a matrix generator in the target hardware engine and sent to the codec unit. The process of the matrix generator generating the corresponding generation matrix is ​​as follows: the controller in the target hardware engine can obtain the redundant message amount R and the original message amount M from the first encoding task, and send the obtained redundant message amount R and the original message amount M to the matrix generator, the matrix generator generates a generation matrix of (M+R)*M according to the redundant message amount R and the original message amount M, and sends the (M+R)*M generation matrix to the codec unit.

[0132] 807. The target hardware engine stores the R redundant messages in the memory.

[0133] After the codec unit in the target hardware engine generates the R redundant messages, the R redundant messages are cached in the cache unit. The cache unit sends a first message storage request to the memory. The first message storage request carries the storage addresses of the R redundant messages and the R redundant messages, wherein the storage addresses of the R redundant messages include the storage address of each redundant message. After the memory receives the first message storage request, the memory stores the R redundant messages in the storage addresses of the R redundant messages.

[0134] 808. When the storage of the R redundant messages is completed, the target hardware engine adds the storage addresses of the R redundant messages in the first encoding task to obtain first encoding completion information of the M original messages, where the first encoding completion information is used to indicate that the encoding of the M original messages is completed.

[0135] The target hardware engine can also replace the encoding identifier in the first encoding task with an encoding completion identifier, and the encoding completion identifier is used to complete the encoding of the original message. The embodiment of the present application does not specifically limit the representation method of the encoding completion identifier. Since the first encoding task includes the storage addresses and encoding parameters of M first messages, the first encoding completion information can include the storage addresses of R redundant messages, the storage addresses of M original messages, and encoding parameters. When the first encoding task carries the priority of the first data stream, the first encoding completion information also includes the priority of the first data stream.

[0136] 809. The target hardware engine stores the first encoding completion information in a first target receiving queue, where the first target receiving queue is used to store the encoding completion information task of the to-be-processed data stream of the first network device.

[0137] The first network device may preset multiple receiving queues, each receiving queue is used to store the encoding completion information of the data stream to be processed by the first network device, and the first target receiving queue may be any queue in the multiple receiving queues. The multiple receiving queues may be located in any one of the memory, processor and target hardware engine of the first network device.

[0138] In some possible implementations, the first network device may set a priority for each receiving queue, and each receiving queue is used to store encoding completion information of data streams with the same priority. Fig. 9 For example, Fig. 9 There are 1 receiving queue A with priority A and 1 receiving queue B with priority B in the memory, wherein priority A is higher than priority B. At this time, receiving queue A stores task completion information 3, 5 and 6 (in Fig. 9 The receiving queue B stores task completion information 1, 2, and 4, wherein task completion information 3, 5, and 6 are coded completion information with a priority of A, respectively, and task completion information 1, 2, and 4 (in Fig. 9 The “completion information 3, 5 and 6” in the figure are respectively a coding completion information with a priority of B.

[0139] In some possible implementations, the target hardware engine adds the first encoding completion information to the first target receiving queue in the memory according to the priority of the first data stream, and the priority of the first target receiving queue is equal to the priority of the first data stream. Specifically, the target hardware engine can determine the first target receiving queue corresponding to the priority of the first data stream in the memory according to the priority of the first data stream, and when the number of encoding completion information in the first target receiving queue is less than the second target number, the target hardware engine adds the first encoding completion information to the first target receiving queue, wherein the second target number is the maximum number of encoding completion information that can be stored in the first target receiving queue. When the number of encoding completion information in the first target receiving queue is equal to the second target number, the FEC software interface queries whether the number of encoding completion information in the first target receiving queue is less than the second target number at intervals of the second preset time length, and once it is less than the second target number, the first encoding completion information is added to the first target receiving queue. The embodiment of the present application does not specifically limit the second preset time length.

[0140] 810. The processor reads first encoding completion information from the first target receiving queue.

[0141] This step 810 can be performed by the FEC software interface of the processor. The FEC software interface can poll each receiving queue according to the priority. The FEC software interface can first determine whether the encoding completion information can be obtained in the first target receiving queue by polling. In some possible implementations, the FEC software interface sequentially queries each receiving queue according to the order of priority to see whether there is other encoding completion information, and each queue in each receiving queue corresponds to a priority; in each first receiving queue, when there is no other encoding completion information in the queue with a higher priority than the first target receiving queue, the first encoding completion information is obtained from the first target receiving queue.

[0142] The process of the FEC software interface polling each receiving queue can be: the FEC software interface queries the first receiving queue with the highest priority among the various receiving queues. When there is encoding completion information in the first receiving queue, the FEC software interface obtains an encoding completion information from the head of the first receiving queue, and executes the following step 811 according to the encoding completion information; every third preset time period, the FEC software interface queries the first receiving queue again. When the encoding completion information is still stored in the first receiving queue, a new encoding completion information is obtained from the head of the first receiving queue again. Until there is no encoding task stored in the first sending queue, the FEC software interface queries whether the second receiving queue corresponding to the next priority among the multiple first receiving queues has encoding completion information. When encoding completion information is stored, the encoding completion information is obtained from the second receiving queue, and the following step 811 is executed. When there is no encoding completion information stored in the second receiving queue, the third receiving queue second only to the second priority is queried according to priority.

[0143] When the encoding completion information in a first receiving queue is obtained by the FEC software interface, the next encoding completion information in the first receiving queue becomes the head of the first receiving queue, so that the FEC software interface can obtain the next encoding completion information from the head of the first receiving queue next time.

[0144] 811. The processor obtains M original messages and R redundant messages from the memory according to the first encoding completion information.

[0145] This step 811 can be performed by the FEC software interface in the processor. The FEC software interface can obtain the storage addresses of the R redundant messages, the storage addresses of the M original messages, and the encoding parameters from the first encoding completion information; the FEC software interface sends a second message acquisition request to the memory, and the second message acquisition request carries the storage addresses of the R redundant messages and the storage addresses of the M original messages. When the memory receives the second message acquisition request, the memory returns the R redundant messages and the M original messages to the FEC software interface according to the storage addresses of the R redundant messages and the storage addresses of the M original messages in the second message acquisition request.

[0146] 812. The processor sends M original messages and R redundant messages to the second network device.

[0147] This step 812 can be performed by the FEC software interface in the processor. After the FEC software interface obtains the R redundant messages and the M original messages returned by the memory, the FEC software interface encapsulates the R redundant messages and the M original messages into one FEC message according to the encoding parameters in the first encoding completion information. In some possible implementations, this step 812 can be implemented by the process shown in the following steps 8121-8123.

[0148] Step 8121, the FEC software interface fills the messages whose sizes are smaller than the target size among the M original messages according to the target size in the encoding parameters, and obtains M messages of equal length, each of which has a size of the target size.

[0149] Step 8122: The FEC software interface adds an FEC message header to each equal-length message to obtain M original FEC messages, and adds an FEC message header to each redundant message to obtain R redundant FEC messages. The FEC message header carries the encoding parameters of the M original messages.

[0150] For example, Fig.10 In the schematic diagram of an FEC message provided in the embodiment of the present application, when Fig.10 When the payload message of the FEC message in the first data stream is an equal-length message formed by the original messages in the first data stream, the FEC message is an original FEC message; when the payload message of the FEC message is a redundant message, the FEC message is a redundant FEC message.

[0151] The FEC message header is used to indicate the encoding status of the M original messages. The FEC message header carries M original encoding parameters, such as Fig.10 The FEC message header in carries the original message amount M=4, the redundant message amount R=2, and the target size L=30MB. The FEC message header may also carry the target identifier of the M original messages, which is used to indicate the number of times the original messages in the first data stream are encoded, for example, Fig.10 If the target identifier in the FEC message header is 1.2, it indicates that the first network device performs a second encoding on the message in the first data stream 1, and the M original messages are the original messages in the first data stream used for the second encoding.

[0152] The FEC message header may also carry a priority identifier, an algorithm identifier, a sequence number of each message in the first data stream of the M original messages, a sequence number of each equal-length message in the matrix to be encoded, and a sequence number of each redundant message in the encoding matrix, wherein the priority identifier is used to indicate the priority of the first data stream, the algorithm identifier is used to indicate the algorithm used by the first network device in the encoding process, the sequence number of each equal-length message in the matrix to be encoded is the row number of each equal-length message in the matrix to be encoded, and the sequence number of each redundant message in the encoding matrix is ​​the row number of each redundant message in the encoding matrix. For example, in Fig.10 In the FEC header, the sequence numbers of the original messages A0-A3 in the first data stream are 10, 11, 12 and 13 respectively; the sequence numbers of the equal-length messages M0-M3 are 0, 1, 2 and 3 respectively; and the sequence numbers of the redundant messages R0-R1 are 4 and 5 respectively. Fig.10 The example of FEC header is Figure 1 The encoding calculation process shown is based on.

[0153] Step 8123: The processor sends M original FEC messages and R redundant FEC messages.

[0154] Since the message headers of the M original FEC messages and the R redundant FEC messages are the same, the M original FEC messages and the R redundant FEC messages can be regarded as a group of FEC messages. For any FEC message among the M original FEC messages and the R redundant FEC messages, after the FEC software interface obtains any FEC message, it outputs the any FEC message to the TM engine in the first network device. Since the FEC software interface can continuously output FEC messages to the TM engine, the TM engine can form a coding stream with the first data stream. After the TM engine manages the coding stream, it outputs the managed coding stream to the PPE. The PPE forwards the managed coding stream to the GE / GXE network port. The GE / GXE network port outputs the managed coding stream to the second network device so that the second network device can obtain the coding stream from the coding stream.

[0155] To further illustrate the interaction between the processor, target hardware engine, and memory in the first network device during the encoding process, see Fig.11 The embodiment of the present application shown provides a flowchart of FEC encoding, which specifically includes steps 1101-11106.

[0156] Step 1101: The UDP agent sends a storage completion message to the FEC software interface.

[0157] Step 1102: When the number of storage completion messages received by the FEC software interface is equal to M, a first encoding task is generated and sent to the task cache in the memory.

[0158] The task cache includes multiple sending queues and multiple receiving queues, and the FEC software interface can send the first encoding task to the first target sending queue corresponding to the priority.

[0159] Step 1103: The target hardware engine obtains the first encoding task from the first target sending queue of the task cache, and reads M original messages from the memory according to the storage address in the first encoding task.

[0160] Step 1104: The target hardware engine performs FEC encoding on the M original messages read to obtain R redundant messages. The target hardware engine stores the R redundant messages in the memory and sends the first encoding completion information to the first target receiving queue in the task cache.

[0161] Step 1105, the FEC software interface reads the first encoding completion information from the first target receiving queue in the task cache, and according to the first completion information, reads the M original messages and R redundant messages in the memory, and encapsulates the FEC message headers in the M original messages and the R redundant messages respectively to obtain the FEC message.

[0162] Step 1106: The FEC software interface sends an FEC message.

[0163] The process shown in the above steps 807-812 is a process in which the target processing engine, the memory, and the processor cooperate to send M original messages and R redundant messages to the second network device. In some possible implementations, the target processing engine can also directly send the M original messages and R redundant messages to the processor, and the processor executes the process shown in 8122-8123 to achieve the transmission of M original messages and R redundant messages. In some possible implementations, the target processing engine can also perform the process shown in 8122-8123 by itself, so as to achieve the transmission of M original messages and R redundant messages.

[0164] The method provided in the embodiment of the present application performs FEC encoding on the M original messages in the first data stream directly in the target hardware engine of the first network device without performing FEC encoding in the processor, thereby reducing the CPU overhead and improving the encoding efficiency of the first network device, thereby making it easier for the first network device to meet the requirements of high throughput during message transmission. In addition, the first network device can perform the above-mentioned dynamic adjustment on the encoding parameters, thereby improving the encoding efficiency of the first network device by adjusting the encoding parameters.

[0165] After the second network device obtains the coded stream, if the original FEC message in the coded stream is lost, the second network device can recover the lost FEC message by decoding the FEC message that is not lost. The processing process may be: after the second network device obtains any coded stream, it may store the any coded stream in the memory; if the number of original FEC messages in any group of FEC messages in any coded stream is less than the original message amount M during encoding, it indicates that there is packet loss in the transmission process of any group of FEC messages, then the processor in the second network device may generate a decoding task for indicating decoding of any group of FEC messages, and the processor may send the decoding task to the memory; the target hardware engine in the second network device reads the decoding task in the memory, and performs FEC encoding on any group of FEC messages stored in the memory according to the encoding task, and restores the lost original messages in any group of FEC messages, and the target hardware engine stores the restored original messages in the memory; then, the processor may obtain the original FEC messages and the restored original messages that are not lost in any group of FEC messages from the memory, and remove the FEC message headers of the original FEC messages that are not lost to obtain the original messages that are not lost. To further illustrate the processing process, see Fig.12 A flowchart of a message processing method provided by an embodiment of the present application is shown, wherein the second network device may include a processor and a target hardware engine, and the process of the method includes steps 1201-1213.

[0166] 1201. The processor obtains a first group of FEC messages from a received first data stream, where all FEC messages in the first group of FEC messages have a same FEC message header, and the FEC message header includes an original message volume M of FEC encoding.

[0167] The second network device can obtain multiple encoded streams, the first data stream can be any encoded stream in the pair of encoded streams, the first data stream can be composed of multiple groups of FEC messages, the first group of FEC messages is any group of FEC messages in the multiple groups of FEC messages, and the first group of FEC messages includes M original FEC messages output by the first network terminal after one encoding and R redundant FEC messages.

[0168] When the second network device starts to receive the first data stream, the second network device stores each FEC message in the memory of the second network device each time it receives a FEC message in the first data stream. In some possible implementations, the GE / GXE network port of the second network device receives the FEC message and sends the FEC message to the PPE in the second network device. The PPE stores the FEC message in the memory, records the storage address of the FEC message, and sends a storage completion message to the NP engine of the second network terminal. The storage completion message carries the storage address of the FEC message. After the NP engine receives the storage completion message, the storage completion message can be sent to the protocol stack in the CPU of the second network device. Therefore, the UDP agent can collect each storage completion message from the protocol stack and send the collected storage completion message to the FEC software interface of the second network device. The FEC software interface obtains each storage completion message every third preset time. The FEC software interface reads the message header of the FEC message at the storage address corresponding to the memory according to the storage address carried by each storage message, obtains multiple message headers, and compares the multiple message headers to obtain the same message header, and determines the FEC messages with the same message header as a group of FEC messages. That is, for the FEC messages in the first data stream, the second network device uses the messages with the same FEC message header in the FEC messages newly stored in the third preset time as the first group of FEC messages every third preset time. The embodiment of the present application does not specifically limit the third preset time. Since the FEC message header carries a target identifier, which is used to indicate the number of encodings, in some possible implementations, when the target identifiers in the message headers of multiple FEC messages are the same, it can also be said that these multiple FEC messages are messages obtained after the same encoding, that is, a group of FEC messages.

[0169] 1202. When the number of original messages in the first group of FEC messages is less than the original message amount M, the processor generates a first decoding task according to the first group of FEC messages, where the first decoding task is used to instruct decoding of the first group of FEC messages.

[0170] This step 1202 can be performed by the FEC software interface in the processor. After the FEC software interface determines the first group of FEC messages, the second network device can obtain the encoding parameters from the message header of a message in the first group of FEC messages. The original message amount M in the encoding parameters is the message amount of the original FEC messages initially included in the first group of FEC messages. Since each original FEC message corresponds to an original message during encoding, when the message amount of the original FEC messages in the first group of FEC messages is less than the original message amount M, that is, the number of original messages in the first group of FEC messages is less than the original message amount M, it means that at least one original FEC message in the first group of FEC messages is lost, that is, in the process of transmitting the first group of FEC messages from the first network device to the second network device, part of the original FEC messages are lost, that is, the original messages during encoding are lost. In order to restore the first data stream before encoding, the FEC software interface can generate a first decoding task so that the target hardware engine decodes the non-lost FEC messages in the first group of FEC messages according to the first decoding task to restore the lost original FEC messages.

[0171] The first decoding task includes the storage address of the first group of FEC messages or the first group of FEC messages, so that the target hardware engine can obtain the first group of FEC messages from the memory according to the storage address of the first group of FEC messages, or so that the target hardware engine can directly obtain the first group of FEC messages from the first decoding task. When the first data stream has a priority, the first decoding task may also include the priority of the first data stream.

[0172] When the message volume of the original FEC messages in the multiple FEC messages is equal to the original message volume M in the encoding parameter, it means that the original FEC messages in the first group of FEC messages are not lost, and the second network device can execute the following step 1211.

[0173] 1203. The processor stores the first decoding task in a second target sending queue, where the second target sending queue is used to store decoding tasks of a data stream to be processed of a second network device, where the data stream to be processed of the network device includes the first data stream.

[0174] This step 1203 can be performed by the FEC software interface in the processor. The data stream to be processed in this step 1203 is also the coded stream to be processed. The second network device can preset multiple sending queues, each sending queue is used to store the decoding tasks of the data stream to be processed of the second network device, and the second target sending queue can be any queue in the multiple sending queues. The multiple sending queues can be located in any one of the memory, processor and target hardware engine of the second network device.

[0175] In some possible implementations, the second network device may set a priority for each sending queue, and each sending queue is used to store decoding tasks of data streams of the same priority. In some possible implementations, this step 1203 may include: according to the priority of the first data stream, the processor adds the first decoding task to the second target sending queue, and the priority of the second target sending queue is equal to the priority of the first data stream. The process of the processor adding the first decoding task to the second target sending queue is the same as the process of the processor adding the first encoding task to the first target sending queue in step 803. Here, the specific process of adding the first decoding task to the second target sending queue is not repeated in the embodiment of the present application.

[0176] 1204. The target hardware engine reads the first decoding task from the second target sending queue.

[0177] The target hardware engine can first poll each second sending queue in the memory according to the priority level to determine whether the target hardware engine wants to send from the second target sending queue. In some possible implementations, the target hardware engine queries each sending queue in turn according to the priority level of each sending queue. Each queue in each sending queue corresponds to a priority level. In each sending queue, when there are no other decoding tasks in the queue with a higher priority than the second target sending queue, the target hardware engine reads the first decoding task from the second target sending queue.

[0178] The process of the target hardware engine obtaining the first decoding task by polling each sending queue is the same as the process of the target hardware engine obtaining the first encoding task by polling each sending queue in step 804. Here, the embodiment of the present application does not elaborate on the process of obtaining the first decoding task by polling each sending queue.

[0179] 1205. The target hardware engine obtains the first group of FEC messages from the memory according to the storage address of the first group of FEC messages in the first decoding task.

[0180] The process shown in step 1205 is the same as the process shown in step 805, and the embodiment of the present application does not repeat step 1205. In some possible implementations, when the first decoding task carries the first group of FEC messages, the target hardware engine can directly obtain the first group of FEC messages from the first decoding task without obtaining it from the memory. The first group of FEC messages obtained by the target hardware engine, that is, the FC messages that are not lost in the first group of FEC messages, include the original FEC messages that are not lost and the redundant FEC messages that are not lost.

[0181] 1206. The target hardware engine performs FEC decoding on the original message in the first group of FEC messages and the redundant message of the original message to obtain the lost original message in the first group of FEC messages.

[0182] When the target hardware engine obtains the first group of FEC messages, the data processing unit in the target hardware engine can remove the message headers of the original FEC messages and the message headers of the redundant FEC messages in the first group of FEC messages to obtain multiple equal-length messages and at least one redundant message, each of which is an original message lost in the first group of FEC messages; the data processing unit can form a recovery matrix with the multiple equal-length messages and the at least one redundant message, and send the recovery matrix to the encoding and decoding unit, and the matrix generator constructs the corresponding target checksum. Matrix, the corresponding target check matrix is ​​sent to the encoding and decoding unit; the encoding and decoding unit multiplies the inverse matrix of the corresponding target check matrix with the recovery matrix to obtain the matrix to be encoded; then according to the sequence number of each equal-length message and the sequence number of the redundant message in the FEC message header, it can be determined which equal-length messages are lost and which redundant messages are lost, that is, which original FEC messages are lost or which redundant FEC messages are lost, so that the lost equal-length messages can be obtained from the matrix to be encoded, thereby obtaining the lost original messages, so as to implement this step 1206. Figure 2 The process of multiplying the inverse matrix of the target inspection matrix and the recovery matrix is ​​introduced in the embodiment of the present application, and this process is not repeated here.

[0183] Among them, the process of the matrix generator constructing the corresponding target check matrix is ​​as follows: the controller in the target hardware engine determines the amount of lost redundant FEC messages according to the redundant message amount R in the coding parameters in the message header, and the amount of lost redundant FEC messages is the difference between the redundant message amount R and the amount of redundant FEC messages in multiple FEC messages; the controller determines the amount of lost original FEC messages according to the original message amount M in the coding parameters in the FEC message header and the amount of original FEC messages in multiple FEC messages, and the amount of lost original FEC messages is the difference between the original message amount M and the amount of original FEC messages in multiple FEC messages; the controller sends the amount of lost redundant FEC messages and the amount of lost original FEC messages to the matrix generator, and the matrix generator constructs the corresponding target check matrix according to the amount of lost redundant FEC messages and the amount of lost original FEC messages, and sends the corresponding target check matrix to the encoding and decoding unit.

[0184] The process shown in steps 1205-1206 is a process of performing FEC decoding on the original message in the first group of FEC messages and the redundant message of the original message according to the first decoding task to obtain the lost original message in the first group of FEC messages.

[0185] 1207. The target hardware engine stores the lost original messages in the first group of FEC messages in the memory.

[0186] The process of step 1207 is the same as that of step 807, and the embodiment of the present application will not elaborate on step 1207.

[0187] 1208. When the lost original message is stored, the target hardware engine adds the storage address of the lost original message to the first decoding task to obtain first decoding completion information, where the first decoding completion information is used to indicate that the decoding of the first group of FEC messages is completed.

[0188] The first decoding completion information carries the storage address of the lost original message and the original FEC message in the first group of FEC messages. When the first data stream has a priority, the first decoding completion information also carries the priority of the first data stream. The process shown in this step 1208 is the same as the process of generating the first encoding completion information in step 808. Here, this embodiment of the present application does not repeat this step 1208.

[0189] 1209. The target hardware engine adds the first decoding completion information to the second target receiving queue, and the second target receiving queue is used to store the decoding completion information of the to-be-processed encoded stream of the second network device.

[0190] The second network device may preset multiple receiving queues, each receiving queue is used to store decoding completion information of the to-be-processed coded stream of the second network device, and the second target receiving queue may be any queue in the multiple receiving queues. The multiple receiving queues may be located in any one of the memory, processor and target hardware engine of the second network device.

[0191] In some possible implementations, the second network device may set a priority for each receiving queue. In some possible implementations, the first decoding completion information is added to the second target receiving queue in the memory according to the priority of the coded stream, and the priority of the second target receiving queue is equal to the priority of the coded stream. The specific adding process is the same as the process of adding the first encoding completion information to the first target receiving queue in step 809.

[0192] 1210. The processor reads first decoding completion information from the second target receiving queue.

[0193] This step 1210 can be performed by the FEC software interface in the processor. The FEC software interface can poll each second receiving queue according to the priority level. The FEC software interface can first determine whether the first decoding completion information can be obtained in the second target receiving queue by polling. In some possible implementations, the second receiving queues are sequentially queried according to the order of priority to see whether there are other decoding completion information. Each queue in each second receiving queue corresponds to a priority; in each second receiving queue, when there is no other decoding completion information in the queue with a higher priority than the second target receiving queue, the decoding completion information is obtained from the second target receiving queue. The process of the FEC software interface polling each receiving queue in this step 1210 is the same as the process of the FEC software interface polling each receiving queue in step 810.

[0194] 1211. The processor obtains the original FEC message and the lost original message in the first group of FEC messages from the memory according to the first decoding completion information.

[0195] The process shown in this step 1211 is the same as the process of obtaining M original messages and R redundant messages in step 811. Here, this embodiment of the application does not elaborate on this step 1211.

[0196] 1212. The processor restores the data stream before encoding the first data stream according to the original FEC messages in the first group of FEC messages and the lost original messages.

[0197] This step 1212 may be performed by the FEC software interface in the processor. The FEC software interface may first remove the message headers of the original FEC messages that are not lost in the first group of FEC messages, wait until a plurality of equal-length messages are received, and then restore the data stream before the first data stream is encoded based on the plurality of equal-length messages and the lost original messages. In some possible implementations, this step 1212 may be implemented by the process shown in the following steps 12A-12C.

[0198] Step 12A: For the original FEC messages in the first group of FEC messages, the FEC software interface removes the FEC message header of each original FEC message to obtain multiple messages of equal length.

[0199] Step 12B: The FEC software interface removes the data filled in the multiple equal-length messages and the lost original messages to obtain M original messages in the data stream before the first data stream is encoded.

[0200] Step 12C: The FEC software interface sorts the M original messages according to the sequence numbers of the original messages carried in the FEC message headers and the sizes of the sequence numbers to obtain the data stream before the first data stream is encoded.

[0201] 1213. The processor sends the data stream to the second terminal.

[0202] This step 1213 is similar to step 8123, and the embodiment of the present application will not elaborate on this step 1213.

[0203] To further illustrate the interaction between the processor, target hardware engine, and memory in the second network device during the decoding process, see Fig.13 The embodiment of the present application shown provides a flowchart of FEC decoding, which specifically includes steps 1301-1306.

[0204] Step 1301: The UDP agent sends a storage completion message of each FEC message to the FEC software interface.

[0205] Step 1302: When the FEC software interface receives a storage completion message for a group of FEC messages, if an original FEC message is lost in the group of FEC messages, a first decoding task is generated based on the received group of FEC messages, and the first decoding task is sent to the task cache in the memory.

[0206] The task cache includes multiple sending queues and multiple receiving queues, and the FEC software interface can send the first decoding task to the second target sending queue corresponding to the priority.

[0207] Step 1303: The target hardware engine obtains the first decoding task from the second target sending queue of the task cache, and reads a group of FEC messages from the memory according to the storage address in the first decoding task.

[0208] Step 1304: The target hardware engine decodes the read set of FEC messages to obtain the lost original messages, stores the lost original messages in the memory, and adds the first decoding completion information to the second target receiving queue in the memory.

[0209] Step 1305, the FEC software interface reads the first decoding completion information from the second target receiving queue in the task cache, and based on the first decoding completion information, reads a group of FEC messages and the lost original messages in the memory, and removes the message headers of a group of FEC messages to obtain messages of equal length.

[0210] Step 1306: The FEC software interface processes the equal-length message to obtain a data stream, and outputs the data stream.

[0211] The process shown in the above steps 1207-1213 is a data flow process sent to the second terminal in a coordinated manner by the target processing engine, the memory, and the processor. In some possible implementations, the target processing engine can also directly send the first group of FEC messages and the lost original messages to the processor, and the processor executes the process shown in 1212-1213. In some possible implementations, the target processing engine can also execute the process shown in 1212-1213 by itself.

[0212] The method provided in the embodiment of the present application directly performs FEC decoding on the FEC messages that are not lost in the first group of FEC messages in the target hardware engine of the second network device without performing FEC decoding in the CPU. Therefore, it is possible to reduce the CPU overhead and improve the decoding efficiency of the second network device, thereby making it easier for the second network device to meet the requirements of high throughput during message transmission.

[0213] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present disclosure, and will not be described in detail here.

[0214] When the message processing device provided in the embodiment of the present application processes the message, only the division of the above-mentioned functional modules is used as an example. In actual application, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the message processing method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0215] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0216] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A message processing method, characterized in that: Applied to a network device including a processor and a target hardware engine, the method includes: The processor generates a first encoding task according to M original messages in a first data stream to be processed, where M is a positive integer, and the first encoding task is used to instruct encoding of the M original messages; The processor adds the first encoding task to a first target sending queue according to the priority of the first data stream, where the first target sending queue is used to store encoding tasks of the to-be-processed data stream of the network device, the priority of the first target sending queue is equal to the priority of the first data stream, and the to-be-processed data stream of the network device includes the first data stream; The target hardware engine reads the first encoding task from the first target sending queue; The target hardware engine performs forward error correction (FEC) encoding on the M original messages according to the first encoding task to obtain R redundant messages, where R is a positive integer.

2. The method according to claim 1, characterized in that: The target hardware engine reading the first encoding task from the first target sending queue includes: The target hardware engine sequentially queries whether there is an encoding task in each sending queue according to the order of priority of each sending queue, and each queue in the sending queue corresponds to a priority; In each of the sending queues, when there is no encoding task in a queue with a higher priority than the first target sending queue, the target hardware engine reads the first encoding task from the first target sending queue.

3. The method according to claim 1, characterized in that Before the processor generates the first encoding task according to the M original messages in the stored first data stream to be processed, the method further includes: The network device stores the received original message in the first data stream into a memory of the network device; If the amount of uncoded original messages of the first data stream in the memory of the network device is equal to or greater than M, the processor obtains the M original messages from the uncoded original messages of the first data stream.

4. The method according to any one of claims 1 to 3, characterized in that: The first encoding task includes the storage addresses of the M original messages, or the first encoding task includes the storage addresses of the M original messages and the priority of the first data stream, or the first encoding task includes the M original messages, or the first encoding task includes the M original messages and the priority of the first data stream.

5. A message processing method, characterized in that: Applied to a network device including a processor and a target hardware engine, the method includes: The processor obtains a first group of FEC messages from the received first data stream, wherein all FEC messages in the first group of FEC messages have the same FEC message header, and the FEC message header includes an original message amount M of FEC encoding; When the number of original messages in the first group of FEC messages is less than the original message amount M, the processor generates a first decoding task according to the first group of FEC messages, where the first decoding task is used to instruct decoding of the first group of FEC messages; The processor adds the first decoding task to a second target sending queue according to the priority of the first data flow, the second target sending queue is used to store decoding tasks of the to-be-processed data flow of the network device, the priority of the second target sending queue is equal to the priority of the first data flow, and the to-be-processed data flow of the network device includes the first data flow; The target hardware engine reads the first decoding task from the second target sending queue; The target hardware engine performs FEC decoding on the original messages in the first group of FEC messages and the redundant messages of the original messages according to the first decoding task to obtain the lost original messages in the first group of FEC messages.

6. The method according to claim 5, characterized in that The target hardware engine reading the first decoding task from the second target sending queue includes: The target hardware engine sequentially queries whether there are decoding tasks in each sending queue according to the priority of each sending queue, and each queue in the sending queue corresponds to a priority; In each of the sending queues, when there are no other decoding tasks in a queue with a higher priority than the second target sending queue, the target hardware engine reads the first decoding task from the second target sending queue.

7. A message processing device, characterized in that: The device comprises: A processor, configured to generate a first encoding task according to M original messages in a first data stream to be processed, where M is a positive integer, and the first encoding task is used to instruct encoding of the M original messages; The processor is further configured to add the first encoding task to a first target sending queue according to the priority of the first data stream, the first target sending queue being used to store encoding tasks of the data stream to be processed of the device, the priority of the first target sending queue being equal to the priority of the first data stream, and the data stream to be processed of the device including the first data stream; The target hardware engine is further configured to read the first encoding task from the first target sending queue; The target hardware engine is used to perform forward error correction FEC encoding on the M original messages according to the first encoding task to obtain R redundant messages, where R is a positive integer.

8. The device according to claim 7, characterized in that The target hardware engine is used to: The target hardware engine sequentially queries whether there are encoding tasks in each sending queue according to the order of priority of each sending queue, and each queue in the sending queue corresponds to a priority; In each of the sending queues, when there is no encoding task in a queue with a higher priority than the first target sending queue, the first encoding task is read from the first target sending queue.

9. A message processing device, characterized in that: The apparatus includes a processor and a target hardware engine; The processor is configured to obtain a first group of FEC messages from a received first data stream, wherein all FEC messages in the first group of FEC messages have the same FEC message header, and the FEC message header includes an original message amount M of FEC encoding; When the number of original messages in the first group of FEC messages is less than the original message amount M, generating a first decoding task according to the first group of FEC messages, the first decoding task being used to instruct decoding of the first group of FEC messages; The processor is further configured to add the first decoding task to a second target sending queue according to the priority of the first data stream, the second target sending queue being used to store decoding tasks of the data stream to be processed of the device, the priority of the second target sending queue being equal to the priority of the first data stream, and the data stream to be processed of the device including the first data stream; The target hardware engine is further used to read the first decoding task from the second target sending queue; The target hardware engine is used to perform FEC decoding on the original messages in the first group of FEC messages and the redundant messages of the original messages according to the first decoding task, so as to obtain the lost original messages in the first group of FEC messages.

10. The device according to claim 9, characterized in that The target hardware engine is used to: According to the priority of each sending queue, query in turn whether there is a decoding task in each sending queue, each queue in the sending queue corresponds to a priority; In each of the sending queues, when there are no other decoding tasks in a queue with a higher priority than the second target sending queue, the first decoding task is read from the second target sending queue.

11. A chip, characterized in that: The method comprises a processor and a target hardware engine, wherein the processor is used to implement the processor in the method according to any one of claims 1 to 4, and the target hardware engine is used to implement the target hardware engine in the method according to any one of claims 1 to 4.

12. A chip, characterized in that: The method comprises a processor and a target hardware engine, wherein the processor is used to implement the processor in the method according to any one of claims 5 to 6, and the target hardware engine is used to implement the target hardware engine in the method according to any one of claims 5 to 6.