Message analysis method and device, equipment and storage medium
By performing physical layer processing and format reorganization on wireless signals in the communication module of an embedded device, a target communication message carrying complete protocol layer message header information is generated. This solves the problem that embedded devices cannot perform network message analysis and realizes effective analysis and diagnosis functions in resource-constrained environments.
Patent Information
- Application Number
- CN202511767091.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-02-27
AI Technical Summary
Existing network packet analysis tools cannot work effectively on resource-constrained embedded devices, especially in wireless network environments where embedded devices cannot perform complete protocol layer header information analysis.
By performing physical layer processing on the terminal's wireless signal through the communication module of the embedded device, the raw data packets are obtained, and the format is reorganized and the instructions are encapsulated to generate the target communication message, which carries the complete protocol layer message header information and is sent to the microcontroller to call a lightweight analysis tool for parsing.
It enables effective network packet analysis on resource-constrained embedded devices, solves the problem of embedded devices being unable to adapt to PC-based tools, and enhances the robustness and robustness of network applications.
Smart Images

Figure CN121585751A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of Internet of Things (IoT) technology, and in particular relates to a message analysis method, apparatus, device, and storage medium. Background Technology
[0002] Network packets, as carriers of information transmission, are crucial for network management and security. Current network packet analysis relies on dedicated PC-based tools such as Wireshark and Sniffer. These tools require substantial hardware resources to achieve packet capture, protocol identification, and data extraction, making them unsuitable for resource-constrained embedded devices. Furthermore, embedded devices in wireless network environments typically employ an architecture combining an MCU (Microcontroller Unit) and a communication module. Packets transmitted from the communication module to the MCU are usually truncated, lacking header information, thus hindering effective network packet analysis in embedded devices. Summary of the Invention
[0003] This application provides a packet analysis method, apparatus, device, and storage medium, aiming to solve the technical problem of how to achieve effective network packet analysis on resource-constrained embedded devices.
[0004] In a first aspect, embodiments of this application provide a message analysis method, the method being applied to a communication module in an embedded device, the embedded device including a communication module and a microcontroller, the communication module and the microcontroller being communicatively connected; the method comprising: The wireless signal sent by the terminal is processed by the physical layer to obtain the raw data packet; wherein the raw data packet includes the data field and the message header information of multiple protocol layers in the network communication protocol stack; The original data packet is reformatted and encapsulated with instructions to obtain a target communication message; wherein, the target communication message includes an instruction header, which is used to identify that the format of the target communication message is the original format including the message header information of the multiple protocol layers; The target communication message is sent to the microcontroller, so that the microcontroller, based on the instruction header in the target communication message, calls a message analysis tool to parse the target communication message and obtain the message header information and data fields of the multiple protocol layers.
[0005] In one feasible implementation, the step of reformatting and encapsulating the original data packet to obtain the target communication message includes: The header information and data fields of multiple protocol layers in the original data packet are assembled in a preset order to generate reconstructed data; Add an instruction header to the recombined data to obtain a target communication message that conforms to the attention instruction format.
[0006] In one feasible implementation, the instruction header consists of an attention instruction prefix and raw data commands.
[0007] In one feasible implementation, the message header information of the multiple protocol layers includes message header information of the network interface layer, message header information of the network layer, message header information of the transport layer, and message header information of the application layer. The preset order is the hierarchical order of the network communication protocol stack from the bottom layer to the top layer.
[0008] Secondly, embodiments of this application provide a message analysis method, which is applied to a microcontroller in an embedded device. The embedded device includes a communication module and a microcontroller, and the communication module and the microcontroller are communicatively connected. The method includes: Upon receiving a target communication message sent by the communication module, the target communication message is identified to obtain an instruction header; wherein, the target communication message is obtained by the communication module after format reassembly and instruction encapsulation of the original data packet; the original data packet includes a data field and message header information of multiple protocol layers in the network communication protocol stack; The message analysis tool is invoked according to the instruction header; The target communication message is parsed using the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
[0009] In one feasible implementation, the packet analysis tool includes a network interface layer header parsing module, a network layer header parsing module, a transport layer header parsing module, and an application layer header parsing module; The network interface layer header parsing module is used to parse the header information of the network interface layer in the target communication message; The network layer header parsing module is used to parse the network layer header information in the target communication message; The transport layer header parsing module is used to parse the transport layer header information in the target communication message; The application layer header parsing module is used to parse the application layer header information in the target communication message.
[0010] Thirdly, embodiments of this application provide a message analysis apparatus, which is applied to a communication module in an embedded device. The embedded device includes a communication module and a microcontroller, and the communication module and the microcontroller are communicatively connected. The apparatus includes: The processing module performs physical layer processing on the wireless signals sent by the terminal to obtain raw data packets; wherein, the raw data packets include data fields and message header information of multiple protocol layers in the network communication protocol stack; An encapsulation module is used to reorganize the format and encapsulate the instructions of the original data packet to obtain a target communication message; wherein, the target communication message includes an instruction header, which is used to identify that the format of the target communication message is the original format including the message header information of the multiple protocol layers; The sending module is used to send the target communication message to the microcontroller, so that the microcontroller can call the message analysis tool to parse the target communication message based on the instruction header in the target communication message, and obtain the message header information and data fields of the multiple protocol layers.
[0011] Fourthly, embodiments of this application provide a message analysis apparatus, which is applied to a microcontroller in an embedded device. The embedded device includes a communication module and a microcontroller, and the communication module and the microcontroller are communicatively connected. The apparatus includes: The identification module is used to identify the target communication message and obtain the instruction header when it receives the target communication message sent by the communication module; wherein the target communication message is obtained by the communication module after format reassembly and instruction encapsulation of the original data packet; the original data packet includes a data field and message header information of multiple protocol layers in the network communication protocol stack; The calling module is used to invoke the message analysis tool according to the instruction header; The parsing module is used to parse the target communication message according to the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
[0012] Fifthly, embodiments of this application provide an embedded device, the embedded device including a communication module and a microcontroller, the communication module and the microcontroller being communicatively connected; The communication module is used to perform physical layer processing on the wireless signals sent by the terminal to obtain raw data packets; wherein, the raw data packets include data fields and message header information of multiple protocol layers in the network communication protocol stack; The communication module is further used to re-format and encapsulate the original data packet to obtain a target communication message; wherein, the target communication message includes an instruction header, which is used to identify that the format of the target communication message is the original format including the message header information of the multiple protocol layers; The communication module is also used to send the target communication message to the microcontroller; The microcontroller is used to identify the target communication message and obtain the instruction header; The microcontroller is also used to invoke a message analysis tool according to the instruction header; The microcontroller is also used to parse the target communication message according to the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
[0013] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement the message analysis method as described in the first or second aspect.
[0014] In a seventh aspect, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform a message analysis method as described in the first or second aspect.
[0015] The message analysis method, apparatus, device, and storage medium of this application embodiment first perform physical layer processing on the wireless signal sent by the terminal through a communication module to obtain the original data packet containing complete message header information and data fields of each protocol layer. Then, after format reassembly, it is encapsulated with a target communication message with an instruction header identifying the original complete format and sent to the MCU. Based on the instruction header, the MCU can call a message analysis tool adapted to embedded resources to complete the parsing. This not only solves the problem that existing PC-side tools cannot adapt to the limited resources of embedded devices, but also retains and transmits complete message header information through the communication module, making up for the defect of incomplete message data under the MCU combined with the communication module architecture. Finally, it realizes effective network message analysis on resource-constrained embedded devices, providing reliable support for valuable functions such as network fault diagnosis and performance analysis, and increasing the robustness and robustness of network applications. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1This is a schematic flowchart of an embodiment of a message analysis method provided in this application. Figure 2 This is a network topology diagram of the message analysis method provided in Embodiment 1 of this application; Figure 3 This is a schematic diagram of message encapsulation and parsing of the message analysis method provided in Embodiment 1 of this application; Figure 4 This is a schematic diagram of the overall process of the message analysis method provided in Embodiment 1 of this application; Figure 5 This is a flowchart illustrating a second embodiment of a message analysis method provided in this application. Figure 6 This is a schematic diagram of the structure of a message analysis device for a communication module of an embedded device provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a message analysis device for a microcontroller applied to an embedded device, provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of an embedded device provided in an embodiment of this application. Detailed Implementation
[0018] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0019] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0020] Existing network packet analysis relies on dedicated PC (Personal Computer) tools such as Wireshark and Sniffer. These tools require sufficient hardware resources to achieve packet capture, protocol identification, and data extraction, and cannot be directly adapted to resource-constrained embedded devices. At the same time, embedded devices in wireless network environments often adopt a typical architecture of MCU (Microcontroller Unit) combined with communication module. The packets transmitted from the communication module to the MCU are usually truncated and do not include header information, which makes it impossible for embedded devices to perform effective network packet analysis.
[0021] To address the problems of the prior art, embodiments of this application provide a message analysis method, apparatus, device, and storage medium. The message analysis method provided in this application embodiment will be described first below.
[0022] Figure 1 A flowchart illustrating a message analysis method provided in one embodiment of this application is shown. Figure 1 As shown, the method is applied to a communication module in an embedded device, the embedded device including a communication module and a microcontroller, and the communication module and the microcontroller are communicatively connected; the method may include steps 210-230: Step 210: Perform physical layer processing on the wireless signal sent by the terminal to obtain the original data packet; wherein the original data packet includes the data field and message header information of multiple protocol layers in the network communication protocol stack.
[0023] In this embodiment, the execution entity is the communication module in an embedded device. An embedded device is a resource-constrained dedicated computing device that employs a hardware architecture combining a microcontroller (MCU) and a communication module. The MCU is responsible for running the application program and providing the necessary hardware environment, while the communication module is responsible for receiving wireless network packets. Its main components include a radio frequency module, a baseband chip, and a power amplifier (PA). After receiving a packet, the communication module transmits the packet to the MCU through a physical interface, commonly a UART serial port.
[0024] In some embodiments, the communication module of the embedded device can perform physical layer processing on the wireless signals sent by the terminal to obtain raw data packets containing complete protocol stack header information. Subsequently, the communication module re-formats and encapsulates the raw data packets with instructions, and sends the resulting target communication message to the MCU. Upon receiving this message, the MCU can invoke its built-in lightweight analysis tools to parse it, thereby enabling effective network packet analysis on resource-constrained embedded devices.
[0025] Wireless signals refer to electromagnetic wave signals transmitted by terminals communicating with embedded devices based on wireless communication protocols (such as Bluetooth and Wi-Fi), and are the physical carriers of network messages. Terminals send network messages to the communication modules of embedded devices via wireless networks (such as cellular networks). This process can be addressed using IP (Internet Protocol Address) addresses to complete message delivery.
[0026] After receiving the wireless signal sent by the terminal, the communication module performs physical layer processing on the wireless signal, including but not limited to analog-to-digital conversion, demodulation, decoding / decryption, etc., to obtain the raw data packet. The raw data packet contains complete message header information and data fields from multiple protocol layers in the network communication protocol stack. Among them, the data field is the core business data to be transmitted by the terminal and is the core content carried by the network message.
[0027] A network communication protocol stack refers to a layered collaborative architecture defined to achieve network communication. Each layer encapsulates and decapsulates data layer by layer through standardized message header information. The message header information of multiple protocol layers refers to the identification and control fields added by each layer of the network communication protocol stack to achieve data transmission control.
[0028] In one feasible implementation, the message header information of the multiple protocol layers includes message header information of the network interface layer, message header information of the network layer, message header information of the transport layer, and message header information of the application layer.
[0029] Optionally, taking the TCP (Transmission Control Protocol) / IP protocol stack as an example, the network communication protocol stack includes four protocol layers: network interface layer, network layer, transport layer, and application layer. The network topology is as follows: Figure 2 As shown. The physical layer, also known as the network interface layer, is the lowest layer of the TCP / IP protocol suite, and is also called the link layer or data link layer. It primarily handles the details of physical hardware and data links, including network adapters, data frame encapsulation and decapsulation, and MAC (Media Access Control) address management. The main task of this layer is to transmit data packets from one device to another, facilitating communication through physical media (such as Ethernet cables or Wi-Fi signals).
[0030] The network layer, the layer of the IP protocol, is responsible for handling packet routing and addressing. It uses IP addresses to identify different computers and devices and determines the best path for packets to be transmitted across the network. Routers are devices that operate at this layer; they are responsible for passing packets from one subnet to another until they reach their destination device.
[0031] The transport layer is the core of the TCP / IP protocol suite, responsible for end-to-end communication and data reliability. It defines two main protocols: TCP and UDP (User Datagram Protocol).
[0032] The application layer is the highest layer of the TCP / IP protocol suite, containing various application protocols used to implement different types of network applications and services.
[0033] Based on the TCP / IP four-layer network architecture, network packets are composed of data content and header information. At the sending end, packet headers are added sequentially from the application layer to the physical layer, with each layer's header enclosing the previous one. At the receiving end, the packet headers are parsed layer by layer from the physical layer to the application layer to obtain the packet content.
[0034] Optionally, the encapsulation and parsing of the message header are illustrated as follows: Figure 3 As shown: HEADER1 to HEADER4 are, in order, Ethernet header, network header, transport header, and application header. The message header information includes the IP addresses of the sender and destination, the transport port, the MAC address, the protocol type, and checksum information. The encapsulation process at the sending end is as follows: Figure 3 The header information is added layer by layer from top to bottom, i.e., from the application layer to the transport layer to the network layer to the network interface layer. The parsing process at the receiving end is as follows: Figure 3 The header is parsed layer by layer from bottom to top, i.e., from the network interface layer to the network layer to the transport layer to the application layer.
[0035] The message headers of multiple protocol layers include those of the network interface layer, network layer, transport layer, and application layer. The network interface layer header includes, but is not limited to, source MAC address, destination MAC address, and frame type identifier, used for frame transmission control at the data link layer. The network layer header includes, but is not limited to, source IP address, destination IP address, and protocol type (e.g., TCP / UDP), used for cross-network routing and forwarding. The transport layer header includes, but is not limited to, source port number, destination port number, and protocol identifier (TCP / UDP), used for end-to-end transmission control and traffic management. The application layer header includes, but is not limited to, application layer protocol identifier, protocol version, and data length, used for defining the format and controlling the interaction of specific business data.
[0036] Optionally, unlike existing methods that remove the header information of each protocol layer in the wireless signal after physical layer processing, this embodiment retains the header information of each protocol layer after physical layer processing of the wireless signal.
[0037] Step 220: Reformat and encapsulate the original data packet to obtain the target communication message; wherein the target communication message includes an instruction header, which is used to identify that the format of the target communication message is the original format including the message header information of the multiple protocol layers.
[0038] A target communication message is a complete command string conforming to the AT command format, formed by the communication module after reorganizing and encapsulating the original data packet. Target communication messages are suitable for transmission within resource-constrained embedded devices and can be recognized and processed by the MCU's instruction parsing mechanism.
[0039] The instruction header is a specific string located at the beginning of the target communication message, used to identify that the target communication message is in the original format that includes header information from multiple protocol layers.
[0040] Optionally, the communication module reassembles the original data packets in raw (RAW) format and encapsulates them into an AT command framework to generate the target communication message. This method ensures compatibility with existing AT command processing procedures. The command header (i.e., the AT command header) serves as the message's identifier, used to determine whether its content is raw data.
[0041] In one feasible implementation, step 220 may include steps A11-A12: Step A11: Assemble the message header information and data fields of multiple protocol layers in the original data packet according to a preset order to generate reconstructed data.
[0042] Step A12: Add an instruction header to the recombined data to obtain a target communication message that conforms to the attention instruction format.
[0043] The preset order refers to the fixed arrangement rules pre-configured by the communication module for reassembling the components of the original data packet.
[0044] Optionally, the communication module first locates the header information and data fields of each protocol layer by parsing the format of the original data packet. After accurate location, the module extracts the header information of each layer sequentially and assembles the header information and data fields of multiple protocol layers in a preset order to form a continuous, structured reconstructed data. The communication module constructs an instruction header according to the attention instruction format specification and adds the constructed instruction header to the beginning of the reconstructed data, forming the target communication message consisting of the instruction header and the reconstructed data.
[0045] In this embodiment, by reassembling the original data and encapsulating the standard instructions within the communication module, the complete message header information is transmitted to the MCU while ensuring compatibility with existing AT command processing procedures.
[0046] In one feasible implementation, the instruction header consists of an attention instruction prefix and raw data commands.
[0047] Optionally, the instruction header consists of the attention instruction prefix AT and the raw data command (e.g., RAWDATA). For example, the instruction header is AT+RAWDATA. The attention instruction prefix is a common prefix in the AT instruction set, used to wake up and notify the MCU that a subsequent instruction will be processed.
[0048] By using the above-mentioned instruction header design, and through the collaborative logic of ensuring compatibility with a general prefix and accurately identifying custom commands, the problems of embedded devices being unable to adapt to PC-side analysis tools and missing message header information in existing technologies are solved, while also taking into account the compatibility requirements of embedded devices' resource limitations.
[0049] In one feasible implementation, the preset order is a hierarchical order from the bottom layer to the top layer of the network communication protocol stack.
[0050] Optionally, the preset order is the hierarchical order of the network communication protocol stack from bottom to top, that is, the outermost and first encapsulated message header information is placed first, specifically: message header information of the network interface layer to message header information of the network layer to message header information of the transport layer to message header information of the application layer to data payload.
[0051] By assembling the network communication protocol stack from bottom to top, the naturalness and correctness of the parsing logic are ensured, logical errors and dependency confusion in the parsing process are avoided, parsing efficiency is significantly improved, and MCU resource consumption is minimized.
[0052] In some embodiments, Table 1 is used as an example to illustrate the specific composition of the target communication message: AT+RAWDATA is the instruction header, which is unique; HEADER1 is the application layer header information; HEADER2 is the transport layer header information, which encapsulates application layer data; HEADER3 is the network layer header information, which encapsulates transport layer data; HEADER4 is the network interface layer (e.g., Ethernet layer, link layer) header information, which encapsulates network layer data packets as the outermost layer; DATA is the data field.
[0053] Table 1 Step 230: Send the target communication message to the microcontroller, so that the microcontroller can call the message analysis tool to parse the target communication message based on the instruction header in the target communication message, and obtain the message header information and data fields of the multiple protocol layers.
[0054] The message analysis tool is a lightweight analysis software adapted to the resource limitations of embedded devices, which encapsulates specialized parsing functions for message header information of each protocol layer.
[0055] In some embodiments, the communication module sends the encapsulated target communication message as a data stream through its physical interface with the MCU. After receiving the target communication message, the microcontroller can identify the instruction header at the beginning of the target communication message. Based on the instruction header, the MCU can call the embedded message analysis tool to decapsulate and analyze the message header information of each protocol layer in sequence, and extract the final data field.
[0056] Optionally, with Figure 4 The following example illustrates the message analysis process: Host B sends network packets to the wireless communication module of Host A via a wireless network; the wireless communication module processes the raw (RAW) network packets, fully preserving the header information of each protocol layer; subsequently, it performs format reassembly and AT command encapsulation on the processed raw data packets to generate the target communication message and sends it to the MCU; unlike the messages sent to the MCU by the wireless communication module in the prior art that lack valid header information, the target communication message in this embodiment carries complete header information of each protocol layer, so the MCU can directly call the embedded message analysis tool to complete accurate and efficient message analysis and processing.
[0057] This embodiment first performs physical layer processing on the wireless signal sent by the terminal through the communication module to obtain the original data packet containing complete message header information and data fields of each protocol layer. Then, after format reassembly, it is encapsulated into a target communication message with an instruction header identifying the original format and sent to the MCU. Based on this instruction header, the MCU can call a message analysis tool adapted to embedded resources to complete the parsing. This not only solves the problem that existing PC-side tools cannot adapt to the limited resources of embedded devices, but also makes up for the defect of incomplete message data under the MCU combined with the communication module architecture by preserving and transmitting complete message header information through the communication module. Ultimately, it realizes effective network message analysis on resource-constrained embedded devices, providing reliable support for valuable functions such as network fault diagnosis and performance analysis, and increasing the robustness and robustness of network applications.
[0058] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 5 The message analysis method is applied to a microcontroller in an embedded device, the embedded device including a communication module and a microcontroller, the communication module and the microcontroller being communicatively connected, and the method including steps 310-330: Step 310: Upon receiving a target communication message sent by the communication module, perform message identification on the target communication message to obtain the instruction header; wherein, the target communication message is obtained by the communication module after format reassembly and instruction encapsulation of the original data packet; the original data packet includes a data field and message header information of multiple protocol layers in the network communication protocol stack.
[0059] In this embodiment, the execution entity is a microcontroller (MCU) in an embedded device. An embedded device is a resource-constrained dedicated computing device that employs a hardware architecture combining a microcontroller (MCU) and a communication module. The MCU is responsible for running the application program and providing the necessary hardware environment, while the communication module is responsible for receiving wireless network packets. Its main components include a radio frequency module, a baseband chip, and a power amplifier (PA). After receiving a packet, the communication module transmits the packet to the MCU through a physical interface, commonly a UART serial port.
[0060] Optionally, the microcontroller may include one or more processor cores and memory storing computer program instructions. The processor core may be an ARM Cortex-M series, RISC-V, or other microcontroller core designed specifically for embedded applications. The memory may include on-chip flash memory and static random access memory. The on-chip flash memory is used to store firmware program code and constant data; the static random access memory is used to provide temporary storage space for program execution.
[0061] In some embodiments, the MCU receives target communication messages through its physical interface with the communication module. An instruction parser (e.g., an AT instruction parser) running within the MCU parses the received target communication messages. When it identifies an instruction header (e.g., AT+RAWDATA) that matches a preset rule, it determines that a complete target communication message has been successfully received. The parser then separates the instruction header and the reconstructed data (excluding the instruction header) from the identified target communication message.
[0062] Step 320: Invoke the message analysis tool according to the instruction header.
[0063] After the MCU recognizes that the instruction header matches the preset rules, it calls the message analysis tool and jumps to execute the entry function of the message analysis tool corresponding to the instruction header to ensure that the target communication message can be correctly parsed.
[0064] Step 330: Parse the target communication message using the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
[0065] Based on its embedded message analysis tool, the MCU first extracts the reconstructed data from the target communication message, and then decapsulates and parses the reconstructed data in the preset order when the communication module is assembled, to obtain the message header information and data fields of each protocol layer.
[0066] In one feasible implementation, the packet analysis tool includes a network interface layer header parsing module, a network layer header parsing module, a transport layer header parsing module, and an application layer header parsing module; the network interface layer header parsing module is used to parse the network interface layer header information in the target communication packet; the network layer header parsing module is used to parse the network layer header information in the target communication packet; the transport layer header parsing module is used to parse the transport layer header information in the target communication packet; and the application layer header parsing module is used to parse the application layer header information in the target communication packet.
[0067] In some embodiments, the message analysis tool is functionally divided, and specialized parsing functions for message header information of each protocol layer are encapsulated, which may include: a network interface layer header parsing module, a network layer header parsing module, a transport layer header parsing module, and an application layer header parsing module.
[0068] The network interface layer header parsing module parses the network interface layer header information in the target communication message to obtain parameters including, but not limited to, source MAC address, destination MAC address, and frame type identifier. The network layer header parsing module parses the network layer header information to obtain parameters including, but not limited to, source IP address, destination IP address, and protocol type (e.g., TCP / UDP). The transport layer header parsing module parses the transport layer header information to obtain parameters including, but not limited to, source port number, destination port number, and protocol identifier (TCP / UDP). The application layer header parsing module parses the application layer header information to obtain parameters including, but not limited to, application layer protocol identifier, protocol version, and data length.
[0069] In this implementation, specialized parsing modules are divided and work together according to the protocol stack layer to achieve accurate and targeted extraction of message header information of each protocol layer, ensuring the integrity and accuracy of parsing, and adapting to the layer-by-layer parsing logic to improve efficiency; at the same time, the message analysis tools are simplified, improving their practicality on resource-constrained embedded devices.
[0070] In this embodiment, after the MCU receives the target communication message through the physical interface, it completes the identification and extraction of the instruction header through the instruction header parser, solving the inefficiency problem of indiscriminate reception by traditional MCUs. Based on the valid instruction header, it directly calls the embedded lightweight analysis tool to complete the parsing, without the need for complex adaptation and scheduling. This adapts to the characteristics of MCU's limited computing power and memory, and solves the problem that existing PC-side tools cannot adapt to the resource-constrained embedded devices. Furthermore, the communication module retains and transmits complete message header information, making up for the defect of incomplete message data under the MCU combined with the communication module architecture. Finally, it realizes effective network message analysis on resource-constrained embedded devices, providing reliable support for valuable functions such as network fault diagnosis and performance analysis, and increasing the robustness and robustness of network applications.
[0071] like Figure 6 As shown in the figure, this application embodiment provides a message analysis device 200. The device is applied to a communication module in an embedded device. The embedded device includes a communication module and a microcontroller, and the communication module and the microcontroller are communicatively connected. The device may include a processing module 201, an encapsulation module 202, and a sending module 203. The processing module 201 performs physical layer processing on the wireless signal sent by the terminal to obtain the original data packet; wherein the original data packet includes the data field and the message header information of multiple protocol layers in the network communication protocol stack.
[0072] The encapsulation module 202 is used to re-format and encapsulate the original data packet to obtain a target communication message; wherein, the target communication message includes an instruction header, which is used to identify that the format of the target communication message is the original format including the message header information of the multiple protocol layers.
[0073] The sending module 203 is used to send the target communication message to the microcontroller, so that the microcontroller can call a message analysis tool to parse the target communication message based on the instruction header in the target communication message, and obtain the message header information and data fields of the multiple protocol layers.
[0074] Optionally, the encapsulation module 202 is further configured to: The header information and data fields of multiple protocol layers in the original data packet are assembled in a preset order to generate reconstructed data; Add an instruction header to the recombined data to obtain a target communication message that conforms to the attention instruction format.
[0075] like Figure 7As shown in the figure, this application embodiment provides a message analysis device 300. The device is applied to a microcontroller in an embedded device. The embedded device includes a communication module and a microcontroller, and the communication module and the microcontroller are communicatively connected. The device may include an identification module 301, a calling module 302, and a parsing module 303. The identification module 301 is used to identify the target communication message and obtain the instruction header when it receives the target communication message sent by the communication module; wherein the target communication message is obtained by the communication module after format reassembly and instruction encapsulation of the original data packet; the original data packet includes data field and message header information of multiple protocol layers in the network communication protocol stack.
[0076] The calling module 302 is used to call the message analysis tool according to the instruction header.
[0077] The parsing module 303 is used to parse the target communication message according to the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
[0078] Figure 8 The diagram shows the structure of an embedded device provided in an embodiment of this application. The embedded device 400 includes a communication module 401 and a microcontroller 402, and the communication module 401 and the microcontroller 402 are communicatively connected. The communication module 401 is used to perform physical layer processing on the wireless signals sent by the terminal to obtain raw data packets; wherein, the raw data packets include a data field and message header information of multiple protocol layers in the network communication protocol stack; The communication module 401 is further used to re-format and encapsulate the original data packet to obtain a target communication message; wherein, the target communication message includes an instruction header, which is used to identify that the format of the target communication message is the original format including the message header information of the multiple protocol layers; The communication module 401 is also used to send the target communication message to the microcontroller 402; The microcontroller 402 is used to identify the target communication message and obtain the instruction header; The microcontroller 402 is also used to invoke a message analysis tool according to the instruction header; The microcontroller 402 is further configured to parse the target communication message according to the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
[0079] Furthermore, in conjunction with the message analysis methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the message analysis methods in the above embodiments.
[0080] This application also provides a computer program product, including a computer program that, when executed by a processor, implements any of the message analysis methods described in the above embodiments.
[0081] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0082] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable read-only memory (EROM), floppy disks, compact disc read-only memory (CD-ROM), optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0083] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0084] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0085] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A method of packet analysis, the method comprising: The method is applied to a communication module in an embedded device, the embedded device comprising the communication module and a microcontroller, the communication module and the microcontroller being in communication connection; the method comprising: performing physical layer processing on a wireless signal sent by a terminal to obtain an original data packet; wherein the original data packet comprises data domain and message header information of multiple protocol layers in a network communication protocol stack; performing format reorganization and instruction encapsulation on the original data packet to obtain a target communication message; wherein the target communication message comprises an instruction header, and the instruction header is used to identify that the format of the target communication message is an original format comprising the message header information of the multiple protocol layers; sending the target communication message to the microcontroller, so that the microcontroller invokes a message analysis tool to analyze the target communication message based on the instruction header in the target communication message, to obtain the message header information of the multiple protocol layers and the data domain.
2. The method of claim 1, wherein, The step of performing format reorganization and instruction encapsulation on the original data packet to obtain a target communication message comprises: assembling the message header information of the multiple protocol layers and the data domain in the original data packet in a preset order to generate reorganized data; adding an instruction header to the reorganized data to obtain a target communication message conforming to an attention instruction format.
3. The method according to claim 1 or 2, characterized in that, The instruction header is composed of an attention instruction prefix and an original data command.
4. The method according to claim 1 or 2, characterized in that, The message header information of the multiple protocol layers comprises network interface layer message header information, network layer message header information, transport layer message header information, and application layer message header information; The preset order is a hierarchical order from a bottom layer to a top layer of the network communication protocol stack.
5. A method of packet analysis, the method comprising: The method is applied to a microcontroller in an embedded device, the embedded device comprising a communication module and a microcontroller, the communication module and the microcontroller being in communication connection; the method comprising: in a case where a target communication message sent by the communication module is received, performing message identification on the target communication message to obtain an instruction header; wherein the target communication message is obtained by performing format reorganization and instruction encapsulation on an original data packet by the communication module; and the original data packet comprises data domain and message header information of multiple protocol layers in a network communication protocol stack; invoking a message analysis tool according to the instruction header; analyzing the target communication message according to the message analysis tool to obtain the message header information of the multiple protocol layers and the data domain.
6. The method of claim 5, wherein, The message analysis tool comprises a network interface layer header analysis module, a network layer header analysis module, a transport layer header analysis module, and an application layer header analysis module; The network interface layer header analysis module is used to analyze network interface layer message header information in the target communication message; The network layer header analysis module is used to analyze network layer message header information in the target communication message; The transport layer header analysis module is used to analyze transport layer message header information in the target communication message; The application layer header analysis module is used to analyze application layer message header information in the target communication message.
7. A packet analysis apparatus characterized by comprising: The device is applied to a communication module in an embedded device, the embedded device comprising a communication module and a microcontroller, the communication module and the microcontroller being in communication connection; the device comprising: a processing module, configured to perform physical layer processing on a wireless signal sent by a terminal to obtain an original data packet; wherein the original data packet comprises data field and message header information of multiple protocol layers in a network communication protocol stack; a packaging module, configured to perform format reorganization and instruction packaging on the original data packet to obtain a target communication message; wherein the target communication message comprises an instruction header, and the instruction header is used to identify that the format of the target communication message is an original format comprising the message header information of the multiple protocol layers; a sending module, configured to send the target communication message to the microcontroller, so that the microcontroller invokes a message analysis tool to analyze the target communication message based on the instruction header in the target communication message to obtain the message header information of the multiple protocol layers and the data field.
8. A packet analysis apparatus characterized by comprising: The device is applied to a microcontroller in an embedded device, the embedded device comprising a communication module and a microcontroller, the communication module and the microcontroller being in communication connection; the device comprising: an identification module, configured to perform message identification on a target communication message sent by the communication module to obtain an instruction header; wherein the target communication message is obtained by performing format reorganization and instruction packaging on an original data packet by the communication module; the original data packet comprises data field and message header information of multiple protocol layers in a network communication protocol stack; an invoking module, configured to invoke a message analysis tool according to the instruction header; an analysis module, configured to analyze the target communication message according to the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
9. An embedded device, characterized by The embedded device comprises a communication module and a microcontroller, the communication module and the microcontroller being in communication connection; The communication module is configured to perform physical layer processing on a wireless signal sent by a terminal to obtain an original data packet; wherein the original data packet comprises data field and message header information of multiple protocol layers in a network communication protocol stack; The communication module is further configured to perform format reorganization and instruction packaging on the original data packet to obtain a target communication message; wherein the target communication message comprises an instruction header, and the instruction header is used to identify that the format of the target communication message is an original format comprising the message header information of the multiple protocol layers; The communication module is further configured to send the target communication message to the microcontroller; The microcontroller is configured to perform message identification on the target communication message to obtain an instruction header; The microcontroller is further configured to invoke a message analysis tool according to the instruction header; The microcontroller is further configured to analyze the target communication message according to the message analysis tool to obtain the message header information of the multiple protocol layers and the data field.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the message analysis method in any one of claims 1 to 4 or 5 to 6.