CN117651084A - Heterogeneous protocol message processing method and device, electronic equipment and storage medium - Google Patents

Heterogeneous protocol message processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117651084A
CN117651084A CN202410108277.XA CN202410108277A CN117651084A CN 117651084 A CN117651084 A CN 117651084A CN 202410108277 A CN202410108277 A CN 202410108277A CN 117651084 A CN117651084 A CN 117651084A
Authority
CN
China
Prior art keywords
message
matching
configuration
heterogeneous protocol
message content
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202410108277.XA
Other languages
Chinese (zh)
Other versions
CN117651084B (en
Inventor
朱珂
常超
张明伟
闻亮
肖峰
高庆
陈培岩
田境遴
吴乐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingxin Microelectronics Technology Tianjin Co Ltd
Original Assignee
Jingxin Microelectronics Technology Tianjin Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingxin Microelectronics Technology Tianjin Co Ltd filed Critical Jingxin Microelectronics Technology Tianjin Co Ltd
Priority to CN202410108277.XA priority Critical patent/CN117651084B/en
Publication of CN117651084A publication Critical patent/CN117651084A/en
Application granted granted Critical
Publication of CN117651084B publication Critical patent/CN117651084B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a heterogeneous protocol message processing method, a heterogeneous protocol message processing device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring message content and heterogeneous protocol types corresponding to the message content; traversing a preset configuration set according to the heterogeneous protocol type to obtain configuration corresponding to the heterogeneous protocol type; according to the configuration, carrying out operation on the message content to generate a pre-matching string; and when the pre-matching string is identical to the preset matching template, uploading the message content according to the configuration. The method can adapt to various message formats by distinguishing the messages according to the heterogeneous protocol types. Through preset configuration, messages of various protocol types can be processed under the same interface without modifying core codes. By generating the pre-matching string, the matching difficulty can be simplified, and the conversion efficiency can be improved. By comparing the pre-matching string with the matching template, the accuracy of the feeding process is ensured, the overall stability is improved, and the defects of poor expansibility and stability in the prior art are overcome.

Description

Heterogeneous protocol message processing method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of the internet of things, in particular to a heterogeneous protocol message processing method, a heterogeneous protocol message processing device, electronic equipment and a storage medium.
Background
With the continuous development of internet service and internet of things, the network data volume is rapidly increased, and greater demands are also being made on the interconnection interfaces of heterogeneous network data. With this background, the importance of the conversion efficiency of heterogeneous networks is not negligible. However, the current market-oriented switches support multiple single protocol families, while the advent of software-defined interconnect chips, such as the tiger wing, can effectively support multiple heterogeneous protocols.
In general, each type of heterogeneous protocol has its own specific specifications, and their framing principles and formats at the data link layer are different. Because the network protocol stack or the monitoring equipment of the heterogeneous protocol has no unified processing method for uploading the heterogeneous protocol message, when the upper layer business software receives the heterogeneous protocol message, the corresponding interface is required to be called according to different protocols, which leads to confusion of code organization and unclear architecture to a certain extent.
Typically, the software defined interconnect chip has the capability to support the uploading of heterogeneous protocol messages to the central processor, while in switches and monitoring devices of heterogeneous protocols, these protocol messages need to be uploaded to the upper protocol module for processing. The use of Socket is a good solution when receiving and transmitting network messages. However, a standard Socket generally performs matching based on some specific fields in a TCP/IP protocol packet, such as an IP address, a port number, and a protocol number, and only after the matching is successful, the packet can be sent to a Socket queue to be received in a user state. In heterogeneous protocols, due to the diversity of link layer framing principles and message formats, standard sockets are not only suitable for ethernet protocols, but also poorly adaptable to other protocols. The binding of standard Socket and device description structure also limits the device description structure applicable to other heterogeneous protocols besides ethernet messages. If a heterogeneous protocol family and a protocol thereof are newly added, the core code of the Socket module is required to be repaired according to the current Socket implementation, and the expandability and the stability have obvious problems.
Disclosure of Invention
Therefore, the technical problem to be solved by the invention is to overcome the defect of poor expansibility and stability in the prior art, thereby providing a heterogeneous protocol message processing method, a heterogeneous protocol message processing device, electronic equipment and a storage medium.
According to a first aspect, the invention discloses a heterogeneous protocol message processing method, which comprises the following steps: acquiring message content and heterogeneous protocol types corresponding to the message content; traversing a preset configuration set according to the heterogeneous protocol type to obtain configuration corresponding to the heterogeneous protocol type; according to the configuration, calculating the message content to generate a pre-matching string; and when the pre-matching string is identical to a preset matching template, uploading the message content according to the configuration.
Optionally, the method further comprises: repeating the operation until the configuration set is traversed.
Optionally, the configuring includes: matching the mark; and before the operation is performed on the message content according to the configuration and the pre-matching string is generated, the method further comprises the steps of: acquiring the configured matching mark; when the match flag is not enabled, continuing to traverse the remainder of the configuration set.
Optionally, the configuring includes: matching tail marks, matching message lengths and attention fields; and according to the configuration, operating the message content to generate a pre-matching string, including: acquiring the matching tail mark, the matching message length and the concerned domain; when the matching tail mark is enabled, acquiring message data from the tail of the message content according to the length of the matching message; and performing AND operation on the message data and the concerned domain to generate the pre-matching string.
Optionally, the configuring further comprises: a match report Wen Pianyi; the operation is carried out on the message content according to the configuration to generate a pre-matching string, and the method further comprises the following steps: when the matching tail mark is not enabled, shifting the message content according to the shifting of the matching message to generate shifting message content; acquiring message data from the offset message content according to the length of the matching message; and performing AND operation on the message data and the concerned domain to generate the pre-matching string.
Optionally, the configuring includes: a matching field; and when the pre-matching string is the same as a preset matching template, uploading the message content according to the configuration, including: acquiring the matching domain, and taking the matching domain as the matching template; comparing any byte in the pre-matching string with the byte corresponding to the matching template in sequence; and when each byte in the pre-matching string is identical to the byte corresponding to the matching template, uploading the message content according to the configuration.
Optionally, the configuring includes: the message sending offset and message sending length; the step of uploading the message content according to the configuration comprises the following steps: acquiring the offset and the length of the sending message; shifting the message content according to the shifting of the sending message to generate a shifting message content; acquiring the data of the sending message from the content of the sending offset message according to the length of the sending message; and uploading the uploading message data.
According to a second aspect, the present invention discloses a heterogeneous protocol message processing device, which comprises: the acquisition module is used for acquiring the message content and the heterogeneous protocol type corresponding to the message content; the traversing module is used for traversing a preset configuration set according to the heterogeneous protocol type to obtain a configuration corresponding to the heterogeneous protocol type; the operation module is used for operating the message content according to the configuration to generate a pre-matching string; and the uploading module is used for uploading the message content according to the configuration when the pre-matching string is the same as a preset matching template.
According to a third aspect, the invention discloses an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the steps of the heterogeneous protocol message processing method according to any of the first aspect and the optional implementation manner of the first aspect.
According to a fourth aspect, the present invention discloses a computer readable storage medium, on which a computer program is stored, which when being executed by a processor, implements the steps of the heterogeneous protocol message processing method according to any of the alternative embodiments of the first aspect and the first aspect.
The technical scheme of the invention has the following advantages:
1. the heterogeneous protocol message processing method disclosed by the invention can realize adaptation to various message formats by accurately distinguishing the messages in the heterogeneous protocol types. By adopting the preset configuration of the heterogeneous protocol types, the diversified protocol type messages can be processed under the same interface, and the expandability of the system is effectively ensured only by modifying the configuration without changing the core code. By computing the messages to generate the pre-match strings, the complexity of the matching can be simplified. On the basis, by comparing the pre-matching string with the matching template, the accuracy of the feeding process is ensured and the stability of the whole system is enhanced. In conclusion, the heterogeneous protocol message processing method provided by the invention overcomes the defects of poor expansibility and stability in the prior art.
2. The heterogeneous protocol message processing method disclosed by the invention realizes the unified uploading of the protocol message in the software-defined interconnection heterogeneous protocol stack or the monitoring equipment. The upper layer heterogeneous protocol software only needs to create and configure the corresponding SDI socket according to the heterogeneous protocol message characteristics, and is flexible and simple to use and reduces the complexity of the software. The upper protocol software or the network monitoring software is based on standard SDI socket programming, so that the operation is simple, the learning cost of user developers is greatly reduced, and the threshold of use is reduced. And the method has good expansibility, and the service of upper protocol processing software or network monitoring software is changed or increased, so that only the SDI socket configuration is required to be readjusted or increased, and the SDI socket module is not required to be modified. And the user can configure the appointed load, and the whole message is not required to be sent to the socket by the socket, so that the interactive flow of the user mode and the kernel mode can be reduced, unnecessary memory copy is reduced, and the IO bandwidth and performance of the system are saved. By being configured to be based on tail matching, only load information at a specific position of the tail of the message can be focused.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a specific example of a method for processing a heterogeneous protocol packet according to an embodiment of the present invention;
FIG. 2 is a flowchart of another specific example of a method for processing a heterogeneous protocol packet according to an embodiment of the present invention;
FIG. 3 is a flowchart of another specific example of a method for processing a heterogeneous protocol packet according to an embodiment of the present invention;
FIG. 4 is a flowchart of another specific example of a method for processing a heterogeneous protocol packet according to an embodiment of the present invention;
FIG. 5 is a flowchart of another specific example of a method for processing a heterogeneous protocol packet according to an embodiment of the present invention;
FIG. 6 is a flowchart of another specific example of a method for processing a heterogeneous protocol message according to an embodiment of the present invention;
FIG. 7 is a flowchart of another specific example of a method for processing a heterogeneous protocol packet according to an embodiment of the present invention;
FIG. 8 is a flowchart of another specific example of a method for processing a heterogeneous protocol message according to an embodiment of the present invention;
FIG. 9 is a flowchart of another specific example of a method for processing a heterogeneous protocol packet according to an embodiment of the present invention;
FIG. 10 is a schematic block diagram of a specific example of a heterogeneous protocol message processing apparatus according to an embodiment of the present invention;
FIG. 11 is a diagram illustrating an embodiment of an electronic device according to the present invention;
fig. 12 is a diagram showing a specific example of a storage medium according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made apparent and fully in view of the accompanying drawings, in which some, but not all embodiments of the invention are shown. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the directions or positional relationships shown in the drawings, are merely for convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should be noted that, unless explicitly specified and limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be either fixedly connected, detachably connected, or integrally connected, for example; can be mechanically or electrically connected; the two components can be directly connected or indirectly connected through an intermediate medium, or can be communicated inside the two components, or can be connected wirelessly or in a wired way. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
In addition, the technical features of the different embodiments of the present invention described below may be combined with each other as long as they do not collide with each other.
The invention discloses a heterogeneous protocol message processing method, as shown in figure 1, comprising the following steps:
step S1, obtaining message content and heterogeneous protocol types corresponding to the message content.
Specifically, the message content may include: protocol header, source and destination addresses, message length, message type, message data, error detection code, and other fields. The protocol header contains an identifier and version information of a protocol and is used for identifying and analyzing the protocol type of the message; the source address and the target address indicate the address information of the sender and the receiver of the message so as to determine the transmission path of the message; the message length is used for clearly determining the message length so that a receiver can correctly analyze the message; the message type indicates the purpose or function of the message, such as a request message, a response message, etc.; the message data contains the data content actually transmitted, and can be text, image, audio or other forms of data; the error detection code is used for detecting whether the message is in error or damaged in the transmission process; other fields are other specific fields that may be defined by different protocols to meet the requirements of the protocol itself. In particular, the message content may also include other data according to practical situations, which is not limited in the present invention.
Specifically, the heterogeneous protocol types may include: transport layer protocols, network layer protocols, data link layer protocols, and application layer protocols. Wherein the transport layer protocol is responsible for providing reliable data transmission between hosts in the network; the network layer protocol is responsible for providing data transmission and routing functions between routers in the network; the data link layer protocol is responsible for providing reliable data transmission between nodes in the network; the application layer protocol is responsible for defining the rules and data formats of communication between applications. In particular, there are many other types of heterogeneous protocols, such as audio/video transmission protocol, domain name system protocol, dynamic host configuration protocol, etc., which can be selectively configured according to actual communication requirements, which the present invention is not limited to.
And step S2, traversing a preset configuration set according to the heterogeneous protocol type to obtain the configuration corresponding to the heterogeneous protocol type.
Specifically, the configuration set contains a plurality of configurations, and the plurality of configurations can be distinguished by heterogeneous protocols.
For example, when a socket is used as an interface for receiving and transmitting network messages, the configuration set may be represented by an sdi_socket_all variable. Wherein, all configuration files of any heterogeneous protocol K can be expressed as sdi_sock_all [ K ].
For example, when a socket is used as an interface for receiving and transmitting network messages, the configuration may be represented by an sdi_socket_list variable.
And step S3, according to the configuration, carrying out operation on the message content to generate a pre-matching string.
Specifically, the pre-matching string refers to a pattern string to be matched, which is determined in advance in a character string matching algorithm. In performing string matching, the algorithm compares the pre-match string to the target string (target) byte by byte to determine if there is a match.
For example, the process of generating the pre-matching string may extract a portion of data in the message content according to the configuration, and then perform a logic operation on the portion of data according to the configuration requirement, so as to obtain the pre-matching string. In particular, the process of generating the pre-matching string may also be performed by other means in the art, which the present invention is not limited to.
And S4, when the pre-matching string is identical to a preset matching template, uploading the message content according to the configuration.
Specifically, the uploading refers to a process of transmitting data from a sender to a receiver in network communication, and generally includes a process of connecting the receiver, encapsulating the data, transmitting the data, and the like.
For example, the uploading process may extract a part of data in the message content according to the configuration, and then upload the data according to the configuration requirement. In particular, the process of uploading may be performed in other manners in the prior art, which is not limited by the present invention.
The heterogeneous protocol message processing method disclosed by the invention can realize adaptation to various message formats by accurately distinguishing the messages in the heterogeneous protocol types. By adopting the preset configuration of the heterogeneous protocol types, the diversified protocol type messages can be processed under the same interface, and the expandability of the system is effectively ensured only by modifying the configuration without changing the core code. By computing the messages to generate the pre-match strings, the complexity of the matching can be simplified. On the basis, by comparing the pre-matching string with the matching template, the accuracy of the feeding process is ensured and the stability of the whole system is enhanced. In conclusion, the heterogeneous protocol message processing method provided by the invention overcomes the defects of poor expansibility and stability in the prior art.
As an alternative embodiment of the present invention, as shown in fig. 2, the heterogeneous protocol packet processing method further includes the following steps:
and S5, repeating the operation until the configuration set is traversed.
Specifically, according to the actual situation, any heterogeneous protocol K in the configuration set may include a plurality of configurations, that is, sdi_sock_all [ K ] includes a plurality of sdi_sock_list. In a similar case, it is necessary to ensure that all configurations corresponding to the heterogeneous protocol K are performed.
As an alternative embodiment of the present invention, the configuration includes: matching the mark; as shown in fig. 3, before the operation is performed on the message content according to the configuration to generate the pre-matching string, the method further includes the following steps:
step S21, obtaining the configured matching mark.
The match flag is used to indicate whether the match function flag is enabled, 1 is enabled, and 0 is disabled. Illustratively, when a socket is used as an interface for receiving and transmitting a network message, the socket can be represented by a match variable.
And step S22, when the matching mark is not enabled, continuing to traverse the rest of the configuration set.
Specifically, when the match flag is 0, it represents that the match flag is not enabled, at which time the configuration is not matched, directly skipped, and the rest of the configuration set is continuously traversed.
Similarly, when the match flag is 1, it represents that the match flag is enabled, at which point the configuration needs to be matched, i.e., a pre-match string is generated and an up operation is performed for the configuration.
As an alternative embodiment of the present invention, the configuration includes: matching tail marks, matching message lengths and attention fields;
the tail match flag is used to indicate whether tail match is enabled, 1 is enabled, and 0 is disabled. Wherein, the matching message length is used to represent the byte number of the matching. The attention field is used for representing a data area which is concerned by a user, the length is the length of a matching message based on bits, the attention time is set to 1, and the non-attention time is set to 0.
For example, when a socket is used as an interface for receiving and transmitting a network message, a matching tail flag may be represented by a tail_match variable, a matching message length may be represented by a match_len variable, and a field of interest may be represented by a care variable.
The operation is performed on the message content according to the configuration to generate a pre-matching string, as shown in fig. 4, including the following steps:
step S31, the matching tail mark, the matching message length and the concerned domain are obtained;
step S32, when the matched tail mark is enabled, acquiring message data from the tail of the message content according to the length of the matched message;
specifically, when the tail flag is enabled, that is, when the tail_match variable is 1, the message data is sequentially read from the tail of the message content according to the value of the match_len variable.
For example, when the tail_match variable is 1 and the match_len variable is 8, the last 8 bytes of data of the message content is read, and the 8 bytes of data are taken as the message data.
And step S33, performing AND operation on the message data and the concerned domain to generate the pre-matching string.
Specifically, as the message data and the concerned domain are both matched with the message length, the corresponding bits of the message data and the concerned domain are subjected to AND operation in sequence to generate a pre-matched string. Wherein the operation logic of the AND operation is 1 if and only if both corresponding bits are 1, and 0 if one of the two corresponding bits is 0.
For example, when the message data is 0xF100AB00 and the attention domain is 0x01010011, the first group of corresponding bits are F and 0, the result is 0, the second group of corresponding bits are 1 and 1, the result is 1, and the result is 01000000, and the result is used as the pre-matching string.
As an alternative embodiment of the present invention, the configuration further includes: a match report Wen Pianyi;
wherein, the matching message offset is used to represent the number of bytes of the message offset, and represents the beginning of the message Wen Pi timing from the message offset position. For example, when a socket is used as an interface for receiving and transmitting a network packet, the match message Wen Pianyi may be represented by a match_offset variable.
The operation is performed on the message content according to the configuration to generate a pre-matching string, as shown in fig. 5, and further includes the following steps:
step S34, when the matching tail mark is not enabled, the message content is shifted according to the matching message shift, and shifted message content is generated;
specifically, when the tail_match variable is 0, the message content is offset according to the match_offset, and an offset message content is generated.
For example, when the tail_match variable is 0 and the match_offset variable is 2, if the message content is 0xF100112233, the offset message content 0x112233 is generated by offsetting the message content by 2 bytes according to the match_offset variable being 2.
Step S35, according to the length of the matching message, obtaining message data from the offset message content;
specifically, according to the value of the match_len variable, the message data are sequentially read from the offset message content.
For example, when the match_len variable is 8, that is, 8 bytes of data at the content of the offset message is read, and the 8 bytes of data are used as the message data.
And step S36, performing AND operation on the message data and the implementation interest domain to generate the pre-matching string.
Specifically, as the message data and the concerned domain are both matched with the message length, the corresponding bits of the message data and the concerned domain are subjected to AND operation in sequence to generate a pre-matched string. Wherein the operation logic of the AND operation is 1 if and only if both corresponding bits are 1, and 0 if one of the two corresponding bits is 0.
For example, when the message data is 0xF100AB00 and the attention domain is 0x01010011, the first group of corresponding bits are F and 0, the result is 0, the second group of corresponding bits are 1 and 1, the result is 1, and the like, the operation result is 0x01000000, and the operation result is used as a pre-matching string.
As an alternative embodiment of the present invention, the configuration includes: a matching field;
the matching domain is a preset group of binary codes, the length of the matching domain is the length of a matching message, and the matching domain is preset according to actual needs based on bits. For example, when a socket is used as an interface for receiving and transmitting a network message, the matching domain may be represented by a templet variable.
When the pre-matching string is the same as a preset matching template, the message content is sent up according to the configuration, as shown in fig. 6, including the following steps:
step S41, obtaining the matching domain, and taking the matching domain as the matching template;
step S42, comparing any byte in the pre-matching string with the corresponding byte of the matching template in sequence;
illustratively, when the match_len variable is 4 and the pre-match string is 0x01000000, if the match field is 0x01000000, the corresponding bits of the pre-match string and the match field are sequentially compared, the first set of corresponding bits is 0 and 0, the same, the second set of corresponding bits is 1 and 1, the same, and so on.
And step S43, when each byte in the pre-matching string is identical to the byte corresponding to the matching template, uploading the message content according to the configuration.
As an alternative embodiment of the present invention, the configuration includes: the message sending offset and message sending length;
the message sending offset is used for specifying the message sending offset position, and the message sending length is used for specifying the message sending length.
For example, when a socket is used as an interface for receiving and transmitting a network packet, the upload Wen Pianyi may be represented by an upload_offset variable. In particular, when the complete message content is sent, the value is filled with 0.
Similarly, when a socket is used as an interface for receiving and transmitting a network message, the length of the uplink message can be represented by an uplink_size variable. In particular, when the complete message is configured for upload, the value is filled with-1.
As shown in fig. 7, the step of uploading the message content according to the configuration includes the following steps:
step S44, obtaining the offset of the sent message and the length of the sent message;
step S45, shifting the message content according to the shifting of the sent message to generate a shifted message content;
specifically, the message content is offset according to the uplink_offset, and an uplink offset message content is generated.
For example, when the uplink_offset variable is 2, if the message content is 0xF1001123F1 …, the uplink offset message content 0x1123F1 … is generated by offsetting the message content by 2 bytes according to the uplink_offset variable being 2.
Step S46, according to the length of the report message, acquiring report message data from the report offset message content;
specifically, according to the value of the upload_size variable, the message data is sequentially read from the content of the upload offset message.
For example, when the upload_size variable is 8, 8 bytes of data of the upload offset message content are read, and the 8 bytes of data are taken as the upload message data.
Step S47, uploading the upload message data.
As an optional implementation manner of the present invention, when using a socket as an interface for receiving and transmitting a network message, the method further includes: changing to kernel source code and adding sdi_sock.ko module.
Specifically, sdi_socket. Ko implements SDI socket-related code. The method comprises socket registration, creation, deletion and setsockopt configuration interfaces, SDI socket processing threads and the like. The Socket registration interface is used for calling the socket_register and registering the SDI Socket into Linux. The Socket creation interface is used for applying and initializing a struct Socket structure and assigning Socket opts functions. The Socket opts interface is used for realizing a Socket operation interface and comprises a release interface, a setsockopt interface, a sendmsg interface and a recvmsg interface. In particular, the Socket opts interface is an SDI Socket configuration interface, and may be used to apply for an SDI Socket matching management data structure sdi_socket_list, assign a value to the structure according to the incoming parameter sdi_socket, and insert the SDI Socket matching management data structure into a global Socket matching chain (sdi_socket_all).
As an optional implementation manner of the present invention, when a socket is used as an interface for receiving and transmitting a network message, the configuration preset process may be sequentially specified according to different protocols.
Illustratively, when configuring an a Socket according to an ethernet protocol, first, call a Socket interface to create an ETH a protocol Socket, and designate the protocol as ethernet, examples are available: lock=socket (af_sdi, dock_raw, af_proto_eth). Then, assuming that the destination mac address is xxxx-yyyy-zzz, the message can be determined to be an A message, and the A protocol SDI socket configuration structure is constructed according to the SDI socket configuration structure description, wherein the A protocol SDI socket configuration structure is as follows: struct sdi_sockopt askopt= {1,0,6,0, { xx, xx, yy, yy, zz, zz }, {0xFF, -1}. And finally, invoking setsockopt (Asock, AF_SDI, SDI_OPT_ADD_MATCH, & Askopt, sizeof (Askopt)) and issuing the A protocol configuration information to the SDI sock module.
Similarly, when BSocket is configured according to FC protocol, first call socket interface to create FC B protocol socket, and assign the protocol as FC, it is available: bsock=socket (af_sdi, dock_raw, af_proto_fc). Then, assuming that the destination FCID is aaXXcc (XX represents no attention), the message can be determined to be an FC B protocol message, and the configuration structure of the B protocol SDI socket is constructed according to the SDI socket configuration structure description: struct sdi_sockopt bskopt= {1,0,3,5, { aa, 0x00, cc }, {0xFF, 0x00, 0xFF, 0, -1}. And finally, invoking setsockopt (Block, AF_SDI, SDI_OPT_ADD_MATCH, & Bskopt, sizeof (Bskopt)) and issuing the B protocol configuration information to the SDI sock module.
Similarly, when Csocket is configured according to the K heterogeneous protocol, first, call the socket interface to create the K heterogeneous protocol C protocol socket, and designate the protocol as K, which can be obtained: csock=socket (af_sdi, dock_raw, af_proto_k). Then, assuming that the content of the last N bytes of the message is rrsstt …, the message can be judged to be a K heterogeneous protocol C protocol message, and only the front M bytes of the message need to be sent up to the protocol after hit, and the configuration structure of the C protocol SDI socket is constructed according to the description of the configuration structure of the SDI socket: struct sdi_sockopt cskopt= {1, n,0, { rr, ss, tt, … }, {0xFF, … }, 0, M }. Finally, call setsockopt (Csock, af_sdi, sdi_opt_add_match, & Cskopt, sizeof (Cskopt)) and issue the C protocol configuration information to the SDI sock module.
As an alternative embodiment of the present invention, as shown in fig. 8, a message receiving is further included.
Illustratively, the SDI chip receives a protocol message and uploads the protocol message to the CPU, and after the message is uploaded through PCIe, the PCIe driver receives the protocol message, and identifies the heterogeneous protocol type and the received message interface ID according to a chip agreed mode, so that the message content and the heterogeneous protocol type can be obtained.
As an alternative embodiment of the present invention, a data overall flow chart is shown in fig. 9.
The heterogeneous protocol message processing method disclosed by the invention realizes the unified uploading of the protocol message in the software-defined interconnection heterogeneous protocol stack or the monitoring equipment. The upper layer heterogeneous protocol software only needs to create and configure the corresponding SDI socket according to the heterogeneous protocol message characteristics, and is flexible and simple to use and reduces the complexity of the software. The upper protocol software or the network monitoring software is based on standard SDI socket programming, so that the operation is simple, the learning cost of user developers is greatly reduced, and the threshold of use is reduced. And the method has good expansibility, and the service of upper protocol processing software or network monitoring software is changed or increased, so that only the SDI socket configuration is required to be readjusted or increased, and the SDI socket module is not required to be modified. And the user can configure the appointed load, and the whole message is not required to be sent to the socket by the socket, so that the interactive flow of the user mode and the kernel mode can be reduced, unnecessary memory copy is reduced, and the IO bandwidth and performance of the system are saved. By being configured to be based on tail matching, only load information at a specific position of the tail of the message can be focused.
The invention also discloses a heterogeneous protocol message processing device, as shown in fig. 10, comprising:
the acquisition module 1 is used for acquiring message content and heterogeneous protocol types corresponding to the message content; the specific details refer to the description related to step S1 in the method embodiment of the present invention, and are not repeated here.
The traversing module 2 is used for traversing a preset configuration set according to the heterogeneous protocol type to obtain a configuration corresponding to the heterogeneous protocol type; the details refer to the description related to step S2 in the method embodiment of the present invention, and will not be described herein.
The operation module 3 is used for operating the message content according to the configuration to generate a pre-matching string; the details refer to the description related to step S3 in the method embodiment of the present invention, and will not be repeated here.
The uploading module 4 is configured to upload the message content according to the configuration when the pre-matching string is the same as a preset matching template; the details are described in the related description of step S4 in the method embodiment of the present invention, and are not repeated here.
The heterogeneous protocol message processing device disclosed by the invention can realize adaptation to various message formats by accurately distinguishing the messages in the heterogeneous protocol types. By adopting the preset configuration of the heterogeneous protocol types, the diversified protocol type messages can be processed under the same interface, and the expandability of the system is effectively ensured only by modifying the configuration without changing the core code. By computing the messages to generate the pre-match strings, the complexity of the matching can be simplified. On the basis, by comparing the pre-matching string with the matching template, the accuracy of the feeding process is ensured and the stability of the whole system is enhanced. In conclusion, the heterogeneous protocol message processing device provided by the invention overcomes the defects of poor expansibility and stability in the prior art.
The embodiment of the present invention further provides an electronic device, as shown in fig. 11, where the electronic device may include a processor 201 and a memory 202, where the processor 201 and the memory 202 may be connected by a bus or other means, and in fig. 11, the connection is exemplified by a bus.
The processor 201 may be a central processing unit (Central Processing Unit, CPU). The processor 201 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSPs), application specific integrated circuits (Application Specific Integrated Circuit, ASICs), field programmable gate arrays (Field-Programmable Gate Array, FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above.
The memory 202 is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the heterogeneous protocol message processing method in the embodiment of the present invention. The processor 201 executes various functional applications of the processor and data processing, i.e., implements the heterogeneous protocol packet processing method in the above-described method embodiment, by running non-transitory software programs, instructions, and modules stored in the memory 202.
Memory 202 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created by the processor 201, etc. In addition, memory 202 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 202 may optionally include memory located remotely from processor 201, which may be connected to processor 201 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more modules are stored in memory 202 that, when executed by processor 201, perform the heterogeneous protocol message processing method of the embodiment shown in fig. 1.
Specific details of the electronic device may be understood in response to the corresponding relevant descriptions and effects in the embodiment shown in fig. 1, which are not described herein.
The embodiment of the present invention further provides a computer readable storage medium, as shown in fig. 12, on which a computer program 301 is stored, which when executed by a processor, implements the steps of a heterogeneous protocol packet processing method in the above embodiment. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a Flash Memory (Flash Memory), a Hard Disk (HDD), or a Solid State Drive (SSD); the storage medium may also comprise a combination of memories of the kind described above.
It will be appreciated by those skilled in the art that implementing all or part of the above-described embodiment method may be implemented by a computer program to instruct related hardware, where the program may be stored in a computer readable storage medium, and the program may include the above-described embodiment method when executed. Wherein the storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a Flash Memory (Flash Memory), a Hard Disk (HDD), or a Solid State Drive (SSD); the storage medium may also comprise a combination of memories of the kind described above.
Although the exemplary embodiments and their advantages have been described in detail, those skilled in the art may make various changes, substitutions and alterations to these embodiments without departing from the spirit of the invention and the scope of protection as defined by the appended claims. For other examples, one of ordinary skill in the art will readily appreciate that the order of the process steps may be varied while remaining within the scope of the present invention.
Furthermore, the scope of the present application is not intended to be limited to the particular embodiments of the process, machine, manufacture, composition of matter, means, methods and steps described in the specification. From the present disclosure, it will be readily understood by those of ordinary skill in the art that processes, machines, manufacture, compositions of matter, means, methods, or steps, presently existing or later to be developed that perform substantially the same function or achieve substantially the same result as the corresponding embodiments described herein may be utilized according to the present disclosure. Accordingly, the appended claims are intended to include within their scope such processes, machines, manufacture, compositions of matter, means, methods, or steps.

Claims (10)

1. The heterogeneous protocol message processing method is characterized by comprising the following steps:
acquiring message content and heterogeneous protocol types corresponding to the message content;
traversing a preset configuration set according to the heterogeneous protocol type to obtain configuration corresponding to the heterogeneous protocol type;
according to the configuration, calculating the message content to generate a pre-matching string;
and when the pre-matching string is identical to a preset matching template, uploading the message content according to the configuration.
2. The heterogeneous protocol message processing method according to claim 1, further comprising:
judging whether the configuration set is traversed completely, if not, turning to traversing a preset configuration set according to the heterogeneous protocol type to obtain configuration corresponding to the heterogeneous protocol type.
3. The heterogeneous protocol message processing method according to claim 1, wherein the configuring includes: matching the mark;
and before the operation is performed on the message content according to the configuration and the pre-matching string is generated, the method further comprises the steps of:
acquiring the configured matching mark;
when the match flag is not enabled, continuing to traverse the remainder of the configuration set.
4. The heterogeneous protocol message processing method according to claim 1, wherein the configuring includes: matching tail marks, matching message lengths and attention fields;
and according to the configuration, operating the message content to generate a pre-matching string, including:
acquiring the matching tail mark, the matching message length and the concerned domain;
when the matching tail mark is enabled, acquiring message data from the tail of the message content according to the length of the matching message;
and performing AND operation on the message data and the implementation focus domain to generate the pre-matching string.
5. The heterogeneous protocol message processing method according to claim 4, wherein the configuring further comprises: a match report Wen Pianyi;
the operation is carried out on the message content according to the configuration to generate a pre-matching string, and the method further comprises the following steps:
when the matching tail mark is not enabled, shifting the message content according to the shifting of the matching message to generate shifting message content;
acquiring message data from the offset message content according to the length of the matching message;
and performing AND operation on the message data and the concerned domain to generate the pre-matching string.
6. The heterogeneous protocol message processing method according to claim 1, wherein the configuring includes: a matching field;
and when the pre-matching string is the same as a preset matching template, uploading the message content according to the configuration, including:
acquiring the matching domain, and taking the matching domain as the matching template;
comparing any byte in the pre-matching string with the byte corresponding to the matching template in sequence;
and when each byte in the pre-matching string is identical to the byte corresponding to the matching template, uploading the message content according to the configuration.
7. The heterogeneous protocol message processing method according to claim 1, wherein the configuring includes: the message sending offset and message sending length;
the step of uploading the message content according to the configuration comprises the following steps:
acquiring the offset and the length of the sending message;
shifting the message content according to the shifting of the sending message to generate a shifting message content;
acquiring the data of the sending message from the content of the sending offset message according to the length of the sending message;
and uploading the uploading message data.
8. A heterogeneous protocol message processing apparatus, comprising:
the acquisition module is used for acquiring the message content and the heterogeneous protocol type corresponding to the message content;
the traversing module is used for traversing a preset configuration set according to the heterogeneous protocol type to obtain a configuration corresponding to the heterogeneous protocol type;
the operation module is used for operating the message content according to the configuration to generate a pre-matching string;
and the uploading module is used for uploading the message content according to the configuration when the pre-matching string is the same as a preset matching template.
9. An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the steps of the heterogeneous protocol message processing method of any of claims 1-7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the heterogeneous protocol message processing method according to any of claims 1-7.
CN202410108277.XA 2024-01-26 2024-01-26 Heterogeneous protocol message processing method and device, electronic equipment and storage medium Active CN117651084B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410108277.XA CN117651084B (en) 2024-01-26 2024-01-26 Heterogeneous protocol message processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410108277.XA CN117651084B (en) 2024-01-26 2024-01-26 Heterogeneous protocol message processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117651084A true CN117651084A (en) 2024-03-05
CN117651084B CN117651084B (en) 2024-04-19

Family

ID=90045363

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410108277.XA Active CN117651084B (en) 2024-01-26 2024-01-26 Heterogeneous protocol message processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117651084B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160197992A1 (en) * 2015-01-05 2016-07-07 International Business Machines Corporation File storage protocols header transformation in rdma operations
CN106657149A (en) * 2017-01-24 2017-05-10 恒生电子股份有限公司 Communication protocol conversion method and device
CN108521378A (en) * 2018-04-23 2018-09-11 天津芯海创科技有限公司 Retransmission method, device and the network switching equipment of heterogeneous protocol message
CN116760911A (en) * 2023-06-06 2023-09-15 井芯微电子技术(天津)有限公司 Heterogeneous protocol conversion system and method
CN117354382A (en) * 2023-09-21 2024-01-05 云南电网有限责任公司迪庆供电局 Communication protocol conversion method, system, device and storage medium
CN117395329A (en) * 2023-12-13 2024-01-12 井芯微电子技术(天津)有限公司 Method, device and storage medium for receiving and transmitting Ethernet two-layer protocol message

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160197992A1 (en) * 2015-01-05 2016-07-07 International Business Machines Corporation File storage protocols header transformation in rdma operations
CN106657149A (en) * 2017-01-24 2017-05-10 恒生电子股份有限公司 Communication protocol conversion method and device
CN108521378A (en) * 2018-04-23 2018-09-11 天津芯海创科技有限公司 Retransmission method, device and the network switching equipment of heterogeneous protocol message
CN116760911A (en) * 2023-06-06 2023-09-15 井芯微电子技术(天津)有限公司 Heterogeneous protocol conversion system and method
CN117354382A (en) * 2023-09-21 2024-01-05 云南电网有限责任公司迪庆供电局 Communication protocol conversion method, system, device and storage medium
CN117395329A (en) * 2023-12-13 2024-01-12 井芯微电子技术(天津)有限公司 Method, device and storage medium for receiving and transmitting Ethernet two-layer protocol message

Also Published As

Publication number Publication date
CN117651084B (en) 2024-04-19

Similar Documents

Publication Publication Date Title
CN110380970B (en) Self-adaptive data message forwarding method and device suitable for heterogeneous network
US11711288B2 (en) Centralized error telemetry using segment routing header tunneling
US11652735B2 (en) Multicast data packet processing method, and apparatus
CN109688057A (en) The message forwarding method and device of section route network based on IPV6
US10735373B2 (en) Communications over multiple protocol interfaces in a computing environment
CN113259239A (en) Method, equipment and system for forwarding message in hybrid network
WO2022142390A1 (en) Packet encapsulation and de-encapsulation method and device, storage medium, and electronic device
CN117651084B (en) Heterogeneous protocol message processing method and device, electronic equipment and storage medium
US20230327983A1 (en) Performance measurement in a segment routing network
US20220094613A1 (en) Message sampling method, decapsulation method, node, system and storage medium
CN116521602A (en) Bus data transmission method and device and storage medium
US8625619B2 (en) Domain gateway control system and method thereof
CN109995603B (en) Method and device for measuring packet loss under Tag model and electronic equipment
WO2022134674A1 (en) Message transmission method and apparatus, and device, storage medium and system
CN115174414A (en) Method, system and electronic device for automatically identifying devices and device paths in session
US10523795B2 (en) Small form-factor pluggable module
CN114884905A (en) Flow mirroring method, device, equipment and computer storage medium
CN112714063B (en) Message transmission method, device and digital processing chip
CN108616453B (en) Method, device and system for network equipment
TWI603599B (en) Data sharing method and electronic device using same
JP3834157B2 (en) Service attribute assignment method and network device
CN116800447A (en) Message processing method, message checking method and device
CN115473847A (en) Forwarding method, forwarding system, electronic device, and computer-readable storage medium
CN116389248A (en) Gateway batch configuration method, device, terminal equipment and storage medium
CN116962537A (en) Data transmission method, device, network equipment and storage medium

Legal Events

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