Network data packet test method and device, terminal and storage medium

By capturing and decoding network packets on the OHOS platform, the compatibility problem of Wireshark tools for the OHOS platform is solved, effective analysis and diagnosis of network traffic is realized, and the stability and security of the system are improved.

CN119276759APending Publication Date: 2025-01-07深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411334372.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

The existing Wireshark tools cannot be used directly on the OHOS platform, which limits the monitoring and analysis of network traffic in the OHOS system.

Method used

By capturing the target network packets on the OHOS platform, converting them to the original data flow format, saving them in a temporary folder, and notifying the Wireshark tool for decoding through the target communication pipeline, the Wireshark tool supports the OHOS platform.

Benefits of technology

This enables developers and operation and maintenance personnel to easily perform network traffic analysis and problem diagnosis on the OHOS platform, improving the stability and security of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119276759A_ABST
    Figure CN119276759A_ABST
Patent Text Reader

Abstract

The invention discloses a network data packet testing method and device, a terminal and a storage medium. The method comprises the following steps: capturing a target network data packet on a target platform based on a data packet capturing module, wherein the target platform is an OHOS platform; storing the target network data packet in a temporary folder; constructing a target communication pipeline, and processing the target network data packet based on the notification of the target communication pipeline; and decoding the target network data packet based on a Wreshark tool. According to the method and the device, the problem that in the prior art, a Wreshark tool lacks effective support on an OHOS platform is solved, and developers and operation and maintenance personnel can capture and analyze data packets on the OHOS platform more conveniently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to a method, device, terminal and storage medium for testing a network data packet. Background Art

[0002] In the process of network development and operation and maintenance, capturing and analyzing network packets is a very important task. The Wireshark tool is a widely used network packet analysis tool that supports decoding and analysis of multiple protocols. However, the current Wireshark tool lacks effective support for the OHOS platform and cannot be used directly on the platform, which limits developers' monitoring and analysis of network traffic in the OHOS system.

[0003] OHOS is an open source operating system developed by Huawei, which is designed to be applicable to a variety of terminal devices, such as smart homes, wearable devices, etc. Due to the particularity and novelty of the OHOS platform, existing network capture tools are difficult to run directly on it, and a method is urgently needed to enable the Wireshark tool to work effectively on the OHOS platform.

[0004] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention

[0005] The main purpose of the present invention is to provide a method, device, terminal and storage medium for testing network data packets, aiming to solve the problem that network capture tools in the prior art are difficult to run directly on the OHOS platform.

[0006] In order to achieve the above object, the present invention provides a method for testing a network data packet in a first aspect, wherein the method for testing a network data packet comprises:

[0007] Capturing target network data packets on a target platform based on a data packet capture module, wherein the target platform is an OHOS platform;

[0008] Saving the target network data packet in a temporary folder;

[0009] Building a target communication pipeline, and processing the target network data packet based on the target communication pipeline notification;

[0010] The target network data packet is decoded based on the Wireshark tool.

[0011] In one implementation, capturing a target network data packet on a target platform includes:

[0012] Based on the first database, network data packets are captured in real time on the target platform. When the target network data packets are successfully captured, the target data packets are converted into the original data stream format. The first database includes libpcap library or winpcap library.

[0013] In one implementation, the step of storing the target network data packet in a temporary folder includes:

[0014] Converting the target network data packet in the original data stream format into a target format based on the second database, so that the Wireshark tool can process the target network data packet;

[0015] The target network data packet converted into the target format is saved in the temporary folder.

[0016] In one implementation, the processing of the target network data packet based on the target communication pipe notification includes:

[0017] Transmitting target data capture status information to the Wireshark tool based on the target communication pipeline, wherein the target data capture status information includes the number of captured network data packets and the storage location of the network data packets;

[0018] The Wireshark tool receives the target data capture state information and processes the target network data packet based on the target data capture state information.

[0019] In one implementation, decoding the target network data packet based on the Wireshark tool includes:

[0020] Reading the target network data packet in the temporary folder based on the second data and decoding the target network data packet based on a built-in decoder to obtain target information;

[0021] The target information is presented in the target software for analysis and debugging.

[0022] In one implementation, the data packet capture module communicates with the Wireshark tool via an API interface.

[0023] In one implementation, the temporary folder automatically encrypts the stored data.

[0024] A second aspect of the present invention is a network data packet testing device, comprising:

[0025] A controller creation module, configured to receive a first signal and create a target controller based on the first signal, wherein the target controller is configured to control a target control device;

[0026] A second signal receiving module, configured to receive a second signal, where the second signal is a signal for controlling a target sub-device based on the target controller;

[0027] A binding module is used to create a target control protocol based on the second signal and bind the target control protocol to the target controller, wherein the target control protocol is used to remotely manage and control the target sub-device.

[0028] According to a third aspect of the present invention, a terminal is provided, wherein the terminal comprises: a memory, a processor, and a test program for network data packets stored in the memory and executable on the processor, wherein the test program for network data packets implements the steps of the network data packet test method as described above when executed by the processor.

[0029] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the network data packet testing method described in any one of the above items.

[0030] Beneficial effects: Compared with the prior art, the present invention provides a method, device, terminal and storage medium for testing network data packets. In the method for testing network data packets provided by the present invention, firstly, the target network data packet is captured on the target platform based on the data packet capture module, and the target platform is the OHOS platform. Then, the target network data packet is saved in a temporary folder, a target communication pipeline is constructed, and the target network data packet is notified and processed based on the target communication pipeline. Finally, the target network data packet is decoded based on the Wireshark tool. The present invention provides users with a method for testing network data packets, which solves the problem that the Wireshark tool in the prior art lacks effective support for the OHOS platform, so that developers and operation and maintenance personnel can more conveniently perform network traffic analysis and problem diagnosis on the OHOS platform, which helps to improve the stability and security of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A flowchart of an embodiment of a method for testing a network data packet provided by the present invention;

[0032] Figure 2 A structural principle diagram of an embodiment of a network data packet testing device provided by the present invention;

[0033] Figure 3 A schematic diagram of an operating environment of an embodiment of a terminal provided by the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0035] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0036] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.

[0037] A network data packet testing method provided by the present invention can be applied to a terminal with computing capability, and the terminal can execute the network data packet testing method provided by the present invention to manage and control edge sub-devices.

[0038] Embodiment 1

[0039] In this embodiment, a network data packet testing method is provided, which is applicable to the OpenHarmony Operating System (OHOS) platform to enhance its compatibility with network data capture and analysis tools such as the Wireshark tool.

[0040] Network packet capture and analysis are critical to network development, maintenance, management, and security. They not only help network professionals better understand and optimize network performance, but also ensure network security and provide valuable data and insights for future network development.

[0041] Specifically, in this embodiment, the network data capture tool Wireshark provides support for OHOS by establishing a temporary folder and a communication pipeline.

[0042] Specific as Figure 1 As shown, the network data packet testing method provided in this embodiment includes the steps of:

[0043] S100 . Capturing target network data packets on a target platform based on a data packet capture module, wherein the target platform is an OHOS platform.

[0044] The capturing of target network data packets on the target platform includes:

[0045] Based on the first database, network data packets are captured in real time on the target platform. When the target network data packets are successfully captured, the target data packets are converted into the original data stream format. The first database includes libpcap library or winpcap library.

[0046] In the present embodiment, the network data packets are captured on the OHOS platform mainly by using the libpcap library or the winpcap library. Among them, the libpcap library and the winpcap library play a role on different operating system platforms respectively. The libpcap library is mainly used in Unix / Linux platforms, while the winpcap library is designed for Windows platforms. The core function of these libraries is to realize the real-time capture of network data packets at the kernel level of the operating system, thereby making it possible to perform tasks such as network traffic analysis, fault diagnosis and security monitoring.

[0047] Specifically, the libpcap library is an open source packet capture library that provides a set of APIs that enable developers to write programs on Unix / Linux systems to capture packets transmitted on the network. The libpcap library supports multiple link layer protocols, such as Ethernet, PPP, and Token Ring, enabling it to be used in different network environments. The working principle of the libpcap library is mainly through the creation of a special "sniffing" mode network interface, which can receive all network traffic passing through the local machine, regardless of whether the traffic is sent to the local machine. Developers can use the libpcap library's API to write programs to filter, capture, and analyze data packets, which is very useful for scenarios such as network performance analysis, fault diagnosis, and network security audits. The libpcap library also supports saving captured data packets to disk for subsequent analysis. This function is particularly important when it is necessary to monitor network conditions for a long time.

[0048] The winpcap library is a packet capture and network analysis tool designed specifically for the Windows platform. It is compatible with the libpcap library and provides similar functions. The main advantage of the winpcap library is that it can support multiple Windows operating systems and can run on various versions of Windows. Using the winpcap library, developers can implement functions such as capturing, analyzing and forwarding network packets under the Windows environment. The winpcap library also provides a powerful packet filtering engine, and users can customize filtering rules according to their needs and only capture packets of interest. In addition, the winpcap library can also be used in the development of network statistics and network intrusion detection systems because it can provide detailed information about network status and activities.

[0049] Through the libpcap library or the winpcap library, real-time capture of network data packets can be achieved at the OHOS system kernel level.

[0050] Specifically, first, the libpcap library or the winpcap library needs to be obtained and installed in the local terminal. Since OHOS may be different from a standard Linux or Windows environment, these libraries need to be compiled from source code to ensure compatibility.

[0051] In this embodiment, after the target network data packet is captured on the target platform, the target network data packet is converted into an original data stream format for use by the OHOS platform.

[0052] Furthermore, in this embodiment, when the data packet capture module is run on the OHOS platform, only authorized users and processes can perform data packet capture operations, thereby preventing unauthorized access from causing leakage of sensitive data.

[0053] Specifically, after the target network data packet is captured on the target platform, the method further includes:

[0054] S200: Save the target network data packet in a temporary folder.

[0055] The step of saving the target network data packet in a temporary folder includes:

[0056] Converting the target network data packet in the original data stream format into a target format based on the second database, so that the Wireshark tool can process the target network data packet;

[0057] The target network data packet converted into the target format is saved in the temporary folder.

[0058] Specifically, in this embodiment, the captured network data packets are processed using the second database and stored in a temporary file. In this embodiment, the second database may be a libwiretap library, which is a core component of the Wireshark tool and is specifically used to process capture files of various formats. Through the Wireshark tool library, the captured data is converted into the target format and saved in the temporary storage of the OHOS system, wherein the target format is a format that can be recognized by the Wireshark tool.

[0059] It can be seen that the captured target network data packets will be sent to the temporary file storage module for processing. The libwiretap library plays an important role in this process. It can convert the original data packets into a file format that the Wireshark tool can understand and save them to the temporary storage path of the OHOS platform, that is, the temporary folder. Considering the storage characteristics of the OHOS platform, the path and management method of temporary files can be optimized according to actual needs. For example, a ring buffer can be used to manage storage space to prevent excessive storage space occupation.

[0060] Furthermore, the temporary folder will automatically encrypt the stored data. Specifically, in order to prevent the captured data packets from being stolen or tampered with during transmission and storage, the data in the temporary file can be encrypted. In this way, even if the temporary file is illegally obtained, its content cannot be directly read.

[0061] S300, constructing a target communication pipeline, and processing the target network data packet based on the target communication pipeline notification.

[0062] The processing of the target network data packet based on the target communication pipe notification includes:

[0063] Transmitting target data capture status information to the Wireshark tool based on the target communication pipeline, wherein the target data capture status information includes the number of captured network data packets and the storage location of the network data packets;

[0064] The Wireshark tool receives the target data capture state information and processes the target network data packet based on the target data capture state information.

[0065] The data packet capture module communicates with the Wireshark tool via an API interface.

[0066] In this embodiment, in order to enable the Wireshark tool to obtain the captured data packet information in real time, a target communication pipeline constructed based on a pipeline communication mechanism is designed. This mechanism transmits data capture status information by establishing a bidirectional pipeline between the data packet capture module and the Wireshark tool.

[0067] Specifically, when a new data packet is captured and written to the temporary folder, the data packet capture module sends a notification to the Wireshark tool through a pipeline. The notification contains necessary information, such as the number of captured data packets, the storage location of the file, etc. After receiving the notification, the Wireshark tool can immediately start reading the new data packet file, thereby ensuring the real-time nature of data packet analysis.

[0068] Furthermore, considering the scalability of the OHOS platform, the modules communicate with each other through API interfaces, which facilitates the expansion and update of functions in the future. For example, in the future, the parser of the Wireshark tool can be expanded to support more new network protocols or increase support for specific hardware interfaces.

[0069] S400: Decode the target network data packet based on the Wireshark tool.

[0070] Decoding the target network data packet based on the Wireshark tool includes:

[0071] Reading the target network data packet in the temporary folder based on the second data and decoding the target network data packet based on a built-in decoder to obtain target information;

[0072] The target information is presented in the target software for analysis and debugging.

[0073] The Wireshark tool is a powerful network data analysis tool with a built-in libwireshark library core. Specifically, the libwireshark library is the core library of Wireshark, which provides rich protocol parsing functions and network analysis tools.

[0074] The libwireshark library is designed as a low-level library file to support the advanced features of Wireshark. This library contains a series of exported functions specifically for protocol parsing and other network analysis related tasks. Through these functions, developers can implement complex network analysis functions in their own applications.

[0075] And the libwireshark library is mainly aimed at developers and professionals who need to integrate network analysis functions into their own programs. It provides a series of functions from packet capture, protocol parsing to data filtering. The design of this library takes into account ease of use and extensibility, so that developers can easily call the functions it provides, or expand existing functions by writing plug-ins. Its application is very wide, from simple network fault diagnosis to complex network security analysis, all can be achieved using the libwireshark library. In the field of security, the libwireshark library can help professionals capture and analyze possible security threats, such as malware propagation or intrusion attempts. In protocol development and testing, developers can use the libwireshark library to verify whether the implementation of the new protocol is correct and ensure its compatibility with existing systems.

[0076] As can be seen, the libwireshark library is a powerful and flexible network protocol parsing library, through which complex network analysis functions can be implemented in custom programs. Whether it is a network engineer, security expert or software developer, everyone can benefit from this library.

[0077] In this embodiment, the Wireshark tool uses the libwiretap library to read the target network data packet in the temporary file folder.

[0078] Specifically, the read target network data packet will be passed to the libwireshark library core for processing. The Wireshark tool identifies the protocol type in the data packet through a built-in or plug-in parser and decodes the data packet content. For example, for HTTP data packets, the Wireshark tool can identify its header information, request method, response status and other details; for TCP data packets, the Wireshark tool can display information such as the source IP address, destination IP address, port number, sequence number, etc.

[0079] After decoding is completed, the Wireshark tool presents the parsed information in a user-friendly manner, which is convenient for developers or operation and maintenance personnel to conduct further analysis and debugging. Since the Wireshark tool itself has a powerful filtering function, users can view specific types of data packets by setting filtering conditions, thereby diagnosing problems more effectively.

[0080] Furthermore, as a multi-terminal operating system, the network environment of the OHOS platform may involve a wide range of application scenarios, including IoT devices, smart homes, and Internet of Vehicles. Therefore, when testing network data packets on the OHOS platform, it is necessary to consider the adaptation of the platform. This embodiment can widely support a variety of network interfaces and protocols by using the libpcap library or the winpcap library. In order to improve the performance on the OHOS platform, especially on resource-constrained embedded devices, in this embodiment, the data capture process can also be optimized, including: reducing redundant capture of data packets, using filtering rules to only capture data packets of interest or optimizing the writing speed of temporary files, and avoiding system performance degradation due to disk IO.

[0081] Furthermore, in this embodiment, various possible abnormal situations are also considered, such as network interruption, insufficient storage space, etc. Through a robust abnormality handling mechanism, it is possible to ensure that the system can be smoothly restored in abnormal situations and avoid data loss.

[0082] In order to ensure that the system can be smoothly restored and avoid data loss in abnormal situations such as network interruption and insufficient storage space, the following strategies and methods are adopted in this embodiment:

[0083] (1) Error detection and handling mechanism:

[0084] Exception detection: Detect abnormal conditions through exception detection mechanisms in the code. For example, in Java, try-catch-finally blocks can be used to capture and handle exceptions.

[0085] Error logging: When an exception occurs, the error information and stack trace are recorded in the log file to facilitate the analysis of the root cause of the problem later.

[0086] Exception classification processing: Provide different processing logic according to different types of exceptions, such as processing IOException and SQLException separately.

[0087] (2) Redundancy design and fault tolerance mechanism:

[0088] Backup system: Set up one or more backup systems so that when the main system fails, it can quickly switch to the backup system to continue providing services.

[0089] Redundant storage: Redundant storage of critical data, such as using RAID technology or distributed storage systems to ensure data persistence.

[0090] (3) Data backup and recovery strategy:

[0091] Regular backup: Regularly back up important data, including full backup and incremental backup, to ensure that it can be restored to the most recent stable state in any case.

[0092] Disaster Recovery Plan: Develop a detailed disaster recovery plan, including emergency response steps and a rapid recovery process for backup data.

[0093] (4) Resource monitoring and early warning system:

[0094] System monitoring: Real-time monitoring of system resource usage, such as CPU, memory, disk space, etc., and immediate notification of relevant personnel once an abnormality is detected.

[0095] Early warning mechanism: Establish an early warning mechanism to automatically trigger an early warning when the system load is too high or resources are about to be exhausted so that timely measures can be taken.

[0096] (5) Optimize the program’s exception handling logic:

[0097] Precise exception capture: Try to capture the most specific exception type and avoid capturing all exceptions.

[0098] Minimize try block scope: Make sure the try block contains only code that may throw an exception.

[0099] Appropriate exception handling: Perform appropriate processing based on the exception type and avoid simply ignoring or swallowing the exception.

[0100] (6) Use transaction management to ensure data consistency:

[0101] Database transactions: Use database transactions in operations involving data modification to ensure the atomicity of the operations and the consistency of the data status even if an exception occurs.

[0102] Distributed transaction management: In a distributed system, distributed transaction management tools are used to coordinate transactions on different nodes to ensure the consistency of cross-node operations.

[0103] (7) Using checkpoints and log files:

[0104] Checkpoint exception handling: Set checkpoints at key execution points to save the current state, and restore from the most recent checkpoint when an exception occurs.

[0105] Log file exception handling: Record key operations during program execution into log files so that unfinished operations can be restored by replaying the logs when an exception occurs.

[0106] (8) Resource cleanup and recycling:

[0107] Resource cleanup: Ensure that resources are released in the finally block, such as closing a file stream or database connection, regardless of whether an exception occurs.

[0108] Resource recovery mechanism: Design an effective resource recovery mechanism, such as the garbage collector in Java, to prevent resource leakage.

[0109] Through the network data packet testing method provided in this embodiment, the Wireshark tool can be successfully adapted on the OHOS platform, so that the network data packets in the OHOS system can be accurately captured and deeply analyzed. Moreover, the network data packet testing method provided in this embodiment has wide adaptability: it can support a variety of network interfaces and protocols of the OHOS platform, and is suitable for a variety of terminal devices and application scenarios; it has real-time performance: through the pipeline communication mechanism, the Wireshark tool can obtain and analyze the captured network data packets in real time, ensuring the timeliness of data analysis; it has high efficiency: through the optimization of data capture and storage processes, the network data packet testing method provided in this embodiment can achieve efficient data packet capture on the OHOS platform, reducing the consumption of system resources; it has security: the present invention ensures the security of the network data packet capture and analysis process through means such as authority management and data encryption, and prevents the leakage of sensitive data.

[0110] It can be seen that the network data packet testing method provided in this embodiment overcomes the shortcomings of the prior art, especially solves the adaptation problem of Wireshark on the OHOS platform. Through the network data packet testing method provided in this embodiment, developers and operation and maintenance personnel can more conveniently perform network traffic analysis and problem diagnosis on the OHOS platform, which helps to improve the stability and security of the system.

[0111] In summary, this embodiment provides a method for testing a network data packet. First, based on a data packet capture module, a target network data packet is captured on a target platform, the target platform is the OHOS platform, and then the target network data packet is saved in a temporary folder, a target communication pipeline is constructed, and the target network data packet is notified and processed based on the target communication pipeline. Finally, the target network data packet is decoded based on the Wireshark tool. This embodiment provides a method for testing a network data packet for users, which solves the problem that the Wireshark tool in the prior art lacks effective support for the OHOS platform, so that developers and operation and maintenance personnel can more conveniently perform network traffic analysis and problem diagnosis on the OHOS platform, which helps to improve the stability and security of the system.

[0112] It should be understood that, although the various steps in the flowcharts given in the accompanying drawings of the present invention are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, the execution of the steps in the present invention is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps of the present invention may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0113] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by signaling related hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0114] Embodiment 2

[0115] Based on the above embodiments, the present invention also provides a network data packet testing device, the functional module diagram of which is shown in FIG. Figure 2 As shown, the test device for the network data packet includes:

[0116] A capture module, which captures target network data packets on a target platform based on a data packet capture module, wherein the target platform is an OHOS platform, as described in the first embodiment;

[0117] A storage module, storing the target network data packet in a temporary folder, as described in the first embodiment;

[0118] A communication module, which processes the target network data packet based on the target communication channel notification, as described in the first embodiment;

[0119] The decoding module is used to decode the target network data packet based on the Wireshark tool, as described in detail in the first embodiment.

[0120] Embodiment 3

[0121] like Figure 3 As shown, based on the above-mentioned network data packet testing method, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 3 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0122] The memory 20 may be an internal storage unit of the terminal in some embodiments, such as a hard disk or memory of the terminal. The memory 20 may also be an external storage device of the terminal in other embodiments, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a test program 40 of a network data packet is stored on the memory 20, and the test program 40 of the network data packet can be executed by the processor 10, thereby realizing the test method of the network data packet in the present application.

[0123] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the test method of the network data packet.

[0124] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.

[0125] In one embodiment, when the processor 10 executes the test program 40 of the network data packet in the memory 20, the following steps are implemented:

[0126] Capturing target network data packets on a target platform based on a data packet capture module, wherein the target platform is an OHOS platform;

[0127] Saving the target network data packet in a temporary folder;

[0128] Building a target communication pipeline, and processing the target network data packet based on the target communication pipeline notification;

[0129] The target network data packet is decoded based on the Wireshark tool.

[0130] Wherein, capturing the target network data packet on the target platform includes:

[0131] Based on the first database, network data packets are captured in real time on the target platform. When the target network data packets are successfully captured, the target data packets are converted into the original data stream format. The first database includes libpcap library or winpcap library.

[0132] The step of saving the target network data packet in a temporary folder includes:

[0133] Converting the target network data packet in the original data stream format into a target format based on the second database, so that the Wireshark tool can process the target network data packet;

[0134] The target network data packet converted into the target format is saved in the temporary folder.

[0135] Wherein, the processing of the target network data packet based on the target communication channel notification includes:

[0136] Transmitting target data capture status information to the Wireshark tool based on the target communication pipeline, wherein the target data capture status information includes the number of captured network data packets and the storage location of the network data packets;

[0137] The Wireshark tool receives the target data capture state information and processes the target network data packet based on the target data capture state information.

[0138] Wherein, decoding the target network data packet based on the Wireshark tool includes:

[0139] Reading the target network data packet in the temporary folder based on the second data and decoding the target network data packet based on a built-in decoder to obtain target information;

[0140] The target information is presented in the target software for analysis and debugging.

[0141] Wherein, the data packet capturing module communicates with the Wireshark tool via an API interface.

[0142] The temporary folder automatically encrypts the stored data.

[0143] Embodiment 4

[0144] The present invention also provides a computer-readable storage medium on which one or more programs are stored. The one or more programs can be executed by one or more processors to implement the steps of the network data packet testing method described in the above embodiment.

[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for testing a network data packet, characterized in that: The network data packet testing method comprises: Capturing target network data packets on a target platform based on a data packet capture module, wherein the target platform is an OHOS platform; Saving the target network data packet in a temporary folder; Building a target communication pipeline, and processing the target network data packet based on the target communication pipeline notification; The target network data packet is decoded based on the Wireshark tool.

2. The method for testing a network data packet according to claim 1, characterized in that: The capturing of target network data packets on the target platform includes: Based on the first database, network data packets are captured in real time on the target platform. When the target network data packets are successfully captured, the target data packets are converted into the original data stream format. The first database includes libpcap library or winpcap library.

3. The method for testing a network data packet according to claim 1, characterized in that: The step of saving the target network data packet in a temporary folder includes: Converting the target network data packet in the original data stream format into a target format based on the second database, so that the Wireshark tool can process the target network data packet; The target network data packet converted into the target format is saved in the temporary folder.

4. The method for testing a network data packet according to claim 3, characterized in that: The processing of the target network data packet based on the target communication pipe notification includes: transmitting target data capture status information to the Wireshark tool based on the target communication pipeline, wherein the target data capture status information includes the number of captured network data packets and the storage location of the network data packets; The Wireshark tool receives the target data capture state information and processes the target network data packet based on the target data capture state information.

5. The method for testing a network data packet according to claim 3, characterized in that: Decoding the target network data packet based on the Wireshark tool includes: Reading the target network data packet in the temporary folder based on the second data and decoding the target network data packet based on a built-in decoder to obtain target information; The target information is presented in the target software for analysis and debugging.

6. The method for testing a network data packet according to claim 1, characterized in that: The data packet capturing module communicates with the Wireshark tool via an API interface.

7. The method for testing a network data packet according to claim 1, characterized in that: The temporary folder automatically encrypts the stored data.

8. A network data packet testing device, characterized in that: The device comprises: A capture module, which captures target network data packets on a target platform based on the data packet capture module, wherein the target platform is an OHOS platform; A storage module, storing the target network data packet in a temporary folder; A communication module, for processing the target network data packet based on the target communication channel notification; The decoding module is used to decode the target network data packet based on the Wireshark tool.

9. An intelligent terminal, characterized in that: The intelligent terminal includes a memory, a processor, and a network data packet testing program stored in the memory and executable on the processor. When the network data packet testing program is executed by the processor, the steps of the network data packet testing method as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a test program for a network data packet, and when the test program for the network data packet is executed by a processor, the steps of the network data packet test method as described in any one of claims 1-7 are implemented.