Method and device for monitoring communication abnormity on automobile bus
The long-short-term memory neural network model is used to identify vehicle bus communication anomalies, which solves the problem that existing technology is difficult to capture complex anomalies and identify types, achieves highly accurate anomaly detection and targeted alarms, and improves troubleshooting and driving safety.
Patent Information
- Application Number
- CN202410835034.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN118740449A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of automobile communication, and in particular to a method and a device for monitoring communication anomalies on an automobile bus. Background Art
[0002] With the rapid development of automotive electronic technology, the automotive bus system, as the core of information transmission within the vehicle, bears the important task of connecting various electronic control units (ECUs) and transmitting key information. However, the automotive bus system faces various potential communication anomaly risks, which may lead to vehicle performance degradation and even endanger driving safety.
[0003] At present, the monitoring methods for automotive bus communication anomalies mainly rely on traditional threshold judgments or simple statistical models. These methods are unable to cope with complex and changeable communication anomalies. Especially when abnormal events are far apart from normal events in time, these methods often find it difficult to capture these long-term dependent relationships, resulting in high false alarm rates or missed alarm rates.
[0004] Moreover, although the existing technology can detect whether there is an abnormality in communication to a certain extent, it is often limited to a "yes" or "no" judgment, and fails to further identify the specific type of abnormality; the limitation of this method is that it cannot provide detailed information about the nature of the abnormality to the driver or maintenance personnel, so it is impossible to take corresponding measures in a targeted manner. For example, communication abnormalities may include data transmission delays, data loss, data errors, illegal access, etc., each type requires a different processing strategy; if the monitoring system can only determine whether there is an abnormality, but cannot identify the specific type of abnormality, then it cannot provide effective guidance for subsequent troubleshooting and repair. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the technical problem to be solved by the present invention is to provide a method and device for monitoring communication anomalies on a vehicle bus based on a long short-term memory neural network model to identify communication anomalies on the vehicle bus and issue an alarm according to the abnormal situation.
[0006] In order to solve the above technical problems, a technical solution adopted by the present invention is: to provide a method for monitoring communication anomalies on a vehicle bus, comprising the following steps:
[0007] Acquire communication data with an abnormal type label, and preprocess the communication data;
[0008] Extracting the ID sequence of messages for a period of time and the time interval sequence of the messages from the preprocessed communication data to obtain sample data;
[0009] Constructing an anomaly recognition model and using the sample data to train and optimize the anomaly recognition model;
[0010] The trained anomaly recognition model is used to identify communication anomalies on the vehicle bus and send corresponding alerts based on the type of communication anomaly.
[0011] Further, the step of preprocessing the communication data includes the following sub-steps:
[0012] Data cleaning, removing or correcting incomplete, erroneous or inconsistent data in communication data;
[0013] Data normalization, scaling the communication data so that it falls into a small specific interval;
[0014] Window partitioning, which divides the communication data into windows of fixed size;
[0015] Target variable encoding ensures that the target data in the communication data is correctly encoded.
[0016] Furthermore, the step of extracting the ID sequence of messages within a period of time and the time interval sequence between the messages from the preprocessed communication data specifically includes the following sub-steps:
[0017] Arrange the preprocessed communication data in chronological order;
[0018] Traversing the communication data, extracting the ID of each message and the corresponding timestamp;
[0019] The extracted message IDs are arranged into a sequence in chronological order to obtain an ID sequence;
[0020] The difference between the timestamps of two adjacent messages is calculated, and all the differences are combined into a sequence according to the message order to obtain a time interval sequence.
[0021] Furthermore, the anomaly recognition model adopts a long short-term memory neural network, including an input layer, a hidden layer and an output layer;
[0022] The input layer is used to input the ID sequence and time interval sequence of the message;
[0023] The hidden layer includes three layers of LSTM units, which are used to learn and extract the time dependency and sequence features in the input data of the input layer. The LSTM units include an input gate, a forget gate, an output gate and a memory cell;
[0024] The output layer includes two fully connected layers for converting the features extracted by the hidden layer into final anomaly category predictions, wherein the anomaly categories include drop attacks, eavesdropping attacks, denial of service attacks, fuzzy attacks, spoofing attacks, replay attacks, and bus shutdown attacks.
[0025] Furthermore, the step of using sample data to train and optimize the anomaly recognition model specifically includes the following sub-steps:
[0026] Divide the sample data into training set and validation set according to a certain ratio;
[0027] Training the anomaly recognition model using the training set data;
[0028] Using the validation set data to evaluate the accuracy, precision, and recall of the trained anomaly recognition model and adjusting hyperparameters according to the evaluation results to optimize the anomaly recognition model, wherein the hyperparameters include the number of training rounds and the learning rate reduction ratio;
[0029] Retrain the model with the adjusted hyperparameters and evaluate the performance of the model again using the validation set.
[0030] Iterate the optimization until the performance of the model meets the requirements.
[0031] Furthermore, the step of training the anomaly recognition model with the training set data specifically includes the following sub-steps:
[0032] Initialization parameters, including weight matrices and bias items corresponding to the input gate, the forget gate, the output gate, and the memory cells, respectively;
[0033] Input the training set data and target data into the input layer, where the target data is the anomaly type corresponding to each message;
[0034] The output of the hidden layer is calculated based on the data of the input training set and passed to the output layer. After classification by the output layer, the prediction result is output;
[0035] Calculate the loss function based on the difference between the prediction result output by the output layer and the target data;
[0036] Calculate the gradient of the loss function with respect to each parameter and use the Adam optimization algorithm to update the parameters according to the calculated gradient;
[0037] Repeat the iterative optimization until the loss on the validation set does not decrease after multiple iterations, the model converges, or the training reaches the preset number of training rounds.
[0038] Furthermore, the step of calculating the output of the hidden layer according to the input training set data specifically includes the following sub-steps:
[0039] Receive data from the input layer and process the data using the input gate, forget gate, output gate, and memory cells to extract the time dependency and sequence features in the data, and pass the processed data to the second-layer LSTM unit;
[0040] Receive the output of the first layer LSTM unit as input, continue to extract deeper temporal dependencies and sequence features, and pass the processed data to the third layer LSTM unit;
[0041] The output of the second layer LSTM unit is received as input, the final sequence features are extracted, and the hidden state of this layer is output, which includes the time dependency and sequence features extracted by the LSTM unit through its gate structure and memory cells.
[0042] Furthermore, the step of using the trained anomaly recognition model to identify communication anomalies on the vehicle bus specifically includes the following sub-steps:
[0043] Receive real-time communication data on the bus and pre-process it;
[0044] Extracting a sequence of IDs of messages over a period of time and a sequence of time intervals of the messages from the preprocessed communication data;
[0045] The extracted ID sequence and time interval sequence are input as input features into the input layer of the trained anomaly recognition model;
[0046] Receiving input feature data of an input layer and processing the input feature data using an input gate, a forget gate, an output gate, and a memory cell to extract time dependency and sequence features in the sequence;
[0047] The softmax activation function is used to convert sequence features into probability distribution. Each probability corresponds to an abnormal category, and the category with the highest probability is selected as the abnormal category of the final output.
[0048] In order to solve the above technical problems, the present invention adopts a technical solution: providing a device for monitoring communication anomalies on a vehicle bus, comprising:
[0049] A preprocessing module, used to obtain communication data with abnormal type labels and preprocess the communication data;
[0050] A feature extraction module is used to extract the ID sequence of messages within a period of time and the time interval sequence of the messages from the communication data preprocessed by the preprocessing module to obtain sample data;
[0051] A model building and training module, used to build an anomaly recognition model and train and optimize the anomaly recognition model using the sample data;
[0052] An identification module, used to identify communication anomalies on the vehicle bus using a trained anomaly identification model;
[0053] The alarm module is used to issue corresponding alarms according to the abnormality type identified by the abnormality identification module.
[0054] Furthermore, the feature extraction module includes:
[0055] A sorting module, used to arrange the pre-processed communication data in chronological order;
[0056] An extraction module, used to traverse the communication data and extract the ID of each message and the corresponding timestamp;
[0057] An ID sequence forming module is used to form a sequence of the extracted message IDs in chronological order to obtain an ID sequence;
[0058] The calculation module is used to calculate the difference between the timestamps of two adjacent messages, and to form a sequence of all the differences according to the message order to obtain a time interval sequence.
[0059] The method and device for monitoring communication anomalies on a vehicle bus of the present invention have at least the following beneficial effects: the present invention can effectively capture various abnormal situations in the communication process by extracting message ID sequences and time interval sequences as input features of the model; by adopting a long short-term memory neural network model, it can effectively capture long-term dependencies in communication data, and even when abnormal events are far apart from normal events in time, communication anomalies can be accurately identified, thereby greatly reducing false alarm rates and missed alarm rates, and improving the accuracy of communication anomaly detection; the present invention can not only detect communication anomalies on the vehicle bus in a timely manner, but also further identify specific anomaly types, and issue corresponding alarms according to the anomaly types, so that the driver or maintenance personnel can quickly and more specifically take corresponding measures, thereby improving the efficiency of troubleshooting and repairing, avoiding vehicle performance degradation or driving safety hazards caused by communication anomalies, and improving driving safety and reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0061] Figure 1 The flowchart is a method for monitoring communication anomalies on a vehicle bus according to an embodiment of the present invention.
[0062] Figure 2 for Figure 1 Flow chart of step S1 in FIG.
[0063] Figure 3 for Figure 1 Flowchart of step S2 in FIG.
[0064] Figure 4 for Figure 1 A flowchart of using the sample data to train and optimize the anomaly recognition model in step S3.
[0065] Figure 5 for Figure 4 Flowchart of step S32 in FIG.
[0066] Figure 6 for Figure 1 Flow chart of using the trained anomaly recognition model in step S4 to identify communication anomalies on the vehicle bus.
[0067] Figure 7 The present invention is a structural block diagram of an embodiment of a device for monitoring communication anomalies on a vehicle bus. DETAILED DESCRIPTION
[0068] The present invention will be further described below in conjunction with the accompanying drawings.
[0069] See also Figure 1 , is a flow chart of an implementation method of a method for monitoring communication anomalies on a vehicle bus of the present invention. This implementation method specifically includes the following steps:
[0070] S1. Acquire communication data with an abnormal type label, and pre-process the communication data.
[0071] In this embodiment, the data packets that have been made public are obtained, and the communication data in them are labeled with abnormal types, which can be directly used for the training of the abnormal identification model in this solution. The abnormal types include discard attacks, eavesdropping attacks, denial of service attacks, fuzzy attacks, spoofing attacks, replay attacks, and bus shutdown attacks. It should be understood that in addition to specific abnormal types, normal messages are also included.
[0072] See also Figure 2 , this step S1 includes the following sub-steps:
[0073] S11. Data cleaning: removing or correcting incomplete, erroneous or inconsistent data in communication data.
[0074] Specifically, delete duplicate data, check and delete duplicate messages in communication data; process missing values, identify missing values in the data (such as missing timestamps or message IDs), and fill them in according to business logic (such as using the previous or next valid value, average, median, etc.) or delete records containing missing values; detect and process outliers, use statistical methods or business rules to detect outliers (such as timestamp anomalies, ID format errors, etc.), and correct or delete them.
[0075] S12: Data normalization: scaling the communication data so that it falls into a small specific interval.
[0076] Specifically, the Z-Score standardization method is used to first calculate the mean μ and standard deviation σ of the time interval series, and then convert each time interval x into (x-μ) / σ. In addition, data standardization also includes: timestamp standardization, ensuring that all timestamps use a unified format and time zone; unit standardization, if the data contains measurements in different units (such as timestamps in seconds, milliseconds or minutes), then convert them to a unified measurement unit.
[0077] S13: Window division: dividing the communication data into windows of fixed sizes.
[0078] Specifically, determine the time window size of the message sequence to be extracted (such as the past 5 minutes, 10 minutes, etc.); divide the continuous communication data into multiple time windows according to the determined time window size, and the data in each window will be used as a sample for subsequent analysis.
[0079] S14: Target variable encoding, ensuring that the target data in the communication data is correctly encoded.
[0080] In this embodiment, the target data is the abnormal type of communication data, which needs to be converted into a numerical form for modeling, and can be encoded using methods such as one-hot encoding or label encoding.
[0081] S2. Extracting an ID sequence of messages within a period of time and a time interval sequence of the messages from the preprocessed communication data to obtain sample data.
[0082] The shape of the sample data is (X1, X2), where X1 represents an ID sequence, for example (000, 44B, 31A, ...), and X2 represents a time interval sequence, for example (0.000247, 0.000256, 0.000245, ...).
[0083] Taking the message ID sequence and time interval sequence as the input features of the model can effectively capture various abnormal situations in the communication process. These features contain not only information about the content of the communication (through the ID sequence), but also information about the communication process (through the time interval sequence). Under normal circumstances, the message ID sequence may show a certain regularity or continuity. For example, in the CAN protocol, the message ID is used for bus arbitration and data filtering, and each sending node usually has its specific ID range. Therefore, if an abnormal change in the ID sequence is detected, such as a sudden interruption, discontinuous jump, or repeated ID, this may indicate a problem with the communication. The change pattern of the message ID can also be used to identify different communication modes. The time interval sequence of the message reflects the rate and rhythm of the communication. Under normal circumstances, the communication traffic may show a certain periodicity or stability. For example, in some applications, messages may be sent at a fixed frequency. By analyzing the time interval sequence, abnormal rate changes such as sudden traffic increase or decrease, irregular jitter, or long delays can be detected.
[0084] See also Figure 3 , this step S2 includes the following sub-steps:
[0085] S21, arranging the preprocessed communication data in chronological order.
[0086] Arrange the preprocessed communication data in chronological order to ensure that the messages are arranged in the order of the time of sending or receiving.
[0087] S22, traverse the communication data, and extract the ID and corresponding timestamp of each message.
[0088] Traverse the sorted communication data and extract the unique ID and corresponding timestamp of each message. The timestamp usually indicates the exact time when the message is sent or received.
[0089] S23. Group the extracted message IDs into a sequence in chronological order to obtain an ID sequence.
[0090] Specifically, an empty ID sequence list is created, and in the process of traversing the communication data, the ID of each message is added to the ID sequence list in chronological order, and finally a message ID sequence arranged in chronological order is obtained.
[0091] S24. Calculate the difference between the timestamps of two adjacent messages, and combine all the differences into a sequence according to the message order to obtain a time interval sequence.
[0092] Specifically, create an empty time interval sequence list, start from the second message, calculate the difference between the timestamp of the current message and the timestamp of the previous message, that is, the time interval; add each calculated time interval to the time interval sequence list in the order of the messages, and finally obtain a time interval sequence arranged in the order of the messages. It should be noted that for the first message, since there is no previous message, it is not necessary (or can be set to 0) to calculate the time interval.
[0093] In this embodiment, in order to ensure the accuracy and completeness of the data, the ID sequence and time interval sequence are also checked to ensure that their lengths are consistent and correspond correctly. If any anomalies or errors are found, such as unreasonable timestamps, repeated IDs, etc., they should be corrected or removed accordingly.
[0094] S3: construct an anomaly recognition model and use the sample data to train and optimize the anomaly recognition model.
[0095] Specifically, the anomaly recognition model adopts a long short-term memory neural network, including an input layer, a hidden layer and an output layer; the input layer is used to input the ID sequence and time interval sequence of the message; the hidden layer includes three layers of LSTM units, which are used to learn and extract the time dependency and sequence features in the input data of the input layer, and the LSTM unit includes an input gate, a forget gate, an output gate and a memory cell; the output layer includes two fully connected layers, which are used to convert the features extracted by the hidden layer into the final anomaly category prediction.
[0096] See also Figure 4 In step S3, the step of using the sample data to train and optimize the anomaly recognition model includes the following sub-steps:
[0097] S31. Divide the sample data into a training set and a validation set according to a certain ratio.
[0098] In this embodiment, the sample data is divided into a training set and a validation set in a ratio of 7:3.
[0099] S32: training the anomaly recognition model using the training set data.
[0100] See also Figure 5 , this step S32 includes the following sub-steps:
[0101] S321. Initialize parameters, which include weight matrices and bias items corresponding to the input gate, the forget gate, the output gate, and the memory cells, respectively.
[0102] Set the initial weights and biases of the input gate, forget gate, output gate, and memory cells, and use the compute_class_weight() function to balance the weights of different categories. Especially when the training data is unbalanced, set the class_weight parameter to 'balanced', which helps the model better learn the features of the minority category.
[0103] S322. Input the training set data and target data into the input layer, where the target data is the abnormality type corresponding to each message.
[0104] S323. Calculate the output of the hidden layer based on the data of the input training set and pass it to the output layer. After classification by the output layer, output the prediction result.
[0105] The specific method for calculating the output of the hidden layer based on the data of the input training set is as follows: receiving the data of the input layer, and using the input gate, forget gate, output gate and memory cells to process the data, extracting the time dependency and sequence features in the data, and passing the processed data to the second layer LSTM unit; receiving the output of the first layer LSTM unit as input, continuing to extract deeper time dependency and sequence features, and passing the processed data to the third layer LSTM unit; receiving the output of the second layer LSTM unit as input, extracting the final sequence features, and outputting the hidden state of this layer, wherein the hidden state includes the time dependency and sequence features extracted by the LSTM unit through its gate structure and memory cells.
[0106] Each layer of LSTM units includes an input gate, a forget gate, an output gate, and a memory cell. The input gate determines the new information that should be stored in the memory cell; the forget gate determines the old information that should be forgotten or retained in the memory cell; the output gate determines the information that should be output based on the state of the memory cell; and the memory cell is used to store the long-term dependencies of the sequence.
[0107] The calculation formula of the forget gate is:
[0108] f t =σ(ω f [h t-1 ;X t ]+b f )
[0109] Among them, f t represents the value of the forget gate, σ represents the sigmoid function, ω f represents the weight matrix of the forget gate, h t-1 represents the hidden state at the previous moment, X t represents the data of the training set input at the current moment, b f Represents the bias term of the forget gate;
[0110] The calculation formula of the input gate is:
[0111] i t =σ(ω i [h t-1 ;X t ]+b i )
[0112] Among them, i t represents the value of the input gate, ω i represents the weight matrix of the input gate, b i represents the bias term of the input gate;
[0113] The calculation formula of the output gate is:
[0114] o t =σ(ω o [h t-1 ;X t ]+b o )
[0115] Among them, t represents the value of the output gate, ω o represents the weight matrix of the output gate, b o Represents the bias term of the output gate.
[0116] The output layer converts the output of the fully connected layer into a probability distribution through the Softmax function, which represents the likelihood of each category.
[0117] S324. Calculate the loss function based on the difference between the prediction result output by the output layer and the target data.
[0118] Calculating the loss function is to calculate the difference between the predicted probability distribution and the actual label. For example, the predicted probability of a denial of service attack is 0.7, the probability of a fuzzy attack is 0.15, the probability of a spoofing attack is 0.1, and the probability of a normal message is 0.05. The label is a denial of service attack. The difference between the predicted probability of a denial of service attack and the actual label is quantified through the loss.
[0119] S325. Calculate the gradient of the loss function with respect to each parameter and use the Adam optimization algorithm to update the parameters according to the calculated gradient.
[0120] S326, repeat iterative optimization until the loss on the validation set does not decrease after multiple iterations, the model converges or the training reaches a preset number of training rounds.
[0121] S33, using the validation set data to evaluate the accuracy, precision and recall of the trained anomaly recognition model and adjusting hyperparameters according to the evaluation results to optimize the anomaly recognition model, wherein the hyperparameters include the number of training rounds and the learning rate reduction ratio.
[0122] In order to alleviate the overfitting problem and make the model converge, in this embodiment, a strategy of dynamically adjusting the learning rate is adopted. When the number of training rounds exceeds 80, the learning rate is reduced to half of the original after every 10 training rounds. The round number setting value and the learning rate reduction ratio are based on observing the training / test loss curve, finding that the curve has a small fluctuation range and a slow decline, estimating the number of training rounds with the best fitting effect, and selecting after multiple value tests.
[0123] S34. Retrain the model using the adjusted hyperparameters and evaluate the performance of the model using the validation set again.
[0124] S35. Iterate the optimization until the performance of the model meets the requirements.
[0125] Repeat steps S33 and S34 to continuously adjust and optimize the model until the performance of the model meets preset requirements or reaches an acceptable level.
[0126] S4. Use the trained anomaly recognition model to identify communication anomalies on the vehicle bus and send corresponding alarms according to the type of communication anomalies.
[0127] See also Figure 6 In step S4, the step of using the trained abnormality recognition model to identify communication abnormalities on the vehicle bus includes the following sub-steps:
[0128] S41, receiving real-time communication data on the bus and preprocessing it.
[0129] Real-time communication data is captured from the vehicle bus and necessary preprocessing is performed on it, including data cleaning (removing outliers or missing values), standardization, window division, and target variable encoding. The specific preprocessing method is the same as steps S11 to S14 and will not be repeated here.
[0130] S42: extracting a sequence of IDs of messages over a period of time and a sequence of time intervals of the messages from the preprocessed communication data.
[0131] S43: Input the extracted ID sequence and time interval sequence as input features into the input layer of the trained anomaly recognition model.
[0132] S44, receiving input feature data of the input layer and using an input gate, a forget gate, an output gate, and a memory cell to process the input feature data, and extracting time dependency and sequence features in the sequence.
[0133] S45. Use the softmax activation function to convert the sequence features into a probability distribution. Each probability corresponds to an abnormal category, and the category with the highest probability is selected as the abnormal category of the final output.
[0134] In the output layer of the model, the softmax function is used to convert the output of the model into a probability distribution, so that the most likely abnormal category can be selected; the softmax function converts the original output of the model into a probability distribution, where the sum of the probabilities of all categories is 1, and based on the probability distribution of the softmax output, the category with the highest probability is selected as the final abnormal detection result. The abnormal categories include discard attacks, eavesdropping attacks, denial of service attacks, fuzzy attacks, spoofing attacks, replay attacks, and bus shutdown attacks. It should be understood that there are also cases where normal messages are output.
[0135] See also Figure 7 , is a structural block diagram of an embodiment of a device for monitoring communication anomalies on a vehicle bus of the present invention. The device for monitoring communication anomalies on a vehicle bus in this embodiment is used to implement the method for monitoring communication anomalies on a vehicle bus as described in the above embodiment. Specifically, the device for monitoring communication anomalies on a vehicle bus in this embodiment includes a preprocessing module 100, a feature extraction module 200, a model building and training module 300, a recognition module 400 and an alarm module 500. Among them:
[0136] The preprocessing module 100 is used to obtain communication data with abnormal type tags and preprocess the communication data.
[0137] The feature extraction module 200 is used to extract the ID sequence of messages for a period of time and the time interval sequence of the messages from the communication data preprocessed by the preprocessing module 100 to obtain sample data. The feature extraction module 200 includes a sorting module 210, an extraction module 220, an ID sequence forming module 230 and a calculation module 240. Among them: the sorting module 210 is used to arrange the preprocessed communication data in chronological order; the extraction module 220 is used to traverse the communication data and extract the ID of each message and the corresponding timestamp; the ID sequence forming module 230 is used to group the extracted message IDs into a sequence in chronological order to obtain an ID sequence; the calculation module 240 is used to calculate the difference between the timestamps of two adjacent messages, and group all the differences into a sequence in the order of the messages to obtain a time interval sequence.
[0138] The model building and training module 300 is used to build an abnormality recognition model and train and optimize the abnormality recognition model with the sample data. The abnormality recognition model includes an input layer, a hidden layer and an output layer; the input layer is used to input the ID sequence and time interval sequence of the message; the hidden layer includes three layers of LSTM units, which are used to learn and extract the time dependency and sequence features in the input data of the input layer, and the LSTM unit includes an input gate, a forget gate, an output gate and a memory cell; the output layer includes two fully connected layers, which are used to convert the features extracted by the hidden layer into the final abnormality category prediction.
[0139] The identification module 400 is used to identify communication anomalies on the vehicle bus using the anomaly identification model trained by the training module 300. The categories of communication anomalies include discard attacks, eavesdropping attacks, denial of service attacks, fuzzy attacks, spoofing attacks, replay attacks, and bus shutdown attacks, and also include normal messages.
[0140] The alarm module 500 is used to issue a corresponding alarm according to the abnormal type identified by the abnormal identification model. The alarm module 500 encrypts the alarm information and sends it to the domain controller, ensuring the security and reliability of the alarm information. After receiving the alarm information, the domain controller will perform corresponding processing, including recording the alarm information, notifying relevant personnel, taking corresponding protective measures, etc.
[0141] In specific implementation, the device for monitoring communication anomalies on the vehicle bus of this solution is integrated into the wiring harness. It only requires replacing the wiring harness and upgrading the domain controller program. The upgrade cost is low and there is no need to change the original device node.
[0142] The present invention can effectively capture various abnormal situations in the communication process by extracting message ID sequences and time interval sequences as input features of the model; by adopting a long short-term memory neural network model, it can effectively capture long-term dependencies in communication data, and even when abnormal events are far apart from normal events in time, communication anomalies can be accurately identified, thereby greatly reducing false alarm rates and missed alarm rates, and improving the accuracy of communication anomaly detection; the present invention can not only detect communication anomalies on the vehicle bus in a timely manner, but also further identify specific anomaly types, and issue corresponding alarms according to the anomaly types, so that drivers or maintenance personnel can quickly and more specifically take corresponding measures, thereby improving the efficiency of troubleshooting and repairing, avoiding vehicle performance degradation or driving safety hazards caused by communication anomalies, and improving driving safety and reliability; by integrating the device for monitoring communication anomalies on the vehicle bus of the present solution into the wiring harness, it is only necessary to replace the wiring harness and upgrade the domain controller program, which is low-cost and does not require changes to the original device nodes.
Claims
1. A method for monitoring communication anomalies on a vehicle bus, It is characterized in that The following steps are involved: Acquire communication data with an abnormal type label, and preprocess the communication data; Extracting the ID sequence of messages for a period of time and the time interval sequence of the messages from the preprocessed communication data to obtain sample data; Constructing an anomaly recognition model and using the sample data to train and optimize the anomaly recognition model; The trained anomaly recognition model is used to identify communication anomalies on the vehicle bus and send corresponding alerts based on the type of communication anomaly.
2. The method for monitoring communication anomalies on a vehicle bus as claimed in claim 1, It is characterized in that The step of preprocessing the communication data includes the following sub-steps: Data cleaning, removing or correcting incomplete, erroneous or inconsistent data in communication data; Data normalization, scaling the communication data so that it falls into a small specific interval; Window partitioning, which divides the communication data into windows of fixed size; Target variable encoding ensures that the target data in the communication data is correctly encoded.
3. The method for monitoring communication anomalies on a vehicle bus as claimed in claim 1, It is characterized in that The step of extracting the ID sequence of messages for a period of time and the time interval sequence between the messages from the pre-processed communication data specifically includes the following sub-steps: Arrange the preprocessed communication data in chronological order; Traversing the communication data, extracting the ID of each message and the corresponding timestamp; The extracted message IDs are arranged into a sequence in chronological order to obtain an ID sequence; The difference between the timestamps of two adjacent messages is calculated, and all the differences are combined into a sequence according to the message order to obtain a time interval sequence.
4. The method for monitoring communication anomalies on a vehicle bus as claimed in claim 1, Features: The anomaly recognition model adopts a long short-term memory neural network, including an input layer, a hidden layer and an output layer; The input layer is used to input the ID sequence and time interval sequence of the message; The hidden layer includes three layers of LSTM units, which are used to learn and extract the time dependency and sequence features in the input data of the input layer. The LSTM units include an input gate, a forget gate, an output gate and a memory cell; The output layer includes two fully connected layers for converting the features extracted by the hidden layer into final anomaly category predictions, wherein the anomaly categories include drop attacks, eavesdropping attacks, denial of service attacks, fuzzy attacks, spoofing attacks, replay attacks, and bus shutdown attacks.
5. The method for monitoring communication anomalies on a vehicle bus as claimed in claim 4, It is characterized in that The step of using sample data to train and optimize the anomaly recognition model specifically includes the following sub-steps: Divide the sample data into training set and validation set according to a certain ratio; Training the anomaly recognition model using the training set data; Using the validation set data to evaluate the accuracy, precision, and recall of the trained anomaly recognition model and adjusting hyperparameters according to the evaluation results to optimize the anomaly recognition model, wherein the hyperparameters include the number of training rounds and the learning rate reduction ratio; Retrain the model with the adjusted hyperparameters and evaluate the performance of the model again using the validation set. Iterate the optimization until the performance of the model meets the requirements.
6. The method for monitoring communication anomalies on a vehicle bus as claimed in claim 5, It is characterized in that The step of training the abnormality recognition model with the training set data specifically includes the following sub-steps: Initialization parameters, including weight matrices and bias items corresponding to the input gate, the forget gate, the output gate, and the memory cells, respectively; Input the training set data and target data into the input layer, where the target data is the anomaly type corresponding to each message; The output of the hidden layer is calculated based on the data of the input training set and passed to the output layer. After classification by the output layer, the prediction result is output; Calculate the loss function based on the difference between the prediction result output by the output layer and the target data; Calculate the gradient of the loss function with respect to each parameter and use the Adam optimization algorithm to update the parameters according to the calculated gradient; Repeat the iterative optimization until the loss on the validation set does not decrease after multiple iterations, the model converges, or the training reaches the preset number of training rounds.
7. The method for monitoring communication anomalies on a vehicle bus as claimed in claim 6, It is characterized in that The step of calculating the output of the hidden layer according to the data of the input training set specifically includes the following sub-steps: Receive data from the input layer and process the data using the input gate, forget gate, output gate, and memory cells to extract the time dependency and sequence features in the data, and pass the processed data to the second-layer LSTM unit; Receive the output of the first layer LSTM unit as input, continue to extract deeper temporal dependencies and sequence features, and pass the processed data to the third layer LSTM unit; The output of the second layer LSTM unit is received as input, the final sequence features are extracted, and the hidden state of this layer is output, which includes the time dependency and sequence features extracted by the LSTM unit through its gate structure and memory cells.
8. The method for monitoring communication anomalies on a vehicle bus as claimed in claim 3, It is characterized in that The step of using the trained anomaly recognition model to identify communication anomalies on the vehicle bus specifically includes the following sub-steps: Receive real-time communication data on the bus and pre-process it; Extracting a sequence of IDs of messages over a period of time and a sequence of time intervals of the messages from the preprocessed communication data; The extracted ID sequence and time interval sequence are input as input features into the input layer of the trained anomaly recognition model; Receiving input feature data of an input layer and processing the input feature data using an input gate, a forget gate, an output gate, and a memory cell to extract time dependency and sequence features in a sequence; The softmax activation function is used to convert sequence features into probability distribution. Each probability corresponds to an abnormal category, and the category with the highest probability is selected as the abnormal category of the final output.
9. A device for monitoring communication anomalies on a vehicle bus, It is characterized in that include: A preprocessing module, used to obtain communication data with abnormal type labels and preprocess the communication data; A feature extraction module is used to extract the ID sequence of messages within a period of time and the time interval sequence of the messages from the communication data preprocessed by the preprocessing module to obtain sample data; A model building and training module, used to build an anomaly recognition model and train and optimize the anomaly recognition model using the sample data; An identification module, used to identify communication anomalies on the vehicle bus using a trained anomaly identification model; The alarm module is used to issue corresponding alarms according to the abnormality type identified by the abnormality identification module.
10. The device for monitoring communication anomalies on a vehicle bus as claimed in claim 9, It is characterized in that The feature extraction module comprises: A sorting module, used to arrange the pre-processed communication data in chronological order; An extraction module, used to traverse the communication data and extract the ID of each message and the corresponding timestamp; An ID sequence forming module is used to form a sequence of the extracted message IDs in chronological order to obtain an ID sequence; The calculation module is used to calculate the difference between the timestamps of two adjacent messages, and to form a sequence of all the differences according to the message order to obtain a time interval sequence.
Citation Information
Patent Citations
Vehicle-mounted bus message processing method and device, vehicle-mounted terminal and storage medium
CN115484059A
CAN-FD anomaly detection method based on time sequence content attention and long and short term memory network
CN117176421A
Method and apparatus for detecting attack in CAN BUS
KR102477705B1
Temporal anomaly detection on automotive networks
US20160188396A1
Cited By
1553 bus data anomaly detection method
CN119420567A
Intelligent networked automobile information safety assessment method, system and equipment
CN122226511A
