PCAP data analysis method, device and equipment based on serialization protocol

By defining message files and dictionaries and deserializing PCAP data packets, the problem of PCAP data file analysis in fully automatic train monitoring system is solved, efficient data analysis and visual analysis are realized, and data readability and analysis efficiency are improved.

CN118916036APending Publication Date: 2024-11-08CASCO SIGNAL LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410959814.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

The prior art cannot effectively parse and analyze PCAP data files based on the serialization protocol in fully automatic train monitoring systems, which limits the understanding and analysis of data information between software.

Method used

By defining message files and dictionaries, using compilation tools to generate source code files, capturing PCAP packets and deserializing them, and reconstructing the packets for parsing and visual analysis.

Benefits of technology

It improves the readability and maintainability of PCAP data, enhances the reliability and security of data, simplifies the data analysis process, and improves the analysis efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916036A_ABST
    Figure CN118916036A_ABST
Patent Text Reader

Abstract

The invention relates to a PCAP data analysis method, device and equipment based on a serialization protocol, and the method comprises the steps: defining information exchanged between software of a full-automatic train monitoring system as a message file, and compiling the defined message file into a source code file through a compiling tool; defining a message dictionary for storing message names and message types of the message files; capturing a source code file and storing the source code file as a PCAP data packet, deserializing application layer data of each data packet in the PCAP data packet according to a defined dictionary, generating a deserialized byte character string, and storing or transmitting the deserialized byte character string in a text form; and a PCAP data packet is reconstructed, and analysis and visual analysis of PCAP data deserialization are realized. Compared with the prior art, the method has the advantages that the PCAP data analysis based on the serialization protocol is realized, the readability and maintainability of the PCAP data are improved, and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network technology, and in particular to a PCAP data parsing method, device and equipment based on a serialization protocol. Background Art

[0002] Serialization protocol refers to the process of converting a data structure or object state into a form that can be stored or transmitted. During the serialization process, the object is broken down into a series of bytes that can be reassembled in a specific order to reconstruct the object. This process can ensure the integrity and consistency of the object so that the object can be correctly reconstructed on different systems or platforms.

[0003] PCAP (Packet Capture) is a common network data capture format that allows users to capture network packets in an original, unmodified manner. It is based on the implementation of the operating system kernel layer to capture packets, and can capture network packets and perform various operations, such as filtering, deep analysis, etc. PCAP files refer to the format in which network packets captured by PCAP technology are stored in file form. PCAP file parsing technology is a technology that extracts the network packet information contained in PCAP files by reading and analyzing them. It is widely used in network communications, security auditing, protocol analysis and other fields.

[0004] Due to the simplicity and scalability of the serialization protocol, the fully automatic train monitoring system currently uses high-efficiency data serialization for data transmission between software. However, it is currently impossible to read and parse the PCAP data files based on the serialization protocol captured by each software, which limits the understanding and analysis of data information between software in the fully automatic train monitoring system. Therefore, it is of great significance to develop a PCAP data parsing method based on the serialization protocol.

[0005] How to implement PCAP data parsing based on serialization protocol has become a technical problem that needs to be solved. Summary of the invention

[0006] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a PCAP data parsing method, device and equipment based on a serialization protocol.

[0007] The purpose of the present invention can be achieved by the following technical solutions:

[0008] According to one aspect of the present invention, a PCAP data parsing method based on a serialization protocol is provided, the method comprising the following steps:

[0009] Step S1, defining the information exchanged between the software of the fully automatic train monitoring system as a message file, and using a compilation tool to compile the defined message file into a source code file;

[0010] Step S2, define a message dictionary for storing the message name and message type of the message file in step S1;

[0011] Step S3, capturing the source code file of step S1 and saving it as a PCAP data packet, deserializing the application layer data of each data packet in the PCAP data packet according to the dictionary defined in step S2, generating a deserialized byte string, and storing or transmitting it in text form;

[0012] Step S4: reconstruct the PCAP data packet to implement the deserialization parsing and visual analysis of the PCAP data.

[0013] Preferably, the source code file is used to generate message classes and encoding and decoding.

[0014] More preferably, the encoding and decoding specifically includes: converting a message object into binary data or converting binary data into a message object.

[0015] Preferably, in step S2, the key of the dictionary is the ID of the message, and the value of the dictionary is the type of the message.

[0016] Preferably, the process of step S3 includes:

[0017] a) Read the global header of the PCAP packet;

[0018] b) traverse the packet header and packet content of each packet in the PCAP packet;

[0019] c) Obtain the data content of each data packet, and according to the dictionary defined in step S2, take out the number of bytes that need to be deserialized by the application layer in each data packet and the corresponding message type, and use them as parameters to call the deserialization function for deserialization operation.

[0020] More preferably, the process of calling the deserialization function to perform the deserialization operation includes:

[0021] First, obtain the message class from the source code file of step S1;

[0022] Next, use the message class to create an empty message object and parse the byte string that needs to be deserialized into the properties of the message object by using the codec function in the message class;

[0023] Then, iterate over each field and corresponding value in the message object and concatenate them in string form;

[0024] Finally, the concatenated string is encoded into ASCII code and stored or transmitted in text form.

[0025] More preferably, the global header of the PCAP data packet is read in binary mode.

[0026] Preferably, the process of reconstructing the PCAP data packet includes:

[0027] Create a new PCAP package object to store the parsed PCAP data;

[0028] The global header of the PCAP data packet, the header of each data packet, and the byte string deserialized by the application layer are concatenated as the data packet content and written into a new PCAP packet object to form a new PCAP data packet.

[0029] According to another aspect of the present invention, a PCAP data parsing device based on a serialization protocol is provided, the device comprising a message file compilation module, a deserialization module, a PCAP packet reconstruction module and a PACP data parsing module which are connected in sequence.

[0030] Preferably, the message file compiling module is used to define the information exchanged between software during the operation of the fully automatic train monitoring system as a message file, and use a compilation tool to compile the defined message file into a source code file.

[0031] Preferably, the deserialization module reads the global header of the PCAP data packet in binary mode, traverses the header and content of each data packet, calls the deserialization function to parse the number of bytes that need to be deserialized in the application layer of each data packet and the corresponding message type, and stores or transmits them in text form.

[0032] Preferably, the PCAP packet reconstruction module is used to reconstruct the PCAP packet, that is, to splice the PCAP data packet global header, the packet header of each data packet and the byte string deserialized by the application layer as the data packet content and write them into a new PCAP file.

[0033] Preferably, the PACP data parsing module is used to implement the deserialization parsing of PCAP data and can perform visual analysis.

[0034] According to a third aspect of the present invention, there is provided an electronic device, comprising a memory and a processor, wherein a computer program is stored in the memory, and the method described above is implemented when the processor executes the program.

[0035] Compared with the prior art, the present invention has the following beneficial effects:

[0036] 1) In the design stage, the present invention defines the information exchanged between the software of the full-automatic train monitoring system as a message file, and combines the defined dictionary for storing message names and message types. By deserializing the PCAP application layer data of the serialization protocol and reconstructing the PCAP data packet, the parsed PCAP data packet contains both the underlying network protocol information and the readable application layer data. Compared with the prior art, the reconstruction of the PCAP data packet can make the parsing and analysis of the PCAP data more convenient and efficient, and can also improve the reliability and security of the data.

[0037] 2) The present invention includes the implementation of deserialization technology, which can restore serialized data to original data; compared with the prior art, the implementation of deserialization technology can improve the readability and maintainability of data.

[0038] 3) The present invention realizes visual analysis of PCAP data, so that users can analyze and understand PCAP data more intuitively; compared with the prior art, the realization of visual analysis can improve the efficiency and accuracy of data analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A schematic diagram of the process of generating a source code file in the present invention;

[0040] Figure 2 Schematic diagram of the process of the PCAP data analysis method of the present invention;

[0041] Figure 3 It is a schematic diagram of the deserialization process in the present invention;

[0042] Figure 4 It is a schematic diagram of the original PCAP data packet in the present invention;

[0043] Figure 5 Schematic diagram of a new PCAP data packet reconstructed in the present invention. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0045] The present embodiment relates to a PCAP data parsing method based on a serialization protocol, which deserializes the application layer data and then rewrites the PCAP data packet, keeping the message structure unchanged, and converts the application layer data into the deserialized data to form a new PCAP packet, thereby solving the problem of unreadable PCAP data packets in the original fully automatic train monitoring system and realizing the parsing of application layer data.

[0046] like Figure 2 , the method comprises the following steps:

[0047] Step S1, first define the information exchanged between software during the operation of the fully automatic train monitoring system as a message file, and use a compilation tool to compile the defined message file into a source code file. The source code file provides the function of generating message classes and codecs, and can convert message objects into binary data or convert binary data into message objects.

[0048] Step S2: define a message dictionary to store message names and message types. The key of the dictionary is the ID value of all messages in the message file, and the ID value is the type of the message in the message file. The message ID is used as the key of the dictionary, and the message type is used as the value of the dictionary.

[0049] Step S3, the PCAP data packet consists of three parts: Global Header, Packet Header and Packet Data. The global header of the original PCAP data packet is read in binary mode. The global header is the global information of each PCAP file and includes the following fields:

[0050] Magic number: This marks the beginning of the file and is used to identify the file and byte order. It can be 0xa1b2c3d4 or 0xd4c3b2a1, indicating big endian mode and original order respectively.

[0051] Major (main) version number and Minor (minor) version number: indicate the version information of the current file.

[0052] ThisZone (local time zone): If GMT is used, the value is 0.

[0053] SigFigs (timestamp precision): indicates the precision of the timestamp.

[0054] SnapLen (maximum storage length): Set the maximum length of the captured data packet.

[0055] LinkType: Indicates the link type, such as Ethernet.

[0056] Step S4, traverse the header and content of each original PCAP data packet. The header of the data packet usually contains the following structure: 1. Timestamp, indicating the timestamp information of the captured data packet, usually including the precision of seconds and microseconds; 2. Data packet length, indicating the actual length of the data packet, including the sum of the header and the body; 3. Capture length, indicating the length of the data packet actually captured and stored in the PCAP file, usually the capture length is less than or equal to the data packet length; 4. Uncaptured length, indicating the length of the data packet not captured in the PCAP file, if the capture length is equal to the data packet length, the uncaptured length is 0.

[0057] Step S5: Obtain the data content of each original PCAP data packet, and according to the defined message dictionary, take out the number of bytes that need to be deserialized by the application layer in each data packet and the corresponding message type, and use them as parameters to call the deserialization function.

[0058] Step S6, this step describes the role of the deserialization function. First, get the message class from the source code file defined in step 1. Use the message class to create an empty message object, and parse the byte string to be deserialized into the properties of the message object by using the codec function in the message class. Then traverse each field and corresponding value in the message object and concatenate them in the form of a string. Finally, encode the resulting string into ASCII code so that it can be stored or transmitted in text form. Step S7, create a new PCAP package object to store the parsed PCAP data.

[0059] Step S8: The PCAP data packet global header, the packet header of each data packet, and the byte string deserialized by the application layer are concatenated as data packet contents and written into a new PCAP file to form a new PCAP data packet.

[0060] Step S9: Open the generated new PCAP data packet, deserialize and parse the PCAP data and perform visual analysis.

[0061] This embodiment also relates to a PCAP data parsing method based on a serialization protocol, which is described in detail in conjunction with a message in PCAP.

[0062] Step S101, as Figure 1 As shown, the corresponding message class is generated according to the message definition:

[0063] / / Define a message to indicate a control or status request

[0064] Message

[0065] {

[0066] / / Optional field, unique identifier of the message

[0067] optional MSGID msg_id=1; / / MSGID field is used to identify the uniqueness of the message

[0068] / / Optional field, RTU (remote terminal unit) identifier

[0069] optional int32rtu_id=2; / / RTU_ID field, indicating the identifier of the remote terminal unit

[0070] / / Optional field, control mode status, indicating the current control mode status

[0071] optional int32control_mode_status=3; / / CONTROL_MODE_STATUS field, indicating the current control mode status

[0072] / / Optional field, requested control mode type

[0073] optional CONTROL_MODE_TYPE control_mode_request_status=4; / / CONTROL_MODE_REQUEST_STATUS field, indicating the requested control mode type

[0074] }

[0075] / / Define an enumeration type to represent different control mode request types

[0076] enum CONTROL_MODE_TYPE

[0077] {

[0078] / / No control mode change requested

[0079] NOT_REQUEST = 0; / / 0 value means no request for control mode change

[0080] / / Center requests local control

[0081] CENTER_REQUEST_LOCAL_CONTROL = 1; / / 1 value means the center requests to transfer control to the local

[0082] / / Center request center control

[0083] CENTER_REQUEST_CENTER_CONTROL = 2; / / A value of 2 indicates that the center requests to maintain or regain control

[0084] / / Local request local control

[0085] LOCAL_REQUEST_LOCAL_CONTROL = 3; / / 3 value means local request keeps control / / local request center controls

[0086] LOCAL_REQUEST_CENTER_CONTROL = 4; / / 4 value means the local request transfers control to the center

[0087] }

[0088] Step S102, as Figure 2 As shown, the message file defined in step S1 is imported, the message queue is traversed, each message file taken out from the queue is compiled, and a source code file is generated.

[0089] Step S103, using the ID of the message in step S101 as the key of the dictionary, and the type of the message as the value of the dictionary;

[0090] Step S104, capture the transmitted source code file through a packet capture tool (such as wireshark, etc.) to obtain a read PCAP data packet (here referred to as the original PCAP data packet), assuming that there is only one message in the original PCAP packet, and this message is the message listed in step S101. Read the global header of the original PCAP data packet and assign it to the global header (global_header), and write global_header into a new PCAP file;

[0091] The original PCAP data is as follows Figure 4 shown.

[0092] Step S105, obtaining the packet header and packet content of the data packet, extracting the number of bytes that need to be deserialized by the application layer and the corresponding message type, and using them as parameters to call the deserialization function;

[0093] Step S106, Figure 3 As shown, the deserialization function first obtains the message class from the module defined in step 1. Use the message class to create an empty message object and call the codec function to parse the byte string to be deserialized into the properties of the message object. Then it traverses each field and corresponding value in the message object and concatenates them in string form. Finally, encode the resulting string into ASCII code;

[0094] Step S107, creating a new PCAP packet object;

[0095] Step S108, concatenating the global header, the data packet header and the byte string deserialized by the application layer and writing them into a new PCAP file;

[0096] Step S109, use the wireshark analysis tool to open the generated PCAP packet and parse the serialized PCAP data such as Figure 5 shown.

[0097] The present embodiment also relates to a PCAP data parsing device based on a serialization protocol, which includes a message file compiling module, a deserialization module, a PCAP package reconstruction module and a PACP data parsing module which are connected in sequence.

[0098] in:

[0099] The message file compilation module is used to define the information exchanged between software during the operation of the fully automatic train monitoring system as a message file, and use a compilation tool to compile the defined message file into a source code file.

[0100] The deserialization module reads the global header of the original PCAP data packet in binary mode, traverses the header and content of each data packet, calls the deserialization function to parse the number of bytes that need to be deserialized by the application layer in each data packet and the corresponding message type, and stores or transmits it in text form.

[0101] The PCAP packet reconstruction module is used to reconstruct the PCAP packet, that is, to concatenate the PCAP packet global header, the header of each packet, and the byte string deserialized at the application layer as the packet content and write them into a new PCAP file.

[0102] The PACP data parsing module is used to implement the deserialization and analysis of PCAP data and perform visual analysis.

[0103] The present embodiment also relates to an electronic device, including a central processing unit (CPU), which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or loaded from a storage unit into a random access memory (RAM). In the RAM, various programs and data required for the operation of the device can also be stored. The CPU, ROM and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.

[0104] Multiple components in the device are connected to the I / O interface, including: input units, such as keyboards, mice, etc.; output units, such as various types of displays, speakers, etc.; storage units, such as disks, optical disks, etc.; and communication units, such as network cards, modems, wireless communication transceivers, etc. The communication unit allows the device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunication networks.

[0105] The processing unit performs the various methods and processes described above, such as methods S1 to S9. For example, in some embodiments, methods S1 to S9 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed on the device via a ROM and / or a communication unit. When the computer program is loaded into the RAM and executed by the CPU, one or more steps of methods S1 to S9 described above may be performed. Alternatively, in other embodiments, the CPU may be configured to execute methods S1 to S9 by any other appropriate means (e.g., by means of firmware).

[0106] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0107] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0108] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0109] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A PCAP data parsing method based on a serialization protocol, characterized in that: The method comprises the following steps: Step S1, defining the information exchanged between the software of the fully automatic train monitoring system as a message file, and using a compilation tool to compile the defined message file into a source code file; Step S2, define a message dictionary for storing the message name and message type of the message file in step S1; Step S3, capturing the source code file of step S1 and saving it as a PCAP data packet, deserializing the application layer data of each data packet in the PCAP data packet according to the message dictionary defined in step S2, generating a deserialized byte string, and storing or transmitting it in text form; Step S4: reconstruct the PCAP data packet to implement the deserialization parsing and visual analysis of the PCAP data.

2. A PCAP data parsing method based on a serialization protocol according to claim 1, characterized in that: The source code file is used to generate message classes and encoding and decoding.

3. A PCAP data parsing method based on a serialization protocol according to claim 2, characterized in that: The encoding and decoding specifically includes: converting a message object into binary data or converting binary data into a message object.

4. A PCAP data parsing method based on a serialization protocol according to claim 1, characterized in that: In the step S2, the key of the dictionary is the ID of the message, and the value of the dictionary is the type of the message.

5. A PCAP data parsing method based on a serialization protocol according to claim 1, characterized in that: The process of step S3 includes: a) Read the global header of the PCAP packet; b) traverse the packet header and packet content of each packet in the PCAP packet; c) Obtain the data content of each data packet, and according to the dictionary defined in step S2, take out the number of bytes that need to be deserialized by the application layer in each data packet and the corresponding message type, and use them as parameters to call the deserialization function for deserialization operation.

6. A PCAP data parsing method based on a serialization protocol according to claim 5, characterized in that: The process of calling the deserialization function to perform the deserialization operation includes: First, obtain the message class from the source code file of step S1; Next, use the message class to create an empty message object and parse the byte string that needs to be deserialized into the properties of the message object by using the codec function in the message class; Then, iterate over each field and corresponding value in the message object and concatenate them in string form; Finally, the concatenated string is encoded into ASCII code and stored or transmitted in text form.

7. A PCAP data parsing method based on a serialization protocol according to claim 5, characterized in that: The global header of the PCAP data packet is read in binary mode.

8. A PCAP data parsing method based on a serialization protocol according to claim 1, characterized in that: The process of reconstructing the PCAP data packet includes: Create a new PCAP package object to store the parsed PCAP data; The global header of the PCAP data packet, the header of each data packet, and the byte string deserialized by the application layer are concatenated as the data packet content and written into a new PCAP packet object to form a new PCAP data packet.

9. A device using the PCAP data parsing method based on serialization protocol according to claim 1, characterized in that: The device comprises a message file compiling module, a deserializing module, a PCAP package reconstruction module and a PACP data parsing module which are connected in sequence.

10. The device according to claim 9, characterized in that The message file compiling module is used to define the information exchanged between software during the operation of the fully automatic train monitoring system as a message file, and use a compiling tool to compile the defined message file into a source code file.

11. The device according to claim 9, characterized in that The deserialization module reads the global header of the PCAP data packet in binary mode, traverses the header and content of each data packet, calls the deserialization function to parse the number of bytes that need to be deserialized in the application layer of each data packet and the corresponding message type, and stores or transmits them in text form.

12. The device according to claim 9, characterized in that The PCAP packet reconstruction module is used to reconstruct the PCAP packet, that is, the PCAP packet global header, the packet header of each packet and the byte string deserialized at the application layer are spliced ​​as the packet content and written into a new PCAP file.

13. The device according to claim 9, characterized in that The PACP data parsing module is used to implement the deserialization parsing of PCAP data and can perform visual analysis.

14. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • PCAP data parsing method based on serialization protocol, and apparatus and device

    WO2026016349A1