CAN bus intrusion detection method based on multi-dimensional feature representation
The CAN bus intrusion detection method based on multi-dimensional feature representation, using sliding window slicing and encoder-classification model, solves the problem of unknown attack detection, realizes efficient and real-time anomaly detection, and improves the detection accuracy and real-time performance of the system.
Patent Information
- Application Number
- CN202510969586.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-15
- Publication Date
- 2025-09-19
AI Technical Summary
The existing vehicle CAN bus intrusion detection system has difficulty detecting unknown attacks, lacks real-time performance and accuracy, and significantly interferes with normal messages, affecting vehicle safety.
A method based on multi-dimensional feature representation is adopted to process CAN bus data through sliding window slicing. Combined with the encoder and classification detection model, real-time anomaly detection is performed, including the identification of no attack, DoS attack, fuzzy attack and unknown attack.
It achieves high-precision and high-speed detection of unknown attacks, can deal with attacks that have not appeared in the training set, improves the real-time performance and accuracy of the detection system, and reduces interference with normal messages.
Smart Images

Figure CN120675795A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data detection technology, and in particular relates to a CAN bus intrusion detection method based on multi-dimensional feature representation. Background Art
[0002] The current problems with vehicle CAN bus intrusion detection systems at home and abroad are: (1) Some detection systems cannot detect unknown attacks and it is difficult to accurately detect and mark all attack messages. (2) Intelligent connected vehicles have extremely high requirements for real-time performance. However, current intrusion detection systems have some shortcomings, including cumbersome operations and interference with normal CAN bus messages, which makes real-time detection difficult. (3) The accuracy of most detection systems is not high, which makes it difficult to ensure the safety of vehicles. Summary of the Invention
[0003] In view of this, the purpose of this application is to provide a CAN bus intrusion detection method based on multi-dimensional feature representation, which can perform real-time anomaly detection with high detection rate, fast speed and high accuracy, and can also deal with unknown attacks that did not appear in the training set.
[0004] This application provides a CAN bus intrusion detection method based on multi-dimensional feature representation, including:
[0005] Using 64 data frames as the window length and 1 data frame as the time step, a sliding window is used to slice the multi-dimensional CAN bus data to obtain fixed-length data frames and corresponding feature vectors containing context features.
[0006] Based on each fixed-length feature vector, after feature extraction using a trained encoder, intrusion type detection is performed using a trained classification detection model; wherein the intrusion types include: no attack, DoS attack, fuzzy attack, gear attack and unknown attack.
[0007] Furthermore, the multi-dimensional CAN bus data includes: an ID consisting of a standard frame with an 11-bit identifier and an extended frame with a 29-bit identifier, a Data consisting of a 64-bit identifier, a DLC represented by a 1-bit decimal, and a Timestamp.
[0008] Furthermore, the multi-dimensional CAN bus data is sliced using a sliding window to obtain a fixed-length data frame and a corresponding feature vector containing context features, including:
[0009] Use sliding windows to slice the multi-dimensional CAN bus data to obtain multiple sequence segments consisting of fixed-length data frames;
[0010] Encode the time difference between the Timestamps of each data frame in the sequence segment to obtain the time difference vector of each data frame;
[0011] For each data frame in the sequence segment, ID, Data, and DLC are converted into binary floating-point vectors respectively, and then fused with the time difference vector to obtain a feature vector containing context features.
[0012] Furthermore, the time difference encoding is performed on the Timestamps between the data frames in the sequence segment to obtain the time difference vectors of the data frames, including:
[0013] The time difference between each data frame in the sequence segment is calculated using the following formula:
[0014] ΔT i =T i -T i-1 , i=1,2,...,L-1;
[0015] Where i represents the i-th time step in the sliding window, L represents the total number of time steps in the sliding window, L = 63;
[0016] The time difference between each data frame is normalized using the following formula:
[0017]
[0018] Where μ ΔT represents the mean of the time difference between each data frame, σ ΔT Indicates the standard deviation of the time difference between each data frame, ΔT norm Represents the normalized value of the time difference between each data frame, where ΔT1 norm =μ ΔT ;
[0019] The normalized value of the time difference between each data frame is used as the time difference vector of each data frame.
[0020] Furthermore, the encoder sequentially sets a padding layer, three convolutional layers and a bottleneck layer along the data transmission direction;
[0021] The encoder is pre-trained by:
[0022] The padding layer is used to make the dimensions of the input fixed-length feature vectors consistent, the convolution layer is used to capture the high-dimensional feature relationship between the fixed-length feature vectors, and the bottleneck layer is used to convert the captured high-dimensional feature relationship into a low-dimensional feature relationship;
[0023] Reconstructing the low-dimensional feature relationship into a high-dimensional feature relationship using a decoder having an inverse feature structure to the encoder;
[0024] The root mean square error between the reconstructed high-dimensional feature relationship and the originally captured high-dimensional feature relationship is calculated, and the root mean square error is used as a loss function to update the parameters of the encoder and decoder until the loss function converges.
[0025] Furthermore, the classification detection model includes: a position encoding module, a sparse attention module, a Transform module and a classification module;
[0026] The classification detection model is pre-trained in the following way:
[0027] Obtain CAN bus data under each intrusion type and obtain the corresponding fixed-length feature vector. Then use the trained encoder to perform feature extraction to obtain a fixed-length low-dimensional feature relationship.
[0028] For each intrusion type, the position encoding module is used to distinguish the order of each time step in the fixed-length low-dimensional feature relationship. The sparse attention module is used to dynamically select global and local attention according to the attention weight of each time step. The Transform module is used to capture global and local dependencies. The classification module integrates the features of the above modules to generate a probability distribution for each intrusion type.
[0029] The cross entropy loss function is used to calculate the difference between the probability distribution of each intrusion type and the actual intrusion type. By penalizing the degree to which the predicted probability deviates from the actual intrusion type, the classification detection model is guided to gradually converge to a better classification boundary during the training process.
[0030] Furthermore, the CAN bus data under each intrusion type is obtained by the following methods:
[0031] Obtain attack-free CAN bus data from the OBD interface of the car;
[0032] Use CANoe to simulate and generate CAN bus data of other intrusion types in the following ways:
[0033] Inject a large number of zero messages as a DoS attack;
[0034] Injecting messages similar to normal data as a fuzzy attack;
[0035] Injecting error messages targeting gear speed as an RPM attack;
[0036] Inject diagnostic attacks and pause attacks without labels as unknown attacks.
[0037] The present application provides a CAN bus intrusion detection method based on multi-dimensional feature representation, which can perform real-time anomaly detection with high detection rate, fast speed and high accuracy, and can also cope with unknown attacks that did not appear in the training set. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A flowchart of a CAN bus intrusion detection method based on multi-dimensional feature representation provided by an embodiment of the present application is shown. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of this technical solution more clear, the following technical solution is further described in detail in conjunction with specific implementation methods. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of this technical solution.
[0040] Please refer to Figure 1 The flowchart of the CAN bus intrusion detection method based on multi-dimensional feature representation is shown in FIG. Figure 1 As shown, the method includes:
[0041] S101. Using 64 data frames as the window length and 1 data frame as the time step, a sliding window is used to slice the multi-dimensional CAN bus data to obtain a fixed-length data frame and a corresponding feature vector containing context features.
[0042] The multi-dimensional CAN bus data includes: an ID consisting of a standard frame with an 11-bit identifier and an extended frame with a 29-bit identifier, a Data consisting of a 64-bit identifier, a DLC represented by a 1-bit decimal, and a Timestamp.
[0043] In this step, a sliding window is used to slice the entire CAN bus data. The sliding window moves frame by frame to obtain continuously covered data frames of fixed length. This ensures that each sliding window can contain a data frame sequence with a period of 64 time steps. At the same time, it enables the subsequent model to capture the temporal context for model training and prediction.
[0044] In specific implementation, a fixed-length data frame and a corresponding feature vector containing context features can be obtained in the following manner:
[0045] Step 1011: Use a sliding window to slice the multi-dimensional CAN bus data to obtain a plurality of sequence segments consisting of fixed-length data frames.
[0046] In this step, using a sliding window to slice the multi-dimensional CAN bus data means that each time step of each sliding window contains multi-dimensional information (ID, Data, DLC, Timestamp) of a data frame, and the multi-dimensional information is used to jointly characterize the characteristics of the data frame at this time step.
[0047] Step 1012: Perform time difference encoding on the Timestamps between the data frames in the sequence segment to obtain a time difference vector for each data frame.
[0048] In this step, in order to solve the problem of large differences in time scales and inconsistency under different sampling rates, time difference encoding is used for Timestamp.
[0049] In specific implementation, the time difference vector of each data frame can be obtained by the following method:
[0050] Step 201: Calculate the time difference between each data frame in the sequence segment using the following formula:
[0051] ΔT i =T i -T i-1 ,i=1,2,...,L-1; (1)
[0052] Where i represents the i-th time step in the sliding window, L represents the total number of L time steps in the sliding window, and L = 63.
[0053] Step 202: Normalize the time difference between each data frame using the following formula:
[0054]
[0055] Where μ ΔT represents the mean of the time difference between each data frame, σ ΔT Indicates the standard deviation of the time difference between each data frame, ΔT norm Represents the normalized value of the time difference between each data frame, where ΔT1 norm =μ ΔT .
[0056] Step 203: Use the normalized value of the time difference between each data frame as the time difference vector of each data frame.
[0057] Step 1013: For each data frame in the sequence segment, convert ID, Data, and DLC into binary floating-point vectors respectively, and fuse them with the time difference vector to obtain a feature vector containing context features.
[0058] In this step, to enable the fusion of the multi-dimensional information of each data frame, each bit of the original ID, Data, and DLC is converted into a floating-point vector. This floating-point vector is simple, direct, and beneficial to the subsequent model's understanding of sequence semantics. It is then fused with the time difference vector to obtain a feature vector containing contextual features.
[0059] S102 : Based on each fixed-length feature vector, after performing feature extraction using a trained encoder, perform intrusion type detection using a trained classification detection model.
[0060] The intrusion types include: no attack, DoS attack, fuzzy attack, gear attack and unknown attack.
[0061] Specifically, the encoder sequentially arranges a padding layer, three convolutional layers and a bottleneck layer along the data transmission direction.
[0062] In a specific implementation, the encoder can be pre-trained in the following manner:
[0063] Step 301: Use the padding layer to make the dimensions of the input fixed-length feature vectors consistent, use the convolution layer to capture the high-dimensional feature relationship between the fixed-length feature vectors, and use the bottleneck layer to convert the captured high-dimensional feature relationship into a low-dimensional feature relationship.
[0064] In this step, the convolutional layer is used to capture the high-dimensional feature relationship between fixed-length feature vectors using the following formula:
[0065]
[0066] Where k h and k w is the height and width of the convolution kernel, Input is the input feature map, Kernel is the convolution kernel weight, Bias is the bias term, and ReLU is the loss function. The specific calculation formula is as follows:
[0067] ReLu(x)=max(0,x). (5)
[0068] Compared to activation functions like Sigmoid and Tanh, the ReLU function doesn't require complex exponential operations, making it faster during training and inference. Furthermore, its gradient in the positive range is always 1 and doesn't decay with increasing network layers, effectively alleviating the vanishing gradient problem and making deep network training more stable. Consider the above operations as a convolutional layer.
[0069] The bottleneck layer after three or more convolution operations is actually also a kind of convolution calculation, except that the convolution kernel is replaced by: Conv2d(384,128,kernel_size=1,stride=1). The main function of this convolution kernel is to compress high-dimensional feature relationships into low-dimensional feature relationships to remove redundant and unimportant information and retain only the most representative key information.
[0070] Step 302: Reconstruct the low-dimensional feature relationship into a high-dimensional feature relationship using a decoder having an inverse feature structure to the encoder.
[0071] In this step, the decoder structure is the reverse engineering of the encoder, and its convolution calculation formula is as follows:
[0072]
[0073] Among them, sigmod is the activation function, and the specific calculation formula is as follows:
[0074]
[0075] Because the goal of the encoder is to reconstruct high-dimensional feature relationships, the high-dimensional feature relationships output by the decoder need to be as close as possible to the high-dimensional feature relationships of the original capture. Using the Sigmoid function can ensure that the decoder output data matches the range of the original capture data, making it easier to calculate the reconstruction error (such as the mean square error).
[0076] Step 303: Calculate the root mean square error between the reconstructed high-dimensional feature relationship and the originally captured high-dimensional feature relationship, and use the root mean square error as a loss function to update the parameters of the encoder and decoder until the loss function converges.
[0077] In this step, the goal of encoder training is to minimize the error between the reconstructed high-dimensional feature relationship and the original captured high-dimensional feature relationship, so that the data representation learned by the model retains important features as much as possible while removing irrelevant information. Therefore, during the training process, this application uses the mean square error as the loss function as shown below:
[0078]
[0079] Where N is the number of samples, Inputi is the original captured high-dimensional feature relationship, and Reconstructedi is the reconstructed high-dimensional feature relationship output by the decoder.
[0080] Using mean square error as the loss function, the smaller the MSE value, the closer the reconstructed high-dimensional feature relationship is to the original captured high-dimensional feature relationship.
[0081] In addition, the backpropagation algorithm is used to update the parameters of the encoder and decoder. That is, the gradient of the loss function with respect to the model parameters is calculated and the optimizer (Adam) is used to update the model parameters. The above steps are repeated until the loss function converges.
[0082] Specifically, the classification detection model includes: a position encoding module, a sparse attention module, a Transform module and a classification module.
[0083] In specific implementation, the classification detection model can be pre-trained in the following ways:
[0084] Step 401: Acquire CAN bus data under each intrusion type and obtain a corresponding fixed-length feature vector, and then use the trained encoder to perform feature extraction to obtain a fixed-length low-dimensional feature relationship.
[0085] In specific implementation, the CAN bus data under each intrusion type can be obtained through the following methods:
[0086] Obtain attack-free CAN bus data from the OBD interface of the car;
[0087] Use CANoe to simulate and generate CAN bus data of other intrusion types in the following ways:
[0088] Inject a large number of zero messages as a DoS attack;
[0089] Injecting messages similar to normal data as a fuzzy attack;
[0090] Injecting error messages targeting gear speed as an RPM attack;
[0091] Inject diagnostic attacks and pause attacks without labels as unknown attacks.
[0092] Step 402: For each fixed-length low-dimensional feature relationship under each intrusion type, the position encoding module is used to distinguish the order of each time step in the fixed-length low-dimensional feature relationship, the sparse attention module is used to dynamically select global and local attention according to the attention weight of each time step, the Transform module is used to capture the global and local dependencies, and the classification module is used to integrate the features of the above modules to generate a probability distribution of each intrusion type.
[0093] In this step, the position encoding module uses sine and cosine encoding. Its main purpose is to help the model distinguish the order of each time step in the fixed-length low-dimensional feature relationship, so as to help the model capture the temporal dependency. Specifically, the sine and cosine encoding formula is as follows:
[0094]
[0095] Where, PE (pos,2i) Represents the encoded value of the i-th dimension at the pos-th time step, where pos is the position of the time step, i is the feature dimension index (such as 0-255), and d is the dimension of the feature vector (such as 256).
[0096] In the above formulas, the inputs to the sine and cosine functions determine their frequencies. For example, sin(x) will repeat periodically as x increases. The denominator in the formula is 10000. 2i / d The frequency variation range is controlled. When i = 0, the frequency is the lowest (corresponding to a larger period); as i increases, the frequency gradually increases (corresponding to a smaller period). 10000 as the cardinality allows the low-dimensional encoding of the feature vector to capture the global pattern of long time steps (low-frequency changes), and the high-dimensional encoding to capture the local details of short time steps (high-frequency changes). If the cardinality is too small, when the position value grows rapidly, the change in high-dimensional frequency will be too drastic, resulting in the model being unable to capture the relationship between distant time steps. If the cardinality is too large, the frequency difference between adjacent time steps in the sequence will become too small, and the position encoding will be less sensitive to close-range steps.
[0097] Furthermore, the exponential scaling 2i / d dynamically adjusts the denominator based on the feature dimension d: when i is small, the denominator is close to 1, and the input variation of sin and cos is large (capturing local high-frequency features). When i is large, the denominator becomes larger and the input variation is small (capturing global low-frequency features). The base of 10,000 allows this scaling mechanism to change smoothly while covering both global and local information.
[0098] In the existing technology, the traditional attention mechanism calculation formula is as follows:
[0099]
[0100] Where Q, K, and V are the query, key, and value matrices, respectively. If the dimension is [Q, K], then the dot product of Q at all time steps and K at all time steps needs to be calculated: A = QK T , where Q is a matrix of shape [L, d], with a d-dimensional vector for each time step, and K T It is a transposed matrix of shape [d, L], and the dot product calculation result is an attention matrix A of shape [L, L], with a complexity of O(L 2 ). Most values in the attention matrix are insignificant (close to 0), and only a small number of highly relevant values contribute to the final result.
[0101] Therefore, this application adopts a probabilistic method, that is, according to the query norm or other heuristic rules, a part of "important queries" is screened out, and only the attention weights corresponding to these "important queries" are calculated, while other queries are ignored. In this way, the attention matrix A changes from the original fully connected [L, L] to a sparse [L, k], where k << L (usually k = log L), to achieve dynamic selection of global and local attention. The specific steps include:
[0102] Step 1: Calculate the probability distribution of attention weights: For each query, a softmax operation can be used to calculate its attention weight distribution to determine which keys the query should focus on. This attention weight distribution can be achieved through the following probability calculation:
[0103]
[0104] Where, P ij It represents the correlation between the i-th Query and the j-th Key, that is, the probability of attention allocation.
[0105] Step 2: Select global and local attention: Calculate the probability of correlation between the query and the local neighborhood for each time step, and select the time step with the larger probability value for calculation.
[0106] Here, it is possible to dynamically select important global time steps, such as the start and end of the sequence and the time steps where abnormal signals are located.
[0107] Through the above probability distribution, we can determine which keys the query of each time step should interact with. At this time, the attention matrix becomes sparse, that is, only a part of the elements are non-zero, and the other elements are zero. Local attention is obtained in the following way: for each query, attention is calculated only for the k time steps adjacent to it, and the correlation of other time steps is zero. Global attention is obtained in the following way: several globally important time steps (such as outliers) are selected to interact with all time steps, and the correlation of other time steps is still zero. Therefore, the final attention matrix is a sparse matrix that contains key local and global dependencies. The computational complexity is reduced from the traditional O(L 2 ) is reduced to O(L·k).
[0108] Furthermore, the sparse attention module's targeted attention calculation enables the Transformer module to break through the limitations of sequence length and is very effective in processing large-scale data. The specific operations and functions of the Transformer module and the classification module are as follows:
[0109] The core function of the Transformer module is to transform the input sequence into a context-sensitive feature representation through the sparse attention module and feedforward network described above, capturing global and local dependencies, thereby providing efficient and accurate input for subsequent tasks (anomaly detection).
[0110] The classification module is the last layer of the classification task, specifically including: fully connected layer and Softmax activation function, their functions are as follows: the fully connected layer is used to integrate the features of the input data and generate scores for each category; the Softmax activation function is used to convert these scores into probability distributions, thereby intuitively indicating the possibility that the input belongs to each category, thus completing the multi-classification target detection task. Among them, the calculation formula of the Softmax function is as follows:
[0111]
[0112] Step 403: Calculate the difference between the probability distribution of each intrusion type and the actual intrusion type using the cross entropy loss function, and guide the classification detection model to gradually converge to a better classification boundary during the training process by penalizing the degree to which the predicted probability deviates from the actual intrusion type.
[0113] In this step, in order to improve the model's discriminative ability in multi-classification tasks, the classification module uses the following cross-entropy loss function (Cross-EntropyLoss) as the main training objective function: ; (13)
[0115]
[0116] Cross-entropy loss can effectively measure the difference between the probability distribution of each intrusion type output by the model and the actual intrusion type. By penalizing the degree to which the predicted probability deviates from the actual intrusion type, it guides the model to gradually converge to a better classification boundary during the training process.
[0117] In this application, the classifier receives the high-dimensional time series representation or potential feature representation output by the front module (such as encoder, Transformer), and finally outputs the predicted probability corresponding to all intrusion types (such as normal, DoS, Fuzzy, etc.). In each training step, the cross-entropy loss function calculates the gradient and back-propagates according to the difference between the predicted result and the actual intrusion type, thereby continuously optimizing the model parameters. The use of the cross-entropy loss function not only helps to improve the model's ability to accurately classify known attack types, but also enhances the model's discrimination effect on boundary samples and confused categories. It is particularly suitable for scenarios with uneven category distribution or diverse forms of attack behavior.
[0118] The final prediction module is also implemented by a simple linear layer (hereinafter referred to as MLP, multi-layer perceptron). The MLP structure is: input → linear layer → activation function → linear layer → output, that is, a simple two-layer MLP:
[0119] f pred (z)=W2·ReLu(W1z+b1)+b2; (15)
[0120] The input is the context representation vector z output by Transformer. Compared with a single linear layer, MLP can model complex nonlinear relationships and extract features based on the current context to predict the next state of the time series. Once x is predicted, t+1 It can be compared with the true value to generate the corresponding prediction error. The prediction error in this example is implemented using the mean square error as the prediction error:
[0121]
[0122] The prediction error generated is linearly weighted with the reconstruction error generated by the encoder, that is:
[0123] Anomaly Scor(t)=α×e rec (t)+β×e pred (t); (17)
[0124] During actual model operation, its core detection mechanism relies on the calculation and determination of anomaly scores. This score is typically defined and quantified by learning the reconstruction error, prediction error, or other statistical metrics of normal samples in the feature space, based on training the model exclusively on normal data. During the training phase, the model automatically establishes a scoring mechanism to measure whether the input conforms to normal behavior patterns, thereby forming a baseline anomaly threshold range.
[0125] The above content is only a preferred embodiment of the present invention. For ordinary technicians in this field, many changes can be made in the specific implementation methods and application scopes based on the ideas of the present technical content. As long as these changes do not deviate from the concept of the present invention, they all fall within the scope of protection of the present invention.
Claims
1. A CAN bus intrusion detection method based on multi-dimensional feature representation, characterized in that: The method comprises: Using 64 data frames as the window length and 1 data frame as the time step, a sliding window is used to slice the multi-dimensional CAN bus data to obtain fixed-length data frames and corresponding feature vectors containing context features. Based on each fixed-length feature vector, after feature extraction using a trained encoder, intrusion type detection is performed using a trained classification detection model; wherein the intrusion types include: no attack, DoS attack, fuzzy attack, gear attack and unknown attack.
2. The method according to claim 1, wherein The multi-dimensional CAN bus data includes: an ID consisting of a standard frame with an 11-bit identifier and an extended frame with a 29-bit identifier, a Data consisting of a 64-bit identifier, a DLC represented by a 1-bit decimal, and a Timestamp.
3. The method according to claim 2, wherein The method of using a sliding window to slice the multi-dimensional CAN bus data to obtain a fixed-length data frame and a corresponding feature vector containing context features includes: Use sliding windows to slice the multi-dimensional CAN bus data to obtain multiple sequence segments consisting of fixed-length data frames; Encode the time difference between the Timestamps of each data frame in the sequence segment to obtain the time difference vector of each data frame; For each data frame in the sequence segment, ID, Data, and DLC are converted into binary floating-point vectors respectively, and then fused with the time difference vector to obtain a feature vector containing context features.
4. The method according to claim 3, wherein The time difference encoding is performed on the Timestamps between the data frames in the sequence segment to obtain the time difference vectors of the data frames, including: The time difference between each data frame in the sequence segment is calculated using the following formula: ΔT i =T i -T i-1 ,i=1,2,...,L-1; Where i represents the i-th time step in the sliding window, L represents the total number of time steps in the sliding window, L = 63; The time difference between each data frame is normalized using the following formula: Where μ ΔT represents the mean of the time difference between each data frame, σ ΔT Indicates the standard deviation of the time difference between each data frame, ΔT norm Represents the normalized value of the time difference between each data frame, where ΔT1 norm =μ ΔT ; The normalized value of the time difference between each data frame is used as the time difference vector of each data frame.
5. The method according to claim 1, wherein The encoder sequentially sets a padding layer, three convolutional layers and a bottleneck layer along the data transmission direction; The encoder is pre-trained by: The padding layer is used to make the dimensions of the input fixed-length feature vectors consistent, the convolution layer is used to capture the high-dimensional feature relationship between the fixed-length feature vectors, and the bottleneck layer is used to convert the captured high-dimensional feature relationship into a low-dimensional feature relationship; Reconstructing the low-dimensional feature relationship into a high-dimensional feature relationship using a decoder having an inverse feature structure to the encoder; The root mean square error between the reconstructed high-dimensional feature relationship and the originally captured high-dimensional feature relationship is calculated, and the root mean square error is used as a loss function to update the parameters of the encoder and decoder until the loss function converges.
6. The method according to claim 1, wherein The classification detection model includes: a position encoding module, a sparse attention module, a Transform module and a classification module; The classification detection model is pre-trained in the following way: Obtain CAN bus data under each intrusion type and obtain the corresponding fixed-length feature vector. Then use the trained encoder to perform feature extraction to obtain a fixed-length low-dimensional feature relationship. For each intrusion type, the position encoding module is used to distinguish the order of each time step in the fixed-length low-dimensional feature relationship. The sparse attention module is used to dynamically select global and local attention according to the attention weight of each time step. The Transform module is used to capture global and local dependencies. The classification module integrates the features of the above modules to generate a probability distribution for each intrusion type. The cross entropy loss function is used to calculate the difference between the probability distribution of each intrusion type and the actual intrusion type. By penalizing the degree to which the predicted probability deviates from the actual intrusion type, the classification detection model is guided to gradually converge to a better classification boundary during the training process.
7. The method according to claim 6, wherein The CAN bus data under each intrusion type is obtained through the following methods: Obtain attack-free CAN bus data from the OBD interface of the car; Use CANoe to simulate and generate CAN bus data of other intrusion types in the following ways: Inject a large number of zero messages as a DoS attack; Injecting messages similar to normal data as a fuzzy attack; Injecting error messages targeting gear speed as an RPM attack; Inject diagnostic attacks and pause attacks without labels as unknown attacks.
Citation Information
Cited By
CAN bus attack intrusion detection method based on self-attention mechanism
CN121585464A