Vehicle communication security test method and vehicle
By generating test cases and obtaining bus metrics and response results through a target generative adversarial network model, the problem of low accuracy in vehicle communication network security testing is solved, and more comprehensive testing results are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI KAIYANG TECHNOLOGY CO LTD
- Filing Date
- 2026-01-16
- Publication Date
- 2026-05-01
AI Technical Summary
In existing technologies, the accuracy of vehicle communication network security testing is low, making it difficult to conduct comprehensive and in-depth testing of complex communication networks.
Test cases are generated using a target generative adversarial network model and sent to the controller via the controller local area network bus. Bus metrics and response results are obtained, and the communication security test results are determined based on these metrics and results.
It improves the comprehensiveness and accuracy of vehicle communication network testing, and solves the problem of low accuracy in vehicle communication network security testing.
Smart Images

Figure CN121967286A_ABST
Abstract
Description
Test methods and vehicles for vehicle communication security Technical Field
[0001] This application relates to the field of vehicle network security technology, and more specifically, to a test method and vehicle for vehicle communication security. Background Technology
[0002] Currently, with the rapid development of intelligent connected vehicles, the in-vehicle network structure is becoming increasingly complex, which brings users a better riding experience, but also poses network security issues for vehicles.
[0003] In related technologies, fuzz testing is commonly used when conducting security tests on vehicle communication networks. This fuzz testing method relies on randomly generated or finite rule-based test cases. The number of such test cases is limited and their specificity is weak, making it difficult to conduct comprehensive and in-depth testing of complex in-vehicle communication networks. Therefore, there is a technical problem of low accuracy in testing the security of vehicle communication networks.
[0004] There is currently no good solution to the technical problem of low accuracy in communication network security testing of the aforementioned vehicles. Summary of the Invention
[0005] This application provides a testing method and vehicle for vehicle communication security, in order to at least solve the technical problem of low accuracy in vehicle communication network security testing.
[0006] According to one aspect of the embodiments of this application, a method for testing vehicle communication security is provided. The method includes: responding to a controller of a vehicle under test accessing a simulation test platform via a controller local area network (CLAN) bus, and invoking a target generative adversarial network (GAN) model to generate test cases, wherein the test cases are used to test the controller's response capability to abnormal communication data, the simulation test platform is used to simulate the operating environment of the communication network of the vehicle under test, and the target GAN model is obtained by pre-training an initial GAN model using communication data samples; sending the test cases to the controller via the CLAN bus at a preset rate; acquiring bus metrics of the CLAN bus and acquiring the controller's response results, wherein the bus metrics are used to characterize the operating state of the CLAN bus, and the response results are used to characterize the controller's response behavior after receiving the test cases; and determining the communication security test result of the vehicle under test based on the bus metrics and the response results, wherein the communication security test result is used to characterize whether the communication network of the vehicle under test is in a secure state.
[0007] Optionally, the target generative adversarial network model includes a target generator model and a target discriminator model. The target generative adversarial network model is called to generate test cases, including: calling the target generator model in the target generative adversarial network to generate initial test cases, wherein the initial test cases are communication messages that conform to the rules of the controller local area network bus protocol and have variability in structure and content; and expanding the initial test cases to obtain test cases.
[0008] Optionally, the initial test cases are expanded to obtain test cases, including at least one of the following: flipping the bits in the communication message corresponding to the initial test cases to obtain test cases; adjusting the message length of the communication message corresponding to the initial test cases to obtain test cases; or modifying the bits in the communication message corresponding to the initial test cases to obtain test cases.
[0009] Optionally, obtaining bus metrics of the controller local area network (CLAN) bus includes: obtaining the bus load rate of the CLAN bus, wherein the bus load rate is used to characterize the communication busyness of the corresponding CLAN bus; and obtaining the number of error frames of the CLAN bus, wherein the number of error frames is used to characterize the data transmission quality of the CLAN bus; and determining the bus load rate and the number of error frames as bus metrics.
[0010] Optionally, based on bus metrics and response results, the communication security test result of the vehicle under test is determined, including: in response to a bus metric being greater than or equal to a bus metric threshold, and / or in response to a response result indicating that the controller's response behavior after receiving a test case does not match the expected response behavior corresponding to the test case, the communication security test result of the vehicle under test indicates that the communication network of the vehicle under test is not in a secure state; in response to a bus metric being less than a bus metric threshold, and / or in response to a response result indicating that the controller's response behavior after receiving a test case matches the expected response behavior, the communication security test result of the vehicle under test indicates that the communication network of the vehicle under test is in a secure state.
[0011] Optionally, the method further includes: in response to a communication security test result indicating that the communication network of the vehicle under test is not in a secure state, obtaining a target test case that causes the controller's response behavior to deviate from the expected response behavior; and using the target test case to iteratively train the target generative adversarial network model to obtain an updated target generative adversarial network model.
[0012] Optionally, the method further includes: acquiring multiple frames of first communication messages of the vehicle sample under different operating states, and generating multiple frames of second communication messages based on simulation software; determining the multiple frames of first communication messages and multiple frames of second communication messages as multiple frames of communication data samples, wherein the multiple frames of communication data samples include normal communication data samples and abnormal communication data samples.
[0013] Optionally, the method further includes: standardizing multi-frame communication data samples to obtain standardized multi-frame communication data samples, wherein the standardized multi-frame communication data samples have a fixed data length; clustering the standardized multi-frame communication data samples based on the identification information corresponding to each standardized multi-frame communication data sample to obtain at least one cluster set, wherein the identification information is used to characterize the sample type to which the communication data sample belongs, and the cluster set corresponds to the sample type; expanding the at least one cluster set to obtain at least one expanded cluster set; adjusting the sequence length of at least one communication data sample in the expanded at least one cluster set based on a preset length to obtain at least one target cluster set, wherein the sequence length of the communication data samples in the target cluster set is equal; and training the initial generative adversarial network model based on the at least one target cluster set to obtain a target generative adversarial network model.
[0014] Optionally, the initial generative adversarial network (GAN) model is trained based on at least one target cluster set to obtain a target GAN model, including: pre-training the initial generator model in the initial GAN model based on at least one target cluster set to obtain a pre-trained initial generator model; performing adversarial training on the pre-trained initial generator model and the initial discriminator model in the initial GAN model to obtain a trained initial generator model and a trained initial discriminator model; validating the trained initial generator model and the trained initial discriminator model based on a loss function to obtain a validation result; responding to the validation result indicating that the trained initial generator model and the trained initial discriminator model are in a stable state, determining the trained initial generator model as the target generator model, and the trained initial discriminator model as the target discriminator model; and determining the target generator model and the target discriminator model as the target GAN model.
[0015] According to another aspect of the embodiments of this application, a vehicle is also provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of this application when it runs.
[0016] In this embodiment, when the controller of the vehicle under test (VUT) is connected to the simulation test platform via the Controller Area Network (CLAN) bus, a target generative adversarial network (GAN) model can be invoked to generate test cases. After obtaining the test cases, they are sent to the controller via the CLAN bus at a preset rate. Then, the bus metrics of the CLAN bus and the controller's response results are obtained. Based on the bus metrics and response results, the communication security test results of the VUT can be determined. In other words, in this embodiment, generating test cases using a pre-trained target GAN model improves the diversity of test cases. Sending these test cases to the controller via the CLAN bus and determining the communication security test results of the VUT based on the CLAN bus metrics and the controller's response results improves the comprehensiveness and accuracy of the vehicle's communication network testing, thus solving the technical problem of low accuracy in vehicle communication network security testing. Attached Figure Description
[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0018] Figure 1 is a flowchart of a vehicle communication security testing method according to an embodiment of this application;
[0019] Figure 2 is a flowchart of a CAN bus protocol fuzzy testing method based on intelligent seed generation according to an embodiment of this application;
[0020] Figure 3 is a schematic diagram of a CAN bus data set construction module according to an embodiment of this application;
[0021] Figure 4 is a schematic diagram of the construction and fuzz test verification of a generative adversarial model according to an embodiment of this application;
[0022] Figure 5 is a schematic diagram of a vehicle communication security test device according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] According to an embodiment of this application, an embodiment of a test method for vehicle communication security is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0026] This embodiment provides a test method for vehicle communication security. Figure 1 is a flowchart of the test method for vehicle communication security according to an embodiment of this application. As shown in Figure 1, the process includes the following steps.
[0027] In step S101, the controller of the vehicle under test connects to the simulation test platform through the controller local area network bus and calls the target generative adversarial network model to generate test cases.
[0028] In the technical solution provided in step S101 of this application, the controller can be used to represent a device in a vehicle that monitors and controls a specific system or function. For example, the controller can be an Electronic Control Unit (ECU). The controller local area network bus can be used to represent the communication protocol in the vehicle that undertakes data exchange between ECUs. For example, the controller local area network bus can be a Controller Area Network (CAN) bus. The simulation test platform can be used to simulate the operating environment of the communication network of the vehicle under test. For example, the simulation test platform can be a Hardware-in-the-Loop (HIL) test platform. The target generative adversarial network model can be a model obtained by pre-training an initial generative adversarial network model using communication data samples. For example, the target generative adversarial network model can be a sequence generative adversarial network, wherein the communication data samples can be a CAN bus message dataset. The test cases can be used to test the controller's response capability to abnormal communication data. For example, the test cases can be communication messages generated by the target generative adversarial network model that conform to the CAN communication protocol rules and have certain variation characteristics in structure and content.
[0029] In this embodiment, when the controller of the vehicle under test is connected to the simulation test platform via the controller area network bus, the target generative adversarial network model can be invoked to generate test cases. For example, using the HIL test system as the simulation test platform, the ECU of the vehicle under test is connected to the HIL test system via the CAN bus, and then the trained target generative adversarial network model is invoked to generate test cases.
[0030] In this step, test cases are generated by calling the target generative adversarial network model. Since the target generative adversarial network model is trained in advance using communication data samples, it can generate high-quality and diverse test cases so that the vehicle's communication network can be comprehensively and reliably tested in the future.
[0031] Step S102: Send the test cases to the controller via the controller local area network bus at a preset rate.
[0032] In the technical solution provided in step S102 above, the preset rate can be used to represent the number of test case frames sent to the controller per unit time, wherein the preset rate is controllable. For example, in the initial stage of testing, the preset rate can be set to 50 frames / second to avoid CAN bus overload. This is only an example and is not a specific limitation.
[0033] In this embodiment, after test cases are generated, they can be sent to the controller via the controller local area network bus at a preset rate. For example, initially, test cases can be sent to the controller at a rate of 50 frames per second, and the sending rate can be increased as the test progresses.
[0034] Step S103: Obtain the bus metrics of the controller local area network bus and the response results of the controller.
[0035] In the technical solution provided in step S103 above, the bus indicators can be used to characterize the operating status of the controller local area network bus. For example, the bus indicators may include: bus load rate and number of error frames. The response results can be used to characterize the controller's response behavior after receiving the test case. For example, the response behavior may include: no response, reset, sending illegal messages or functional logic abnormalities.
[0036] In this embodiment, after the test cases are sent to the controller via the controller local area network bus, the bus metrics of the controller local area network bus and the controller's response results can be obtained. For example, after the test cases are sent to the controller, monitoring tools, such as the CAN bus development and testing tool (CANoe), can be used to monitor the CAN bus load rate and the number of error frames in the CAN bus in real time. Simultaneously, by listening to the ECU's response messages and simulating sensor signals to read the ECU's output, it can be determined whether the ECU has exhibited response results such as no response, reset, sending illegal messages, or functional logic abnormalities.
[0037] In this step, by acquiring the bus indicators of the controller local area network bus and the response results of the controller, the operating status of the controller local area network bus and the response behavior of the controller can be determined, thereby providing a basis for judging the communication security test results of the vehicle under test and improving the accuracy of the vehicle's communication network security test.
[0038] Step S104: Based on the bus indicators and response results, determine the communication security test results of the vehicle under test.
[0039] In the technical solution provided in step S104 above, the communication security test results can be used to characterize whether the communication network of the vehicle under test is in a secure state.
[0040] In this embodiment, after obtaining the bus metrics and response results, the communication security test results of the vehicle under test can be determined based on the bus metrics and response results. For example, the communication security test results of the vehicle under test can be determined by the bus load rate and number of error frames of the controller local area network bus, as well as the response behavior of the controller.
[0041] For example, when the bus metric indicates that the bus load rate does not exceed the set threshold, the number of error frames does not surge, and the response results indicate that the controller does not exhibit abnormal behavior such as no response, reset, sending illegal messages, or functional logic abnormalities, it can be determined that the communication network of the vehicle under test is in a safe state.
[0042] In steps S101 to S104 above, test cases are generated by the pre-trained target generative adversarial network model, which can improve the diversity of test cases. Then, the test cases are sent to the controller through the controller local area network bus. Based on the bus index of the controller local area network bus and the response result of the controller, the communication security test result of the vehicle under test is determined, which can improve the comprehensiveness and accuracy of the vehicle's communication network test, thereby solving the technical problem of low accuracy of vehicle communication network security test.
[0043] The test methods for vehicle communication security in this application will be further described below.
[0044] As an optional embodiment, the above-mentioned target generative adversarial network model includes a target generator model and a target discriminator model. Step S101, calling the target generative adversarial network model to generate test cases, includes: calling the target generator model in the target generative adversarial network to generate initial test cases, wherein the initial test cases are communication messages that conform to the rules of the controller local area network bus protocol and have variability in structure and content; and expanding the initial test cases to obtain test cases.
[0045] In this embodiment, the target generator model can be a model for generating communication messages. For example, the target generator model can be a sequence generation structure based on a Long Short-Term Memory (LSTM) network. The target discriminator model can be a model used to distinguish between communication messages generated by the generator model and communication messages obtained from the CAN bus, and to drive the generator model to continuously optimize. For example, the target discriminator model can be a structure combining a one-dimensional convolutional neural network and an attention mechanism. The aforementioned expansion of the initial test cases can be used to represent random mutation of the initial test cases to obtain more initial test cases.
[0046] Optionally, the target generator model in the target generative adversarial network can be invoked to generate initial test cases. For example, the pre-trained target generator model in the target generative adversarial network can be invoked to generate communication messages that conform to the CAN bus protocol rules and have variability in structure and content, thereby obtaining the initial test cases.
[0047] Optionally, after obtaining the initial test cases, the initial test cases can be expanded to obtain additional test cases. For example, after the target generator model generates the initial test cases, the initial test cases can be randomly mutated by flipping, adjusting the length, and modifying the content to obtain expanded initial test cases. The expanded initial test cases are then determined as test cases, wherein the test cases are communication messages that conform to the CAN communication protocol rules and have certain mutability characteristics in structure and content.
[0048] In this step, initial test cases are generated by calling the target generator model in the target generative adversarial network model. By expanding the initial test cases, a large number of test cases can be obtained, thereby improving the testing scope and efficiency of vehicle communication security.
[0049] As an optional implementation method, the initial test case is extended to obtain test cases, including at least one of the following: flipping the bits in the communication message corresponding to the initial test case to obtain test cases; adjusting the message length of the communication message corresponding to the initial test case to obtain test cases; or modifying the bits in the communication message corresponding to the initial test case to obtain test cases.
[0050] In this embodiment, the bit flipping described above can be performed on the bits of data in the communication message, for example, flipping any data bit in the communication message from 0 to 1, or from 1 to 0; the message length adjustment described above can be performed on the length of data in the communication message, for example, adding or deleting bytes in the data in the communication message; the bit modification described above can be performed on the arithmetic increment or decrement of data in the communication message, for example, adding or subtracting 1 from the data in the communication message. These are merely illustrative examples and are not intended to be specific limitations.
[0051] Optionally, after generating the initial test cases, the bits in the communication message corresponding to the initial test cases can be flipped to obtain the test cases. For example, after generating the initial test cases, the bits of the data in the communication message corresponding to the initial test cases can be flipped to obtain the bit-flipped initial test cases, thereby determining the initial test cases and the bit-flipped initial test cases as test cases.
[0052] Optionally, after generating the initial test cases, the message length of the communication message corresponding to the initial test cases can be adjusted to obtain the test cases. For example, after generating the initial test cases, adjusting the data length in the communication message corresponding to the initial test cases can yield the initial test cases with adjusted lengths. Thus, the initial test cases and the initial test cases with adjusted lengths can be determined as test cases.
[0053] Optionally, after generating the initial test cases, the bits in the communication message corresponding to the initial test cases can be modified to obtain the test cases. For example, after generating the initial test cases, the data in the communication message corresponding to the initial test cases can be arithmetically incremented or decremented to obtain the arithmetically incremented and decremented initial test cases. Thus, the initial test cases and the arithmetically incremented and decremented initial test cases are determined as the test cases.
[0054] In this step, after generating the initial test cases, the expanded initial test cases can be obtained by performing bit flipping, length adjustment, and / or arithmetic increment / decrement on the initial test cases. The initial test cases and the expanded initial test cases are then determined as test cases, thereby obtaining test cases with a wide coverage, which in turn improves the diversity of test cases for testing the communication security of vehicles.
[0055] As an optional embodiment, obtaining the bus metrics of the controller local area network (CLAN) bus includes: obtaining the bus load rate of the CLAN bus, wherein the bus load rate is used to characterize the communication busyness of the corresponding CLAN bus; and obtaining the number of error frames of the CLAN bus, wherein the number of error frames is used to characterize the data transmission quality of the CLAN bus; and determining the bus load rate and the number of error frames as bus metrics.
[0056] In this embodiment, the bus load rate can be used to characterize the communication busyness of the controller local area network bus. For example, the bus load rate can be the ratio of the time period for transmitting communication messages to the unit time period within a unit time period. The number of error frames can be used to characterize the data transmission quality of the controller local area network bus. For example, the error frame can be an error communication message sent in the CAN bus due to the detection of a communication error.
[0057] Optionally, after sending test cases to the controller, the bus load rate of the controller's local area network bus can be obtained. For example, by monitoring the CAN bus in real time using the CANoe tool, the length of time for transmitting communication messages on the CAN bus within a unit time period can be obtained. The bus load rate of the CAN bus can be obtained by the ratio of the length of time for transmitting communication messages to the length of the unit time period.
[0058] Optionally, after sending test cases to the controller, the number of error frames on the controller's local area network bus can be obtained. For example, by monitoring the CAN bus in real time using the CANoe tool and recording the number of erroneous communication messages on the CAN bus, the number of error frames on the CAN bus can be obtained.
[0059] Optionally, after obtaining the bus load rate and the number of error frames, the bus load rate and the number of error frames can be determined as bus metrics.
[0060] In this step, the CAN bus is monitored in real time using the CANoe tool. This allows us to obtain the CAN bus load rate and the number of error frames, thereby determining the bus indicators and providing a basis for testing vehicle communication safety, thus improving the accuracy of vehicle communication safety testing.
[0061] As an optional embodiment, step S104, based on bus metrics and response results, determines the communication security test result of the vehicle under test, including: in response to bus metrics being greater than or equal to a bus metric threshold, and / or in response to the controller's response behavior after receiving a test case, as represented by the response result, not matching the expected response behavior corresponding to the test case, determining that the communication security test result of the vehicle under test indicates that the communication network of the vehicle under test is not in a secure state; in response to bus metrics being less than a bus metric threshold, and / or in response to the controller's response behavior after receiving a test case, as represented by the response result, matching the expected response behavior, determining that the communication security test result of the vehicle under test indicates that the communication network of the vehicle under test is in a secure state.
[0062] In this embodiment, the aforementioned bus indicator thresholds can be preset bus load rate thresholds and error frame count thresholds. For example, the bus load rate threshold can be preset to 80%. This is only an example and is not a specific limitation. The aforementioned expected response behavior can be the corresponding response behavior of the controller to the communication messages corresponding to the test cases.
[0063] Optionally, after obtaining the bus metrics and response results, if the bus metrics are greater than or equal to the bus metric threshold, and / or if the controller's response behavior after receiving the test case, as represented by the response results, does not match the expected response behavior corresponding to the test case, then it can be determined that the communication security test results of the vehicle under test indicate that the communication network of the vehicle under test is not in a secure state. For example, when the CAN bus load rate is greater than or equal to the aforementioned bus load rate threshold, and the number of error frames is greater than or equal to the error frame number threshold, and / or the controller's response behavior does not match the expected response behavior, it can be determined that the communication network of the vehicle under test is not in a secure state.
[0064] Optionally, after obtaining the bus metrics and response results, if the bus metrics are less than the bus metric threshold, and / or the response behavior of the controller after receiving the test case, as represented by the response results, matches the expected response behavior, then the communication security test results of the vehicle under test indicate that the communication network of the vehicle under test is in a safe state. For example, when the bus load rate of the CAN bus is less than the aforementioned bus load rate threshold, and the number of error frames is less than the error frame number threshold, and / or the controller's response behavior matches the expected response behavior, it can be determined that the communication network of the vehicle under test is in a safe state.
[0065] In this step, by analyzing the relationship between bus indicators and bus indicator thresholds, as well as the relationship between response behavior and expected response behavior, the communication security test results of the vehicle under test can be determined. Based on the communication security test results, it can be determined whether the communication network of the vehicle under test is in a secure state, thereby improving the accuracy of vehicle communication network security testing.
[0066] As an optional implementation, in response to the communication security test result of the vehicle under test indicating that the communication network of the vehicle under test is not in a secure state, a target test case is obtained that causes the controller's response behavior to be inconsistent with the expected response behavior; using the target test case, the target generative adversarial network model is iteratively trained to obtain an updated target generative adversarial network model.
[0067] In this embodiment, the target test case can be a test case that causes the controller's response behavior to be inconsistent with the expected response behavior.
[0068] Optionally, when the communication security test results of the vehicle under test indicate that the communication network of the vehicle under test is not in a secure state, target test cases that cause the controller's response behavior to deviate from the expected response behavior are obtained. For example, the CAN bus is monitored in real time using the CANoe tool, and target test cases that cause the controller's response behavior to deviate from the expected response behavior are recorded. At the same time, a preset number of test cases before and after the target test cases are recorded, and abnormal communication message data packets are generated.
[0069] Optionally, after obtaining the target test cases, the target generative adversarial network (GAN) model can be iteratively trained using the target test cases to obtain an updated target GAN model. For example, the target test cases and abnormal communication message packets can be used as communication data samples to iteratively update the target GAN model and obtain an updated target GAN model.
[0070] In this step, by obtaining target test cases that cause the controller's response behavior to deviate from the expected response behavior, and by using the target test cases to iteratively train the target generative adversarial network model, the reliability of the target generative adversarial network model can be improved through continuous iterative updates.
[0071] As an optional embodiment, multiple frames of first communication messages of the vehicle under test sample under different operating states are obtained, and multiple frames of second communication messages are generated based on simulation software; the multiple frames of first communication messages and multiple frames of second communication messages are determined as multiple frames of communication data samples, wherein the multiple frames of communication data samples include normal communication data samples and abnormal communication data samples.
[0072] In this embodiment, the aforementioned operating state is used to characterize the operating state of the vehicle sample under test. For example, the aforementioned operating state can be an operating state such as starting, idling, accelerating / decelerating, and shutting down / sleeping. The aforementioned first communication message can be a communication message sent by the controller of the vehicle under test. For example, the aforementioned first communication message can be a CAN communication message. The aforementioned simulation software can be software that can simulate the vehicle sample under test in an edge scenario. For example, the aforementioned simulation software can be the CANoe tool. The aforementioned second communication message can be a message generated by the aforementioned simulation software. For example, the aforementioned second communication message can be a communication message of the vehicle sample under test in an edge scenario.
[0073] Optionally, multiple frames of first communication messages of the vehicle under test sample under different operating states are acquired, and multiple frames of second communication messages are generated based on simulation software. For example, multiple frames of first communication messages of the vehicle under test sample under different operating states in the CAN bus are acquired, and multiple frames of second communication messages of the vehicle under test sample in edge scenarios are simulated, generated, and recorded using the CANoe tool.
[0074] Optionally, after acquiring multiple frames of first and second communication messages, these multiple frames are determined as multi-frame communication data samples. For example, the acquired multiple frames of first and second communication messages can be combined to obtain multi-frame communication data samples, which can then be used to train a target generative adversarial network model.
[0075] In this step, by acquiring multiple frames of first communication messages of the vehicle under test sample under different operating states, and multiple frames of second communication messages generated by simulation software, the multi-frame communication sample data can be determined. Then, the multi-frame sample data can be used to train the target generative adversarial network, thereby improving the practicality of the target generative adversarial network model.
[0076] The training process of the target generative adversarial network model will be further described next.
[0077] As an optional implementation, multi-frame communication data samples are standardized to obtain standardized multi-frame communication data samples, wherein the standardized multi-frame communication data samples have a fixed data length; based on the identification information corresponding to each standardized multi-frame communication data sample, the standardized multi-frame communication data samples are clustered to obtain at least one cluster set, wherein the identification information is used to characterize the sample type to which the communication data sample belongs, and the cluster set corresponds to the sample type; the at least one cluster set is expanded to obtain at least one expanded cluster set; based on a preset length, the sequence length of at least one communication data sample in the expanded at least one cluster set is adjusted to obtain at least one target cluster set, wherein the sequence length of the communication data samples in the target cluster set is equal; based on at least one target cluster set, an initial generative adversarial network model is trained to obtain a target generative adversarial network model.
[0078] In this embodiment, the above-mentioned standardization process can be used to represent the standardization of the data format of multiple frames of communication data samples, for example, converting the hexadecimal data in each frame of communication data sample into decimal data; the above-mentioned identification information can be used to characterize the sample type to which the communication data sample belongs, for example, the above-mentioned identification information can be an arbitration identifier (Arbitration ID, abbreviated as Arbitration ID); the above-mentioned preset length can be a preset length of each frame of communication data sample.
[0079] Optionally, after obtaining multiple frames of communication data samples, the multiple frames of communication data samples are standardized to obtain standardized multiple frames of communication data samples. For example, each byte in each frame of communication data sample is converted from hexadecimal to decimal integer to obtain a communication data sample with a fixed data length, wherein the fixed data length can be 8 bytes, that is, the communication data sample can be converted into an integer sequence of length 8.
[0080] Optionally, after obtaining the standardized multi-frame communication data samples, the standardized multi-frame communication data samples are clustered based on the identification information corresponding to each standardized multi-frame communication data sample to obtain at least one cluster set. For example, by identifying multiple arbitration IDs in the standardized multi-frame communication data samples, and according to the communication data sample types indicated by the multiple arbitration IDs, communication data samples of the same sample type are clustered into a cluster set, thereby obtaining at least one cluster set.
[0081] Optionally, after obtaining at least one cluster set, the at least one cluster set is expanded to obtain at least one expanded cluster set. For example, by randomly mutating the communication sample data in at least one cluster set, the communication sample data in at least one cluster set is amplified by 3 times, thereby obtaining at least one expanded cluster set. This is only an example and is not a specific limitation.
[0082] Optionally, after obtaining at least one expanded cluster set, the sequence length of at least one communication data sample in the expanded cluster set can be adjusted based on a preset length to obtain at least one target cluster set. For example, for communication data samples in the cluster set with a sequence length less than 8, zeros are added to the end to make the sequence length of the communication data sample 8; for communication data samples in the cluster set with a sequence length greater than 8, the first 8 integers in the sequence are truncated to make the sequence length of the communication data sample 8, thus obtaining at least one target cluster set, wherein the sequence length of the data communication samples in the target cluster set is consistent. This is only an example and is not a specific limitation.
[0083] Optionally, after obtaining at least one target cluster set, the initial generative adversarial network (GAN) model can be trained based on the at least one target cluster set to obtain the target GAN model. For example, communication data samples from at least one target cluster set can be input into the initial GAN model, and the initial GAN model can be trained using the communication data samples from the target cluster set to obtain the target GAN model.
[0084] In this step, standardized multi-frame communication data samples are obtained by standardizing the samples. These standardized samples are then clustered according to their identifiers to obtain at least one cluster set. Next, the sequence length of each cluster set is expanded and adjusted to obtain at least one target cluster set. Finally, the initial generative adversarial network (GAN) model is trained using at least one target cluster set to obtain a target GAN model. Because at least one target cluster set is used, the initial GAN model can be trained specifically, thereby improving the practicality of the target GAN model and ultimately increasing the accuracy of vehicle communication safety testing.
[0085] As an optional implementation, training an initial generative adversarial network (GAN) model based on at least one target cluster set to obtain a target GAN model includes: pre-training an initial generator model in the initial GAN model based on at least one target cluster set to obtain a pre-trained initial generator model; performing adversarial training on the pre-trained initial generator model and the initial discriminator model in the initial GAN model to obtain a trained initial generator model and a trained initial discriminator model; validating the trained initial generator model and the trained initial discriminator model based on a loss function to obtain a validation result; responding to the validation result indicating that the trained initial generator model and the trained initial discriminator model are in a stable state, determining the trained initial generator model as the target generator model, and the trained initial discriminator model as the target discriminator model; and determining the target generator model and the target discriminator model as the target GAN model.
[0086] In this embodiment, after obtaining at least one target cluster set, the initial generator model in the initial generative adversarial network model can be pre-trained based on the at least one target cluster set to obtain a pre-trained initial generator model. For example, the initial generator model can be pre-trained using the maximum likelihood estimation method so that the initial generator model can generate communication data samples similar to at least one communication data sample contained in at least one target cluster set, thereby obtaining the pre-trained initial generator model.
[0087] Optionally, after obtaining the pre-trained initial generator model, adversarial training can be performed between the pre-trained initial generator model and the initial discriminator model in the initial generative adversarial network model to obtain the trained initial generator model and the trained initial discriminator model. For example, the pre-trained initial generator model and the initial discriminator model can be trained alternately. First, at least one communication data sample from at least one target cluster set and similar communication data samples generated by the pre-trained initial generator model are respectively input into the initial discriminator model, enabling it to accurately distinguish at least one communication data sample from at least one target cluster set from similar communication data samples generated by the pre-trained initial generator model, thus obtaining the trained initial discriminator model. Second, similar communication data samples generated by the pre-trained initial generator model are input into the trained initial discriminator model. Based on the discrimination results fed back by the initial discriminator model, the pre-trained initial generator model is updated, thus obtaining the trained initial generator model. In other words, during the adversarial training phase, the initial discriminator is used to distinguish between communication data samples generated by the initial generator and real communication data samples, while the initial generator model is used to generate communication data samples sufficient to "deceive" the initial discriminator. This training process employs the policy gradient method to address the gradient backpropagation problem in discrete sequence generation, ensuring that the initial generator model can continuously optimize the "deception level" and diversity of the generated communication data samples.
[0088] Optionally, after obtaining the trained initial generator model and the trained initial discriminator model, the trained initial generator model and the trained initial discriminator model can be validated according to the loss function to obtain the validation results. For example, using an adaptive matrix estimation optimization algorithm, the loss functions of the trained initial generator model and the trained initial discriminator model can be calculated respectively, and the trained initial generator model and the trained initial discriminator model can be validated using the obtained loss functions to obtain the validation results.
[0089] Optionally, after obtaining the validation results, in response to the validation results indicating that the trained initial generator model and the trained initial discriminator model are in a stable state, the trained initial generator model can be determined as the target generator model, and the trained initial discriminator model can be used as the target discriminator model. For example, when the loss function of the trained initial generator model and the loss function of the trained initial discriminator model reach a dynamic equilibrium, the trained initial generator model and the trained initial discriminator model can be used as the target initial generator model and the target initial discriminator model, respectively.
[0090] Optionally, after obtaining the initial target generator model and the initial target discriminator model, the target generator model and the target discriminator model can be determined as a target generative adversarial network model. For example, after obtaining the initial target generator model and the initial target discriminator model, the initial target generator model and the initial target discriminator model can be combined to obtain a target generative adversarial network model.
[0091] In this step, the initial generator model and the initial discriminator model are pre-trained and adversarially trained to obtain the trained initial generator model and the trained initial discriminator model. Then, based on the loss function, the trained initial generator model and the trained initial discriminator model are validated to obtain the target initial generator model and the target initial discriminator model. Based on the target initial generator model and the target initial discriminator model, a target generative adversarial network (GAN) model is generated, thereby improving the reliability of the target GAN model.
[0092] In this embodiment, when the controller of the vehicle under test (VUT) is connected to the simulation test platform via the Controller Area Network (CLAN) bus, a target generative adversarial network (GAN) model can be invoked to generate test cases. After obtaining the test cases, they are sent to the controller via the CLAN bus at a preset rate. Then, the bus metrics of the CLAN bus and the controller's response results are obtained. Based on the bus metrics and response results, the communication security test results of the VUT can be determined. In other words, in this embodiment, generating test cases using a pre-trained target GAN model improves the diversity of test cases. Sending these test cases to the controller via the CLAN bus and determining the communication security test results of the VUT based on the CLAN bus metrics and the controller's response results improves the comprehensiveness and accuracy of the vehicle's communication network testing, thereby solving the technical problem of low accuracy in vehicle communication network security testing.
[0093] The above technical solutions of the present application embodiments will be further illustrated below with reference to preferred embodiments of the present invention.
[0094] In related technologies, fuzz testing is commonly used when testing the network security of vehicle communication networks. This fuzz testing method relies on randomly generated or finite rule-based test cases. The number of such test cases is limited and their specificity is weak, making it difficult to conduct comprehensive and in-depth testing of complex in-vehicle communication networks. Therefore, there is a technical problem of low accuracy in testing the network security of vehicle communication networks.
[0095] However, this application proposes a testing method for vehicle communication security. When the controller of the vehicle under test (VUT) is connected to the simulation test platform via the Controller Area Network (CLAN) bus, a target generative adversarial network (GAN) model can be invoked to generate test cases. After obtaining the test cases, the test cases are sent to the controller via the CLAN bus at a preset rate. Then, the bus metrics of the CLAN bus and the controller's response results are obtained. Based on the bus metrics and response results, the communication security test results of the VUT can be determined. In other words, in this embodiment, generating test cases through a pre-trained target GAN model can improve the diversity of test cases. Sending the test cases to the controller via the CLAN bus and determining the communication security test results of the VUT based on the CLAN bus metrics and the controller's response results can improve the comprehensiveness and accuracy of vehicle communication network testing, thereby solving the technical problem of low accuracy in vehicle communication network security testing.
[0096] Figure 2 is a flowchart of a CAN bus protocol fuzz testing method based on intelligent seed generation according to an embodiment of this application. As shown in Figure 2, the method includes the following steps.
[0097] Step S210, Dataset Construction.
[0098] In this embodiment, a high-quality, diverse CAN bus message dataset is constructed to lay the foundation for subsequent deep learning model training. This step may further include: step S211, data collection, and step S212, data processing. Figure 3 is a schematic diagram of a CAN bus dataset construction module according to an embodiment of this application. As shown in Figure 3, the dataset construction may include: data collection and data processing. Data collection may include: multi-source data acquisition, multi-protocol acquisition, multi-scenario acquisition, and abnormal data acquisition; data processing may include: format standardization, data clustering analysis, data augmentation optimization, and sequence length unification.
[0099] The data collection and data processing processes will be described in more detail below.
[0100] Step S211, data collection.
[0101] In this embodiment, a multi-source fusion data acquisition strategy is adopted to ensure the comprehensiveness of the data.
[0102] Strategy 1: Direct Data Acquisition: Connect the test host's CAN interface card directly to the HIL test platform's CAN bus to capture all messages flowing through the bus. This is the primary data source.
[0103] Strategy 2: On-board diagnostic system interface acquisition: Simulate the on-board diagnostic system interface in the test platform and acquire standard diagnostic service messages. These messages usually involve deeper vehicle control logic.
[0104] Strategy 3: Simulation Platform Acquisition: Utilize CANoe simulation software to simulate and generate edge scenario messages that are difficult to capture in actual acquisition, such as extremely high bus load rate or specific ECU failure.
[0105] Strategy 4, Scenario Coverage: During data acquisition, the control system simulates different vehicle states, including starting, idling, acceleration / deceleration, and engine shutdown / sleep, and records at least 10 minutes of CAN communication data for each state. A total of approximately 5 million raw CAN message frames are collected.
[0106] Step S212, data processing.
[0107] In this embodiment, the collected raw data is cleaned, transformed, and enhanced to make it suitable for training the initial generative adversarial network model. Subsequently, the collected data is further processed through data format standardization, multi-dimensional clustering analysis, data augmentation optimization, and sequence length unification.
[0108] Optionally, data format standardization includes converting the raw hexadecimal data of each CAN message frame (e.g., 1A 2B3C 4D 00 00 00 00) into a decimal integer sequence. For example, each byte (8 bits) is converted into an integer between 0 and 255, resulting in an 8-byte message being converted into an 8-bit integer sequence [26,43,60,77,0,0,0,0]. Simultaneously, the arbitration ID of the message (e.g., 0x100) is recorded and used as a key tag for the message sequence.
[0109] Optionally, multi-dimensional clustering analysis includes using clustering algorithms to automatically divide messages into several groups based on arbitration IDs and data domain value distribution characteristics (such as mean and variance). For example, the clustering results may show that message data patterns are stable for IDs 0x100-0x1FF and are classified as "Body Control"; message data with IDs 0x200-0x2FF change frequently and are classified as "Powertrain". This helps in subsequent targeted model training based on protocol subsets.
[0110] Optionally, data augmentation optimization includes employing time-series data augmentation techniques to address the issue of insufficient data volume in certain states (e.g., error frames). For a continuous CAN message sequence, methods such as window sliding (generating overlapping subsequences), adding small noise (numerically increasing the perturbation by ±1), and random masking (randomly setting some bytes in the sequence to zero) were used to expand the original dataset by approximately 3 times, effectively improving the model's generalization ability.
[0111] Optionally, sequence length unification includes standardizing all processed message sequences to a fixed length. For sequences shorter than 8 bytes (e.g., some messages are truncated), zeros are padded at the end; for sequences longer than 8 bytes, the first 8 bytes are truncated. Ultimately, all input model sequences are vectors of length 8.
[0112] Step S220, Model Construction.
[0113] In this embodiment, a generative adversarial network is constructed and trained based on the processed dataset. Its core function is to learn the deep distribution patterns of CAN bus messages. This step may further include: step S221, model architecture design, and step S222, model training and optimization.
[0114] Step S221, Model architecture design.
[0115] In this embodiment, the first architecture, the generator, employs a two-layer LSTM network as its core. Its input is a random noise vector (50 dimensions) and the generation result from the previous time step, with the hidden layer dimension set to 128. LSTM can effectively learn the temporal dependencies of CAN message data. The generator's output layer generates a probability distribution for the 256 possible values (0-255) at each position in the sequence, thereby "sampling" a complete 8-byte message sequence.
[0116] Architecture 2, Discriminator: Employs a one-dimensional convolutional neural network combined with an attention mechanism. The input is an 8-byte message sequence. First, an embedding layer maps each integer to a dense vector. Then, two one-dimensional convolutional layers (kernel sizes of 3 and 5, and filter counts of 64 and 128 respectively) are used to extract local features. Subsequently, an attention mechanism is introduced to assign different weights to different bytes in the sequence, highlighting the influence of key bytes. Finally, a fully connected layer and activation function output a scalar between 0 and 1, representing the probability that the input is a "real CAN message".
[0117] Architecture 3, Protocol Constraint Embedding: A protocol constraint layer is added after the generator's output layer. This layer performs hard corrections on the generated results based on prior knowledge (e.g., certain bytes of messages with certain IDs must be 0 or 1). For example, if it is known that the highest bit of the 0th byte of a message with ID 0x101 must be 0, the generator will force that bit to be 0 after outputting, ensuring that the generated message conforms to the protocol specification in syntax.
[0118] Step S222, Model training and optimization.
[0119] In this embodiment, a sequence generative adversarial network training paradigm is adopted, combined with a variety of optimization strategies.
[0120] Strategy 1: Generator Pre-training: First, using the maximum likelihood estimation method, the generator is pre-trained for approximately 100 rounds with real CAN message data, allowing it to initially learn to generate sequences similar to real data. The discriminator does not participate in the training during this stage.
[0121] Strategy 2, Adversarial Training: After pre-training, the generator and discriminator are trained alternately. Discriminator Training: Real packets are marked as 1, and packets generated by the generator are marked as 0. The discriminator is trained to accurately distinguish between the two. Generator Training: The discriminator parameters are fixed, and the generator generates packets and inputs them into the discriminator. Since the generator's output is discrete, gradient descent cannot be directly used. Therefore, a policy gradient method is adopted, using high scores from the discriminator as rewards to update the generator's parameters, encouraging it to generate packets that can "deceive" the discriminator. Monte Carlo search is introduced during this process to evaluate some generated sequences, addressing the reward allocation problem when generating long sequences.
[0122] Strategy 3, Multi-objective optimization: The generator's reward function integrates three objectives: deception degree: the score given by the discriminator; protocol compliance degree: the degree to which the generated message violates protocol constraints (e.g., length, fixed value); diversity degree: the degree of difference between the generated message and the existing seed library.
[0123] Strategy 4, Parameter Tuning: An adaptive matrix estimation optimizer is used, with an initial learning rate set to 0.001 and a learning rate decay strategy employed. The batch size is determined to be 64 using grid search. The entire adversarial training process lasts approximately 500 rounds until the loss functions of the generator and discriminator reach dynamic equilibrium.
[0124] Step S230, fuzz testing.
[0125] In this embodiment, a seed file is generated using a trained intelligent model to drive a fuzzing process, thereby discovering potential vulnerabilities in the vehicle ECU. This step may further include: step S231, test environment setup; step S232, test execution and monitoring; and step S233, result evaluation and optimization. Figure 4 is a schematic diagram of a generative adversarial model construction and fuzzing verification according to an embodiment of this application. As shown in Figure 4, firstly, the generator can generate decimal false messages (e.g., false messages), and then input the generated false messages into the discriminator for training the generator. Simultaneously, to expand the training set, the controlled industrial control device can generate real protocol messages, and process these messages to obtain training data. Then, the training data is input into the discriminator for adversarial training of the discriminator and the generator. Finally, the trained generator generates decimal false messages, converts the generated false messages into hexadecimal data, and finally inputs the converted hexadecimal data into the tested industrial control device for fuzzing.
[0126] Step S231, test environment setup.
[0127] In this embodiment, a hardware-in-the-loop test environment is used as the primary verification platform. The test host, connected to the HIL platform's CAN bus via an interface card, can both monitor bus traffic and inject test messages into the bus.
[0128] Step S232, test execution and monitoring.
[0129] This embodiment includes steps such as initial seed generation, fuzz test execution, real-time status monitoring, and security protection mechanisms. Specifically, for initial seed generation, 500 high-quality initial test cases (seed files) are randomly sampled from a trained generator. These seeds are not completely random noise, but rather messages learned by the model that conform to CAN communication rules and possess a certain degree of variability.
[0130] Optionally, for fuzz testing execution, the fuzz manager on the test host loads these 500 seed files. A mutation-based fuzzing strategy is employed. Starting with these smart seeds, they are further randomly mutated (e.g., bit flipping, byte addition / deletion, arithmetic addition / subtraction, etc.) to generate a large number of test cases. These test cases are then injected into the CAN bus via an interface card at a controlled rate (e.g., initially set to 50 frames per second to avoid bus overload).
[0131] Optionally, for real-time status monitoring, the monitoring tool (e.g., CANoe) monitors key indicators on the bus in real time, including: bus load rate: set a threshold of 80%, and suspend injection if it exceeds this threshold; number of error frames: closely monitor the surge in active and passive error frames; ECU behavior: by listening to the ECU's response messages and reading the ECU's output by simulating sensor signals, determine whether it exhibits abnormal behavior such as no response, reset, sending illegal messages, or functional logic abnormalities (e.g., the fault light is turned on for no reason).
[0132] Optionally, a software circuit breaker mechanism is implemented for safety protection: when the bus load is monitored to exceed 85% for an extended period or a critical ECU (e.g., engine controller) stops communicating for more than 2 seconds, message injection is immediately stopped, and a series of known normal messages are sent to attempt to restore the bus state. An emergency physical switch is provided in the hardware to disconnect the test host's CAN connection with a single click.
[0133] Step S233: Result evaluation and optimization.
[0134] In this embodiment, after the test has been running for 12 hours, the test results can be analyzed, including vulnerability discovery, efficiency comparison, model iteration, and other aspects.
[0135] Optionally, for vulnerability discovery, the core task is to proactively identify potential vehicle network vulnerabilities. The plan involves injecting test messages into the bus to monitor and record abnormal behavior of the target ECU, such as whether resets or communication errors occur. Finally, all captured anomalies need to be summarized and analyzed.
[0136] Optionally, for efficiency comparisons, it can be compared with fuzz testing using traditional randomly generated seed files under the same test duration and resources to demonstrate its advantages in improving test efficiency and depth.
[0137] Optionally, for model iteration, the messages that trigger anomalies during the test and their context sequences can be recorded and fed back as new training data to the dataset in step S210 for incremental training of the model in the next round, thereby achieving self-evolution and continuous optimization of the entire system.
[0138] In this embodiment, a generative adversarial network is constructed by building a CAN bus dataset, and then the generative adversarial network is used to perform fuzz testing on the vehicle's communication network security, thereby improving the comprehensiveness and accuracy of the vehicle's communication network testing and solving the technical problem of low accuracy in vehicle communication network security testing.
[0139] This application also provides a vehicle communication security testing device. It should be noted that this vehicle communication security testing device can be used to execute a vehicle communication security testing method according to an embodiment of this application. Figure 5 is a schematic diagram of a vehicle communication security testing device according to an embodiment of this application. As shown in Figure 5, the vehicle communication security testing device 500 may include: a generation unit 501, a sending unit 502, an acquisition unit 503, and a determination unit 504.
[0140] The generation unit 501 is used to respond to the controller of the vehicle under test accessing the simulation test platform through the controller local area network bus, and to call the target generative adversarial network model to generate test cases. The test cases are used to test the controller's response capability to abnormal communication data. The simulation test platform is used to simulate the operating environment of the communication network of the vehicle under test. The target generative adversarial network model is obtained by training the initial generative adversarial network model in advance using communication data samples.
[0141] The sending unit 502 is used to send test cases to the controller via the controller local area network bus at a preset rate.
[0142] The acquisition unit 503 is used to acquire the bus indicators of the controller local area network bus and the response results of the controller. The bus indicators are used to characterize the operating status of the controller local area network bus, and the response results are used to characterize the response behavior of the controller after receiving the test case.
[0143] The determination unit 504 is used to determine the communication security test result of the vehicle under test based on bus indicators and response results, wherein the communication security test result is used to characterize whether the communication network of the vehicle under test is in a secure state.
[0144] In this embodiment of the application, test cases are generated by a pre-trained target generative adversarial network model, which can improve the diversity of test cases. Then, the test cases are sent to the controller through the controller local area network bus. Based on the bus index of the controller local area network bus and the response result of the controller, the communication security test result of the vehicle under test is determined, which can improve the comprehensiveness and accuracy of the vehicle's communication network test, thereby solving the technical problem of low accuracy of vehicle communication network security test.
[0145] Embodiments of this application also provide a vehicle, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods described in various embodiments of this application when it runs.
[0146] Embodiments of this application also provide a computer-readable storage medium including a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to perform the methods of various embodiments of this application.
[0147] Embodiments of this application also provide a computer program product, including a computer program that, when executed by a processor, implements the methods of various embodiments of this application.
[0148] Embodiments of this application also provide a computer program product, including a non-volatile computer-readable storage medium for storing a computer program that, when executed by a processor, implements the methods in various embodiments of this application.
[0149] Embodiments of this application also provide a computer program that, when executed by a processor, implements the methods described in the various embodiments of this application.
[0150] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0151] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0152] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0153] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0154] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the 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 to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0155] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A test method for vehicle communication security, characterized in that, include: The controller of the vehicle under test (VUT) connects to the simulation test platform via the controller local area network (CLAN) bus and calls the target generative adversarial network (GAN) model to generate test cases. These test cases test the controller's response capability to abnormal communication data. The simulation test platform simulates the operating environment of the VUT's communication network. The target GAN model is obtained by pre-training an initial GAN model using communication data samples. The test cases are sent to the controller via the CLAN bus at a preset rate. Bus metrics of the CLAN bus and the controller's response results are obtained. The bus metrics characterize the operating status of the CLAN bus, and the response results characterize the controller's response behavior after receiving the test cases. Based on the bus metrics and the response results, the communication security test result of the VUT is determined, indicating whether the VUT's communication network is in a secure state.
2. The method according to claim 1, characterized in that, The target generative adversarial network model includes a target generator model and a target discriminator model. Generating test cases by calling the target generative adversarial network model includes: calling the target generator model in the target generative adversarial network to generate initial test cases, wherein the initial test cases are communication messages that conform to the Controller Area Network Bus Protocol rules and have variability in structure and content; and expanding the initial test cases to obtain the final test cases.
3. The method according to claim 2, characterized in that, The initial test case is expanded to obtain the test case, which includes at least one of the following: flipping the bits in the communication message corresponding to the initial test case to obtain the test case; The message length of the communication message corresponding to the initial test case is adjusted to obtain the test case; the bits in the communication message corresponding to the initial test case are modified to obtain the test case.
4. The method according to claim 1, characterized in that, Obtaining the bus metrics of the controller local area network (CLAN) bus includes: obtaining the bus load rate of the CLAN bus, wherein the bus load rate is used to characterize the communication busyness level corresponding to the CLAN bus; and obtaining the number of error frames of the CLAN bus, wherein the number of error frames is used to characterize the data transmission quality of the CLAN bus; and determining the bus load rate and the number of error frames as the bus metrics.
5. The method according to claim 4, characterized in that, Based on the bus metric and the response result, the communication security test result of the vehicle under test is determined, including: in response to the bus metric being greater than or equal to a bus metric threshold, and / or in response to the response result indicating that the controller's response behavior after receiving the test case does not match the expected response behavior corresponding to the test case, the communication security test result of the vehicle under test indicates that the communication network of the vehicle under test is not in the secure state; in response to the bus metric being less than the bus metric threshold, and / or in response to the response result indicating that the controller's response behavior after receiving the test case matches the expected response behavior, the communication security test result of the vehicle under test indicates that the communication network of the vehicle under test is in the secure state.
6. The method according to claim 5, characterized in that, The method further includes: in response to a communication security test result of the vehicle under test indicating that the communication network of the vehicle under test is not in the secure state, obtaining a target test case that causes the response behavior of the controller to be inconsistent with the expected response behavior; using the target test case to iteratively train the target generative adversarial network model to obtain an updated target generative adversarial network model.
7. The method according to claim 1, characterized in that, The method further includes: acquiring multiple frames of first communication messages of the vehicle sample under different operating states, and generating multiple frames of second communication messages based on simulation software; determining the multiple frames of first communication messages and the multiple frames of second communication messages as multiple frames of communication data samples, wherein the multiple frames of communication data samples include normal communication data samples and abnormal communication data samples.
8. The method according to claim 7, characterized in that, The method further includes: standardizing the multiple frames of communication data samples to obtain standardized multiple frames of communication data samples, wherein the standardized multiple frames of communication data samples have a fixed data length; clustering the standardized multiple frames of communication data samples based on the identification information corresponding to each of the standardized multiple frames of communication data samples to obtain at least one cluster set, wherein the identification information is used to characterize the sample type to which the communication data sample belongs, and the cluster set corresponds to the sample type; expanding the at least one cluster set to obtain at least one expanded cluster set; adjusting the sequence length of at least one communication data sample in the expanded at least one cluster set based on a preset length to obtain at least one target cluster set, wherein the sequence length of the communication data samples in the target cluster set is equal; and training the initial generative adversarial network model based on the at least one target cluster set to obtain the target generative adversarial network model.
9. The method according to claim 8, characterized in that, Training the initial generative adversarial network (GAN) model based on at least one target cluster set to obtain the target GAN model includes: pre-training the initial generator model in the initial GAN model based on at least one target cluster set to obtain the pre-trained initial generator model; performing adversarial training on the pre-trained initial generator model and the initial discriminator model in the initial GAN model to obtain the trained initial generator model and the trained initial discriminator model; validating the trained initial generator model and the trained initial discriminator model based on a loss function to obtain a validation result; in response to the validation result indicating that the trained initial generator model and the trained initial discriminator model are in a stable state, determining the trained initial generator model as the target generator model and the trained initial discriminator model as the target discriminator model; and determining the target generator model and the target discriminator model as the target GAN model.
10. A vehicle, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, performs the method according to any one of claims 1 to 9.