Data Packet Capturing Method, Device, Electronic Device and Storage Medium

By starting the main process of packet capture and client, listening and storing data packets, the problem of the existing technology being unable to crawl third-party drained data packets is solved, and packet crawling and processing in parallel with multiple clients is realized.

CN115987824BActive Publication Date: 2025-08-01BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211678281.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-26
Publication Date
2025-08-01
Estimated Expiration
2042-12-26

AI Technical Summary

Technical Problem

The prior art cannot support packet capture of solutions that use third-party traffic diversion methods to obtain data packets, resulting in the inability to directly capture data packets in the device for analysis.

Method used

By starting the packet capture main process and the packet capture client, listening to the packet capture client's instructions, the data packet export and import packets flowing through the main process are stored in the target storage area, and the packet capture client reads and processes the packets from the storage area.

Benefits of technology

It realizes the capture and processing of data packets input based on third-party drainage methods, overcomes the packet capture defects of the existing technology, and supports parallel operations of multiple packet capture clients.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115987824B_ABST
    Figure CN115987824B_ABST
Patent Text Reader

Abstract

The present application provides a method, apparatus, electronic device, and storage medium for capturing data packets. Among them, the method for capturing data packets includes: starting a packet capture main process and a packet capture client; when it is monitored that the packet capture client sends a packet capture instruction to the main process, based on the main process, storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area; based on the packet capture client, reading target data packets from the target storage area and processing the target data packets. The present application can achieve capturing data packets. At the same time, the present application can overcome the defect that the prior art cannot support capturing packets for a solution that obtains data packets by using a third-party drainage method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more particularly, to a method, apparatus, electronic device, and storage medium for capturing data packets. Background Art

[0002] With the popularization of the network, network troubleshooting is often involved in daily work. Therefore, data collection and analysis of network devices are basic requirements. In the traditional Linux TCP / IP protocol stack, the Tcpdump tool is usually used to capture and analyze network data packets. For devices that do not directly obtain data packets from the network card but obtain data packets by diverting traffic from a third-party data source, Tcpdump cannot directly capture the data packets in the device for analysis, which is inconvenient for analyzing problems with the device. Summary of the Invention

[0003] The purpose of the embodiments of this application is to provide a method, apparatus, electronic device, and storage medium for capturing data packets to achieve data packet capture. At the same time, this application can overcome the defect that the prior art cannot support packet capture for solutions that obtain data packets by using a third-party diversion method.

[0004] In a first aspect, the present invention provides a method for capturing data packets, the method comprising:

[0005] Start a packet capture main process and a packet capture client;

[0006] When it is monitored that the packet capture client sends a packet capture instruction to the main process, based on the main process, store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in a target storage area;

[0007] Based on the packet capture client, read target data packets from the target storage area and process the target data packets.

[0008] In the embodiments of this application, by starting a packet capture main process and a packet capture client, and then when it is monitored that the packet capture client sends a packet capture instruction to the main process, it is possible to store, based on the main process, the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in a target storage area, and then it is possible to read target data packets from the target storage area based on the packet capture client and process the target data packets, thereby finally completing the capture and processing of the data packets.

[0009] Compared with the prior art, the present application can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in a target storage area, and then the client can read the target data packets from the target storage area. In this way, since the data packets input based on the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input based on the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, and finally the defect that the prior art cannot support packet capturing for the solution of obtaining data packets by using the third-party drainage method is overcome.

[0010] In an optional implementation manner, after starting the packet capture main process and the packet capture client, the method further includes:

[0011] Starting a packet capture monitoring service process to receive the information sent by the packet capture client through the packet capture monitoring service process, where the information sent by the packet capture client includes the packet capture instruction sent by the packet capture client to the main process.

[0012] In the above optional implementation manner, by starting the packet capture monitoring service process, the information sent by the packet capture client can be received through the packet capture monitoring service process, where the information sent by the packet capture client includes the packet capture instruction sent by the packet capture client to the main process.

[0013] In an optional implementation manner, the storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in a target storage area based on the main process includes:

[0014] Based on the main process, calling a dump interface to store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in the target storage area through the dump interface.

[0015] In the above optional implementation manner, by the main process calling the dump interface, the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process can be stored in the target storage area through the dump interface.

[0016] In an optional implementation manner, before storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in a target storage area based on the main process, the method further includes:

[0017] Creating a virtual network port based on the packet capture client;

[0018] Based on the packet capture client, start a virtual network port and apply for the target storage area, where the virtual network port maps to the target storage area.

[0019] In the above optional embodiment, create a virtual network port based on the packet capture client, and then it is possible to start the virtual network port based on the packet capture client and apply for the target storage area, where the virtual network port maps to the target storage area.

[0020] In an optional embodiment, the reading of the target data packet from the target storage area based on the packet capture client includes:

[0021] Based on the packet capture client, call a data reading interface to read the target data packet from the target storage area through the data reading interface and process the target data packet.

[0022] In the above optional embodiment, call a data reading interface through the packet capture client, and then it is possible to read the target data packet from the target storage area through the data reading interface and process the target data packet.

[0023] In an optional embodiment, the method further includes:

[0024] Based on the packet capture client, call a packet capture end and exit interface to clear the virtual network port through the packet capture end and exit interface.

[0025] In the above optional embodiment, based on the packet capture client, it is possible to call a packet capture end and exit interface, and then it is possible to clear the virtual network port through the packet capture end and exit interface.

[0026] In an optional embodiment, the target storage area is a circular memory area.

[0027] In the above optional embodiment, by setting the target storage area as a circular memory area, it is possible to perform data storage operations using less storage space.

[0028] In a second aspect, the present invention provides a data packet capture device, and the device includes:

[0029] A start module, configured to start a packet capture main process and a packet capture client;

[0030] A first packet capture module, configured to, when it is monitored that the packet capture client sends a packet capture instruction to the main process, based on the main process, store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area;

[0031] The second packet capturing module is used to read target data packets from the target storage area based on the packet capturing client and process the target data packets.

[0032] The device according to the second aspect of the present application can start the packet capturing main process and the packet capturing client by executing the packet capturing method. Then, when it is monitored that the packet capturing client sends a packet capturing instruction to the main process, it can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area based on the main process. Furthermore, it can read the target data packets from the target storage area based on the packet capturing client and process the target data packets, thereby finally completing the capturing and processing of the data packets.

[0033] Compared with the prior art, the present application can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area. Furthermore, the client can read the target data packets from the target storage area. In this way, since the data packets input by the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input by the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, finally overcoming the defect that the prior art cannot support packet capturing for the solution of obtaining data packets by the third-party drainage method.

[0034] In a third aspect, the present invention provides an electronic device, including:

[0035] a processor; and

[0036] a memory configured to store machine-readable instructions, and when the instructions are executed by the processor, the packet capturing method according to any one of the foregoing embodiments is executed.

[0037] The electronic device according to the third aspect of the present application can start the packet capturing main process and the packet capturing client by executing the packet capturing method. Then, when it is monitored that the packet capturing client sends a packet capturing instruction to the main process, it can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area based on the main process. Furthermore, it can read the target data packets from the target storage area based on the packet capturing client and process the target data packets, thereby finally completing the capturing and processing of the data packets.

[0038] Compared with the prior art, the present application can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in a target storage area. Furthermore, the client can read the target data packets from the target storage area. In this way, since the data packets input based on the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input based on the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, finally overcoming the defect that the prior art cannot support packet capturing for the solution of obtaining data packets by using the third-party drainage method.

[0039] In a fourth aspect, the present invention provides a storage medium storing a computer program, and the computer program is executed by a processor to perform the data packet capturing method according to any one of the foregoing embodiments.

[0040] The storage medium of the fourth aspect of the present application can start the packet capturing main process and the packet capturing client by executing the data packet capturing method. Furthermore, when it is monitored that the packet capturing client sends a packet capturing instruction to the main process, it can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in the target storage area based on the main process. Furthermore, it can read the target data packets from the target storage area based on the packet capturing client and process the target data packets, thus finally completing the capturing and processing of the data packets.

[0041] Compared with the prior art, the present application can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process in a target storage area. Furthermore, the client can read the target data packets from the target storage area. In this way, since the data packets input based on the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input based on the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, finally overcoming the defect that the prior art cannot support packet capturing for the solution of obtaining data packets by using the third-party drainage method. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0043] Figure 1 It is a schematic flowchart of a data packet capturing method disclosed in an embodiment of the present application;

[0044] Figure 2 It is a schematic structural diagram of a data packet capturing device disclosed in an embodiment of the present application;

[0045] Figure 3 It is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application. Specific embodiments

[0046] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application.

[0047] Embodiment 1

[0048] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a data packet capturing method disclosed in an embodiment of the present application. As Figure 1 shown, the method in the embodiment of the present application includes the following steps:

[0049] 101. Start the packet capture main process and the packet capture client;

[0050] 102. When it is monitored that the packet capture client sends a packet capture instruction to the main process, based on the main process, store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area;

[0051] 103. Based on the packet capture client, read the target data packet from the target storage area and process the target data packet. 4]

[0052] In the embodiment of the present application, by starting the packet capture main process and the packet capture client, and then when it is monitored that the packet capture client sends a packet capture instruction to the main process, it is possible to store, based on the main process, the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area. Furthermore, it is possible to read the target data packet from the target storage area based on the packet capture client and process the target data packet, thereby finally completing the capture and processing of the data packet.

[0053] Compared with the prior art, the embodiment of the present application can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area. Furthermore, the client can read the target data packet from the target storage area. In this way, since the data packets input by the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input by the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, finally overcoming the defect that the prior art cannot support the packet capture of the solution for obtaining data packets by the third-party drainage method.

[0054] In the embodiments of the present application, specifically, the data packet capturing method can be applied to a host. When the network card of the host receives data input from an external network, the data is stored in the memory space mapped by the network card. However, for data input through a third-party drainage method, it will not be placed in the memory space mapped by the network card. But whether it is the data packet stored in the memory space mapped by the network card or the data packet input through the third-party drainage method, both need to pass through the data packet outlet and the data packet inlet of the main process. Therefore, in the embodiments of the present application, by obtaining data from the data packet outlet and the data packet inlet of the main process, it is possible to obtain data packets in the above two situations, and then put the obtained data packets into a specified storage space, so that the client can obtain all the data packets from the storage space and analyze the data packets.

[0055] Furthermore, through steps 101, 102, and 103, the present application realizes packet capturing without relying on a platform. In contrast, since the prior art cannot capture data packets input through a third-party drainage method, the packet capturing of the prior art can only be deployed on platforms that obtain data packets through network cards.

[0056] In the embodiments of the present application, the packet capturing client refers to the management software that interacts with the user. Among them, the management software is provided with an interaction interface. Through this interaction interface, the user can trigger a packet capturing instruction, and then the interaction interface sends the packet capturing instruction to the main process.

[0057] Furthermore, compared with a packet capturing processing method and device provided by the prior art (this method and device can only start one packet capturing client to capture and process), the target storage area of the embodiments of the present application allows multiple packet capturing clients to obtain the captured data packets, that is, the embodiments of the present application also have the advantage of supporting multiple packet capturing clients.

[0058] In the embodiments of the present application, steps 101, 102, and 103 are implemented based on the prior art tcpdump tool. For example, the source code of the tcpdump tool is modified, and the code implementing steps 101, 102, and 103 is embedded into the prior art tcpdump tool to change the packet capturing process of the tcpdump tool. At the same time, other functions provided by the tcpdump tool can also be utilized, such as the interaction function provided by the tcpdump tool.

[0059] Furthermore, through the improvement of the tcpdump tool, a Figure 2 packet capturing framework as shown can be obtained, where Figure 2 is a schematic diagram of a packet capturing framework disclosed in the embodiments of the present application. In Figure 2Among them, Packet ring represents the target storage area, RX represents the data packet inlet of the main process, and TX represents the data packet outlet of the main process.

[0060] It should be noted that for the libpcap tool and the tcpdump tool, please refer to the prior art, and the embodiments of the present application will not elaborate on this.

[0061] In an alternative embodiment, after the steps of starting the packet capture main process and the packet capture client, the method of the embodiments of the present application further includes the following steps:

[0062] Start the packet capture listening service process to receive the information sent by the packet capture client through the packet capture listening service process, where the information sent by the packet capture client includes a packet capture instruction sent by the packet capture client to the main process.

[0063] In the above alternative embodiment, by starting the packet capture listening service process, it is possible to receive the information sent by the packet capture client through the packet capture listening service process, where the information sent by the packet capture client includes a packet capture instruction sent by the packet capture client to the main process.

[0064] In the above alternative embodiment, the packet capture listening service process can be started by the main process.

[0065] In an alternative embodiment, the step of storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area based on the main process includes the following steps:

[0066] Based on the main process, call the dump interface to store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area through the dump interface.

[0067] In the above alternative embodiment, by the main process calling the dump interface, it is possible to store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area through the dump interface.

[0068] It should be noted that for the specific description of the dump interface, please refer to the prior art.

[0069] In an alternative embodiment, before the step of storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area based on the main process, the method of the embodiments of the present application further includes the following steps:

[0070] Create a virtual network port based on the packet capture client;

[0071] Based on the packet capture client, start a virtual network port and apply for a target storage area, where the virtual network port maps to the target storage area.

[0072] In the above optional embodiment, create a virtual network port based on the packet capture client, and then it is possible to start the virtual network port based on the packet capture client and apply for a target storage area, where the virtual network port maps to the target storage area.

[0073] Specifically, the packet capture client can access the target storage area by accessing the virtual network port.

[0074] In an optional embodiment, the step: reading a target data packet from the target storage area based on the packet capture client includes the following sub-steps:

[0075] Based on the packet capture client, call a data reading interface to read the target data packet from the target storage area through the data reading interface and process the target data packet.

[0076] In the above optional embodiment, by calling the data reading interface through the packet capture client, it is possible to read the target data packet from the target storage area through the data reading interface and process the target data packet.

[0077] In the above optional embodiment, further, the packet capture client calls the data reading interface to read the target data packet from the target storage area in an asynchronous acquisition manner and process the target data packet.

[0078] In an optional embodiment, the method of the embodiment of the present application further includes the following steps:

[0079] Based on the packet capture client, call an interface to end packet capture and exit to clear the virtual network port through the interface to end packet capture and exit.

[0080] In the above optional embodiment, based on the packet capture client, it is possible to call the interface to end packet capture and exit, and then it is possible to clear the virtual network port through the interface to end packet capture and exit.

[0081] In an optional embodiment, the target storage area is a circular memory area.

[0082] In the above optional embodiment, by setting the target storage area as a circular memory area, it is possible to perform data storage operations using less storage space.

[0083] Embodiment 2

[0084] Please refer to Figure 2 , Figure 2 which is a schematic structural diagram of a data packet capture device disclosed in the embodiment of the present application. As Figure 2As shown in the figure, the device according to the embodiment of the present application includes the following functional modules:

[0085] The start module 201 is used to start the packet capture main process and the packet capture client;

[0086] The first packet capture module 202 is used to store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area based on the main process when it is monitored that the packet capture client sends a packet capture instruction to the main process;

[0087] The second packet capture module 203 is used to read the target data packets from the target storage area based on the packet capture client and process the target data packets.

[0088] The device according to the embodiment of the present application can start the packet capture main process and the packet capture client by executing the data packet capture method. Furthermore, when it is monitored that the packet capture client sends a packet capture instruction to the main process, it can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area based on the main process. Furthermore, it can read the target data packets from the target storage area based on the packet capture client and process the target data packets, thereby finally completing the capture and processing of the data packets.

[0089] Compared with the prior art, the embodiment of the present application can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area. Furthermore, the client can read the target data packets from the target storage area. In this way, since the data packets input by the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input by the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, finally overcoming the defect that the prior art cannot support the packet capture of the solution for obtaining data packets by the third-party drainage method.

[0090] It should be noted that for other detailed descriptions of the device according to the embodiment of the present application, please refer to the relevant descriptions in Embodiment 1 of the present application, and the embodiment of the present application will not elaborate on this.

[0091] Embodiment 3

[0092] Please refer to Figure 3 , Figure 3 is a schematic structural diagram of an electronic device disclosed in the embodiment of the present application. As Figure 3 shown, the electronic device according to the embodiment of the present application includes:

[0093] A processor 301; and

[0094] A memory 302 is configured to store machine-readable instructions that, when executed by a processor 302, perform the data packet capturing method according to any of the foregoing embodiments.

[0095] By executing the data packet capturing method, the electronic device according to the embodiment of the present application can start a packet capturing main process and a packet capturing client. Then, when it is monitored that the packet capturing client sends a packet capturing instruction to the main process, it can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area based on the main process. Further, it can read the target data packets from the target storage area based on the packet capturing client and process the target data packets, thereby finally completing the capturing and processing of the data packets.

[0096] Compared with the prior art, the embodiment of the present application can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area. Then, the client can read the target data packets from the target storage area. In this way, since the data packets input by the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input by the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, finally overcoming the defect that the prior art cannot support the packet capturing for the solution of obtaining data packets by the third-party drainage method.

[0097] Embodiment 4

[0098] The embodiment of the present application provides a storage medium storing a computer program that, when executed by a processor, performs the data packet capturing method according to any of the foregoing embodiments.

[0099] By executing the data packet capturing method, the storage medium according to the embodiment of the present application can start a packet capturing main process and a packet capturing client. Then, when it is monitored that the packet capturing client sends a packet capturing instruction to the main process, it can store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area based on the main process. Further, it can read the target data packets from the target storage area based on the packet capturing client and process the target data packets, thereby finally completing the capturing and processing of the data packets.

[0100] Compared with the prior art, in the embodiments of the present application, the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process can be stored in the target storage area, and then the client can read the target data packets from the target storage area. In this way, since the data packets input by the third-party drainage method need to pass through the data packet inlet and the data packet outlet of the main process, the data packets input by the third-party drainage method can be obtained through the data packet inlet and the data packet outlet of the main process, and finally the defect that the prior art cannot support packet capture for the solution of obtaining data packets by the third-party drainage method is overcome.

[0101] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling, direct coupling or communication connection may be through some communication interfaces, and the indirect coupling or communication connection of the devices or units may be in an electrical, mechanical or other form.

[0102] In addition, the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0103] Furthermore, in each embodiment of the present application, the functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.

[0104] It should be noted that if a function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art or a part of this technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs.

[0105] In this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0106] The above are only embodiments of this application and are not used to limit the protection scope of this application. For those skilled in the art, this application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection scope of this application.

Claims

1. A method for capturing data packets, characterized in that, The method includes: Starting a packet capture main process and a packet capture client; When it is monitored that the packet capture client sends a packet capture instruction to the main process, based on the main process, storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area; Based on the packet capture client, reading target data packets from the target storage area and processing the target data packets; After starting the packet capture main process and the packet capture client, the method further includes: Starting a packet capture monitoring service process to receive the information sent by the packet capture client through the packet capture monitoring service process, where the information sent by the packet capture client includes the packet capture client sending a packet capture instruction to the main process.

2. The method according to claim 1, characterized in that The storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area based on the main process includes: Based on the main process, calling a dump interface to store the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into the target storage area through the dump interface.

3. The method according to claim 1, wherein Before storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area based on the main process, the method further includes: Based on the packet capture client, creating a virtual network port; Based on the packet capture client, starting the virtual network port and applying for the target storage area, where the virtual network port maps the target storage area.

4. The method according to claim 1, wherein The reading target data packets from the target storage area based on the packet capture client includes: Based on the packet capture client, calling a data reading interface to read the target data packets from the target storage area through the data reading interface and process the target data packets.

5. The method according to claim 3, characterized in that, The method further includes: Based on the packet capture client, calling a packet capture end and exit interface to clear the virtual network port through the packet capture end and exit interface.

6. The method according to claim 1, wherein The target storage area is a circular memory area.

7. A data packet capturing device, characterized in that, The device includes: A start module for starting a packet capture main process and a packet capture client; A first packet capture module for, when it is monitored that the packet capture client sends a packet capture instruction to the main process, based on the main process, storing the data packets flowing through the data packet outlet of the main process and the data packets flowing through the data packet inlet of the main process into a target storage area; A second packet capture module for, based on the packet capture client, reading target data packets from the target storage area and processing the target data packets; The device is further configured to: After starting the packet capture main process and the packet capture client, start a packet capture monitoring service process to receive the information sent by the packet capture client through the packet capture monitoring service process, where the information sent by the packet capture client includes the packet capture client sending a packet capture instruction to the main process.

8. An electronic device, characterized in that, Includes: A processor; And A memory configured to store machine-readable instructions that, when executed by the processor, perform the data packet capture method according to any one of claims 1-6.

9. A storage medium, characterized in that, The storage medium stores a computer program that, when executed by the processor, performs the data packet capture method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Packet capture control method, device and system of cloud real machine and storage medium

    CN112994982A