Communication data packet capturing method and device, electronic equipment and medium
By acquiring and parsing the kernel communication data of the target application process, the problem of difficulty in crawling communication data between applications in a single ECU in the prior art is solved, and efficient crawling communication data packets are achieved.
Patent Information
- Application Number
- CN202411131945.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-11-29
AI Technical Summary
The existing SOME/IP protocol packet crawling method cannot effectively capture communication packets between applications within a single ECU, resulting in poor effectiveness of communication packet crawling.
By obtaining the data grab parameters of the target application process, using a preset monitoring program based on the ebpf open source library for communication monitoring, obtaining kernel communication data, and parsing kernel communication data through data parsing structure and Lua parsing script to obtain the target application process's Communication packet.
It realizes the effective crawling of communication data packets between applications within a single ECU, improves the effectiveness of crawling communication data packets, and can monitor and parse kernel communication data without passing through the network card.
Smart Images

Figure CN119052117A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a communication data packet capture method, device, electronic equipment and medium. Background Art
[0002] The SOME / IP protocol is a communication protocol designed specifically for automotive electronic and electrical architectures, and is intended to support efficient communication and service interaction between different electronic control units (ECUs) in a vehicle. The SOME / IP protocol can support communication between multiple ECUs in a vehicle, as well as communication between applications within a single ECU.
[0003] In the current data packet capture solution for the SOME / IP protocol, tools such as tcpdump are usually used to capture communication data packets generated based on the SOME / IP protocol. This method of capturing communication data packets using data packet capture tools cannot cope with communication data packet capture scenarios under special circumstances, and the effectiveness of communication data packet capture is poor.
[0004] Therefore, how to solve the problem that the existing technology cannot effectively capture communication data packets and the communication data packet capture effectiveness is poor when capturing communication data packets has become a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0005] Based on the above problems, in order to solve the problem that in the prior art, communication data packets cannot be effectively captured and the effectiveness of communication data packet capture is poor, the embodiments of the present application provide a communication data packet capture method, device, electronic device and medium.
[0006] The embodiments of the present application disclose the following technical solutions:
[0007] In a first aspect, the present application provides a communication data packet capture method, comprising:
[0008] Acquire data capture parameters for a target application process; the data capture parameters are used to represent the information transmission medium used by the target application process during data communication and the process identifier of the target application process;
[0009] Perform communication monitoring according to a preset monitoring program and the data capture parameters, and capture kernel communication data sent by the target application process through the information transmission medium; the preset monitoring program is determined based on the ebpf open source library;
[0010] The kernel communication data is parsed to obtain a communication data packet of the target application process.
[0011] In a possible implementation, parsing the kernel communication data to obtain the communication data packet of the target application process includes:
[0012] Determining the kernel data type of the kernel communication data according to the kernel communication data;
[0013] Constructing a data parsing structure of the kernel communication data according to the kernel data type of the kernel communication data and the kernel communication data;
[0014] Data parsing is performed based on the data parsing structure to obtain a communication data packet of the target application process.
[0015] In a possible implementation, the step of parsing the kernel communication data is performed based on a preset Lua parsing script.
[0016] In a possible implementation, the communication data packet capture method is applied to a first operating system corresponding to the target application process; the first operating system includes: a user state and a kernel state;
[0017] The kernel state is used to execute the step of acquiring the data capture parameters and the step of performing communication monitoring according to a preset monitoring program and the data capture parameters, and capturing the kernel communication data sent by the target application process through the information transmission medium;
[0018] The user state is used to execute the step of parsing the kernel communication data to obtain the communication data packet of the target application process.
[0019] In a possible implementation, after capturing the kernel communication data sent by the target application process through the information transmission medium, the method further includes:
[0020] According to a preset communication bridge, the kernel communication data stored in the kernel state is sent to the user state; the preset communication bridge is determined based on the ebpf open source library.
[0021] In a second aspect, the present application provides a communication data packet capture device, comprising:
[0022] An acquisition module, used for acquiring data capture parameters for a target application process; the data capture parameters are used to represent the information transmission medium used by the target application process during data communication and the process identifier of the target application process;
[0023] A monitoring module, used for performing communication monitoring according to a preset monitoring program and the data capture parameters, and capturing kernel communication data sent by the target application process through the information transmission medium; the preset monitoring program is determined based on the ebpf open source library;
[0024] The parsing module is used to parse the kernel communication data to obtain the communication data packet of the target application process.
[0025] In a possible implementation, the parsing module is specifically used to:
[0026] Determining the kernel data type of the kernel communication data according to the kernel communication data;
[0027] Constructing a data parsing structure of the kernel communication data according to the kernel data type of the kernel communication data and the kernel communication data;
[0028] Data parsing is performed based on the data parsing structure to obtain a communication data packet of the target application process.
[0029] In a possible implementation, the communication data packet capturing device further includes:
[0030] A data sending module is used to send the kernel communication data stored in the kernel state to the user state according to a preset communication bridge; the preset communication bridge is determined based on the ebpf open source library.
[0031] In a third aspect, the present application provides an electronic device, the device comprising: a processor, a memory, and a system bus;
[0032] The processor and the memory are connected via the system bus;
[0033] The memory is used to store one or more programs, and the one or more programs include instructions. When the instructions are executed by the processor, the processor performs the operating steps of any possible communication data packet capture method in the first aspect.
[0034] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the operating steps of any possible communication data packet capture method in the first aspect.
[0035] Compared with the prior art, the present application has the following beneficial effects: the embodiment of the present application provides a communication data packet capture method, device, electronic device and medium. In the communication data packet acquisition method provided in the embodiment of the present application, the information transmission medium and the corresponding process identifier used by the target application process when performing data communication can be determined by the data capture parameters. Further, by performing communication monitoring through the preset monitoring program and the data capture parameters, the kernel communication data transmitted in the information transmission medium can be effectively obtained when the target application process communicates with other application processes in the ECU through the information transmission medium. Among them, since the preset monitoring program is determined based on the ebpf open source library, the preset monitoring program can effectively obtain the data transmitted in the kernel state. Therefore, when multiple applications in a single ECU perform data communication, the communication data between the applications belongs to the kernel state data. Even if the applications do not communicate through the network card, the preset monitoring program can also monitor the information transmission medium between the applications to obtain the kernel communication data transmitted between the applications. Finally, the kernel communication data obtained by the preset monitoring program is parsed to effectively obtain the communication data packet of the target application process, thereby realizing the effective capture of the communication data packet and improving the capture effectiveness of the communication data packet. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0037] Figure 1 A schematic diagram of the structure of a communication data packet provided in an embodiment of the present application;
[0038] Figure 2 A flowchart of a kernel communication data parsing method provided in an embodiment of the present application;
[0039] Figure 3 A code schematic diagram of a kernel data type provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of a communication data packet capture method in an actual application scenario provided by an embodiment of the present application;
[0041] Figure 5 A schematic diagram of the structure of a communication data packet capture device provided in an embodiment of the present application;
[0042] Figure 6A schematic diagram of the structure of a communication data packet capture electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0044] As described above, the SOME / IP protocol can support communication between multiple ECUs in a vehicle, and can also support communication between applications in a single ECU. In the current data packet capture solutions for the SOME / IP protocol, tools such as tcpdump are usually used to capture communication data packets generated based on the SOME / IP protocol.
[0045] The core principle of the data packet capture tool is to capture the communication data packets in the communication network card based on the communication network card between ECUs. This method can only be applied in the scenario where multiple ECUs communicate through the network card. When the ECU communicates between multiple applications inside it through the SOME / IP protocol, the communication between applications in a single ECU will not pass through the network card. Therefore, the existing data packet capture tool cannot capture the communication data packets sent based on the SOME / IP protocol. The existing communication data packet capture solution cannot effectively complete the capture of communication data packets, and the effectiveness of communication data packet capture is poor.
[0046] In order to solve the above problems, the embodiments of the present application provide a communication data packet capture method, device, electronic device and medium. In the communication data packet acquisition method provided in the embodiments of the present application, the information transmission medium and the corresponding process identifier used by the target application process when performing data communication can be determined through the data capture parameters. Further, by performing communication monitoring through the preset monitoring program and the data capture parameters, it is possible to effectively obtain the kernel communication data transmitted in the information transmission medium when the target application process communicates with other application processes in the ECU through the information transmission medium. Among them, since the preset monitoring program is determined based on the ebpf open source library, the preset monitoring program can effectively obtain the data transmitted in the kernel state. Therefore, when multiple applications in a single ECU perform data communication, the communication data between the applications belongs to the kernel state data. Even if the applications do not communicate through the network card, the preset monitoring program can also monitor the information transmission medium between the applications to obtain the kernel communication data transmitted between the applications. Finally, the kernel communication data obtained by the preset monitoring program is parsed to effectively obtain the communication data packet of the target application process, thereby realizing the effective capture of the communication data packet and improving the capture effectiveness of the communication data packet.
[0047] Next, the communication data packet capture method provided in the embodiment of the present application will be introduced in conjunction with the specific embodiment drawings.
[0048] See also Figure 1 , which is a schematic diagram of the structure of a communication data packet provided in an embodiment of the present application, specifically comprising the following steps:
[0049] S101: Acquire data capture parameters for a target application process; the data capture parameters are used to represent the information transmission medium used by the target application process during data communication and the process identifier of the target application process.
[0050] When data is communicated between applications within a single ECU, the communication between applications is often completed through their local socket files as the intermediary for information transmission, rather than using a communication network card. Therefore, existing data packet capture tools cannot capture data communication between applications within a single ECU.
[0051] Therefore, in the communication data packet capture method of the embodiment of the present application, when carrying out data capture for the target application process, it is necessary to determine the information transmission medium used by the target application process when performing data communication, as well as the process identifier of the target application process itself. Therefore, the information transmission medium information and the process identifier are obtained in the form of data capture parameters. Among them, in the data capture parameters, the information transmission medium used by the target application process during data communication is represented by the medium identifier of the information transmission medium itself.
[0052] When data is communicated between applications within a single ECU, the information transmission medium used can be a variety of transmission media such as socket files, shared memory, message queues, and pipes. In the process of obtaining data capture parameters, the medium identifier of the information transmission medium needs to be used as a data capture parameter to obtain it. Taking the case where the information transmission medium is a socket file as an example, when the information transmission medium used by the target application process is a socket file, the corresponding medium identifier is the file name of the socket file. In the operating system to which the target application process belongs, there are often multiple socket files as information transmission deadlines. Therefore, by using the socket file name corresponding to the target application process and the process identifier of the target application process as data capture parameters for the target application process, it is possible to determine the socket file specifically used by the target application process during data communication, that is, the information transmission medium used by the target application process during data communication.
[0053] S102: Perform communication monitoring according to a preset monitoring program and the data capture parameters, and capture kernel communication data sent by the target application process through the information transmission medium; the preset monitoring program is determined based on the ebpf open source library.
[0054] After obtaining the data capture parameters of the target application process, the information transmission medium used by the target application process when performing data communication based on the data packet can be determined through the data capture parameters. Therefore, on this basis, by performing communication monitoring on the information transmission medium used by the target application process through a pre-set monitoring program, the communication data sent by the target application process in the corresponding information transmission medium can be effectively captured.
[0055] In actual application scenarios, the information transmission medium corresponding to the target application process may also correspond to other application processes. Therefore, when the preset monitoring program performs communication monitoring, the process identifier of the target application process is used as the monitoring element during communication monitoring, and whether communication data containing the target application process identifier appears in the information transmission medium is detected, so that the communication data sent by the target application process when communicating based on the information transmission medium can be captured.
[0056] Among them, for multiple applications in a single ECU, the applications that perform data communication belong to the same operating system. Since the data communication between applications does not involve the addition of a network card, data is only transmitted through the information transmission medium within the operating system. Therefore, the communication data between applications is the local data of the corresponding operating system, that is, the kernel communication data of the operating system itself.
[0057] It can be seen that when the applications in a single ECU communicate data, in order to obtain the communication data between the target application process and the application, it is necessary to obtain the kernel communication data sent by the target application process in its operating system, so as to complete the data packet capture based on the kernel communication data later. Kernel data refers to the data stored and managed in the kernel of the operating system, and kernel communication data is the communication data transmitted between applications in the operating system. In order to effectively obtain the kernel communication data sent and received between application processes, the preset monitoring program is determined based on a series of interface methods provided by the ebpf open source library, aiming to enable the preset monitoring program to effectively obtain the kernel communication data in the operating system.
[0058] Among them, eBPF (Extended Berkeley Packet Filter) is a technology used to expand kernel functions. EBPF allows developers to run user-defined programs in the kernel safely and efficiently without modifying the kernel code. The eBPF open source library provides a series of processing methods for kernel data in the operating system. By building a preset monitoring program based on the interface method provided in the eBPF open source library, it is possible to effectively obtain kernel communication data. When the preset monitoring program monitors the target application process in the information transmission medium, when it detects kernel communication data that matches the target application process identifier, it can directly capture the kernel communication data sent by the target application process through the interface method provided in the eBPF open source library.
[0059] S103: Parse the kernel communication data to obtain the communication data packet of the target application process. Finally, after completing the data capture for the kernel communication data, since the kernel communication data is often binary data similar to the "0101" style, the kernel communication data at this time cannot be used directly as a data packet. Therefore, after obtaining the kernel communication data, it is necessary to further parse it to obtain the communication data packet corresponding to the target application process. In an embodiment of the present application, the parsing process for the kernel communication data needs to be completed based on the kernel data type of the kernel communication data. Next, the parsing process of the kernel communication data will be introduced in conjunction with the drawings of specific embodiments.
[0060] See also Figure 2, which is a flow chart of a kernel communication data parsing method provided by an embodiment of the present application, specifically comprising the following steps:
[0061] S201: Determine the kernel data type of the kernel communication data according to the kernel communication data;
[0062] First, it is necessary to determine the specific kernel data type of the kernel communication data according to the specific kernel communication data. In the process of determining the kernel data type, the kernel data type of the kernel communication data can be determined by parsing the data of the first byte of the kernel communication data and converting its binary data into hexadecimal data. Among them, different kernel communication data have different kernel data types, such as service discovery, service provision, service request, and service release. Figure 3 As shown in Figure 3 The code diagram of the kernel data type shown lists 21 definition codes of different kernel data types. Different kernel data types have different parsing structures. The embodiment of the present application does not specifically limit the kernel data type.
[0063] S202: constructing a data parsing structure of the kernel communication data according to the kernel data type of the kernel communication data and the kernel communication data;
[0064] Subsequently, a data parsing structure specific to the kernel communication data is constructed based on the kernel data type of the kernel communication data and the actual data in the kernel communication data.
[0065] Among them, each kernel data type corresponds to a specific structure, and each structure contains specific fields for describing kernel communication data. For example, when the kernel data type of kernel communication data is a service discovery type, its corresponding structure contains a four-byte service ID and a four-byte instance ID. It can be seen that the format and content of different kernel data types can be clearly described through the structure specifically corresponding to the kernel data type. By importing the kernel communication data into the structure corresponding to its data type, a data parsing structure for carrying the kernel communication data can be constructed.
[0066] S203: Perform data parsing based on the data parsing structure to obtain a communication data packet of the target application process.
[0067] After obtaining the data parsing structure corresponding to the kernel communication data, since the data parsing structure provides an information storage template and a fixed storage format, by parsing the data parsing structure, the binary data in the kernel communication data can be converted into hexadecimal data, and the hexadecimal data can be converted into understandable, structured information, so that the communication data packet of the target application process can be obtained.
[0068] In a possible implementation, the data parsing process for kernel communication data can be completed by a pre-set preset Lua parsing script. Among them, Lua is a lightweight, embedded scripting language. Through this embedded scripting language, the Lua parsing script developed according to the Lua language can be quickly embedded in the main framework of different program languages, and its Lua parsing script has high flexibility. When the kernel communication data to be parsed changes, the Lua script can be directly modified to complete the parsing of the new kernel communication data without changing the main program language, thereby improving the parsing efficiency of the kernel communication data and improving the efficiency of capturing communication data packets.
[0069] From the previous description, we can know that in a single ECU, the communication data transmitted between applications is the kernel data of its operating system. However, in actual application scenarios, in order to parse the captured kernel communication data to obtain the corresponding communication data packet, the kernel communication data obtained in the kernel state of the operating system needs to be sent to the user state of the operating system, and the Lua parsing script in the user state is used to complete the parsing process of the kernel communication data.
[0070] Next, the process of capturing and parsing kernel communication data to obtain communication data packets in actual application scenarios will be introduced in conjunction with the accompanying drawings of specific embodiments.
[0071] See also Figure 4 , which is a schematic diagram of a communication data packet capture method in an actual application scenario provided by an embodiment of the present application. As shown in the figure, Figure 4 The first operating system shown includes a user state and a kernel state. The kernel state is used to obtain data capture parameters from outside the operating system, and to monitor the communication of the corresponding information transmission medium through the information transmission medium and the process identifier of the target application process contained in the data capture parameters, so as to capture the kernel communication data sent by the target application process in the information transmission medium to other applications.
[0072] After capturing the kernel communication data sent by the target application process, the kernel communication data captured in the kernel state is sent to the data receiving module in the user state through the preset communication bridge MAP between the user state and the kernel state. The data receiving module is used to forward the received kernel communication data to the preset Lua parsing script, so that the preset Lua parsing script can parse the kernel communication data, thereby obtaining the communication data packet sent by the target application process to other applications in the ECU.
[0073] The preset communication bridge is built based on the efbp open source library, and is used to serve as a bridge for kernel communication data between kernel state and user state. Since the efbp open source library contains a series of processing methods for kernel data, building a transmission bridge for communication data between user state and kernel state through the efbp open source library can effectively ensure that the kernel communication data in kernel state can be safely and efficiently transmitted to user state, so that user state can parse the data.
[0074] In particular, in a possible implementation, in the process of communication monitoring through a preset monitoring program, a .bpf file can be encoded based on the ebpf open source library, and the preset monitoring program can be carried by the encoded .bpf file to complete the communication monitoring based on the data capture parameters. Similarly, the preset communication bridge between the kernel state and the user state can also encode the corresponding .cpp file based on the ebpf open source, so as to realize the data transmission function of the preset communication bridge between the kernel state and the user state.
[0075] The embodiment of the present application provides a communication data packet capture method. In the communication data packet acquisition method provided in the embodiment of the present application, the information transmission medium and the corresponding process identifier used by the target application process when performing data communication can be determined through the data capture parameters. Further, by performing communication monitoring through the preset monitoring program and the data capture parameters, it is possible to effectively obtain the kernel communication data transmitted in the information transmission medium when the target application process communicates with other application processes in the ECU through the information transmission medium. Among them, since the preset monitoring program is determined based on the ebpf open source library, the preset monitoring program can effectively obtain the data transmitted in the kernel state. Therefore, when multiple applications in a single ECU perform data communication, the communication data between the applications belongs to the kernel state data. Even if the applications do not communicate through the network card, the preset monitoring program can also monitor the information transmission medium between the applications, thereby obtaining the kernel communication data transmitted between the applications. Finally, the kernel communication data obtained by the preset monitoring program is parsed, and the communication data packet of the target application process can be effectively obtained, which realizes the effective capture of the communication data packet and improves the capture effectiveness of the communication data packet.
[0076] A communication data packet capturing device provided in an embodiment of the present application is introduced below. The communication data packet capturing device described below and the communication data packet capturing method described above can refer to each other.
[0077] See also Figure 5 , which is a schematic diagram of the structure of a communication data packet capture device provided in an embodiment of the present application, including the following modules:
[0078] The acquisition module 100 is used to acquire data capture parameters for a target application process; the data capture parameters are used to represent the information transmission medium used by the target application process during data communication and the process identifier of the target application process;
[0079] The monitoring module 200 is used to perform communication monitoring according to a preset monitoring program and the data capture parameters, and capture the kernel communication data sent by the target application process through the information transmission medium; the preset monitoring program is determined based on the ebpf open source library;
[0080] The parsing module 300 is used to parse the kernel communication data to obtain the communication data packet of the target application process.
[0081] In a possible implementation, the parsing module 300 is specifically configured to:
[0082] Determining the kernel data type of the kernel communication data according to the kernel communication data;
[0083] Constructing a data parsing structure of the kernel communication data according to the kernel data type of the kernel communication data and the kernel communication data;
[0084] Data parsing is performed based on the data parsing structure to obtain a communication data packet of the target application process.
[0085] In a possible implementation, the communication data packet capturing device further includes:
[0086] A data sending module is used to send the kernel communication data stored in the kernel state to the user state according to a preset communication bridge; the preset communication bridge is determined based on the ebpf open source library.
[0087] See also Figure 6 , which is a schematic diagram of the structure of a communication data packet capture electronic device provided in an embodiment of the present application, including:
[0088] A memory 11, used for storing computer programs;
[0089] The processor 12 is used to implement the steps of a communication data packet capture method described in any of the above method embodiments when executing the computer program.
[0090] In this embodiment, the device may be a vehicle-mounted computer, a PC (Personal Computer), or a terminal device such as a smart phone, a tablet computer, a PDA, or a portable computer.
[0091] The device may include a memory 11 , a processor 12 , and a bus 13 .
[0092] Among them, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the device, such as a hard disk of the device. In other embodiments, the memory 11 can also be an external storage device of the device, such as a plug-in hard disk equipped on the device, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 11 can also include both an internal storage unit of the device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the device, such as program codes for executing fault prediction methods, etc., but can also be used to temporarily store data that has been output or is to be output. The processor 12 can be a central processing unit (CPU) in some embodiments.
[0093] In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip, and is used to run program codes or process data stored in the memory 11, such as program codes for executing a fault prediction method.
[0094] The bus 13 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0095] Furthermore, the device may also include a network interface 14, which may optionally include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the device and other electronic devices.
[0096] Optionally, the device may further include a user interface 15, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 15 may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the device and to display a visual user interface.
[0097] Figure 6 Only the device with components 11-15 is shown, and it can be understood by those skilled in the art that Figure 6 The structure shown does not constitute a limitation of the device, and may include fewer or more components than shown, or combine certain components, or arrange the components differently.
[0098] It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for methods, devices, electronic devices and media, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The methods, devices, electronic devices and media described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0099] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A communication data packet capture method, characterized in that: include: Acquire data capture parameters for a target application process; the data capture parameters are used to represent the information transmission medium used by the target application process during data communication and the process identifier of the target application process; Perform communication monitoring according to a preset monitoring program and the data capture parameters, and capture kernel communication data sent by the target application process through the information transmission medium; the preset monitoring program is determined based on the ebpf open source library; The kernel communication data is parsed to obtain a communication data packet of the target application process.
2. The method according to claim 1, characterized in that: The step of parsing the kernel communication data to obtain the communication data packet of the target application process includes: Determining the kernel data type of the kernel communication data according to the kernel communication data; Constructing a data parsing structure of the kernel communication data according to the kernel data type of the kernel communication data and the kernel communication data; Data parsing is performed based on the data parsing structure to obtain a communication data packet of the target application process.
3. The method according to claim 1, characterized in that The step of parsing the kernel communication data is performed based on a preset Lua parsing script.
4. The method according to claim 1, characterized in that: The communication data packet capture method is applied to a first operating system corresponding to the target application process; the first operating system includes: a user state and a kernel state; The kernel state is used to execute the step of acquiring the data capture parameters and the step of performing communication monitoring according to a preset monitoring program and the data capture parameters, and capturing the kernel communication data sent by the target application process through the information transmission medium; The user state is used to execute the step of parsing the kernel communication data to obtain the communication data packet of the target application process.
5. The method according to claim 4, characterized in that After capturing the kernel communication data sent by the target application process through the information transmission medium, the method further includes: According to a preset communication bridge, the kernel communication data stored in the kernel state is sent to the user state; the preset communication bridge is determined based on the ebpf open source library.
6. A communication data packet capture device, characterized in that: include: An acquisition module, used for acquiring data capture parameters for a target application process; the data capture parameters are used to represent the information transmission medium used by the target application process during data communication and the process identifier of the target application process; A monitoring module, used for performing communication monitoring according to a preset monitoring program and the data capture parameters, and capturing kernel communication data sent by the target application process through the information transmission medium; The preset monitoring program is determined based on the ebpf open source library; The parsing module is used to parse the kernel communication data to obtain the communication data packet of the target application process.
7. The device according to claim 6, characterized in that The analysis module is specifically used for: Determining the kernel data type of the kernel communication data according to the kernel communication data; Constructing a data parsing structure of the kernel communication data according to the kernel data type of the kernel communication data and the kernel communication data; Data parsing is performed based on the data parsing structure to obtain a communication data packet of the target application process.
8. The device according to claim 6, characterized in that Also includes: A data sending module, used for sending the kernel communication data stored in the kernel state to the user state according to a preset communication bridge; The preset communication bridge is determined based on the ebpf open source library.
9. An electronic device, characterized in that: The device comprises: a processor, a memory and a system bus; The processor and the memory are connected via the system bus; The memory is used to store one or more programs, and the one or more programs include instructions. When the instructions are executed by the processor, the processor executes the communication data packet capture method according to any one of claims 1 to 5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the communication data packet capture method described in any one of claims 1 to 5 is implemented.
