Python-based SOME / IP subscription behavior test method and device

Through the Python-based SOME/IP subscription behavior testing method, the cost and complex problem of testing the subscription behavior of SOME/IP-SD protocol in the prior art is solved, low-cost and efficient testing is achieved, the process is simplified and the technical threshold is lowered.

CN120075086APending Publication Date: 2025-05-30VOYAH AUTOMOBILE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510001649.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-02
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The prior art relies on expensive professional tools when testing the SOME/IP-SD protocol subscription behavior, and it is not convenient for technicians to conduct in-depth testing, especially those who do not directly support SOME/IP protocol code.

Method used

Provide a SOME/IP subscription behavior testing method based on Python. By running a test script created by Python, it monitors pre-notifications, determines whether to send a subscription request, constructs and sends SOME/IP-SD subscription request messages, and records test data to generate a report.

Benefits of technology

It reduces the cost of subscription behavior testing of SOME/IP-SD protocol and improves testing efficiency, simplifies the testing process, reduces technical requirements, and supports flexible configuration of test parameters to adapt to different test scenarios and requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120075086A_ABST
    Figure CN120075086A_ABST
Patent Text Reader

Abstract

The invention discloses a Python-based SOME / IP subscription behavior test method and device, a program product and a medium. The method comprises the following steps: running a test script created based on Python; executing a behavior monitoring module through the test script to monitor a pre-notification sent by the second controller to the first controller; when the pre-notification is the preset broadcast notification, judging whether the first controller sends a subscription request to the second controller or not according to a preset rule; under the condition that it is determined that the subscription request is sent, a test configuration file is loaded through the test script, and the test configuration file at least comprises a target address and a target port; controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller matched with the target address and the target port through a network; and recording test data in the process of receiving the pre-notification and sending the subscription request message, and generating a test report according to the test data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of automotive network communication, and particularly relates to a SOME / IP subscription behavior testing method, device, program product, and medium based on Python. Background Art

[0002] With the development of automotive networking and intelligence, the SOME / IP protocol, as one of the important standards for in-vehicle network communication, is widely used in fields such as in-vehicle infotainment systems and autonomous driving systems. SOME / IP-SD, as the service discovery mechanism of SOME / IP, is responsible for communication matching between service providers and service consumers. However, the current testing of SOME / IP-SD protocol subscription behavior mainly relies on professional testing tools such as canoe. These tools are not only expensive but also not easily accessible and usable by all technicians. In addition, it is difficult for technicians without directly supporting SOMEIP protocol code to conduct in-depth testing of subscription behavior through existing tools. Summary of the Invention

[0003] Embodiments of this application provide a SOME / IP subscription behavior testing method, device, program product, and medium based on Python, which can at least to a certain extent reduce the testing cost of SOME / IP-SD protocol subscription behavior and improve its testing efficiency.

[0004] Other features and advantages of this application will become apparent through the following detailed description, or be learned in part through the practice of this application.

[0005] According to the first aspect of the embodiments of this application, a SOME / IP subscription behavior testing method based on Python is provided. The method includes: running a test script created based on Python; monitoring a pre-notification sent by a second controller to a first controller based on the test script; in the case where the pre-notification is a preset broadcast notification, determining whether the first controller sends a subscription request to the second controller according to a preset rule; in the case of determining that a subscription request is sent, loading a test configuration file through the test script, where the test configuration file at least includes a target address and a target port; controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller that matches the target address and the target port through the network; recording test data during the process of receiving the pre-notification and sending the subscription request message, and generating a test report according to the test data.

[0006] In some embodiments of the present application, based on the foregoing solution, the method further includes: before running a test script created based on Python, constructing the header content and payload content of a subscription request message based on the byte array library and socket database of Python, wherein the header content includes at least one of a protocol version, a message type, a message length, and a service ID.

[0007] In some embodiments of the present application, based on the foregoing solution, loading a test configuration file by the test script includes: parsing test parameters input by a user through a command line based on the parameter parsing library of Python, and generating the test configuration file based on the test parameters.

[0008] In some embodiments of the present application, based on the foregoing solution, controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller that matches the target address and the target port through a network includes: creating a UDP socket based on the socket database of Python to control the first controller to send the pre-constructed SOME / IP-SD subscription request message to the second controller that matches the target address and the target port through the network.

[0009] In some embodiments of the present application, based on the foregoing solution, the test data at least includes the time of receiving the pre-notification and the time of sending the subscription request message, the response content received by the first controller, and the processing result of the subscription request message.

[0010] In some embodiments of the present application, based on the foregoing solution, the test configuration file further includes a service ID, and the method further includes: in the case where the pre-notification is a broadcast notification related to the service ID, determining whether the first controller sends a subscription request to the second controller according to a preset rule.

[0011] In some embodiments of the present application, based on the foregoing solution, the test configuration file further includes an event group ID, and controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller that matches the target address and the target port through a network includes: controlling the first controller to send the pre-constructed SOME / IP-SD subscription request message to the second controller that matches the target address and the target port through the network with the event group ID.

[0012] According to a second aspect of the embodiments of the present application, there is provided a Python-based SOME / IP subscription behavior testing device, the device comprising: a script acquisition unit configured to run a test script created based on Python; a monitoring unit configured to monitor a pre-notification sent by a second controller to a first controller based on the test script; a subscription unit configured to, when the pre-notification is a preset broadcast notification, determine whether the first controller sends a subscription request to the second controller according to a preset rule; and when it is determined that the subscription request is sent, load a test configuration file through the test script, the test configuration file at least including a target address and a target port; control the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller matching the target address and the target port through a network; and a data recording unit configured to record test data during the process of receiving the pre-notification and sending the subscription request message, and generate a test report according to the test data.

[0013] According to a third aspect of the embodiments of the present application, there is provided a computer program product, the computer program product comprising computer instructions stored in a computer-readable storage medium and adapted to be read and executed by a processor so that a computer device having the processor executes the Python-based SOME / IP subscription behavior testing method according to any one of the embodiments in the first aspect above.

[0014] According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable storage medium having at least one computer program instruction stored therein, the at least one computer program instruction being loaded and executed by a processor to implement the operations performed by the Python-based SOME / IP subscription behavior testing method according to any one of the embodiments in the first aspect above.

[0015] This solution reduces the technical requirements for testers, simplifies the test process, and improves the test efficiency through parameterized configuration and automated monitoring. Moreover, the test script in this solution supports flexible configuration of test parameters, can adapt to different test scenarios and requirements, and reduces the test cost. And by lowering the test threshold, this solution helps to encourage more technical personnel to participate in the research and development of the SOME / IP protocol, promoting technological innovation and development.

[0016] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. In the drawings:

[0018] Figure 1 It shows a flowchart of the Python-based SOME / IP subscription behavior test method in an embodiment of the present application;

[0019] Figure 2 It shows a block diagram of the Python-based SOME / IP subscription behavior test device in an embodiment of the present application. Detailed implementation manners

[0020] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0021] In addition, the described features, structures or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, many specific details are provided to give a full understanding of the embodiments of the present application. However, those skilled in the art will realize that the technical solutions of the present application can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, well-known methods, devices, implementations or operations are not shown or described in detail to avoid obscuring various aspects of the present application.

[0022] The block diagrams shown in the drawings are only functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0023] The flowcharts shown in the drawings are only illustrative descriptions and do not necessarily include all the contents and operations / steps, nor do they necessarily need to be executed in the described order. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined. Therefore, the actual execution order may change according to the actual situation.

[0024] In the description of this application, it should be understood that the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of this application, unless otherwise specified, the meaning of "a plurality" is two or more.

[0025] Referring to Figure 1 , a flowchart of a Python-based SOME / IP subscription behavior test method in an embodiment of this application is shown. This Python-based SOME / IP subscription behavior test method can be executed by a device with computing and processing capabilities.

[0026] Referring to Figure 1 As shown, this Python-based SOME / IP subscription behavior test method at least includes the following steps:

[0027] Step 110, run a test script created based on Python;

[0028] Step 120, monitor the pre-notification sent by the second controller to the first controller based on the test script;

[0029] Step 130, when the pre-notification is a preset broadcast notification, determine whether the first controller sends a subscription request to the second controller according to a preset rule;

[0030] Step 140, when it is determined that a subscription request is sent, load a test configuration file through the test script. The test configuration file at least includes a target address and a target port;

[0031] Step 150, control the first controller to send a pre-constructed SOME / IP-SD subscription request message to the second controller that matches the target address and target port through the network;

[0032] Step 160, record the test data during the process of receiving the pre-notification and sending the subscription request message, and generate a test report according to the test data.

[0033] The first controller and the second controller involved in this solution refer to two different controllers. For example, they can refer to two central controllers on a vehicle. These two controllers can perform data interaction through the SOME / IP protocol. The purpose of this solution is to perform an automated test on the subscription request behavior when the two controllers perform data interaction based on SOME / IP.

[0034] In one embodiment, the method further includes: before running a test script created based on Python, constructing the header content and payload content of a subscription request message based on the bytearray library and socket database of Python, where the header content includes at least one of a protocol version, a message type, a message length, and a service ID.

[0035] The test script mentioned in this solution is implemented using Python scripts. When creating the test script, the bytearray library (byte array library) and socket library (socket database) of Python can be utilized to implement the construction of the subscription request. Specifically, according to the SOME / IP-SD protocol specification, the header (Header) and payload (Payload) of the subscription request can be constructed. Among them, the header content includes key information such as the protocol version, message type, message length, and service ID. The payload content includes the event group ID and optional parameters. In this way, it can be ensured that the message format strictly conforms to the protocol standard of SOME / IP-SD.

[0036] After running the test script created based on Python, the behavior monitoring module can be executed through the test script to monitor the pre-notification sent by the second controller to the first controller. In this solution, when running the test script created based on Python, that is, during the test process of the SOME / IP-SD subscription behavior, the monitoring of the hardware offer message of the OIB (central controller) or other SOME / IP service providers can be extended based on the network communication module, that is, the monitoring of the pre-notification can be achieved by executing the behavior monitoring module. Specifically, the behavior monitoring module can automatically identify and parse the service discovery information (i.e., pre-notification) sent from the OIB (central controller) or other SOME / IP devices. After identifying a specific preset broadcast notification, it can be determined whether the first controller needs to send a subscription request to the second controller according to the preset rules. In the case where it is determined according to the preset rules that the first controller needs to send a subscription request to the second controller, the test configuration file can be loaded through the test script, and then the pre-constructed subscription request message can be sent to the second controller. Further, the behavior monitoring module supports monitoring multiple service IDs and event group IDs, and processing multiple subscription requests and responses simultaneously to improve the test efficiency.

[0037] In one embodiment, the test configuration file includes at least a target address and a target port to implement test automation. The test configuration file also includes a service ID. In the case where the pre-notification is a pre-notification related to the service ID, it can be determined whether the first controller sends a subscription request to the second controller according to the preset rules. Among them, technicians can customize the preset rules according to specific scenarios, which are not limited here.

[0038] When it is determined to send a subscription request, a test configuration file can be loaded through a test script, and then the first controller is controlled to send a pre-constructed SOME / IP-SD subscription request message to a second controller that matches the target address and target port through the network. Specifically, the test configuration file further includes an event group ID. Controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller that matches the target address and target port through the network includes: controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to the second controller that matches the target address and target port with the event group ID of the pre-constructed SOME / IP-SD subscription request message.

[0039] Among them, the test configuration file can refer to a configuration file formed by parameters input by the user, or a pre-set configuration file. In one embodiment, loading the test configuration file through the test script includes: parsing the test parameters input by the user through the command line based on a Python-based parameter parsing library, and generating a test configuration file based on the test parameters input by the user. Among them, the parameter parsing library can parse the command line input, allowing the user to configure the target address, port, service ID, event group ID, and optional source IP address, etc. It can also provide the function of converting a hexadecimal string to an integer to facilitate the user's input. For example, the service ID and event group ID are often represented in hexadecimal, and the service ID and event group ID can be converted to an integer. At the same time, it supports the reading of user-defined configuration files to implement more complex test scenario settings.

[0040] In one embodiment, controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller that matches the target address and target port through the network includes: creating a UDP socket based on a Python-based socket database to control the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller that matches the target address and target port through the network. Among them, the socket database (socket library) is responsible for sending the constructed SOME / IP-SD subscription request message to the specified target address and port through the network. It also supports asynchronous communication, can listen for the server's response while sending the request, and also includes an error handling mechanism to ensure that it can be gracefully processed and feedback to the user when a network exception occurs.

[0041] In one embodiment, the test data at least includes the time of receiving the pre-notification and the time of sending the subscription request message, the response content received by the first controller, and the processing result of the subscription request message.

[0042] After sending a subscription request, the sending status information can be printed in real time, including success, failure, and specific error information. Key information during the test process can also be recorded, such as the time of receiving the pre-notification and the time of sending the subscription request message, the response content received by the first controller, and the processing result of the subscription request message, etc., which is convenient for subsequent analysis and debugging. At the same time, a function for generating test result reports can also be provided, supporting the export of test data in formats such as CSV and JSON, which is convenient for data analysis and archiving.

[0043] In a specific embodiment, it is assumed that the test parameters included in the test configuration file are:

[0044] Target address: 192.168.1.100

[0045] Port: 30490

[0046] Service ID: 0x1234

[0047] Event group ID: 0x5678

[0048] These test parameters can be input by the user through the command line or from a pre-edited configuration file, and then the configuration file is parsed to obtain them. First, a test script created based on Python can be executed, and then start listening for offer messages (i.e., pre-notifications) on the network. When an offer message related to the service ID 0x1234 is recognized, a subscription request is automatically sent to the event group ID 0x5678. And the IP address of the controller where the event group ID is located is 192.168.1.100, and its port address is 30490. Further, the test script can construct the header content and payload content of the subscription request according to the test parameters, and send the subscription request to the event group ID at the target address and port through a UDP socket. During the interaction between the two controllers, the sending status and the received response information can be printed, and key information during the test process, such as the sending time and the response content, etc., can be recorded. The test script can also generate a test result report, including detailed information such as the sent subscription request, the received response, and the test time. Technicians can export the report for subsequent analysis and archiving.

[0049] Through parameterized configuration and automated monitoring, this solution reduces the technical requirements for testers, simplifies the test process, and improves test efficiency. As a widely used programming language, the simple and easy-to-learn features of Python make the method used in this invention easier for technicians to master and use. This solution is not only applicable to the automotive field, but also can be widely applied to other network communication scenarios that require SOME / IP-SD protocol support, such as industrial automation, smart home, etc. Moreover, the test scripts in this solution support flexible configuration of test parameters, can adapt to different test scenarios and requirements, and reduce the test cost. By lowering the test threshold, this solution helps to promote more technicians to participate in the research and development of the SOME / IP protocol, and promotes technological innovation and development.

[0050] The following describes the device embodiments of the present application, which can be used to execute the SOME / IP subscription behavior test method based on Python in the above embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the embodiments of the SOME / IP subscription behavior test method based on Python in the above of the present application.

[0051] See Figure 2 , which shows a block diagram of the SOME / IP subscription behavior test device based on Python in the embodiments of the present application.

[0052] As Figure 2 shown, according to the SOME / IP subscription behavior test device 200 based on Python in the embodiments of the present application, the device 200 includes: a script acquisition unit 201, a monitoring unit 202, a subscription unit 203, and a data recording unit 204.

[0053] Among them, the script acquisition unit 201 is used to run the test script created based on Python; the monitoring unit 202 is used to monitor the pre-notification sent by the second controller to the first controller based on the test script; the subscription unit 203 is used to, when the pre-notification is a preset broadcast notification, determine whether the first controller sends a subscription request to the second controller according to a preset rule; in the case of determining that a subscription request is sent, load a test configuration file through the test script, and the test configuration file includes at least a target address and a target port; control the first controller to send a pre-constructed SOME / IP-SD subscription request message to the second controller that matches the target address and the target port through the network; the data recording unit 204 is used to record the test data during the process of receiving the pre-notification and sending the subscription request message, and generate a test report according to the test data.

[0054] Based on the same inventive concept, an embodiment of the present application further provides a computer program product, which includes computer instructions stored in a computer-readable storage medium and adapted to be read and executed by a processor, so that a computer device having the processor executes the above-mentioned Python-based SOME / IP subscription behavior test method.

[0055] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, in which at least one computer program instruction is stored, and the at least one computer program instruction is loaded and executed by a processor to implement the operations performed by the above-mentioned Python-based SOME / IP subscription behavior test method.

[0056] The functions described herein can be implemented in hardware, software executed by a processor, firmware, or any combination thereof. If implemented in software executed by a processor, the functions can be stored as one or more instructions or code on a computer-readable medium or transmitted via a computer-readable medium. Other examples and implementations are within the scope and spirit of the present application and the appended claims. For example, due to the nature of software, the functions described above can be implemented using software executed by a processor, hardware, firmware, hardwiring, or any combination of these. In addition, each functional unit can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.

[0057] In several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units can be a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of units or modules can be in an electrical or other form.

[0058] The units described as separate components may or may not be physically separated. The components serving as control devices may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

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

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

Claims

1. A Python-based SOME / IP subscription behavior testing method, characterized in that: The method comprises: Run test scripts created based on Python; monitoring the pre-notification sent by the second controller to the first controller based on the test script; In the case where the pre-notification is a preset broadcast notification, determining, according to a preset rule, whether the first controller sends a subscription request to the second controller; In the case of determining to send a subscription request, loading a test configuration file through the test script, wherein the test configuration file at least includes a target address and a target port; Controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller matching the target address and the target port through a network; The test data in the process of receiving the pre-notification and sending the subscription request message is recorded, and a test report is generated according to the test data.

2. The method according to claim 1, characterized in that The method further comprises: Before running the test script created based on Python, the header content and payload content of the subscription request message are constructed based on Python's byte array library and socket database, wherein the header content includes at least one of the protocol version, message type, message length, and service ID.

3. The method according to claim 1, characterized in that: Loading the test configuration file through the test script includes: The Python-based parameter parsing library parses the test parameters input by the user through the command line, and generates the test configuration file based on the test parameters.

4. The method according to claim 1, characterized in that Controlling the first controller to send the pre-constructed SOME / IP-SD subscription request message to the second controller matching the target address and the target port through the network includes: A UDP socket is created based on a Python socket database to control the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller matching the target address and the target port through a network.

5. The method according to claim 1, characterized in that: The test data at least includes the time of receiving the pre-notification and the time of sending the subscription request message, the response content received by the first controller, and the processing result of the subscription request message.

6. The method according to claim 1, characterized in that The test configuration file also includes a service ID, and the method further includes: In the case where the pre-notification is a broadcast notification associated with the service ID, it is determined according to a preset rule whether the first controller sends a subscription request to the second controller.

7. The method according to claim 1, characterized in that The test configuration file also includes an event group ID, and controlling the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller matching the target address and the target port through a network includes: Control the first controller to send a pre-constructed SOME / IP-SD subscription request message to the event group ID of the second controller matching the target address and the target port through the network.

8. A Python-based SOME / IP subscription behavior testing device, characterized in that: The device comprises: Script acquisition unit, used to run test scripts created based on Python; a monitoring unit, configured to monitor the pre-notification sent by the second controller to the first controller based on the test script; a subscription unit, configured to, when the pre-notification is a preset broadcast notification, determine, according to a preset rule, whether the first controller sends a subscription request to the second controller; if it is determined to send a subscription request, load a test configuration file through the test script, wherein the test configuration file at least includes a target address and a target port; and control the first controller to send a pre-constructed SOME / IP-SD subscription request message to a second controller matching the target address and the target port through a network; The data recording unit is used to record the test data in the process of receiving the pre-notification and sending the subscription request message, and generate a test report according to the test data.

9. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium and are suitable for being read and executed by a processor, so that a computer device having the processor executes the Python-based SOME / IP subscription behavior testing method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which are loaded and executed by a processor to implement the operations performed by the Python-based SOME / IP subscription behavior testing method as described in any one of claims 1 to 7.