Disclosure of Invention
In view of this, the disclosure provides a method, an apparatus, a device, an electronic device, and a computer readable medium for analyzing message data, which can update an offset memory data lookup table and a protocol type memory data lookup table in real time, thereby realizing dynamic configuration of message analysis types, without modifying codes to re-write FPGA programs, and accelerating product update iteration speed.
Other features and advantages of the present disclosure will be apparent from the following detailed description, or may be learned in part by the practice of the disclosure.
According to one aspect of the disclosure, a message data analysis method is provided, and the method comprises the steps of identifying a first layer protocol type of message data, determining a first layer offset query address and a lower layer protocol query address based on the first layer protocol type, extracting key field data of the message data based on the first layer offset query address and the lower layer protocol query address, and analyzing the message data based on a preset strategy to generate an analysis result when the key field data meets the preset strategy.
In an exemplary embodiment of the disclosure, the method further includes determining a lower protocol type based on the key field data when the key field data does not meet a preset policy, determining a lower offset query address and a last protocol query address based on the lower protocol type, and resolving the message data based on the lower offset query address and the last protocol query address to generate a resolved result.
In one exemplary embodiment of the present disclosure, the method further comprises storing a plurality of offset query addresses based on the offset memory and storing a plurality of protocol query addresses based on the protocol type querier.
In one exemplary embodiment of the present disclosure, real-time modification of the plurality of offset query addresses and the plurality of protocol query addresses according to a data modification instruction is included.
In one exemplary embodiment of the present disclosure, determining a first layer offset query address and a lower layer protocol query address based on the first layer protocol type includes determining the first layer offset query address based on data length information of the first layer protocol type and determining the lower layer protocol query address based on data length information of the first layer protocol type.
In one exemplary embodiment of the disclosure, extracting key field data of the message data based on the first layer offset query address and a lower layer protocol query address includes determining offset data based on the first layer offset query address, determining a protocol type based on the lower layer protocol query address, and parsing the message data based on the offset data and the protocol type to extract the key field data.
In an exemplary embodiment of the disclosure, parsing the message data based on the offset data and the protocol type to extract the key field data includes offsetting the message data based on the offset data and parsing the offset message data according to the protocol type to extract the key field data.
In an exemplary embodiment of the disclosure, when the key field data meets a preset policy, analyzing the message data based on the preset policy to generate an analysis result includes analyzing the message data according to a TCP protocol to generate an analysis result when the key field data is the TCP protocol.
According to one aspect of the disclosure, a message data analysis device is provided, which comprises an identification module for identifying a first layer protocol type of message data, an address module for determining a first layer offset query address and a lower layer protocol query address based on the first layer protocol type, a data module for extracting key field data of the message data based on the first layer offset query address and the lower layer protocol query address, and an analysis module for analyzing the message data based on a preset strategy to generate an analysis result when the key field data meets the preset strategy.
In one exemplary embodiment of the present disclosure, an instruction module is included for modifying the plurality of offset query addresses and the plurality of protocol query addresses in real time according to a data modification instruction.
According to one aspect of the disclosure, a message data analysis device is provided, and the device comprises a message data analysis device used for identifying a first layer protocol type of message data, a first layer offset query address and a lower layer protocol query address which are determined based on the first layer protocol type, key field data of the message data are extracted based on the first layer offset query address and the lower layer protocol query address, when the key field data meet a preset strategy, the message data are analyzed based on the preset strategy to generate an analysis result, an offset memory is used for storing a plurality of offset query addresses so that the message data analysis device can inquire, and a protocol type memory is used for storing a plurality of protocol query addresses so that the message data analysis device can inquire.
According to an aspect of the disclosure, an electronic device is presented, comprising one or more processors, storage means for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement a method as described above.
According to an aspect of the present disclosure, a computer-readable medium is presented, on which a computer program is stored, which program, when being executed by a processor, implements a method as described above.
According to the method, the device, the electronic equipment and the computer readable medium for analyzing the message data, the first layer protocol type of the message data is identified, the first layer offset query address and the lower layer protocol query address are determined based on the first layer protocol type, key field data of the message data are extracted based on the first layer offset query address and the lower layer protocol query address, when the key field data meet a preset strategy, the message data are analyzed based on the preset strategy to generate an analysis result, and the offset memory data query table and the protocol type memory data query table can be updated in real time, so that dynamic configuration of the message analysis type is realized, a code is not required to be modified to rewrite an FPGA program, and the product updating iteration speed is accelerated.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments can be embodied in many different forms and should not be construed as limited to the embodiments set forth herein, but rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and thus a repetitive description thereof will be omitted.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the disclosed aspects may be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, apparatus, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow diagrams depicted in the figures are exemplary only, and do not necessarily include all of the elements and operations/steps, nor must they be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the order of actual execution may be changed according to actual situations.
It will be understood that, although the terms first, second, third, etc. may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one element from another element. Accordingly, a first component discussed below could be termed a second component without departing from the teachings of the concepts of the present disclosure. As used herein, the term "and/or" includes any one of the associated listed items and all combinations of one or more.
Those skilled in the art will appreciate that the drawings are schematic representations of example embodiments and that the modules or flows in the drawings are not necessarily required to practice the present disclosure, and therefore, should not be taken to limit the scope of the present disclosure.
The technical abbreviations are explained as follows:
and the FPGA is Field Programmable GATE ARRAY a field programmable gate array.
IPv4: internet Protocol version 4 fourth edition of the internet protocol.
IHL INTERNET HEADER LENGTH IP header length, IPv4 header length information data.
The TCP Transmission Control Protocol transport control protocol is a connection-oriented, reliable, byte stream based transport layer communication protocol.
Fig. 1 is a schematic diagram of a message parsing method according to the prior art. As shown in fig. 1, the invention of the disclosure finds that the conventional message parsing method firstly recognizes that the protocol layer is Ethernet according to the received data of the protocol layer 1, then obtains the next layer protocol as IPv4 according to the type information of the Ethernet layer, and determines the offset 1 of the protocol layer 1, thereby extracting the data of the IPv4 layer, and then obtains the next layer protocol as TCP according to the data of the IPv4 layer, and determines the offset 2 of the protocol layer 2, thereby completing the parsing of all the protocol layers layer by layer.
The traditional parsing method has the advantages that all types of messages which can be parsed are determined, logic codes are written according to the types which need to be parsed, the codes are required to be modified and FPGA programs are required to be rewritten every time a new type of message is updated, then related functions are tested, the updating iteration speed of network communication equipment using the parsing method is low, and the network communication equipment is difficult to adapt to the increasing business demands.
In view of the technical bottleneck in the prior art, in the method, the device and the equipment for analyzing the message data, the memory is used for respectively storing the header offset and the protocol type which need to be inquired in the process of analyzing the message, and the memory is connected through the communication bus of the external processor, so that the offset and the lower protocol type which are modified in real time are used for realizing the method for analyzing the message by dynamic configuration, and a code re-programming program is not required to be modified.
The present disclosure is described in detail below with the aid of specific examples.
Fig. 2 is a flow chart illustrating a method of message data parsing according to an exemplary embodiment. The message data parsing method 20 at least includes steps S202 to S208.
As shown in fig. 2, in S202, a first layer protocol type of the message data is identified. The first layer protocol type identified by the message data can be any type of data protocol in the prior art.
In S204, a first layer offset query address and a lower layer protocol query address are determined based on the first layer protocol type. The first layer offset query address may be determined based on data length information of the first layer protocol type, and the lower layer protocol query address may be determined based on data length information of the first layer protocol type.
In S206, the key field data of the message data is extracted based on the first layer offset query address and the lower layer protocol query address. Determining offset data based on the first layer offset query address, determining a protocol type based on the lower layer protocol query address, and analyzing the message data based on the offset data and the protocol type to extract the key field data.
In one embodiment, the method further comprises storing a plurality of offset query addresses based on the offset memory and storing a plurality of protocol query addresses based on the protocol type querier.
More specifically, the offset memory stores a plurality of corresponding relations between offset query addresses and offsets through an offset query table, and queries offset data in the offset query table according to the first-layer offset query address.
More specifically, the protocol type inquirer stores a plurality of corresponding relations between the protocol inquiry addresses and the protocol types through the protocol inquiry address table. And inquiring the protocol type in a protocol inquiry address table according to the lower protocol inquiry address.
In one embodiment, the method further comprises modifying the plurality of offset query addresses and the plurality of protocol query addresses in real time according to a data modification instruction. The protocol inquiry address table and the offset inquiry table can reserve a space, can be modified in real time, and can modify the corresponding relation between the offset inquiry address and the offset and the corresponding relation between the protocol inquiry address and the protocol type in real time according to the data modification instruction.
The method comprises the steps of analyzing the message data based on the offset data and the protocol type to extract the key field data, and analyzing the offset message data according to the protocol type to extract the key field data.
In S208, when the key field data meets a preset policy, the message data is parsed based on the preset policy to generate a parsing result. And when the key field data is a TCP protocol, analyzing the message data according to the TCP protocol to generate an analysis result.
In one embodiment, the method further comprises the steps of determining a lower protocol type based on the key field data when the key field data does not meet a preset strategy, determining a lower offset query address and a last protocol query address based on the lower protocol type, extracting the key field data of the message data based on the lower offset query address and the last protocol query address, and analyzing the message data to generate an analysis result when the key field data is a TCP protocol. And when the key field data is not the TCP protocol, extracting the lower protocol address again to extract the key field data and analyzing.
According to the message data analysis method, the first layer protocol type of the message data is identified, the first layer offset query address and the lower layer protocol query address are determined based on the first layer protocol type, key field data of the message data are extracted based on the first layer offset query address and the lower layer protocol query address, when the key field data meet a preset strategy, the message data are analyzed based on the preset strategy to generate an analysis result, an offset memory data query table and a protocol type memory data query table can be updated in real time, dynamic configuration of the message analysis type is achieved, a code is not required to be modified to rewrite an FPGA program, and the product updating iteration speed is accelerated.
It should be clearly understood that this disclosure describes how to make and use particular examples, but the principles of this disclosure are not limited to any details of these examples. Rather, these principles can be applied to many other embodiments based on the teachings of the present disclosure.
Fig. 3 is a flow chart illustrating a method of message data parsing according to another exemplary embodiment. The flow 30 shown in fig. 3 is a detailed description of the flow shown in fig. 2.
As shown in fig. 3, in S302, message data is received.
In S304, a first layer protocol type is identified.
In S306, an offset query address is determined.
In S308, the lower protocol query address is determined.
In S310, key field data is extracted.
In S312, whether the analysis result is a preset analysis result.
In S314, the analysis result is output.
In S316, the lower layer data is parsed.
After receiving new message data, identifying the first layer protocol type, calculating the offset inquiry address of the layer according to the length information of the first layer protocol data and outputting the offset inquiry address to an offset memory, wherein the offset memory outputs the offset corresponding to the inquiry address, then calculating the lower layer protocol inquiry address according to the lower layer protocol data information and outputting the lower layer protocol inquiry address to a protocol type memory, the protocol type memory outputs the protocol type corresponding to the inquiry address, extracts key field data according to the current protocol type, judges whether analysis is finished according to the received lower layer protocol type, outputs the current analysis result if analysis is finished, receives new packet data, and jumps to the lower layer protocol according to the received offset to continue analysis if not finished.
Fig. 4 is a schematic diagram illustrating a message data parsing method according to another exemplary embodiment. In a specific embodiment, as shown in fig. 5, the first layer protocol is identified as Ethernet, an offset query address 1 is generated and output to the offset query memory, and a return value is fixed 14, as shown in fig. 6, the protocol query address 1 is obtained according to the type information of the Ethernet layer, and output to the protocol type query memory, and the return value is 2 (IPv 4 protocol).
The data of the IPv4 layer can be continuously analyzed after the message data is shifted by 14 bytes. And calculating an offset query address 2 according to the IHL information of the IPv4 layer, outputting the offset query address 2 to an offset query memory, obtaining a Protocol query address 2 according to the Protocol information of the IPv4 layer, outputting the Protocol query address 2 to a Protocol type query memory, and outputting a return value of 4 (TCP Protocol).
The data of the TCP layer can be continuously analyzed after the message data is shifted by 20 bytes. And generating end analysis mark information when the current protocol layer is identified as TCP, and outputting an analysis result, and receiving new packet data by the message analysis device.
And in the analysis process, selecting and extracting key data of each layer according to actual project requirements.
More specifically, according to the method for analyzing message data disclosed by the disclosure, default data is preset according to the type of the message to be analyzed by the offset memory data lookup table and the protocol type memory data lookup table, and the type of the message to be analyzed can be updated in real time by a processor (CPU and the like), so that the type of the message to be analyzed is increased, and the FPGA program is not required to be rewritten, thereby realizing a dynamic configuration function.
According to the message data analysis method, the data lookup table of the offset memory and the data lookup table of the protocol type memory can be updated in real time through the external processor, so that dynamic configuration of message analysis types is realized. And using an offset memory and a protocol type memory to realize query allocation of offset and protocol types in the process of analyzing the message.
Those skilled in the art will appreciate that all or part of the steps implementing the above described embodiments are implemented as a computer program executed by a CPU. The above-described functions defined by the above-described methods provided by the present disclosure are performed when the computer program is executed by a CPU. The program may be stored in a computer readable storage medium, which may be a read-only memory, a magnetic disk or an optical disk, etc.
Furthermore, it should be noted that the above-described figures are merely illustrative of the processes involved in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It will be readily appreciated that the processes shown in the above figures do not indicate or limit the temporal order of these processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, for example, among a plurality of modules.
The following are device embodiments of the present disclosure that may be used to perform method embodiments of the present disclosure. For details not disclosed in the embodiments of the apparatus of the present disclosure, please refer to the embodiments of the method of the present disclosure.
Fig. 7 is a block diagram illustrating a message data parsing apparatus according to an exemplary embodiment. As shown in fig. 7, the message data parsing device 70 includes an identification module 702, an address module 704, a data module 706, a parsing module 708, and the message data parsing device 70 may further include an instruction module 710.
The identifying module 702 is configured to identify a first layer protocol type of the message data;
the address module 704 is configured to determine a first layer offset query address and a lower layer protocol query address based on the first layer protocol type;
The data module 706 is configured to extract key field data of the packet data based on the first-layer offset query address and a lower-layer protocol query address;
The parsing module 708 is configured to parse the message data based on a preset policy to generate a parsing result when the key field data satisfies the preset policy.
The instruction module 710 is configured to modify the plurality of offset query addresses and the plurality of protocol query addresses in real time according to a data modification instruction.
According to the message data analysis device, the offset memory and the protocol type memory are used for inquiring and allocating the offset and the protocol type in the process of analyzing the message, and the offset memory data inquiry table and the protocol type memory data inquiry table can be updated in real time through the external processor, so that the dynamic configuration of the message analysis type is realized, the FPGA program is not required to be rewritten by modifying codes, and the product updating iteration speed is accelerated.
Fig. 8 is a block diagram of a message data parsing apparatus according to another exemplary embodiment. As shown in fig. 8, the message data parsing device 80 includes a message data parsing apparatus 802, an offset memory 804, a protocol type memory 806, and the message data parsing device 80 may further include a processor 808.
The message data parsing device 802 is configured to identify a first layer protocol type of the message data, determine a first layer offset query address and a lower layer protocol query address based on the first layer protocol type, extract key field data of the message data based on the first layer offset query address and the lower layer protocol query address, parse the message data based on a preset policy to generate a parsing result when the key field data meets the preset policy, where specific internal modules of the message data parsing device 802 may be set as internal modules of the message data parsing device 70.
More specifically, the message data parsing device 802 may be configured to identify a first protocol type of the message data, calculate an offset query address, calculate a lower protocol query address, extract key field data, and receive data matching switch information sent by the processor.
The offset memory 804 is configured to store a plurality of offset query addresses for the message data parsing device to query;
more specifically, the offset memory 804 may be used to output a corresponding offset based on the received query address, receiving a processor data modification instruction.
The protocol type memory 806 is configured to store a plurality of protocol query addresses for querying by the packet data parsing device.
More specifically, the protocol type memory 806 may be configured to output a corresponding protocol type based on the received query address and receive a processor data modification instruction.
The processor 808 is configured to modify the plurality of offset query addresses and the plurality of protocol query addresses in real time according to the data modification instruction.
According to the message data analysis equipment, the first-layer protocol type of the message data is identified, the first-layer offset query address and the lower-layer protocol query address are determined based on the first-layer protocol type, key field data of the message data are extracted based on the first-layer offset query address and the lower-layer protocol query address, when the key field data meet a preset strategy, the message data are analyzed based on the preset strategy to generate an analysis result, and an offset memory data query table and a protocol type memory data query table can be updated in real time, so that dynamic configuration of the message analysis type is realized, a code is not required to be modified to rewrite an FPGA program, and the product updating iteration speed is accelerated.
Fig. 9 is a block diagram of an electronic device, according to an example embodiment.
An electronic device 900 according to such an embodiment of the present disclosure is described below with reference to fig. 9. The electronic device 900 shown in fig. 9 is merely an example and should not be construed to limit the functionality and scope of use of embodiments of the present disclosure in any way.
As shown in fig. 9, the electronic device 900 is embodied in the form of a general purpose computing device. Components of electronic device 900 may include, but are not limited to, at least one processing unit 910, at least one storage unit 920, a bus 930 connecting the different system components (including storage unit 920 and processing unit 910), a display unit 940, and the like.
Wherein the storage unit stores program code that is executable by the processing unit 910 such that the processing unit 910 performs steps described in the present specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 910 may perform the steps as shown in fig. 2, 3.
The storage unit 920 may include readable media in the form of volatile storage units, such as Random Access Memory (RAM) 9201 and/or cache memory 9202, and may further include Read Only Memory (ROM) 9203.
The storage unit 920 may also include a program/utility 9204 having a set (at least one) of program modules 9205, such program modules 9205 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
The bus 930 may be one or more of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 900 may also be in communication with one or more external devices 900' (e.g., keyboard, pointing device, bluetooth device, etc.), devices that enable a user to interact with the electronic device 900, and/or any devices (e.g., routers, modems, etc.) that the electronic device 900 can communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 950. Also, electronic device 900 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through network adapter 960. The network adapter 960 can communicate with other modules of the electronic device 900 via the bus 930. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 900, including, but not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, as shown in fig. 10, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, and includes several instructions to cause a computing device (may be a personal computer, a server, or a network device, etc.) to perform the above-described method according to the embodiments of the present disclosure.
The software product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of a readable storage medium include an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The computer readable storage medium may include a data signal propagated in baseband or as part of a carrier wave, with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable storage medium may also be any readable medium that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
The computer readable medium carries one or more programs, and when the one or more programs are executed by the equipment, the computer readable medium realizes the functions of identifying the first layer protocol type of the message data, determining a first layer offset query address and a lower layer protocol query address based on the first layer protocol type, extracting key field data of the message data based on the first layer offset query address and the lower layer protocol query address, and analyzing the message data based on a preset strategy to generate an analysis result when the key field data meets the preset strategy. The computer readable medium may also implement the function of modifying the plurality of offset query addresses and the plurality of protocol query addresses in real time according to data modification instructions.
Those skilled in the art will appreciate that the modules may be distributed throughout several devices as described in the embodiments, and that corresponding variations may be implemented in one or more devices that are unique to the embodiments. The modules of the above embodiments may be combined into one module, or may be further split into a plurality of sub-modules.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or in combination with the necessary hardware. Thus, the technical solutions according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, and include several instructions to cause a computing device (may be a personal computer, a server, a mobile terminal, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
Exemplary embodiments of the present disclosure are specifically illustrated and described above. It is to be understood that the disclosure is not to be limited to the details of construction, arrangement or method of implementation described herein, but on the contrary, is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.