Message forwarding method and device, electronic equipment and readable storage medium
By obtaining the type and header length of the video network message for position offset, the problem of poor applicability of video network message forwarding is solved, and efficient message forwarding and processor core utilization are achieved.
Patent Information
- Application Number
- CN202411033656.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-15
AI Technical Summary
Existing technologies cannot effectively forward messages based on the video network protocol, resulting in poor applicability of message forwarding.
By obtaining the type of the message to be forwarded, the video network header and preset reading position are determined. The position is offset according to the length of the video network header, the updated reading position is obtained, and the message is forwarded to the corresponding processor core.
It improves the applicability of message forwarding, accurately obtains the tuple information of video network messages and forwards them to the appropriate processor core, thereby improving the utilization of processor cores and message forwarding performance.
Smart Images

Figure CN118972478A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of message processing, and in particular to a message forwarding method, a message forwarding device, an electronic device and a computer-readable storage medium. Background Art
[0002] Router devices need to forward data packets to the processor core, which can further process and make decisions on the packets, such as protocol parsing, security checks, data conversion, etc. Router devices generally use multi-core central processing units (CPUs), which make the processors more capable of processing packets.
[0003] At present, in order to improve the forwarding performance of data packets, different processor cores are determined according to tuple information of different packets, and then different packets are forwarded to different processor cores for processing.
[0004] However, the current solution is only applicable to messages based on the Internet Protocol. When the message is based on other protocols, the tuple information cannot be obtained, and the message cannot be forwarded to the processor core. Therefore, the applicability of current message forwarding is poor. Summary of the invention
[0005] In view of the above problems, embodiments of the present application are proposed to provide a message forwarding method, a message forwarding device, an electronic device and a computer-readable storage medium that overcome the above problems or at least partially solve the above problems.
[0006] In a first aspect, an embodiment of the present application discloses a message forwarding method, the method comprising:
[0007] Obtaining a message to be forwarded, and determining a message type of the message to be forwarded;
[0008] In the case where it is determined that the message to be forwarded is of the first type, obtaining a visual networking header and a preset reading position in the message to be forwarded; the first type of message is a message based on the visual networking protocol; the preset reading position is used to determine the initial position of the tuple information in the message;
[0009] According to the header length of the visual network header, the preset reading position is offset to obtain an updated reading position;
[0010] In the message to be forwarded, the first tuple information recorded in the updated read position is obtained, and the message to be forwarded is forwarded to a first processor core corresponding to the first tuple information.
[0011] In a second aspect, an embodiment of the present application discloses a message forwarding device, the device comprising:
[0012] A message type module, used to obtain a message to be forwarded and determine the message type of the message to be forwarded;
[0013] The first type module is used to obtain the visual networking header and the preset reading position in the message to be forwarded when it is determined that the message to be forwarded is of the first type; the first type of message is a message based on the visual networking protocol; the preset reading position is used to determine the initial position of the tuple information in the message;
[0014] A position offset module, used for offsetting the preset reading position according to the header length of the visual networking header to obtain an updated reading position;
[0015] The first forwarding module is used to obtain the first tuple information recorded in the updated read position in the message to be forwarded, and forward the message to be forwarded to the first processor core corresponding to the first tuple information.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the message forwarding method described in the first aspect is implemented.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program that enables a processor to execute the message forwarding method as described in the first aspect.
[0018] The embodiments of the present invention include the following advantages:
[0019] In an embodiment of the present invention, by obtaining a message to be forwarded, the message type of the message to be forwarded is determined; when the message to be forwarded is of the first type, the visual network header and the preset reading position in the message to be forwarded are obtained; according to the header length of the visual network header, the preset reading position is offset to obtain an updated reading position; in the message to be forwarded, the first tuple information recorded in the updated reading position is obtained, and the message to be forwarded is forwarded to the first processor core corresponding to the first tuple information. The position can be adaptively offset according to the specific type of the message, so as to adopt the updated reading position to obtain the tuple information, and then the message can be forwarded to the processor core according to the tuple information, thereby improving the applicability of message forwarding. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a step diagram of a message forwarding method of the present application;
[0021] Figure 2 It is a step diagram of another message forwarding method of the present application;
[0022] Figure 3 It is a schematic diagram of the message structure of the second type of message of the present application;
[0023] Figure 4 It is a schematic diagram of the message structure of the first type of message of the present application;
[0024] Figure 5 It is a flowchart of message forwarding of this application;
[0025] Figure 6 It is a structural block diagram of a message forwarding device of the present application;
[0026] Figure 7 It is a structural block diagram of an electronic device of the present application. DETAILED DESCRIPTION
[0027] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0028] Video Internet is a real-time network that can achieve real-time transmission of high-definition video and push many Internet applications towards high-definition video. Video Internet uses real-time high-definition video exchange technology, which can integrate the required services such as high-definition video conferencing, video monitoring, intelligent monitoring analysis, emergency command, digital broadcasting, delayed TV, online teaching, live broadcast, VOD (Video On Demand), TV mail, personal video recorder (PVR), intranet (self-run) channel, intelligent video broadcast control, information release and dozens of other video, voice, picture, text, communication, data and other services on a single system platform, and achieve high-definition quality video playback through TV or computer.
[0029] Figure 1 A message forwarding method is shown, comprising the following steps:
[0030] Step 101, obtaining a message to be forwarded, and determining the message type of the message to be forwarded;
[0031] In the embodiment of the present disclosure, the execution subject may be a message processing module in a router device for message forwarding, such as a network processor. When a message enters a router, the router obtains the message to be forwarded, and then determines the type of the message to be forwarded.
[0032] It is understandable that with the development of communication protocols, message types are diverse, different types of messages have different message structures, and the parameter information included in the message structure is also different. Therefore, the messages can be classified based on the parameters in the messages, and the classification method is not specifically limited here.
[0033] Step 102, when it is determined that the message to be forwarded is of the first type, obtaining a visual networking header and a preset reading position in the message to be forwarded; the first type of message is a message based on the visual networking protocol; the preset reading position is used to determine the initial position of the tuple information in the message;
[0034] In the embodiment of the present disclosure, the message type may include a first type, and the first type message may be a message based on the visual networking protocol, and the first type message carries a visual networking header. The first type of message is a visual networking message encapsulated by the visual networking protocol, and the visual networking header includes some communication information transmitted based on the visual networking protocol.
[0035] When it is determined that the message to be forwarded is of the first type, the visual networking header can be obtained in the message to be forwarded. And it is used to determine the initial position of the tuple information in the message. The initial position is predetermined, and the tuple information can be located in the message structure according to the initial position. It can be understood that the initial position can be directly applicable to other types of messages other than visual networking messages, such as TCP / IP messages based on Transmission Control Protocol / Internet Protocol (TCP / IP). In other types of messages, the tuple information in the message can be located directly based on the initial position.
[0036] Step 103, offsetting the preset reading position according to the header length of the visual network header to obtain an updated reading position;
[0037] In the embodiment of the present disclosure, in the embodiment of the present disclosure, when it is determined to be the first type, that is, the current message to be forwarded is a visual networking message. It can be understood that compared with other types of messages such as TCP / IP messages, visual networking messages additionally carry visual networking headers related to the visual networking protocol. Tuple information is also recorded at specific locations in the visual networking message.
[0038] However, the message structures of the visual network message and the TCP / IP message are different, and the difference in message structure may be caused by the visual network header. If the tuple information is read based on the preset reading position only applicable to TCP / IP messages, the tuple information in the visual network message cannot be obtained.
[0039] Therefore, the preset reading position can be offset according to the header length of the visual networking header, so that the data pointer used to read data can be offset from the preset reading position. Since the preset reading position corresponds to the tuple information of the TCP / IP message, and the difference in the message structure between the visual networking message and the TCP / IP message lies in the visual networking header. Then, after the offset of the header length of the visual networking header, the data pointer can reach the position where the tuple information of the visual networking message is located, that is, the reading position is updated.
[0040] For example, the header length of the visual network header can be 40 bytes, and a 40-byte position offset can be performed based on the preset reading position, and the data pointer position after the offset is the updated reading position.
[0041] By determining the header length of the visual networking header of the second type of message, and based on the preset reading position, performing a position offset corresponding to the header length of the visual networking header to obtain an updated reading position, the tuple information in the visual networking message can be accurately located, thereby improving the accuracy of message forwarding.
[0042] Step 104: Obtain the first tuple information recorded in the updated read position in the message to be forwarded, and forward the message to be forwarded to the first processor core corresponding to the first tuple information.
[0043] In an embodiment of the present disclosure, after determining the update read position, the first tuple information of the visual network message can be read based on the update read position, and then the first processor core corresponding to the first tuple information can be determined and forwarded to the first processor core. The first tuple information includes specific communication information, and the first tuple information can be a triplet or a quintuple. The communication information in the triplet can be the source IP address, the target IP address, and the protocol type, and the communication information in the quintuple can be the source IP address, the target IP address, the protocol type, the source port, and the target port.
[0044] The corresponding processor core can be determined according to different tuple information. A mapping relationship may be pre-established between different tuple information and processor cores, and the corresponding processor core can be determined according to a specific tuple information. How to determine the corresponding processor core based on the tuple information is not specifically limited here. After determining the first processor core corresponding to the first tuple information, the first type of message is forwarded to the first processor core corresponding to the first tuple information, and the first processor core performs subsequent processing on the first type of message.
[0045] It is understandable that the next message to be forwarded can still be of the first type, and the processor core corresponding to the next message to be forwarded can also be called the first processor core. However, since the tuple information of multiple first-type messages may be different, although they all correspond to the first processor core, the respective first processor cores may be different processor cores.
[0046] In summary, in the embodiment of the present invention, the message type of the message to be forwarded is determined by obtaining the message to be forwarded; when the message to be forwarded is of the first type, the visual network header and the preset reading position in the message to be forwarded are obtained; according to the header length of the visual network header, the preset reading position is offset to obtain an updated reading position; in the message to be forwarded, the first tuple information recorded in the updated reading position is obtained, and the message to be forwarded is forwarded to the first processor core corresponding to the first tuple information. The position can be adaptively offset according to the specific type of the message, so as to adopt the updated reading position to obtain the tuple information, and then the message can be forwarded to the processor core according to the tuple information, thereby improving the applicability of message forwarding.
[0047] Figure 2 is a flowchart of another message forwarding method provided by an embodiment of the present disclosure;
[0048] Step 201, obtaining a message to be forwarded, and determining the message type of the message to be forwarded;
[0049] Step 202, when it is determined that the message to be forwarded is of the first type, obtain a visual networking header and a preset reading position in the message to be forwarded; the first type of message is a message based on the visual networking protocol; the preset reading position is used to determine the initial position of the tuple information in the message;
[0050] Step 203, offsetting the preset reading position according to the header length of the visual network header to obtain an updated reading position;
[0051] Step 204: Obtain the first tuple information recorded in the updated read position in the message to be forwarded, and forward the message to be forwarded to the first processor core corresponding to the first tuple information.
[0052] For details of the above steps 201-204, please refer to Figure 1 The contents of the embodiments will not be repeated here.
[0053] Optionally, the method further includes:
[0054] Step 205, when it is determined that the message to be forwarded is of the second type, obtaining the second tuple information recorded in the preset reading position in the message to be forwarded; the second type of message is a message based on the Internet Protocol;
[0055] Step 206: forward the message to be forwarded to the second processor core corresponding to the second tuple information.
[0056] In the embodiment of the present disclosure, the second type of message may be a message based on the Internet protocol, for example, a TCP / IP message encapsulated by the TCP / IP protocol.
[0057] When it is determined to be a second type of message, that is, the current message to be forwarded is a TCP / IP message based on the Internet protocol, the second tuple information recorded in the message can be directly obtained from the message structure of the forwarded message according to the preset reading position.
[0058] The preset reading position is a fixed position, which is used to specify a position in the message, and the position records the tuple information. Since the message structure of the TCP / IP message is fixed, for different TCP / IP messages, based on the same preset reading position, the tuple information of each message can be obtained in different TCP / IP messages.
[0059] The process of forwarding the message to be forwarded to the second processor core corresponding to the second tuple information is similar to the process of forwarding the message to be forwarded to the first processor core corresponding to the first tuple information, which will not be described in detail here.
[0060] Optionally, the step 201 of obtaining a message to be forwarded, determining the message type of the message to be forwarded, includes:
[0061] Acquire a message to be forwarded, and determine characteristic parameters carried in a message structure of the message to be forwarded; the characteristic parameters are used to indicate the type of the message to be forwarded; at least some characteristic parameters are different between different types of messages to be forwarded;
[0062] According to the characteristic parameter, it is determined that the message to be forwarded is of the first type or the second type.
[0063] In the disclosed embodiment, a message to be forwarded is obtained, and characteristic parameters of the message are extracted from the message structure of the message to be forwarded. The characteristic parameters may indicate the type of the message to be forwarded, and at least some characteristic parameters may be different between different types of messages to be forwarded, and characteristic values of different characteristic parameters may also be different.
[0064] The characteristic parameter can be determined based on a specific field or byte sequence in the message, such as a protocol identifier, a version number, a source address, a destination address, a command or an operation code, etc. The specific type of the message can be determined based on one or more characteristic parameters or further based on the specific characteristic values of the characteristic parameters. For example, the protocol identifier can be used to determine whether the message to be forwarded is of the first type or the second type.
[0065] Optionally, when it is determined that the message to be forwarded is of the second type, the step of obtaining the second tuple information recorded in the preset reading position in the message to be forwarded includes:
[0066] When it is determined that the message to be forwarded is of the second type, obtaining a target header corresponding to the preset reading position in the message structure of the message to be forwarded;
[0067] A second five-tuple of information is read from the target header; the second five-tuple of information indicates a communication method corresponding to the second type.
[0068] In the embodiment of the present disclosure, the tuple information may be recorded in a TCP / IP header (TCP / IP header) of a TCP / IP message, that is, a target header. The preset reading position is used to indicate the target header in the message structure.
[0069] It is understandable that in a TCP / IP message, if the preset reading position is a point position, then this point can be the starting point of the TCP / IP header in the TCP / IP message, and the TCP / IP header can be read from the starting point to obtain the tuple information. If the preset reading position is a position range, then this position range can be the position range corresponding to the entire TCP / IP header in the TCP / IP message, and the entire position range can be directly read to obtain the tuple information.
[0070] Figure 3 It is a schematic diagram of the second type of message structure provided by an embodiment of the present disclosure; the second type of message structure includes a TCP / IP header 301, other headers 302, and data 303 carried in the message, and the preset reading position can be the starting point on the left side of the TCP / IP header 301.
[0071] When a TCP / IP message includes multiple headers, the corresponding target header, i.e., the TCP / IP header, can be determined according to the preset reading position. When obtaining the tuple information recorded in the TCP / IP message, the data pointer is moved to the preset reading position to read the five-tuple information in the TCP / IP header.
[0072] Optionally, the step of obtaining the first tuple information recorded in the updated read position in the message to be forwarded includes:
[0073] Sub-step 2041, in the message structure of the message to be forwarded, according to the updated reading position, obtaining a target header corresponding to the updated reading position;
[0074] Sub-step 2042, obtaining a first five-tuple of information in the target header; the first five-tuple of information represents a communication mode corresponding to the first type.
[0075] In the embodiment of the present disclosure, since the difference in the message structure between the first type and the second type may be in the visual networking header, a TCP / IP header may also exist in the first type of visual networking message, and the tuple information of the visual networking message may also be recorded in the TCP / IP header.
[0076] After determining the update read position, according to the update read position, in the first type of message structure, a target header corresponding to the update read position is obtained, for example, a TCP / IP header, and the first five-tuple information can be obtained by reading the TCP / IP header.
[0077] Figure 4 It is a schematic diagram of the first type of message structure provided by the embodiment of the present disclosure; the first type of message includes a TCP / IP header 401, other headers 402, and a visual networking header 403 located between the TCP / IP header 401 and the other headers 402, and also data 404. Since there is an additional visual networking header 403 in the visual networking message, the position of the TCP / IP header 401 in the message structure is moved backward. Therefore, the preset reading position in the second type of message is actually at the starting point on the left side of the visual networking header 403, and it needs to be offset based on the preset reading position so that the updated reading position is at the starting point on the left side of the TCP / IP header 401.
[0078] Optionally, the step of forwarding the message to be forwarded to a first processor core corresponding to the first tuple information includes:
[0079] Sub-step 2043, performing a hash operation based on the first tuple information to obtain a target hash value corresponding to the first tuple information;
[0080] Sub-step 2044, performing a modulo operation based on the target hash value and the number of processor cores to obtain a target index corresponding to the target hash value; each processor core has a corresponding index;
[0081] Sub-step 2045: determine a first processor core corresponding to the target index, and forward the message to be forwarded to the first processor core.
[0082] In the disclosed embodiment, when determining the second processor core corresponding to the target hash value of the first tuple information, a modulo operation, i.e., "hash%corenum", can be performed based on the target hash value and the number of processor cores. The modulo operation is the process of calculating the remainder of the division of two numbers. Use "hash%CPUcoreNum" to obtain a remainder whose value is in the range of 0 to (CPUcoreNum-1). The value of the remainder can be directly used as the target index. According to the number of processor cores, a corresponding index can be assigned to each processor. For example, if there are 4 processor cores, the indexes are 0, 1, 2, and 3 respectively.
[0083] A second processor core is determined from among the multiple processor cores according to the target index, and the second type message is forwarded to the second processor core.
[0084] It is understandable that when determining the second processor core corresponding to the target hash value of the second tuple information, the corresponding second processor core may also be determined by a modulo operation.
[0085] In the implementation of the embodiment of the present disclosure, a target hash value corresponding to the first tuple information is obtained by performing a hash operation based on the first tuple information; a modulo operation is performed based on the target hash value and the number of processor cores to obtain a target index corresponding to the target hash value; the first processor core corresponding to the target index is determined, and the first type of visual networking message is forwarded to the first processor core. The visual networking message can be evenly forwarded to different processor cores, thereby improving the utilization rate of multiple processor cores, thereby improving the message forwarding performance.
[0086] Optionally, the step of forwarding the message to be forwarded to a first processor core corresponding to the first tuple information includes:
[0087] Performing a hash operation based on the first tuple information to obtain a target hash value corresponding to the first tuple information;
[0088] Determine a first processor core corresponding to the target hash value based on a mapping relationship between the target hash value, a preset hash value, and a processor core;
[0089] Forward the message to be forwarded to the first processor core.
[0090] In the disclosed embodiment, a hash operation may also be performed based on the first tuple information to obtain a target hash value corresponding to the first tuple information. Based on the mapping relationship between the target hash value, the preset hash value and the processor core, the first processor core corresponding to the target hash value is determined, and the first type of visual network message is forwarded to the corresponding first processor core.
[0091] The mapping relationship can be mapping the hash value to a specific processor core according to a predefined rule or configuration such as a hash table, or dynamically mapping the hash value to different processor cores according to the system load and core availability. The specific mapping method is not specifically limited here.
[0092] Figure 5 is a flowchart of message forwarding provided by an embodiment of the present disclosure;
[0093] Step 501, the data message arrives at the message processing module; Step 502, determine the message type according to the tuple information in the header; Step 503, for the first type, offset the data pointer based on the value of the visual network header length; Step 504, for the second type, perform hash operation (data hashing) and map it to the corresponding second processor core; Step 505, perform hash operation (data hashing) on the first type of message, and map it to the corresponding first processor core.
[0094] In an embodiment of the present invention, by obtaining a message to be forwarded, the message type of the message to be forwarded is determined; when the message to be forwarded is of the first type, the visual network header and the preset reading position in the message to be forwarded are obtained; according to the header length of the visual network header, the preset reading position is offset to obtain an updated reading position; in the message to be forwarded, the first tuple information recorded in the updated reading position is obtained, and the message to be forwarded is forwarded to the first processor core corresponding to the first tuple information. The position can be adaptively offset according to the specific type of the message, so as to adopt the updated reading position to obtain the tuple information, and then the message can be forwarded to the processor core according to the tuple information, thereby improving the applicability of message forwarding.
[0095] Reference Figure 6 , shows a structural block diagram of a message forwarding device 60 of the present application, the device comprising:
[0096] A message type module, used to obtain a message to be forwarded and determine the message type of the message to be forwarded;
[0097] The first type module is used to obtain the visual networking header and the preset reading position in the message to be forwarded when it is determined that the message to be forwarded is of the first type; the first type of message is a message based on the visual networking protocol; the preset reading position is used to determine the initial position of the tuple information in the message;
[0098] A position offset module, used for offsetting the preset reading position according to the header length of the visual networking header to obtain an updated reading position;
[0099] The first forwarding module is used to obtain the first tuple information recorded in the updated read position in the message to be forwarded, and forward the message to be forwarded to the first processor core corresponding to the first tuple information.
[0100] Optionally, the method further includes:
[0101] A second type module is used to obtain the second tuple information recorded in the preset reading position in the message to be forwarded when it is determined that the message to be forwarded is of the second type; the message of the second type is a message based on the Internet Protocol;
[0102] The second forwarding module is used to forward the message to be forwarded to the second processor core corresponding to the second tuple information.
[0103] Optional, message type module, including:
[0104] A characteristic parameter submodule, used to obtain a message to be forwarded, and determine characteristic parameters carried in the message structure of the message to be forwarded; the characteristic parameters are used to indicate the type of the message to be forwarded; at least some characteristic parameters are different between different types of messages to be forwarded;
[0105] The type judgment submodule is used to determine whether the message to be forwarded is of the first type or the second type according to the characteristic parameters.
[0106] Optionally, the first forwarding module includes:
[0107] An update header submodule, configured to obtain, in the message structure of the message to be forwarded, a target header corresponding to the update read position according to the update read position;
[0108] The first tuple submodule is used to obtain the first five-tuple information in the target header; the first five-tuple information represents the communication mode corresponding to the first type.
[0109] Optionally, the first forwarding module includes:
[0110] A first hash submodule is used to perform a hash operation based on the first tuple information to obtain a target hash value corresponding to the first tuple information
[0111] A modulo operation submodule, used to perform a modulo operation based on the target hash value and the number of processor cores to obtain a target index corresponding to the target hash value; each processor core has a corresponding index;
[0112] The index forwarding submodule is used to determine the first processor core corresponding to the target index and forward the message to be forwarded to the first processor core.
[0113] Optionally, the first forwarding module includes:
[0114] A second hash submodule, configured to perform a hash operation based on the first tuple information to obtain a target hash value corresponding to the first tuple information;
[0115] A hash mapping submodule, configured to determine a first processor core corresponding to the target hash value based on a mapping relationship between the target hash value, a preset hash value and a processor core;
[0116] The second forwarding submodule is used to forward the message to be forwarded to the first processor core.
[0117] Optionally, the second forwarding module includes:
[0118] A first target header submodule, configured to obtain, in the message structure of the first type of message, a target header corresponding to the preset reading position according to the preset reading position;
[0119] A second tuple submodule, configured to read a first five-tuple of information in the target header; the first five-tuple of information indicating a communication mode of the first type of message;
[0120] A preset header submodule, configured to obtain a target header corresponding to the preset reading position in the message structure of the message to be forwarded when it is determined that the message to be forwarded is of the second type;
[0121] A second five-tuple of information is read from the target header; the second five-tuple of information indicates a communication method corresponding to the second type.
[0122] In summary, in the embodiment of the present invention, the message type of the message to be forwarded is determined by obtaining the message to be forwarded; when the message to be forwarded is of the first type, the visual network header and the preset reading position in the message to be forwarded are obtained; according to the header length of the visual network header, the preset reading position is offset to obtain an updated reading position; in the message to be forwarded, the first tuple information recorded in the updated reading position is obtained, and the message to be forwarded is forwarded to the first processor core corresponding to the first tuple information. The position can be adaptively offset according to the specific type of the message, so as to adopt the updated reading position to obtain the tuple information, and then the message can be forwarded to the processor core according to the tuple information, thereby improving the applicability of message forwarding.
[0123] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0124] The embodiment of the present invention discloses an electronic device, such as Figure 7As shown, it includes: a processor 71 and a memory 72, the memory 72 stores a program or instruction that can be run on the processor 71, and the program or instruction is executed by the processor 71 to implement any of the message forwarding methods described above. The embodiment of the present invention discloses a computer-readable storage medium, which stores a computer program that enables the processor to execute any of the message forwarding methods described above.
[0125] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0126] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0127] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0128] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0129] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0130] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0131] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0132] The above is a detailed introduction to a message forwarding method, device, equipment and readable storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A message forwarding method, characterized in that: The method comprises: Obtaining a message to be forwarded, and determining a message type of the message to be forwarded; In the case where it is determined that the message to be forwarded is of the first type, obtaining a visual networking header and a preset reading position in the message to be forwarded; the first type of message is a message based on the visual networking protocol; the preset reading position is used to determine the initial position of the tuple information in the message; According to the header length of the visual network header, the preset reading position is offset to obtain an updated reading position; In the message to be forwarded, the first tuple information recorded in the updated read position is obtained, and the message to be forwarded is forwarded to a first processor core corresponding to the first tuple information.
2. The method according to claim 1, characterized in that: The method further comprises: In the case where it is determined that the message to be forwarded is of the second type, obtaining second tuple information recorded in the preset reading position in the message to be forwarded; the message of the second type is a message based on the Internet Protocol; The message to be forwarded is forwarded to a second processor core corresponding to the second tuple information.
3. The method according to claim 1, characterized in that The step of obtaining the message to be forwarded and determining the message type of the message to be forwarded includes: Acquire a message to be forwarded, and determine characteristic parameters carried in a message structure of the message to be forwarded; the characteristic parameters are used to indicate the type of the message to be forwarded; at least some characteristic parameters are different between different types of messages to be forwarded; According to the characteristic parameter, it is determined that the message to be forwarded is of the first type or the second type.
4. The method according to claim 1, characterized in that: The step of obtaining the first tuple information recorded in the updated read position in the message to be forwarded comprises: In the message structure of the message to be forwarded, according to the updated reading position, obtaining a target header corresponding to the updated reading position; A first five-tuple of information is obtained in the target header; the first five-tuple of information indicates a communication method corresponding to the first type.
5. The method according to claim 1, characterized in that The step of forwarding the message to be forwarded to the first processor core corresponding to the first tuple information includes: Performing a hash operation based on the first tuple information to obtain a target hash value corresponding to the first tuple information; Performing a modulo operation based on the target hash value and the number of processor cores to obtain a target index corresponding to the target hash value; each processor core has a corresponding index; Determine a first processor core corresponding to the target index, and forward the message to be forwarded to the first processor core.
6. The method according to claim 1, characterized in that The step of forwarding the message to be forwarded to the first processor core corresponding to the first tuple information includes: Performing a hash operation based on the first tuple information to obtain a target hash value corresponding to the first tuple information; Determine a first processor core corresponding to the target hash value based on a mapping relationship between the target hash value, a preset hash value, and a processor core; Forward the message to be forwarded to the first processor core.
7. The method according to claim 2, characterized in that The step of obtaining the second tuple information recorded in the preset reading position in the message to be forwarded when it is determined that the message to be forwarded is of the second type includes: When it is determined that the message to be forwarded is of the second type, obtaining a target header corresponding to the preset reading position in the message structure of the message to be forwarded; A second five-tuple of information is read from the target header; the second five-tuple of information indicates a communication method corresponding to the second type.
8. A message forwarding device, characterized in that: The device comprises: A message type module, used to obtain a message to be forwarded and determine the message type of the message to be forwarded; The first type module is used to obtain the visual networking header and the preset reading position in the message to be forwarded when it is determined that the message to be forwarded is of the first type; the first type of message is a message based on the visual networking protocol; the preset reading position is used to determine the initial position of the tuple information in the message; A position offset module, used for offsetting the preset reading position according to the header length of the visual networking header to obtain an updated reading position; The first forwarding module is used to obtain the first tuple information recorded in the updated read position in the message to be forwarded, and forward the message to be forwarded to the first processor core corresponding to the first tuple information.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the message forwarding method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer program stored therein enables the processor to execute the message forwarding method as described in any one of claims 1 to 7.
