Message file analysis method, device, equipment, vehicle, medium and product
Patent Information
- Application Number
- CN202611196093.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-07
- Publication Date
- 2026-10-27
AI Technical Summary
[0004]为了解决上述技术问题,本公开提供了一种报文文件的解析方法、装置、设备、车辆、介质及产品,以解决车载报文解析效率低且准确性差的问题
[0017]本公开实施例提供的技术方案与现有技术相比具有如下优点:
Smart Images

Figure CN122994412A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of vehicle technology, and in particular to a method, apparatus, equipment, vehicle, medium, and product for parsing message files. Background Technology
[0002] With the development of automotive Ethernet technology, the Scalable Service-Oriented Middleware over Internet Protocol (SOME / IP) protocol has become the core communication protocol for data interaction and service invocation between in-vehicle electronic control units (ECUs), supporting the integration and intelligent upgrading of automotive systems. During in-vehicle network communication analysis, PacketCapture (PCAP) files are used to store raw in-vehicle communication data packets, while Automotive Open System Architecture Extensible Markup Language (ARXML) files structurally define SOME / IP service interfaces and data types, serving as the core data foundation for in-vehicle message parsing and fault diagnosis.
[0003] In related technologies, the analysis of automotive Ethernet packets is usually carried out by relying on the open-source tool Wireshark. This method can only complete the standard header parsing, but cannot directly parse and obtain the effective field values of the packet. Engineers need to manually perform payload (also known as payload byte stream) deserialization, which increases the time and manpower costs of automotive packet analysis and fault diagnosis, and the parsing efficiency is low and the accuracy is poor. Summary of the Invention
[0004] To address the aforementioned technical problems, this disclosure provides a method, apparatus, device, vehicle, medium, and product for parsing message files, thereby resolving the issues of low efficiency and poor accuracy in parsing vehicle-mounted messages.
[0005] Firstly, this disclosure provides a method for parsing a message file. The method includes: obtaining a message file to be parsed, the message file including multiple target data packets, each target data packet including header information and a payload byte stream; the message file is a vehicle Ethernet message file in a preset format; based on the header information, searching for a target structure definition template that matches the header information in a preset hash table, the target structure definition template being used to carry the parsing rules required to convert the payload byte stream into readable data with business semantics; based on the target structure definition template, performing deserialization parsing on the payload byte stream to obtain the target business semantic data corresponding to the payload byte stream; and visualizing the target business semantic data.
[0006] In one optional implementation, the preset format is an Internet Protocol-based Extensible Service-Oriented Middleware (IPM) format; obtaining the message file to be parsed includes: in response to a user's selection operation, obtaining the original message file corresponding to the selection operation, the original message file including multiple original data packets, each original data packet independently carrying a protocol type identifier; filtering multiple target data packets from the multiple original data packets, and using the multiple target data packets to construct the message file to be parsed; wherein, each target data packet independently carries a target protocol type identifier, the target protocol type identifier being used to characterize each target data packet as a data packet of the Internet Protocol-based Extensible Service-Oriented Middleware (IPM) protocol.
[0007] In one optional implementation, the header information includes a service identifier and a method identifier corresponding to each target data packet; the service identifier is used to identify the vehicle service to which each target data packet belongs; the method identifier is used to identify the calling method within the vehicle service corresponding to each target data packet; the preset hash table includes multiple mapping relationships; the mapping relationship is a mapping relationship between the service identifier, the method identifier, and the structure definition template; based on the header information, searching for a target structure definition template that matches the header information in the preset hash table includes: searching for a target mapping relationship that matches the service identifier and the method identifier in the multiple mapping relationships of the preset hash table; and searching for the target structure definition template corresponding to the target mapping relationship based on the target mapping relationship.
[0008] In one optional implementation, the target business semantic data includes multiple key-value pairs, each key-value pair including a field name and a corresponding field value; the structure definition template includes the field definition of each field among the multiple fields corresponding to the called method, each field definition including a field name and a field type; based on the target structure definition template, the payload byte stream is deserialized and parsed to obtain the target business semantic data corresponding to the payload byte stream, including: reading the field type corresponding to the current field in the target structure definition template, where the current field is any one of the multiple fields; based on the field type, determining the byte data corresponding to the current field in the payload byte stream, and based on the byte data, determining the field value of the current field; based on the field name and field value of the current field, determining the key-value pair corresponding to the current field; and generating the target business semantic data based on the key-value pairs corresponding to each of the multiple fields.
[0009] In one optional implementation, based on the field type, the byte data corresponding to the current field is determined in the payload byte stream, and based on the byte data, the field value of the current field is determined, including: if the current field is a basic single-value type, then the number of first bytes to be read for the current field is determined based on the basic single-value type; the number of first-byte bytes are extracted from the current read offset position of the payload byte stream; the number of first-byte bytes are concatenated according to the byte order corresponding to the preset format to obtain the original value corresponding to the current field, and the original value is used as the field value corresponding to the current field.
[0010] In one optional implementation, based on the field type, the byte data corresponding to the current field is determined in the payload byte stream, and based on the byte data, the field value of the current field is determined, including: if the current field is a preset type, determining the number of placeholder bytes to be read for the preset type; wherein, the preset type is a nested structure type or a variable-length vector type; extracting the byte data of the placeholder byte number from the current read offset position of the payload byte stream; concatenating the byte data of the placeholder byte number according to the byte order corresponding to the preset format to obtain the total byte length value corresponding to the current field, the total byte length value is used to indicate the number of bytes occupied by the internal data of the nested structure corresponding to the current field, or, the variable-length vector corresponding to the current field. The number of bytes occupied by the internal elements of the quantity; byte data of the total byte length value extracted from the remaining subbyte stream, where the remaining subbyte stream is the byte data in the payload byte stream excluding the placeholder bytes; when the preset type is a nested structure type, based on the hierarchical relationship of the nested structures in the target structure definition template and the corresponding field definitions in the nested structures, recursively deserialize the byte data of the total byte length value to obtain the field value corresponding to the current field; when the preset type is a variable-length vector type, based on the field definitions corresponding to the variable-length vector recorded in the target structure definition template, recursively deserialize the byte data of the total byte length value to obtain the field value corresponding to the current field.
[0011] In one optional implementation, based on the field type, the byte data corresponding to the current field in the payload byte stream is determined, and based on the byte data, the field value of the current field is determined, including: if the current field is a fixed-length array type, the total number of multiple data elements included in the array corresponding to the current field pre-configured in the target structure definition template is read, and based on the total number, each array element in the array is traversed sequentially; in a single loop, the number of second bytes to be read for each array element is determined based on the field type corresponding to each array element; the number of byte data corresponding to the second byte is extracted from the current read offset position of the payload byte stream; the number of byte data corresponding to the second byte is concatenated according to the byte order corresponding to the preset format to obtain the original value of each array element; and the original values of multiple elements are determined as the field value corresponding to the current field.
[0012] Secondly, the present invention provides a message file parsing device, which includes: a transceiver module for acquiring a message file to be parsed, the message file including multiple target data packets, each target data packet including header information and a payload byte stream; the message file is a vehicle Ethernet message file of a preset format; a query module for searching a target structure definition template matching the header information in a preset hash table based on the header information, the target structure definition template being used to carry the parsing rules required to convert the payload byte stream into readable data with business semantics; a parsing module for deserializing and parsing the payload byte stream based on the target structure definition template to obtain the target business semantic data corresponding to the payload byte stream; and the transceiver module is also used to visualize the target business semantic data.
[0013] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the message file parsing method of the first aspect or any corresponding embodiment described above.
[0014] Fourthly, the present invention provides a vehicle that includes the aforementioned electronic equipment.
[0015] Fifthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the message file parsing method of the first aspect or any corresponding embodiment thereof.
[0016] In a sixth aspect, the present invention provides a computer program product, including computer instructions, which are used to cause a computer to execute the message file parsing method of the first aspect or any corresponding embodiment described above.
[0017] The technical solution provided in this disclosure has the following advantages compared with the prior art: The message file parsing method provided in this embodiment can obtain an in-vehicle Ethernet message file containing header information and payload byte stream, search for a target structure definition template matching the message header information in a preset hash table, and perform precise deserialization parsing of the payload byte stream based on the target structure definition template to generate business semantic data with complete business semantics, thus completing the visualization display. Since the target structure definition template is used to carry the parsing rules required to convert the payload byte stream into readable data with business semantics, the parsing of in-vehicle Ethernet message files can be performed based on these parsing rules. Compared with related technologies that rely on Wireshark parsing tools and manual parsing to obtain semantic data, this method avoids the drawbacks of time-consuming and labor-intensive script parsing, improves the parsing efficiency and accuracy of in-vehicle Ethernet message files, reduces the cost of manual intervention and secondary data processing, and intuitively presents the message business content through visualization, greatly improving the convenience and practicality of in-vehicle network fault diagnosis and data analysis. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0019] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating a message file parsing method provided according to an embodiment of this application; Figure 2 This is a flowchart illustrating another method for parsing message files according to an embodiment of this application; Figure 3 This is a structural block diagram of a message file parsing device provided according to an embodiment of this application; Figure 4 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0021] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0022] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0023] This application embodiment is applied to the scenario of parsing vehicle Ethernet packet files.
[0024] Among related technologies, the SOME / IP protocol is designed for IP-based communication in the automotive field. Based on IP networks, it enables functions such as service discovery, event notification, and remote procedure calls, playing a crucial role in modern automotive Ethernet communication architectures. This allows different automotive ECUs to efficiently exchange data and call services, improving the integration and intelligence of automotive systems.
[0025] PCAP files are a file format used to store network data packets and are widely used in network traffic analysis. They record detailed information about data packets captured on the network interface, including protocol headers at each layer (data link layer, network layer, and transport layer) and the packet payload. In automotive Ethernet packet parsing scenarios, PCAP files can be used to save raw data from the automotive network communication process, providing a data foundation for subsequent packet parsing and fault diagnosis.
[0026] ARXML is a configuration file in the automotive open system architecture standard used to describe information such as software components, service interfaces, and data types. The ARXML file defines the methods, events, properties, and data types of their input / output parameters of the SOME / IP service interface in a structured manner, and is the core data source for describing the semantics of message services in automotive Ethernet communication.
[0027] In related technologies, the analysis of automotive Ethernet packets is usually carried out using the open-source tool Wireshark. However, this method cannot directly parse and obtain the valid field values of the packets. Engineers need to compare the ARXML file and perform deserialization on the payload byte stream of the parsed packets in order to obtain the semantically readable data corresponding to the payload byte stream. This increases the time and manpower costs of automotive packet analysis and fault diagnosis, and the parsing efficiency is low and the accuracy is poor.
[0028] To address the aforementioned technical problems, this application provides a method for parsing message files. This method acquires a vehicle Ethernet message file in a preset format, searches for a target structure definition template matching the header information in a preset hash table based on the header information, and then deserializes and parses the payload byte stream based on the target structure definition template to obtain the target service semantic data corresponding to the payload byte stream. The target service semantic data is then visualized. This approach strips away the original byte data format, accurately parses out the target service data with complete service semantics, and achieves intelligent parsing and intuitive presentation of the original vehicle Ethernet message data, solving the problems of low efficiency and poor accuracy in vehicle message parsing.
[0029] This embodiment provides a message file parsing method executed by a message file parsing device. The message file parsing device can be any device with computing and communication capabilities. The message file parsing device is equipped with a client, which is used to display the message parsing results and for users to select message files.
[0030] Figure 1 This is a flowchart illustrating a message file parsing method provided in an embodiment of this application; as shown below. Figure 1 As shown, the process includes the following steps: S101, obtain the message file to be parsed.
[0031] The message file is a pre-formatted in-vehicle Ethernet message file. The pre-formatted format is the Scalable Service-Oriented Middleware over Internet Protocol (SOME / IP) format.
[0032] In this embodiment, the message file includes multiple target data packets. Each target data packet includes header information and a payload byte stream. The header information includes a service ID and a method ID corresponding to each target data packet. The service ID identifies the in-vehicle service to which each target data packet belongs; the method ID identifies the calling method within the in-vehicle service corresponding to each target data packet. The payload byte stream (also known as the payload) is binary byte data.
[0033] In one example, in response to a user's selection operation, the original message file corresponding to the selection operation is obtained; multiple target data packets are filtered from multiple original data packets, and the multiple target data packets are used to construct the message file to be parsed.
[0034] The raw message file is in either Packet Capture (PCAP) or Binary Log Format (BLF) format. The raw message file contains multiple raw data packets, each carrying its own independent protocol type identifier.
[0035] Each target data packet independently carries a target protocol type identifier. The target protocol type identifier is used to identify each target data packet as a data packet based on the Internet Protocol Extensible Service-Oriented Middleware Protocol.
[0036] For example, on the client interface, the user selects filtering conditions according to the service identifier of the vehicle service, the method identifier of the calling method within the vehicle service, and / or the user inputs a filtering expression based on the syntax corresponding to the Wireshark parsing tool to perform the selection operation; in response to the user's selection operation, the original packet file corresponding to the selection operation is obtained.
[0037] Optionally, the original message file can be stored according to the output path of the filtered message file to be parsed specified by the user.
[0038] Understandably, by filtering the original message files and configuring a visual interface filter, only SOME / IP messages, selected vehicle services, or service messages of invoked methods need to be analyzed. Target data packets can be pre-selected from the original message files, eliminating irrelevant and redundant messages, effectively reducing the data size of the files to be parsed, significantly shortening the loading and parsing time of large message files, avoiding the problems of redundant parsing computing power and low efficiency, and significantly improving the vehicle message parsing speed. Simultaneously, based on the client-side visual interface interactive filtering function, users can visually and accurately filter messages based on service identifiers, method identifiers, and other dimensions. Users do not need to memorize or write professional filtering syntax, simplifying the message filtering operation process, significantly lowering the operational threshold for vehicle Ethernet message analysis, balancing the efficiency of message parsing with ease of operation, and adapting to various vehicle fault diagnosis and service message analysis scenarios.
[0039] S102, based on the header information, search for the target structure definition template that matches the header information in the preset hash table.
[0040] The preset hash table includes multiple mapping relationships; these mapping relationships are between service identifiers, method identifiers, and structure definition templates.
[0041] In this embodiment, the structure definition template is used to carry the parsing rules required to convert the payload byte stream into readable data with business semantics. The structure definition template includes the method identifier and the service identifier of each calling method, the field definition of each field in the multiple fields corresponding to the calling method, the hierarchical relationship of nested structures and the field definitions of each corresponding field in the nested structure, and the field definitions of each corresponding field in the variable-length vector; the field definition includes the field name, field type, byte order, and field length (e.g., the total number of multiple data elements included in a fixed-length array).
[0042] In some optional embodiments, a target mapping relationship matching the service identifier and method identifier is searched among multiple mapping relationships in a preset hash table; based on the target mapping relationship, the target structure definition template corresponding to the target mapping relationship is searched.
[0043] Understandably, hash table key-value matching offers faster response times and higher retrieval accuracy. By accurately matching target mapping relationships in a pre-defined hash table using service and method identifiers, and then retrieving the corresponding target structure definition template based on the mapping relationship, a one-to-one correspondence is achieved between in-vehicle services, called methods, and structure definition templates. This effectively avoids template mismatches and parsing errors, improves the universality and stability of message parsing, and ensures the accuracy and reliability of parsing results for complex in-vehicle business messages.
[0044] In one example, before searching for the target structure definition template that matches the header information in a preset hash table, the user selects the directory where the ARXML file is located on the client display interface. In response to the user's selection operation on the display interface, the directory where the ARXML file is located is scanned to obtain all ARXML files with the .arxml extension. Metadata describing the SOME / IP service interface definition in the ARXML file is extracted. The structure definition template is constructed based on the extracted metadata, and a preset hash table is constructed with "Service ID + Method ID" as the key.
[0045] S103, based on the target structure definition template, deserialize and parse the payload byte stream to obtain the target business semantic data corresponding to the payload byte stream.
[0046] Among them, deserialization parsing is used to instruct the target structure definition template based on precise matching to restore the unordered binary raw byte data in the payload byte stream into structured data with business meaning (i.e. target business semantic data).
[0047] In this embodiment of the application, the target business semantic data includes multiple key-value pairs; the business semantic data may include the source IP address, destination IP address, Service ID, Method ID, field name, and field value corresponding to the target data packet to be parsed.
[0048] For example, based on the target structure definition template, the payload byte stream is deserialized and parsed according to the parsing rules corresponding to the target structure definition template to obtain the target business semantic data corresponding to the payload byte stream.
[0049] S104 provides a visual representation of the target business semantic data.
[0050] Understandably, after parsing the target business semantic data corresponding to the payload byte stream, the target business semantic data is pushed to the client interface for visualization.
[0051] based on Figure 1 The method described herein can acquire vehicular Ethernet packet files containing header information and payload byte streams, search for a target structure definition template matching the packet header information in a preset hash table, and perform precise deserialization and parsing of the payload byte stream based on the target structure definition template to generate business semantic data with complete business semantics, thus completing the visualization display. Since the target structure definition template carries the parsing rules required to convert the payload byte stream into readable data with business semantics, the vehicular Ethernet packet files can be parsed based on these rules. Compared to related technologies that rely on Wireshark parsing tools combined with manual parsing to obtain semantic data, this method avoids the drawbacks of time-consuming and labor-intensive script parsing, improves the parsing efficiency and accuracy of vehicular Ethernet packet files, reduces manual intervention and secondary data processing costs, and intuitively presents the packet business content through visualization, greatly enhancing the convenience and practicality of vehicular network fault diagnosis and data analysis.
[0052] In an optional example, based on the aforementioned embodiments and as described above, the payload byte stream is deserialized and parsed based on the target structure definition template to obtain the target business semantic data corresponding to the payload byte stream, as follows. For details, please refer to [link to relevant documentation]. Figure 2 As shown, it includes: S201, Read the field type corresponding to the current field in the target structure definition template.
[0053] The current field can be any one of multiple fields. Field types include basic single-value types, nested structure types, variable-length vector types, or variable-length vector types.
[0054] S202, based on the field type, determine the byte data corresponding to the current field in the payload byte stream, and based on the byte data, determine the field value of the current field.
[0055] In some optional implementations, if the current field is a basic single-value type, the number of the first bytes to be read for the current field is determined based on the basic single-value type; the first number of bytes of data are extracted from the current read offset position of the payload byte stream; the first number of bytes of data are concatenated according to the byte order corresponding to the preset format to obtain the original value corresponding to the current field, and the original value is used as the field value corresponding to the current field.
[0056] The default format corresponds to the big-endian byte order of the SOME / IP format.
[0057] In this embodiment of the application, the basic single-value type may include integer, floating-point, and boolean types. For example, the number of bytes required to read the first byte of the current field corresponding to the integer type (int32) is 4 bytes.
[0058] In this embodiment, high-low bit concatenation is used to indicate that, according to the byte order corresponding to the preset format, shifting and bitwise operations are performed on multiple consecutively extracted byte data to adjust the weight position of each byte; the high-bit byte and the low-bit byte are recombined to restore the segmented byte data scattered in the byte stream to the complete original integer value. For example, taking the first number of byte data as [0x12, 0x34] as an example, concatenating the high and low bits of [0x12, 0x34] yields the original value 0x1234 corresponding to the current field.
[0059] Understandably, if the current field is a basic single-value type, the required byte length is accurately matched based on the basic single-value type of the field, and then the corresponding byte segment is extracted from the specified offset position of the byte stream. Following the big-endian byte order of SOME / IP, the high and low byte are concatenated to restore the original value. This enables efficient and standardized serialization parsing of single-value fields in the payload byte stream, effectively avoiding data parsing distortion caused by misreading byte length and disordered byte order. It ensures the consistency, accuracy and stability of SOME / IP message field parsing, and improves the standardization of the message parsing process and the reliability of data reading.
[0060] In some optional implementations, if the current field is a preset type, the number of placeholder bytes to be read for the preset type is determined; byte data of the number of placeholder bytes is extracted from the current read offset position of the payload byte stream; according to the byte order corresponding to the preset format, the byte data of the number of placeholder bytes is concatenated with high and low bits to obtain the total byte length value corresponding to the current field; byte data of the total byte length value is extracted from the remaining sub-byte stream; when the preset type is a nested structure type, based on the hierarchical relationship of the nested structures in the target structure definition template and the corresponding field definitions in the nested structures, recursive deserialization processing is performed on the byte data of the total byte length value to obtain the field value corresponding to the current field; when the preset type is a variable-length vector type, based on the field definitions corresponding to the variable-length vector recorded in the target structure definition template, recursive deserialization processing is performed on the byte data of the total byte length value to obtain the field value corresponding to the current field.
[0061] The default type is either a nested structure (struct) or a variable-length vector (vector).
[0062] In this embodiment, the number of placeholder bytes is used to store the byte length of a fixed byte segment that represents the total length of the data of a variable-length vector or a nested variable-length structure.
[0063] In this embodiment of the application, the total byte length value is used to indicate the number of bytes occupied by the internal data of the nested structure corresponding to the current field, or the number of bytes occupied by the internal elements of the variable-length vector corresponding to the current field.
[0064] In this embodiment of the application, the remaining subbyte stream is the byte data in the payload byte stream excluding the placeholder bytes.
[0065] Understandably, for the two types of composite variable-length fields in the SOME / IP protocol—nested structures and variable-length vectors—the total length of the data entity is parsed by first reading fixed-placeholder bytes to accurately define the boundaries of the sub-byte stream to be parsed, avoiding anomalies such as cross-field reading and data out-of-bounds errors. For nested structures, each internal sub-field is recursively parsed layer by layer according to the template hierarchy. For variable-length vectors, batch recursive deserialization is completed based on the template field definition. Byte concatenation and value restoration are handled based on the big-endian byte order standard. This approach can adapt to complex vehicle message structures with multi-level nesting and dynamically changing lengths. It can also isolate invalid byte streams through pre-length verification, greatly reducing the risk of parsing crashes caused by out-of-order or truncated messages. At the same time, the recursive processing mechanism driven by the structure definition template reduces the development of repetitive parsing logic, improving the reusability, compatibility, and data parsing integrity of the SOME / IP message deserialization code.
[0066] In some optional implementations, if the current field is a fixed-length array type, the total number of data elements in the array corresponding to the current field, which is pre-configured in the target structure definition template, is read, and each array element in the array is traversed sequentially based on the total number. During a single loop, the number of second bytes to be read for each array element is determined based on the field type corresponding to each array element. The number of bytes of data corresponding to the second byte stream is extracted from the current read offset position of the payload byte stream. The high and low bits of the number of bytes of data corresponding to the second byte stream are concatenated according to the byte order corresponding to the preset format to obtain the original value of each array element. The original values of multiple elements are determined as the field value corresponding to the current field.
[0067] In one example, after determining the field value of the current field, the current read offset position is moved to obtain the new read offset position of the payload byte stream.
[0068] Understandably, based on the total number of array elements pre-stored in the structure definition template, the fixed-length array is parsed element by element in a loop. For each array element, the corresponding field type is matched to obtain the length of bytes read in a single read. The original values of each element are restored by concatenating bytes based on big-endian byte order. This method can adapt to the parsing of fixed-length array messages composed of various basic single-value types. The looping and segmenting of the byte stream can accurately control the reading offset, effectively preventing byte reading misalignment and data cross-reading problems, ensuring the accuracy of fixed-length array field parsing in vehicles. At the same time, the common logic of basic field byte parsing is reused, reducing code redundancy and improving the versatility and operational stability of deserialization.
[0069] Optionally, the target structure definition template can be pre-configured with a maximum recursion depth threshold for recursive deserialization processing to prevent abnormal data from causing infinite recursion.
[0070] Specifically, during the recursive parsing of nested structures and variable-length vectors, the current recursion level is counted in real time. Before each entry into the next nested parsing level, the current recursion depth is checked to see if it exceeds a preset threshold. If the recursion depth does not exceed the threshold, the recursive deserialization logic of the next byte stream is executed normally. If the recursion depth reaches or exceeds the preset threshold, the current recursive parsing process is terminated immediately and an illegal message exception is thrown. This avoids program crashes caused by infinite recursion, program stack overflow, and memory exhaustion due to exception messages with circular nesting or malicious excessively long nesting, thereby improving the fault tolerance and operational security of the SOME / IP message parsing module.
[0071] S203, Based on the field name and field value of the current field, determine the key-value pair corresponding to the current field.
[0072] In one example, based on the field name and field value of the current field, the field name is used as the key and the parsed field value is used as the value to combine them to obtain the key-value pair corresponding to the current field.
[0073] S204 generates target business semantic data based on the key-value pairs corresponding to each of the multiple fields.
[0074] In one example, the key-value pairs of all fields in the parsed message file are obtained, and then uniformly integrated and encapsulated into a structured complete data body to obtain the target business semantic data.
[0075] Understandably, the payload byte stream is a binary code stream with no business meaning; the integrated key-value set carries the field business name and the corresponding physical signal value, which can be directly read and used by upper-layer businesses (vehicle diagnostics, central control, and algorithms) without further processing of byte parsing logic.
[0076] Understandably, the process involves reading the field type information of each field based on the target structure definition template. For different field types, matching byte truncation and parsing logic is used to accurately extract the corresponding byte data from the payload byte stream and restore the field value. Then, independent key-value pairs are generated by mapping field names to field values one-to-one. Finally, all field key-value pairs are aggregated to obtain the target business semantic data. Since various fields share a standardized parsing link, there is no need to repeatedly develop parsing code for different message structures. Byte reading boundaries are constrained by field types, effectively avoiding byte misalignment and cross-reading issues. The binary byte stream is transformed into structured data with business identifiers after key-value encapsulation, facilitating direct calls from upper-layer businesses. Simultaneously, unified management of field rules based on templates reduces maintenance costs, comprehensively considering the universality of SOME / IP message parsing, data reading accuracy, and ease of use of business data.
[0077] This embodiment also provides a message file parsing device, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0078] This embodiment provides a message file parsing device, such as... Figure 3 As shown, Figure 3 This is a structural block diagram of a message file parsing apparatus provided according to embodiments of this application; including: The transceiver module 301 is used to acquire the message file to be parsed. The message file includes multiple target data packets, each of which includes header information and payload byte stream. The message file is a vehicle Ethernet message file in a preset format.
[0079] The query module 302 is used to search for a target structure definition template that matches the header information in a preset hash table based on the header information. The target structure definition template is used to carry the parsing rules required to convert the payload byte stream into readable data with business semantics.
[0080] The parsing module 303 is used to deserialize and parse the payload byte stream based on the target structure definition template to obtain the target business semantic data corresponding to the payload byte stream.
[0081] The transceiver module 301 is used to visualize the semantic data of the target business.
[0082] In some optional implementations, the preset format is the Internet Protocol-based Extensible Service-Oriented Middleware (IPM) format; the transceiver module 301 is specifically used to respond to the user's selection operation, obtain the original message file corresponding to the selection operation, the original message file includes multiple original data packets, each original data packet independently carries a protocol type identifier; filter multiple target data packets from the multiple original data packets, and use the multiple target data packets to construct a message file to be parsed; wherein, each target data packet independently carries a target protocol type identifier, the target protocol type identifier is used to characterize each target data packet as a data packet of the Internet Protocol-based Extensible Service-Oriented Middleware (IPM) protocol.
[0083] In some optional implementations, the header information includes a service identifier and a method identifier corresponding to each target data packet; the service identifier is used to identify the vehicle service to which each target data packet belongs; the method identifier is used to identify the calling method within the vehicle service corresponding to each target data packet; the preset hash table includes multiple mapping relationships; the mapping relationship is a mapping relationship between the service identifier, the method identifier, and the structure definition template; the query module 302 is specifically used to search for the target mapping relationship that matches the service identifier and the method identifier in the multiple mapping relationships of the preset hash table; based on the target mapping relationship, the target structure definition template corresponding to the target mapping relationship is searched.
[0084] In some optional implementations, the target business semantic data includes multiple key-value pairs, each including a field name and a corresponding field value; the structure definition template includes the field definition of each field among the multiple fields corresponding to the called method, each field definition including a field name and a field type; the parsing module 303 is specifically used to read the field type corresponding to the current field in the target structure definition template, where the current field is any one of the multiple fields; based on the field type, determine the byte data corresponding to the current field in the payload byte stream, and based on the byte data, determine the field value of the current field; based on the field name and field value of the current field, determine the key-value pair corresponding to the current field; and based on the key-value pairs corresponding to each of the multiple fields, generate the target business semantic data.
[0085] In some optional implementations, the parsing module 303 is specifically used to determine the number of first bytes to be read for the current field based on the basic single-value type if the current field is a basic single-value type; extract the number of first-byte bytes from the current read offset position of the payload byte stream; concatenate the first-byte bytes according to the byte order corresponding to the preset format to obtain the original value corresponding to the current field, and use the original value as the field value corresponding to the current field.
[0086] In some optional implementations, the parsing module 303 is specifically used to determine the number of placeholder bytes to be read for a preset type if the current field is a preset type; wherein the preset type is a nested structure type or a variable-length vector type; extract the byte data of the placeholder byte number from the current read offset position of the payload byte stream; concatenate the byte data of the placeholder byte number according to the byte order corresponding to the preset format to obtain the total byte length value corresponding to the current field, the total byte length value is used to indicate the number of bytes occupied by the internal data of the nested structure corresponding to the current field, or the number of bytes occupied by the internal elements of the variable-length vector corresponding to the current field; and extract the remaining sub-byte data from the remaining sub-byte data. The throttling process extracts byte data equal to the total byte length value. The remaining sub-byte stream consists of byte data from the payload byte stream excluding placeholder bytes. When the preset type is a nested structure, recursive deserialization is performed on the byte data equal to the total byte length value based on the hierarchical relationship of the nested structures in the target structure definition template and the corresponding field definitions within the nested structures to obtain the field value corresponding to the current field. When the preset type is a variable-length vector, recursive deserialization is performed on the byte data equal to the total byte length value based on the field definitions corresponding to the variable-length vector recorded in the target structure definition template to obtain the field value corresponding to the current field.
[0087] In some optional implementations, the parsing module 303 is specifically used to: if the current field is a fixed-length array type, read the total number of multiple data elements included in the array corresponding to the current field pre-configured in the target structure definition template, and based on the total number, sequentially traverse each array element in the array; in a single loop, determine the number of second bytes to be read for each array element based on the field type corresponding to each array element; extract the number of bytes of data corresponding to the second byte from the current read offset position of the payload byte stream; concatenate the high and low bits of the number of bytes of data according to the byte order corresponding to the preset format to obtain the original value of each array element; and determine the original values of multiple elements as the field value corresponding to the current field.
[0088] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0089] In this embodiment, the message file parsing device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0090] This invention also provides an electronic device having the above-described features. Figure 3 The device for parsing the message file shown.
[0091] Please see Figure 4 , Figure 4 This is a schematic diagram of the hardware structure of the electronic device according to an embodiment of this application, such as... Figure 4 As shown, the electronic device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise as required. The processors can process instructions executed within the electronic device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple electronic devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 4 Take a processor 10 as an example.
[0092] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0093] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0094] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0095] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0096] The electronic device also includes a communication interface 30 for communicating with other devices or communication networks.
[0097] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0098] This invention provides a computer program product, which includes computer instructions for causing a computer to execute the method of any embodiment of this invention.
[0099] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0100] The above description is merely a specific embodiment of this disclosure, enabling those skilled in the art to understand or implement it. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to the embodiments described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for parsing message files, characterized in that, The method includes: Obtain the message file to be parsed, the message file includes multiple target data packets, each target data packet includes header information and payload byte stream; the message file is a vehicle Ethernet message file of a preset format; Based on the header information, a target structure definition template matching the header information is searched in a preset hash table. The target structure definition template is used to carry the parsing rules required to convert the payload byte stream into readable data with business semantics. Based on the target structure definition template, the payload byte stream is deserialized and parsed to obtain the target business semantic data corresponding to the payload byte stream; The target business semantic data is visualized.
2. The method according to claim 1, characterized in that, The preset format is an extensible service-oriented middleware format based on the Internet Protocol; obtaining the message file to be parsed includes: In response to a user's selection operation, the original message file corresponding to the selection operation is obtained. The original message file includes multiple original data packets, each of which independently carries a protocol type identifier. Multiple target data packets are filtered from the multiple original data packets, and the multiple target data packets are used to construct the message file to be parsed; wherein, each target data packet independently carries a target protocol type identifier, the target protocol type identifier is used to characterize each target data packet as a data packet based on the Internet Protocol Extensible Service-Oriented Middleware Protocol.
3. The method according to claim 1, characterized in that, The header information includes a service identifier and a method identifier corresponding to each target data packet; the service identifier is used to identify the vehicle service to which each target data packet belongs; the method identifier is used to identify the calling method within the vehicle service corresponding to each target data packet. The preset hash table includes multiple mapping relationships; The mapping relationship is the mapping relationship between the service identifier, the method identifier, and the structure definition template; The step of searching for a target structure definition template that matches the header information in a preset hash table includes: Search for the target mapping relationship that matches the service identifier and the method identifier in the plurality of mapping relationships in the preset hash table; Based on the target mapping relationship, find the target structure definition template corresponding to the target mapping relationship.
4. The method according to claim 3, characterized in that, The target business semantic data includes multiple key-value pairs, each key-value pair including a field name and a field value corresponding to the field name; the structure definition template includes the field definition of each field among the multiple fields corresponding to the calling method, each field definition including a field name and a field type; The process of deserializing and parsing the payload byte stream based on the target structure definition template to obtain the target business semantic data corresponding to the payload byte stream includes: Read the field type corresponding to the current field in the target structure definition template, where the current field is any one of the multiple fields; Based on the field type, determine the byte data corresponding to the current field in the payload byte stream, and based on the byte data, determine the field value of the current field; Based on the field name and field value of the current field, determine the key-value pair corresponding to the current field; The target business semantic data is generated based on the key-value pairs corresponding to each of the multiple fields.
5. The method according to claim 4, characterized in that, The step of determining the byte data corresponding to the current field in the payload byte stream based on the field type, and determining the field value of the current field based on the byte data, includes: If the current field is a basic single-value type, then the number of the first bytes to be read for the current field is determined based on the basic single-value type; Extract the first number of bytes of data from the current read offset position of the payload byte stream; According to the byte order corresponding to the preset format, the first number of bytes of data are concatenated by high and low bits to obtain the original value corresponding to the current field, and the original value is used as the field value corresponding to the current field.
6. The method according to claim 4, characterized in that, The step of determining the byte data corresponding to the current field in the payload byte stream based on the field type, and determining the field value of the current field based on the byte data, includes: If the current field is a preset type, then determine the number of placeholder bytes to be read for the preset type; wherein, the preset type is a nested structure type or a variable-length vector type; Extract the number of placeholder bytes of data from the current read offset position of the payload byte stream; According to the byte order corresponding to the preset format, the byte data of the placeholder byte number is concatenated with high and low bits to obtain the total byte length value corresponding to the current field. The total byte length value is used to indicate the number of bytes occupied by the internal data of the nested structure corresponding to the current field, or the number of bytes occupied by the internal elements of the variable-length vector corresponding to the current field. Extract byte data of the total byte length value from the remaining subbyte stream, wherein the remaining subbyte stream is the byte data in the payload byte stream excluding the number of placeholder bytes; When the preset type is the nested structure type, based on the hierarchical relationship of the nested structure in the target structure definition template and the corresponding field definitions in the nested structure, recursive deserialization processing is performed on the byte data of the total byte length value to obtain the field value corresponding to the current field. When the preset type is the variable-length vector type, based on the field definitions corresponding to the variable-length vector recorded in the target structure definition template, recursive deserialization processing is performed on the byte data of the total byte length value to obtain the field value corresponding to the current field.
7. The method according to claim 4, characterized in that, The step of determining the byte data corresponding to the current field in the payload byte stream based on the field type, and determining the field value of the current field based on the byte data, includes: If the current field is a fixed-length array type, then read the total number of multiple data elements included in the array corresponding to the current field that is pre-configured in the target structure definition template, and based on the total number, traverse each array element in the array in turn. During a single loop, the number of second bytes to be read for each array element is determined based on the field type corresponding to each array element. Extract the second number of bytes of data from the current read offset position of the payload byte stream; According to the byte order corresponding to the preset format, the second number of bytes of data are concatenated by high and low bits to obtain the original value of each array element; The original values of multiple elements are determined as the field values corresponding to the current field.
8. A message file parsing device, characterized in that, The message file parsing device includes: The transceiver module is used to acquire a message file to be parsed. The message file includes multiple target data packets, each of which includes header information and a payload byte stream. The message file is a vehicle Ethernet message file with a preset format. The query module is used to search for a target structure definition template that matches the header information in a preset hash table based on the header information. The target structure definition template is used to carry the parsing rules required to convert the payload byte stream into readable data with business semantics. The parsing module is used to deserialize and parse the payload byte stream based on the target structure definition template to obtain the target business semantic data corresponding to the payload byte stream; The transceiver module is also used to visualize the target business semantic data.
9. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the message file parsing method of any one of claims 1 to 7.
10. A vehicle, characterized in that, Including the electronic device as described in claim 9.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the message file parsing method according to any one of claims 1 to 7.
12. A computer program product, characterized in that, Includes computer instructions, which are used to cause a computer to execute the message file parsing method according to any one of claims 1 to 7.