Method, system and device for testing gateway equipment
Through the testing method of randomly generating and fuzzing processing of CAN and LIN communication data files, the blind spots of traditional fuzz testing methods that cannot effectively detect multi-protocol interactions are solved, and more comprehensive gateway device testing and more efficient security vulnerability detection are achieved.
Patent Information
- Application Number
- CN202510175598.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-05-13
AI Technical Summary
The traditional single protocol fuzz testing method cannot effectively deal with complex interactions between multiple protocols, resulting in blind spots in security testing and insufficient vulnerability detection.
It provides a test method for gateway devices, which randomly generates CAN and LIN communication data files, and uses fuzzy algorithms to convert them, and sends them to the gateway device to be tested to obtain its log to determine whether the test passes or not.
This method can more comprehensively test the gateway equipment to be tested, meet the testing needs based on the conversion between the two protocols, and improve the security vulnerability detection capabilities of multi-protocol systems.
Smart Images

Figure CN119996255A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of testing, and in particular to a testing method, system and device for gateway equipment. Background Art
[0002] The vehicle gateway is an important part of the automotive electronic system, responsible for transmitting information between various networks and subsystems of the vehicle. The vehicle gateway usually integrates multiple communication protocols, such as CAN (Controller Area Network), LIN (Local Interconnect Network, a serial communication protocol based on universal asynchronous receiver and transmitter), CAN with flexible data rate, and Ethernet. The existence of these protocols ensures that various parts of the vehicle system can exchange information efficiently, thereby achieving comprehensive control and management of the vehicle. Therefore, ensuring the stability and security of the vehicle gateway is crucial to the safety of the entire vehicle. Traditional fuzz testing usually focuses on the detection of a single protocol, which makes it difficult to find vulnerabilities in multiple protocol stacks or communication protocols, resulting in blind spots in security testing and incomplete vulnerability detection. For example, fuzz testing for the CAN protocol may only generate fuzzy data related to CAN and send it to the object under test to observe its abnormal response, but ignores the interaction between other protocols (such as LIN, Ethernet, etc.) and the CAN protocol. Therefore, the traditional single-protocol fuzz testing method cannot effectively cope with the complex interaction between multiple protocols. Summary of the invention
[0003] The purpose of the present invention is to provide a test method, system and device for a gateway device, which can meet the test requirements of the gateway device to be tested based on conversion between two protocols. At the same time, the randomly generated communication data file can more comprehensively test the gateway device to be tested.
[0004] In order to solve the above technical problems, the present invention provides a method for testing a gateway device, comprising:
[0005] Randomly generate CAN communication data files and LIN communication data files;
[0006] The randomly generated CAN communication data file and the randomly generated LIN communication data file are respectively converted using a fuzzy algorithm to obtain fuzzy test data;
[0007] Sending the fuzzy test data to a gateway device to be tested, wherein the gateway device to be tested is used to convert the CAN communication data file into a LIN communication data file or convert the LIN communication data file into a CAN communication data file;
[0008] Obtaining the log of the gateway device to be tested;
[0009] Determine whether the gateway device to be tested passes the test based on the log.
[0010] On the other hand, CAN communication data files and LIN communication data files are randomly generated, including:
[0011] Determine the CAN communication protocol and LIN communication protocol;
[0012] Design random generation rules;
[0013] Generate a CAN communication data file that complies with the CAN communication protocol and a LIN communication data file that complies with the LIN communication protocol based on the random generation rule;
[0014] Among them, the CAN communication data files generated by the random generation rule and conforming to the CAN communication protocol include normal CAN communication data files and abnormal CAN communication data files, and the LIN communication data files generated by the random generation rule and conforming to the LIN communication protocol include normal LIN communication data files and abnormal LIN communication data files.
[0015] On the other hand, design random generation rules, including:
[0016] Select one or more of identifier randomization, data length randomization, data load randomization, timing anomaly, and structure anomaly as a method for generating an abnormal CAN communication data file and / or an abnormal LIN communication data file;
[0017] Among them, the identifier randomization includes generating an identifier that is different from the range of normal identifiers, the data length randomization includes generating a data length value that exceeds the legal range, the data load randomization includes filling the data load with random bytes, the timing anomaly includes sending the same frame data or sending multiple frames continuously followed by silence, and the structural anomaly includes sending unaligned frames.
[0018] On the other hand, before converting the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain fuzzy test data, the method further includes:
[0019] Acquire a randomly generated CAN communication data file, wherein the CAN communication data file includes an information identifier, a data length, and a data content portion;
[0020] Acquire a randomly generated LIN communication data file, wherein the LIN communication data file includes a frame type, a frame identifier, and a data content portion;
[0021] Enter the step of converting the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain fuzzy test data.
[0022] On the other hand, the randomly generated CAN communication data file and the randomly generated LIN communication data file are converted using a fuzzy algorithm to obtain fuzzy test data, including:
[0023] Determining configuration parameters of CAN communication, wherein the configuration parameters of CAN communication include the type of fuzzy algorithm, data variation range and test mode;
[0024] Determining configuration parameters of LIN communication, wherein the configuration parameters of LIN communication include the type of molding algorithm, test duration, and injection error;
[0025] The randomly generated CAN is converted based on a fuzzy algorithm in the configuration parameters of the CAN communication, and the randomly generated LIN is converted based on a fuzzy algorithm in the configuration parameters of the LIN communication to obtain fuzzy test data.
[0026] On the other hand, the type of the fuzzy algorithm includes a combination of one or more of random mutation, boundary value test, seed-based mutation and adversarial test;
[0027] The random mutation includes randomly modifying a data content portion of the randomly generated CAN communication data file or the randomly generated LIN communication data file;
[0028] The boundary value test includes testing the maximum value, the minimum value, the value of the preset interval where the maximum value is located, and the value of the preset interval where the minimum value is located of the data content part specified by the communication protocol corresponding to the CAN communication data file or the LIN communication data file;
[0029] The seed-based mutation includes randomly modifying a portion of the data content in the existing historical data;
[0030] The adversarial test includes sending a preset amount of communication data to the gateway device under test within a preset time, and the preset amount exceeds the amount of data that the gateway device under test can process within the preset time.
[0031] On the other hand, obtaining the log of the gateway device to be tested includes:
[0032] Obtaining fuzzy test data, sending data and timestamp in the log of the gateway device to be tested;
[0033] Determining whether the gateway device to be tested passes the test based on the log includes:
[0034] Determining whether the timestamps of the fuzzy test data and the sent data are within a preset forwarding time requirement;
[0035] Determine whether the formats of the fuzzy test data and the sent data conform to a preset data format;
[0036] When the timestamp is within the preset forwarding time requirement and the formats of the fuzzy test data and the sent data conform to the preset data formats, it is determined that the test of the gateway device to be tested has passed.
[0037] On the other hand, after determining whether the gateway device to be tested has passed the test based on the log, the method further includes:
[0038] Sending the fuzzy test data, sent data and test results received by the gateway device to be tested to a visual interface;
[0039] Generate a test report based on the test results.
[0040] In order to solve the above technical problems, the present invention also provides a test system for a gateway device, comprising:
[0041] A generating unit, used for randomly generating a CAN communication data file and a LIN communication data file;
[0042] A conversion unit, used to convert the randomly generated CAN communication data file and the randomly generated LIN communication data file respectively using a fuzzy algorithm to obtain fuzzy test data;
[0043] A sending unit, used for sending the fuzzy test data to a gateway device to be tested, wherein the gateway device to be tested is used for converting the CAN communication data file into a LIN communication data file or converting the LIN communication data file into a CAN communication data file;
[0044] A log acquisition unit, used to acquire the log of the gateway device to be tested;
[0045] A test determination unit is used to determine whether the gateway device to be tested has passed the test based on the log.
[0046] In order to solve the above technical problems, the present invention also provides a test device for a gateway device, comprising:
[0047] Memory for storing computer programs;
[0048] The processor is used to implement the steps of the above-mentioned testing method for the gateway device to be tested when executing the computer program.
[0049] The present invention discloses a test method, system and device for a gateway device, which relates to the field of testing, including: randomly generating a CAN communication data file and a LIN communication data file; converting the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain fuzzy test data; sending the fuzzy test data to the gateway device to be tested; obtaining the log of the gateway device to be tested; and determining whether the gateway device to be tested has passed the test based on the log. The generated fuzzy test data is a communication data file based on two communication protocols, CAN and LIN, and meets the test requirements of the gateway device to be tested for conversion between the two protocols. At the same time, the randomly generated communication data file can test the gateway device to be tested more comprehensively. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the prior art and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0051] Figure 1 A flow chart of a method for testing a gateway device provided by the present invention;
[0052] Figure 2 A network topology diagram of a gateway device provided by the present invention;
[0053] Figure 3 A flow chart of another method for testing a gateway device provided by the present invention;
[0054] Figure 4 A schematic diagram of analog-to-digital test data generation provided by the present invention;
[0055] Figure 5 A schematic diagram of the structure of a test system for a gateway device provided by the present invention;
[0056] Figure 6 A schematic structural diagram of a testing device for a gateway device provided by the present invention. DETAILED DESCRIPTION
[0057] The core of the present invention is to provide a test method, system and device for a gateway device, which can meet the test requirements of the gateway device to be tested based on the conversion between two protocols. At the same time, the randomly generated communication data file can more comprehensively test the gateway device to be tested.
[0058] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] The vehicle gateway is an important part of the automotive electronic system, responsible for transmitting information between various networks and subsystems of the vehicle. The vehicle gateway usually integrates multiple communication protocols, such as CAN (Controller Area Network), LIN (Local Interconnect Network, a serial communication protocol based on universal asynchronous receiver and transmitter), CAN with flexible data rate, and Ethernet. The existence of these protocols ensures that various parts of the vehicle system can exchange information efficiently, thereby achieving comprehensive control and management of the vehicle. Therefore, ensuring the stability and security of the vehicle gateway is crucial to the safety of the entire vehicle. Traditional fuzz testing usually focuses on the detection of a single protocol, which makes it difficult to find vulnerabilities in multiple protocol stacks or communication protocols, resulting in blind spots in security testing and incomplete vulnerability detection. For example, fuzz testing for the CAN protocol may only generate fuzzy data related to CAN and send it to the object under test to observe its abnormal response, but ignores the interaction between other protocols (such as LIN, Ethernet, etc.) and the CAN protocol. Therefore, the traditional single-protocol fuzz testing method cannot effectively cope with the complex interaction between multiple protocols.
[0060] CAN bus (Controller Area Network): This is a high-speed bus that is usually used for important data transmission in vehicle systems, such as engine control unit (ECU), safety system, etc. The CAN bus allows multiple devices (such as ECU, sensors, actuators, etc.) to communicate through a two-wire (CAN_H and CAN_L).
[0061] LIN bus (Local Interconnect Network): This is a low-speed bus, commonly used for communication between low-bandwidth devices. The LIN bus supports a one-master-multiple-slave architecture, that is, the master node controls multiple slave nodes through the bus.
[0062] Figure 2 A network topology diagram of a gateway device provided by the present invention;
[0063] CAN-LIN gateway device: As a bridge between the two, the CAN-LIN gateway device is responsible for connecting the CAN bus with the LIN bus. The device receives data on the CAN bus and converts it to the LIN protocol, or vice versa, converts the data of the LIN bus to the CAN protocol.
[0064] Protocol conversion: The gateway enables devices on the CAN bus and LIN bus to communicate with each other through the protocol conversion function. It receives data from one bus and converts it into another protocol format as needed and forwards it to the target bus.
[0065] Message filtering and routing: The gateway not only performs protocol conversion, but also manages the routing of messages. It filters and routes data according to the configured rules and only delivers relevant messages to the specified bus.
[0066] Figure 1 A flow chart of a method for testing a gateway device provided by the present invention, the method for testing the gateway device to be tested comprising:
[0067] S11: Randomly generate CAN communication data files and LIN communication data files;
[0068] By designing a fuzz testing framework that can test multiple protocols simultaneously, we can comprehensively cover the security vulnerabilities of multi-protocol systems and ensure that cross-protocol vulnerabilities can be discovered in a timely manner.
[0069] The randomly generated CAN communication data files and LIN communication data files may be normal communication data or abnormal data. By randomly generating, a wider test range can be covered.
[0070] S12: using a fuzzy algorithm to convert the randomly generated CAN communication data file and the randomly generated LIN communication data file respectively to obtain fuzzy test data;
[0071] Set the input data frame type, test strategy, fault injection method, etc., and fine-tune the configuration of various operations of fuzz testing. Support users to design customized test cases and fuzzy rules to simulate specific abnormal situations. Support saving configuration files and loading them in subsequent tests for easy reuse and sharing.
[0072] Generates a series of illegal or malformed messages based on the CAN and LIN protocol standards. Each message may be randomly modified to insert invalid data or tamper with existing fields to test the gateway's response to different types of erroneous inputs. The module supports multiple generation strategies, such as full randomization, boundary testing, protocol vulnerability simulation, etc., to ensure that a variety of possible abnormal situations are covered.
[0073] S13: sending the fuzzy test data to the gateway device to be tested, where the gateway device to be tested is used to convert the CAN communication data file into a LIN communication data file or convert the LIN communication data file into a CAN communication data file;
[0074] The main function of the gateway device under test is to receive data packets from the CAN or LIN bus, parse them and process them according to the predetermined protocol rules. The key task of this module is to achieve protocol conversion between CAN and LIN networks to ensure smooth data exchange between the two different protocols. The gateway device under test will generate a response based on the received data and send it back to the corresponding bus or device to complete the data exchange.
[0075] S14: Obtain the log of the gateway device to be tested;
[0076] S15: Determine whether the gateway device to be tested passes the test based on the log.
[0077] Capture communication data from bus activity in real time to display bus status and monitoring results. Collect communication frames from the bus and analyze their contents. Track parameters such as bus load, error counts, and frame traffic to provide status feedback. Buffer and sort real-time data and store key event markers. Record normal data, abnormal data, and configuration parameters of CAN / LIN communication under test in real time. Record log data by timestamp, support file compression, backup, and automatic cleanup. Support log query, filtering, and playback functions to help users track problems.
[0078] The present invention adopts intelligent protocol identification and fuzz testing strategies to reduce unnecessary test steps and optimize the test process, thereby improving the overall test efficiency. For multi-protocol systems, through automated protocol identification and adaptation, manual intervention is greatly reduced, saving test time and cost. By injecting and testing data between CAN-LIN network protocols, potential security risks that may exist in their interaction process are revealed. During the test process, a large number of expected and unexpected data packets are generated according to the characteristics of different protocols, and sent to the gateway device to be tested to trigger possible exception handling behaviors of the on-board gateway device to be tested. For example, when the on-board gateway device to be tested receives a data packet with an abnormal structure, certain functions may be temporarily disabled. This process helps to identify vulnerabilities in applications, devices, or services that may not be revealed by single protocol fuzz testing.
[0079] Figure 3 A flow chart of another method for testing a gateway device provided by the present invention;
[0080] If the processor under test is divided according to function, a main control module and its fuzzy configuration module, log monitoring module, log recording module, report generation module, sending / receiving module and fuzzy testing algorithm module can be obtained.
[0081] First, the communication protocol and other data are obtained from the CAN / LIN communication database through visual network communication, and then sent to the fuzzy test algorithm module after message selection and configuration parameters. The fuzzy test algorithm module is sent to the send / receive module under the main control module after fuzzy algorithm conversion. The gateway device to be tested is the CAN-LIN gateway test component in the figure. After receiving the CAN fuzzy message sent by the CAN network, it returns the LIN network data to the main control module. Similarly, after receiving the LIN fuzzy message sent by the LIN network, it returns the CAN network data to the main control module, thereby triggering the log monitoring module to monitor the log, the log recording module to record the log, and the report generation module to generate the report.
[0082] The present invention discloses a test method for a gateway device, which relates to the field of testing, including: randomly generating a CAN communication data file and a LIN communication data file; respectively converting the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain fuzzy test data; sending the fuzzy test data to a gateway device to be tested; obtaining a log of the gateway device to be tested; and determining whether the gateway device to be tested has passed the test based on the log. The generated fuzzy test data is a communication data file based on two communication protocols, CAN and LIN, and meets the test requirements of the gateway device to be tested for conversion between the two protocols. At the same time, the randomly generated communication data file can test the gateway device to be tested more comprehensively.
[0083] Based on the above embodiments:
[0084] In some embodiments, randomly generating a CAN communication data file and a LIN communication data file includes:
[0085] Determine the CAN communication protocol and LIN communication protocol;
[0086] Design random generation rules;
[0087] Generate a CAN communication data file that complies with the CAN communication protocol and a LIN communication data file that complies with the LIN communication protocol based on a random generation rule;
[0088] Among them, the CAN communication data files generated by the random generation rule and conforming to the CAN communication protocol include normal CAN communication data files and abnormal CAN communication data files, and the LIN communication data files generated by the random generation rule and conforming to the LIN communication protocol include normal LIN communication data files and abnormal LIN communication data files.
[0089] The purpose is to clarify the test scope and protocol specifications processed by the gateway, including: data frame format, identifier (ID) range, data length limit and verification algorithm.
[0090] For example, CAN protocol:
[0091] Standard frame: 11-bit identifier, ID range is 0x000 to 0x7FF.
[0092] Extended frame: 29-bit identifier, ID range is 0x00000000 to 0x1FFFFFFF.
[0093] Data payload length: 0-8 bytes (standard CAN), or up to 64 bytes (CAN-FD).
[0094] Verification: Implicit in the CAN protocol hardware controller.
[0095] For example, LIN protocol:
[0096] Frame identifier range: 0x00 to 0x3F.
[0097] Data payload: 1-8 bytes.
[0098] Verification algorithm: Classic verification (PID verification) or enhanced verification (including data field).
[0099] In some embodiments, a random generation rule is designed, including:
[0100] Select one or more of identifier randomization, data length randomization, data load randomization, timing anomaly, and structure anomaly as a method for generating an abnormal CAN communication data file and / or an abnormal LIN communication data file;
[0101] Among them, identifier randomization includes generating identifiers that are different from the normal identifier range, data length randomization includes generating data length values that exceed the legal range, data load randomization includes filling the data load with random bytes, timing anomalies include sending the same frame data or sending multiple frames continuously followed by silence, and structural anomalies include sending unaligned frames.
[0102] Identifier randomization (ID):
[0103] Generate different ranges of ID values:
[0104] Standard CAN frame random generation: random.randint(0, 0x7FF).
[0105] Exception ID outside the standard range: random.randint(0x800, 0x1FFFFFFF).
[0106] Example: CAN ID = 0xABCDEF (unusual extended ID).
[0107] Data Length (DLC) Randomization:
[0108] Generate a DLC value in the legal range: random.randint(0, 8).
[0109] Generating out-of-range DLC value: random.randint(9, 15).
[0110] Example: DLC = 10 (outside the standard range).
[0111] Data payload randomization:
[0112] Fill the data payload with random bytes: [random.randint(0, 255) for _ in range(dlc)].
[0113] Example data: [0x01, 0xFF, 0x7E, 0x00, 0xAB].
[0114] Timing anomaly:
[0115] Simulate UHF transmission: Send the same frame quickly, for example, once every 1ms.
[0116] Simulate burst frames: send multiple frames in succession followed by a long period of silence.
[0117] Example: The sending interval is set to 0.5ms (which may exceed the actual bus capability).
[0118] Structural abnormalities:
[0119] Sending misaligned frames: for example, with only a partial header or missing checksum.
[0120] Example: Frame data = [0x00, 0xFF, 0x12] (incomplete).
[0121] In some embodiments, before converting the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain the fuzzy test data, the method further includes:
[0122] Obtain a randomly generated CAN communication data file, the CAN communication data file including an information identifier, a data length and a data content portion;
[0123] Obtain a randomly generated LIN communication data file, the LIN communication data file including a frame type, a frame identifier and a data content portion;
[0124] Enter the step of converting the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain fuzzy test data.
[0125] Figure 4 A schematic diagram of analog-to-digital test data generation provided by the present invention;
[0126] In some embodiments, the randomly generated CAN communication data file and the randomly generated LIN communication data file are converted using a fuzzy algorithm to obtain fuzzy test data, including:
[0127] Determine the configuration parameters of CAN communication, which include the type of fuzzy algorithm, data variation range and test mode;
[0128] Determine the configuration parameters of LIN communication, the configuration parameters of LIN communication include the type of molding algorithm, test duration and injection error;
[0129] The randomly generated CAN is converted based on the fuzzy algorithm in the configuration parameters of the CAN communication, and the randomly generated LIN is converted based on the fuzzy algorithm in the configuration parameters of the LIN communication to obtain fuzzy test data.
[0130] In fuzz testing, input data files are usually required to define the range of input parameters and the behavior of fuzz testing. These data files usually contain information such as protocol rules, test targets and data structures, while configuration parameters define the way data is generated, the intensity of the test, etc.
[0131] Assume there is a CAN data file can_data.txt, which contains various parameters of the CAN message (such as ID, data length, data, etc.).
[0132] "#CAN data file:
[0133] ID = 0x700 # message identifier;
[0134] DLC =8 #Data length (up to 8 bytes);
[0135] Data = 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 #data part;
[0136] #Configuration parameters:
[0137] Fuzz Algorithm = Random # Fuzzy algorithm: random data generation;
[0138] Data Variation Range =10 #Data variation range: Randomly change each byte by ±10%;
[0139] Test Mode = Boundary Test # Test mode: Boundary value test".
[0140] In this example:
[0141] ID represents the identifier of the message, which usually needs to be set according to the protocol regulations.
[0142] DLC stands for Data Length.
[0143] Data is the data part, which can be a byte array represented in hexadecimal.
[0144] Fuzz_Algorithm represents the selected fuzzy algorithm (such as random data generation, seed mutation, etc.).
[0145] Data_Variation_Range is the range of data variation, which may indicate the maximum percentage of change for each byte.
[0146] Test_Mode specifies the mode of fuzz testing, such as boundary value testing, random testing, etc.
[0147] Assume there is a LIN data file can_data.txt:
[0148] "#LIN data file:
[0149] FrameType = MasterToSlave #Frame type: master to slave;
[0150] FramelD =0x3C #frame identifier;
[0151] Data = 0x00 0x01 0x02 0xFF #data part;
[0152] #Configuration parameters:
[0153] Fuzz_Algorithm= Boundary #Fuzzy algorithm: boundary value test;
[0154] Test Duration =60 #Test duration: 60 seconds;
[0155] Inject Error = True #Inject error: Enable".
[0156] In this LIN data file:
[0157] FrameType specifies the type of message, whether it is a master to slave communication.
[0158] FrameID is the identifier of the message and usually needs to be within the valid range.
[0159] Data is the data part, which is similar to the data field in CAN.
[0160] Configuration parameters such as Test_Duration and Inject_Error define the duration of the test and whether error injection is enabled.
[0161] In some embodiments, the type of fuzzy algorithm includes a combination of one or more of random mutation, boundary value testing, seed-based mutation, and adversarial testing;
[0162] Random mutation includes randomly modifying a portion of data content in a randomly generated CAN communication data file or a randomly generated LIN communication data file;
[0163] The boundary value test includes testing the maximum value, minimum value, value of the preset interval where the maximum value is located, and value of the preset interval where the minimum value is located of the data content part specified by the communication protocol corresponding to the CAN communication data file or the LIN communication data file;
[0164] Seed-based mutation involves randomly modifying parts of the data content in existing historical data;
[0165] The adversarial test includes sending a preset amount of communication data to the gateway device under test within a preset time, and the preset amount exceeds the amount of data that the gateway device under test can process within the preset time.
[0166] The fuzzy algorithms used include:
[0167] Random mutation: Randomly modify each byte in the data.
[0168] Boundary value testing: testing the maximum value, minimum value and nearby values specified by the protocol.
[0169] Seed-based mutation: mutation based on existing data.
[0170] Adversarial testing: simulating data input from a malicious attacker.
[0171] Take the random mutation algorithm as an example:
[0172] The random mutation algorithm randomly selects a byte in the data and then mutates the byte. Suppose we have the following CAN data:
[0173] Data = 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
[0174] After using the random mutation algorithm, the possible mutation results are as follows:
[0175] The mutated data = 0x00 0xFF 0x02 0x03 0x04 0xBC 0x06 0x07
[0176] In this example, 0x01 is randomly changed to 0xFF, and 0x05 is changed to 0xBC. By repeating this mutation process, fuzz testing will generate a large amount of different mutation data.
[0177] In some embodiments, obtaining a log of the gateway device to be tested includes:
[0178] Obtain fuzzy test data, sent data and timestamp from the log of the gateway device under test;
[0179] Determine whether the gateway device under test has passed the test based on the log, including:
[0180] Determine whether the timestamps of the fuzzy test data and the sent data are within the preset forwarding time requirements;
[0181] Determine whether the format of the fuzzy test data and the sent data conforms to the preset data format;
[0182] When the timestamp is within the preset forwarding time requirement and the formats of the fuzzy test data and the transmitted data conform to the preset data formats, it is determined that the test of the gateway device to be tested has passed.
[0183] Fuzz testing log monitoring module flow:
[0184] Test launch:
[0185] Input: Start fuzz testing and connect to the CAN-LIN gateway.
[0186] Action: Complete initialization, execute fuzz test cases, and activate the log monitoring module.
[0187] Data collection:
[0188] Input: The CAN-LIN gateway receives CAN / LIN data packets from the test tool.
[0189] Operation: The log monitoring module collects these data packets and related test information.
[0190] Output: Generates raw log data, recording packet content, timestamp, response status, etc.
[0191] Log data storage:
[0192] Input: collected log data.
[0193] Operation: Store the log data in a local data file according to the set format.
[0194] Output: Persistently stored log data for easy subsequent query.
[0195] Real-time analytics:
[0196] Input: stored log data.
[0197] Operation: The monitoring module analyzes data in real time and detects system anomalies, such as response timeout, data format error, error code, etc.
[0198] Output: abnormal alerts, performance data (such as throughput, response time, etc.).
[0199] In some embodiments, after determining whether the gateway device to be tested has passed the test based on the log, the method further includes:
[0200] Send the fuzzy test data, sent data and test results received by the gateway device under test to the visual interface;
[0201] Generate a test report based on the test results.
[0202] Automatically generate structured reports from the data and analysis results collected during the test. This module helps users present test results in an easy-to-understand way by automatically summarizing test information and generating reports that can be archived, analyzed, and shared. It can obtain relevant data from the logging module and generate reports. It supports multiple formats of output, such as PDF, CSV, etc.
[0203] Automatically collect test data from the logging module, summarize and count them, and generate error analysis, performance evaluation and other content. Format the data according to predefined templates to generate customizable test reports, supporting multiple export formats. Automatically generate complete reports after the test is completed to reduce manual intervention. Obtain log data and test monitoring information in real time. Analyze and summarize detailed test data and error events to ensure that the report content is accurate and complete. In addition, it will provide real-time test progress and status information to help determine the completeness of the report content and the timing of generation.
[0204] Visualization and Reporting:
[0205] Input: Parsed log data.
[0206] Operation: Generate a visual report interface to display real-time data, error information, performance trends, etc.
[0207] Output: Visual interface, real-time performance chart, error log display.
[0208] End of test:
[0209] Input: Testing completed.
[0210] Operation: After the test is completed, a test report is generated to record all important information and analysis results of the test.
[0211] Output: Test report, including detailed exception information, performance analysis, and success / failure summary.
[0212] Assume the injected frame is {'can_id': '0xFFFFFFFF', 'dlc': 12, 'data': [255, 0, 0,0]}:
[0213] Expected Behavior: The gateway logs the frame as illegal and drops it.
[0214] Unusual behavior: The gateway did not log an exception or reboot.
[0215] After the fuzz test case is executed, a test report can be automatically generated. The following contents are recorded:
[0216] The ID, DLC, and data content of each abnormal data frame sent.
[0217] The gateway's response to each exception data: success / failure, error code, etc.
[0218] Statistics of abnormal data types, analyzing the gateway's handling of different types of exceptions.
[0219] In addition, the test environment needs to be prepared before testing:
[0220] Hardware environment:
[0221] Gateway sample: The gateway ECU as the test target has CAN and LIN interfaces. It can receive CAN messages and forward LIN messages. It can also receive LIN messages and forward CAN messages.
[0222] Fuzz testing hardware equipment: PC, Vector CAN BOX (supports CAN and LIN communications).
[0223] Power supply and simulation environment: Power supply, terminal resistors, and simulation devices to ensure that the test scenarios are close to the real system.
[0224] Software environment:
[0225] CANoe, vTESTstudio simulation environment configuration: CANoe 17.0, vTESTstudio 8.0: Support script development for CAN and LIN fuzz testing, and provide rich diagnostic and analysis functions. Environment configuration files, parameter files, test case execution files, simulation nodes, etc.
[0226] CAN and LIN communication database: This file contains information about the send frames, receive frames, PDUs, signals, communication matrices, and message lengths, types, and cycles of all ECUs on the CAN and LIN networks of the product under test.
[0227] Technical Data Sheet: Information on how the product works, how to boot it, memory map, I / O pinouts, safety controls, processor technical information.
[0228] Development tools: used to write custom fuzz testing scripts.
[0229] Common development languages and libraries: Python (such as using the python-can library), C / C#.
[0230] Further testing environment needs to be built:
[0231] Connect the CAN-LIN gateway product to the test device, configure the CAN network, LIN network and simulation environment. Initialize the network environment and protocol parameters, and prepare to start the test.
[0232] Figure 5 A schematic diagram of the structure of a test system for a gateway device provided by the present invention, wherein the test system for the gateway device to be tested comprises:
[0233] A generating unit 51 is used to randomly generate a CAN communication data file and a LIN communication data file;
[0234] A conversion unit 52, used to convert the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain fuzzy test data;
[0235] A sending unit 53, used for sending the fuzzy test data to the gateway device to be tested, and the gateway device to be tested is used for converting the CAN communication data file into the LIN communication data file or converting the LIN communication data file into the CAN communication data file;
[0236] The log acquisition unit 54 is used to acquire the log of the gateway device to be tested;
[0237] The test determination unit 55 is used to determine whether the gateway device to be tested has passed the test based on the log.
[0238] Based on the above embodiment, it also includes:
[0239] A protocol determination unit, used to determine the CAN communication protocol and the LIN communication protocol;
[0240] A rule design unit, used to design random generation rules;
[0241] The generating unit 51 is specifically used to generate a CAN communication data file conforming to the CAN communication protocol and a LIN communication data file conforming to the LIN communication protocol based on a random generation rule;
[0242] Among them, the CAN communication data files generated by the random generation rule and conforming to the CAN communication protocol include normal CAN communication data files and abnormal CAN communication data files, and the LIN communication data files generated by the random generation rule and conforming to the LIN communication protocol include normal LIN communication data files and abnormal LIN communication data files.
[0243] A rule design unit, specifically used to select one or more of identifier randomization, data length randomization, data load randomization, timing anomaly and structure anomaly as a generation method of abnormal CAN communication data file and / or abnormal LIN communication data file;
[0244] Among them, identifier randomization includes generating identifiers that are different from the normal identifier range, data length randomization includes generating data length values that exceed the legal range, data load randomization includes filling the data load with random bytes, timing anomalies include sending the same frame data or sending multiple frames continuously followed by silence, and structural anomalies include sending unaligned frames.
[0245] A CAN communication data file acquisition unit is used to acquire a randomly generated CAN communication data file, wherein the CAN communication data file includes an information identifier, a data length and a data content portion;
[0246] A LIN communication data file acquisition unit is used to acquire a randomly generated LIN communication data file, wherein the LIN communication data file includes a frame type, a frame identifier and a data content portion;
[0247] The conversion unit 52 is triggered.
[0248] A CAN communication configuration parameter acquisition unit, used to determine the configuration parameters of the CAN communication, the configuration parameters of the CAN communication including the type of fuzzy algorithm, data variation range and test mode;
[0249] A LIN communication configuration parameter acquisition unit, used to determine the configuration parameters of the LIN communication, the configuration parameters of the LIN communication including the type of the molding algorithm, the test duration and the injection error;
[0250] The conversion unit 52 is specifically used to convert the randomly generated CAN based on the fuzzy algorithm in the configuration parameters of the CAN communication, and to convert the randomly generated LIN based on the fuzzy algorithm in the configuration parameters of the LIN communication to obtain the fuzzy test data.
[0251] The types of fuzzy algorithms include random mutation, boundary value testing, seed-based mutation, and adversarial testing, or a combination of one or more of these;
[0252] Random mutation includes randomly modifying a portion of data content in a randomly generated CAN communication data file or a randomly generated LIN communication data file;
[0253] The boundary value test includes testing the maximum value, minimum value, value of the preset interval where the maximum value is located, and value of the preset interval where the minimum value is located of the data content part specified by the communication protocol corresponding to the CAN communication data file or the LIN communication data file;
[0254] Seed-based mutation involves randomly modifying parts of the data content in existing historical data;
[0255] The adversarial test includes sending a preset amount of communication data to the gateway device under test within a preset time, and the preset amount exceeds the amount of data that the gateway device under test can process within the preset time.
[0256] The log acquisition unit 54 is specifically used to obtain the fuzzy test data, the sending data and the timestamp in the log of the gateway device under test;
[0257] The test determination unit 55 is specifically used to determine whether the timestamps of the fuzzy test data and the sent data are within the preset forwarding time requirement;
[0258] Determine whether the format of the fuzzy test data and the sent data conforms to the preset data format;
[0259] When the timestamp is within the preset forwarding time requirement and the formats of the fuzzy test data and the transmitted data conform to the preset data formats, it is determined that the test of the gateway device to be tested has passed.
[0260] A visualization unit, used to send the fuzzy test data, sent data and test results received by the gateway device under test to a visualization interface;
[0261] The report generating unit 51 is used to generate a test report based on the test result.
[0262] For an introduction to the test system for the gateway device to be tested provided in the present application, please refer to the above-mentioned embodiment, which will not be described in detail here.
[0263] Figure 6A schematic diagram of the structure of a test device for a gateway device provided by the present invention, wherein the test device for the gateway device to be tested comprises:
[0264] A memory 61, used for storing computer programs;
[0265] The processor 62 is used to implement the steps of the above-mentioned testing method for the gateway device to be tested when executing the computer program.
[0266] For an introduction to the testing device for the gateway device to be tested provided in the present application, please refer to the above-mentioned embodiment, which will not be described in detail here.
[0267] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0268] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0269] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be 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 the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for testing a gateway device, characterized in that: include: Randomly generate CAN communication data files and LIN communication data files; The randomly generated CAN communication data file and the randomly generated LIN communication data file are respectively converted using a fuzzy algorithm to obtain fuzzy test data; Sending the fuzzy test data to a gateway device to be tested, wherein the gateway device to be tested is used to convert the CAN communication data file into a LIN communication data file or convert the LIN communication data file into a CAN communication data file; Obtaining the log of the gateway device to be tested; Determine whether the gateway device to be tested passes the test based on the log.
2. The testing method of the gateway device to be tested according to claim 1, characterized in that: Randomly generate CAN communication data files and LIN communication data files, including: Determine the CAN communication protocol and LIN communication protocol; Design random generation rules; Generate a CAN communication data file that complies with the CAN communication protocol and a LIN communication data file that complies with the LIN communication protocol based on the random generation rule; Among them, the CAN communication data files generated by the random generation rule and conforming to the CAN communication protocol include normal CAN communication data files and abnormal CAN communication data files, and the LIN communication data files generated by the random generation rule and conforming to the LIN communication protocol include normal LIN communication data files and abnormal LIN communication data files.
3. The testing method of the gateway device to be tested according to claim 1, characterized in that: Design random generation rules, including: Select one or more of identifier randomization, data length randomization, data load randomization, timing anomaly, and structure anomaly as a method for generating an abnormal CAN communication data file and / or an abnormal LIN communication data file; Among them, the identifier randomization includes generating an identifier that is different from the range of normal identifiers, the data length randomization includes generating a data length value that exceeds the legal range, the data load randomization includes filling the data load with random bytes, the timing anomaly includes sending the same frame data or sending multiple frames continuously followed by silence, and the structural anomaly includes sending unaligned frames.
4. The testing method of the gateway device to be tested according to claim 1, characterized in that: The randomly generated CAN communication data file and the randomly generated LIN communication data file are respectively converted using a fuzzy algorithm to obtain fuzzy test data, and the method further includes: Acquire a randomly generated CAN communication data file, wherein the CAN communication data file includes an information identifier, a data length, and a data content portion; Acquire a randomly generated LIN communication data file, wherein the LIN communication data file includes a frame type, a frame identifier, and a data content portion; Enter the step of converting the randomly generated CAN communication data file and the randomly generated LIN communication data file using a fuzzy algorithm to obtain fuzzy test data.
5. The testing method of the gateway device to be tested as claimed in claim 4, characterized in that: The randomly generated CAN communication data file and the randomly generated LIN communication data file are converted using a fuzzy algorithm to obtain fuzzy test data, including: Determining configuration parameters of CAN communication, wherein the configuration parameters of CAN communication include the type of fuzzy algorithm, data variation range and test mode; Determining configuration parameters of LIN communication, wherein the configuration parameters of LIN communication include the type of molding algorithm, test duration, and injection error; The randomly generated CAN is converted based on a fuzzy algorithm in the configuration parameters of the CAN communication, and the randomly generated LIN is converted based on a fuzzy algorithm in the configuration parameters of the LIN communication to obtain fuzzy test data.
6. The testing method of the gateway device to be tested as claimed in claim 5, characterized in that: The type of the fuzzy algorithm includes one or more combinations of random mutation, boundary value test, seed-based mutation and adversarial test; The random mutation includes randomly modifying a data content portion of the randomly generated CAN communication data file or the randomly generated LIN communication data file; The boundary value test includes testing the maximum value, the minimum value, the value of the preset interval where the maximum value is located, and the value of the preset interval where the minimum value is located of the data content part specified by the communication protocol corresponding to the CAN communication data file or the LIN communication data file; The seed-based mutation includes randomly modifying a portion of the data content in the existing historical data; The adversarial test includes sending a preset amount of communication data to the gateway device under test within a preset time, and the preset amount exceeds the amount of data that the gateway device under test can process within the preset time.
7. The method for testing a gateway device to be tested according to any one of claims 1 to 6, characterized in that: Obtain the log of the gateway device under test, including: Obtaining fuzzy test data, sending data and timestamp in the log of the gateway device to be tested; Determining whether the gateway device to be tested passes the test based on the log includes: Determining whether the timestamps of the fuzzy test data and the sent data are within a preset forwarding time requirement; Determine whether the formats of the fuzzy test data and the sent data conform to a preset data format; When the timestamp is within the preset forwarding time requirement and the formats of the fuzzy test data and the sent data conform to the preset data formats, it is determined that the test of the gateway device to be tested has passed.
8. The testing method of the gateway device to be tested as claimed in claim 7, characterized in that: After determining whether the gateway device to be tested has passed the test based on the log, the method further includes: Sending the fuzzy test data, sent data and test results received by the gateway device to be tested to a visual interface; Generate a test report based on the test results.
9. A test system for a gateway device, characterized in that: include: A generating unit, used for randomly generating a CAN communication data file and a LIN communication data file; A conversion unit, used to convert the randomly generated CAN communication data file and the randomly generated LIN communication data file respectively using a fuzzy algorithm to obtain fuzzy test data; A sending unit, used for sending the fuzzy test data to a gateway device to be tested, wherein the gateway device to be tested is used for converting the CAN communication data file into a LIN communication data file or converting the LIN communication data file into a CAN communication data file; A log acquisition unit, used to acquire the log of the gateway device to be tested; A test determination unit is used to determine whether the gateway device to be tested has passed the test based on the log.
10. A test device for a gateway device, characterized in that: include: Memory for storing computer programs; A processor is used to implement the steps of the testing method for the gateway device to be tested as described in any one of claims 1 to 8 when executing the computer program.