Internet of vehicles intrusion detection method and system based on mask strip convolutional autoencoder

CN122457385BActive Publication Date: 2026-08-21HUNAN UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610931009.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-26
Publication Date
2026-08-21
Estimated Expiration
2046-06-26

AI Technical Summary

Technical Problem

[0005]有鉴于此,本发明提供基于掩码条带卷积自编码器的车联网入侵检测方法及系统,解决现有CAN入侵检测方法存在的依赖大量标注数据、对丢帧和噪声鲁棒性不足、难以有效建模payload字段关联和跨帧上下文关系、模型计算复杂度较高以及不适合车载边缘设备部署的问题,能够充分利用未标注CAN数据学习有效特征,并且满足车载边缘设备对轻量化、低时延和低存储开销的要求

Benefits of technology

本发明将连续CAN payload字节转换为二维灰度图像,并使该二维灰度图像中的区域与payload字段、单帧payload和连续帧段形成对应关系,为后续结构化掩码和方向性卷积操作提供了与车载总线通信特性相匹配的数据基础;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122457385B_ABST
    Figure CN122457385B_ABST
Patent Text Reader

Abstract

The application relates to a vehicle networking intrusion detection method and system based on a mask strip convolution autoencoder, which comprises the following steps: converting payload bytes of continuous CAN data frames into a CAN payload grayscale image; generating a block level, frame level or continuous frame mask area and filling the same by using an information amount guided multi-mode mask generator; inputting the mask input image into a mask strip convolution autoencoder for self-supervised reconstruction training; the encoder extracts local byte disturbance, time direction continuous change and cross-field interframe coupling features through a strip convolution module facing the CAN frame structure; calculating a reconstruction loss taking the masked area as a main object and updating parameters; removing the decoder after training, retaining the encoder and connecting a lightweight classification head; and outputting an intrusion detection result by the encoder and the classification head in the deployment stage; the application reduces the dependence on labeled data, enhances the robustness to frame loss, noise and continuous abnormal injection, and meets the lightweight deployment requirements of a vehicle-mounted edge device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of vehicle network security technology, and in particular to a method and system for vehicle network intrusion detection based on a masked stripe convolutional autoencoder. Background Technology

[0002] With the rapid development of intelligent connected vehicles and autonomous driving technology, a large number of electronic control units (ECUs) are deployed inside vehicles. These ECUs typically communicate via the Controller Area Network (CAN) bus to perform key functions such as braking, steering, engine control, and vehicle body control. Due to its low cost, low latency, and broadcast communication characteristics, the CAN bus is widely used in vehicle networks. However, the CAN protocol was not designed with network security requirements in mind and lacks robust authentication, message encryption, and source node verification mechanisms. Once attackers access the vehicle network through the On-Board Diagnostics (OBD) interface, wireless communication interface, or compromised ECUs, they can forge CAN messages and inject malicious data into the bus, thereby triggering denial-of-service attacks, obfuscation attacks, replay attacks, or deception attacks targeting specific functions. These attacks can cause abnormal vehicle control and, in severe cases, threaten the safety of occupants and the road.

[0003] Traditional supervised learning methods typically rely on a large number of labeled attack samples, but attack events are rare in real vehicle network environments, and obtaining large-scale, high-quality labeled data is costly. Some unsupervised or semi-supervised methods use symmetric autoencoders to reconstruct the complete input and use reconstruction loss for anomaly detection. However, reconstructing the complete input as a whole can easily lead the model to learn local textures or low-order statistical features, and cannot fully model the contextual consistency between CAN payload fields and between consecutive messages.

[0004] In addition, in-vehicle edge devices are usually subject to strict limitations in computing resources, storage resources, and response latency. Although Transformer, graph neural networks, or large-scale pre-trained models can capture long-distance dependencies, their model parameter count, training overhead, and inference overhead are high, which is not conducive to rapid deployment and long-term maintenance in vehicles. Especially when changes in vehicle model, firmware version, driving conditions, and time cause data distribution drift, overly complex models are difficult to update frequently. Summary of the Invention

[0005] In view of this, the present invention provides a vehicle network intrusion detection method and system based on a masked stripe convolutional autoencoder, which solves the problems of existing CAN intrusion detection methods, such as reliance on a large amount of labeled data, insufficient robustness to frame loss and noise, difficulty in effectively modeling payload field associations and cross-frame context relationships, high model computational complexity, and unsuitability for deployment in vehicle edge devices. It can make full use of unlabeled CAN data to learn effective features and meet the requirements of vehicle edge devices for lightweight, low latency and low storage overhead.

[0006] To achieve the above objectives, the present invention provides a vehicle network intrusion detection method based on a masked stripe convolutional autoencoder, comprising the following steps: S1. Obtain continuous CAN data frames on the vehicle CAN bus and extract data field payload bytes from the CAN data frames; S2. The payload bytes of consecutive L CAN data frames are arranged into a sliding window sample in chronological order. The sliding window sample is normalized and then rearranged into a CAN payload grayscale image. The correspondence between the pixel position in the CAN payload grayscale image and the payload field number, CAN frame number and cross-line continuation position is determined. S3. Generate a mask matrix for the grayscale image of the CAN payload using an information-guided multi-mode mask generator, and fill the mask matrix using a preset filling strategy to obtain the mask input image. S4. Input the masked input image into a masked stripe convolutional autoencoder for self-supervised reconstruction training; The mask strip convolutional autoencoder includes an encoder and a decoder. The encoder includes at least one strip convolutional module oriented towards the CAN frame structure. The strip convolutional module includes a local convolutional branch, a first-direction strip convolutional branch, a second-direction strip convolutional branch, and a channel fusion branch. S401. Input the masked input image into the encoder to obtain the latent feature representation; S402. Input the latent feature representation into the decoder to obtain the reconstructed image; S403. Calculate the reconstruction loss of the masked strip convolutional autoencoder based on the difference between the reconstructed image and the original CAN payload grayscale image in the masked region; The reconstruction loss is mainly calculated based on the masked region, and the masked strip convolutional autoencoder recovers the masked fields, single frames or continuous frame regions based on the unmasked payload context. S404. Update the parameters of the masked stripe convolutional autoencoder of the encoder and decoder based on the reconstruction loss; S5. After completing the self-supervised reconstruction training, remove the decoder, retain the encoder obtained by the mask reconstruction training and connect it to the lightweight classification head, and use the labeled CAN samples to train the lightweight classification head or fine-tune the encoder and the lightweight classification head. S6. During the vehicle deployment phase, the CAN data frame to be detected is converted into a grayscale image of the CAN payload and then input into the encoder and the lightweight classification head. The encoder extracts the CAN field association and cross-frame context features, and the lightweight classification head outputs the intrusion detection results of normal category or attack category.

[0007] Preferably, payload data is extracted from each CAN data frame using an on-board intrusion detection device, and the payload data includes 8 bytes.

[0008] Preferably, obtaining the grayscale image of the CAN payload specifically includes the following steps: S201. Select L consecutive CAN data frames in chronological order to form a sliding window sample. Each CAN data frame includes B payload bytes. Expand the L×B bytes into a one-dimensional vector in chronological order. S202. Normalize all payload bytes to obtain the value range. The normalized vector; S203. The normalized vector is rearranged into a two-dimensional grayscale matrix of H×W, where H×W=L×B, to obtain the grayscale image of the CAN payload.

[0009] Preferably, generating the masked input image specifically includes the following steps: S301. The grayscale image of the CAN payload is preprocessed and divided into candidate regions to obtain multiple candidate regions to be evaluated; When using block-level masking, the grayscale image of the CAN payload is divided into multiple... Image patches are processed, and each image patch is considered as a block-level candidate region. The side length of the image patch is a preset positive integer, expressed in pixels. Represents a square area composed of rows and columns of pixels; When using frame-level masking or continuous frame masking, the payload byte region corresponding to a CAN data frame is taken as a frame-level candidate region or a continuous candidate region. S302. Calculate the information content score of each candidate region, and determine the importance of the corresponding candidate region based on the information content score; The variance of pixel values ​​within an image block in the block-level candidate region is calculated as the information content score, and the variance of pixel values ​​within a payload byte region in the frame-level candidate region or continuous candidate region is calculated as the information content score. S303. The basic sampling probability of the candidate region is obtained by using power-law normalization, and the basic sampling probability is mixed with a uniform distribution to obtain the final sampling probability. The expression for the basic sampling probability is: ; in, Indicates the first The base sampling probability of each candidate region , They represent the first , Information score of each candidate region A parameter that controls the degree of attention given to high-information regions. This represents a constant that prevents division by zero. Indicates the number of candidate regions; The expression for the final sampling probability is: ; in, Indicates the first The final sampling probability of each candidate region This represents a parameter that controls the mixing ratio of uniform sampling. S304. Select candidate regions to be masked according to the final sampling probability, and generate a mask matrix by combining at least one of block-level masking, frame-level masking, and continuous frame masking. S305. The mask matrix is ​​filled using a preset filling strategy to obtain the mask input image.

[0010] Preferably, the preset padding strategy includes zero padding, mean padding, random noise padding, and random byte padding; The zero-value padding sets the pixel values ​​of the masked region to 0; The mean filler sets the pixel values ​​of the masked region to the pixel mean of the current CAN payload grayscale image; The random noise filling is to replace the pixel values ​​of the masked area with random noise in the range of 0 to 1. The random byte filling is to generate random byte values ​​in the range of 0 to 255 and fill them into the masked area after normalization.

[0011] Preferably, the reconstruction loss includes the reconstruction loss of the masked region and a weighted reconstruction regularization term for the unmasked region, and the expression for the reconstruction loss of the masked region is: ; in, This represents the original CAN payload grayscale image. Represents the mask matrix, Indicates the reconstructed image. This indicates that the corresponding pixel is masked. A constant that prevents division by zero; The total loss expression after adding the weighted reconstruction regularization term for the unmasked region is: ; in, This indicates the weight of the regularization term for the unmasked region, and It is a constant less than 1.

[0012] Preferably, the local convolution branch is used to extract local byte perturbation features in the grayscale image of the CAN payload, and a 3×3 convolution is used; The first directional strip convolution branch is used to extract contextual features along the CAN message time unwinding direction, and a 1×k strip convolution is used. The second directional strip convolution branch is used to extract inter-frame coupling features in the cross-line continuation direction or cross-field direction, and k×1 strip convolution is used. The channel fusion branch is used to fuse the features output by the local convolution branch, the first direction strip convolution branch, and the second direction strip convolution branch, and adopts 1×1 point convolution.

[0013] Preferably, the lightweight classification head includes a global average pooling layer, a first fully connected layer, a ReLU activation layer, and a second fully connected layer; The feature map output by the encoder is converted into a one-dimensional feature vector after global average pooling. It is then mapped to the hidden space through the first fully connected layer, and finally output as a classification result through the second fully connected layer.

[0014] This invention also provides a vehicle network intrusion detection system based on a masked stripe convolutional autoencoder, comprising: The data conversion module is used to acquire continuous CAN data frames on the vehicle CAN bus, extract payload bytes from the CAN data frames, and convert the continuous L frames of payload bytes into a CAN payload grayscale image. A mask generation module is used to generate a mask region based on an information-guided multi-mode mask generator, and fill the mask region with a preset filling strategy to obtain a mask input image; wherein, the mask region includes at least one of block-level mask, frame-level mask, and continuous frame mask; The reconstruction training module is used to perform self-supervised reconstruction training on the masked input image using a masked stripe convolutional autoencoder, and update the encoder and decoder parameters according to the difference between the reconstructed image and the original CAN payload grayscale image; wherein, the encoder includes at least one stripe convolutional module oriented towards the CAN frame structure, the stripe convolutional module includes a local convolutional branch, a first-direction stripe convolutional branch along the CAN message time unrolling direction, a second-direction stripe convolutional branch along the cross-line continuation direction or cross-field direction, and a channel fusion branch; The classification and detection module is used to retain the encoder after completing the self-supervised reconstruction training, connect to a lightweight classification head, and output the normal category or attack category based on the contextual features output by the encoder.

[0015] Preferably, the mask generation module is specifically used for: The grayscale image of the CAN payload is divided into candidate regions, and the information content score of each candidate region is calculated. The basic sampling probability is obtained by power-law normalization and then mixed with a uniform distribution to obtain the final sampling probability. Based on the final sampling probability, candidate regions to be masked are selected, and a mask matrix including at least one of block-level mask, frame-level mask, or continuous frame mask is generated.

[0016] Compared with the prior art, the beneficial effects of the present invention are: This invention converts continuous CAN payload bytes into a two-dimensional grayscale image and establishes a correspondence between the regions in the two-dimensional grayscale image and the payload field, single-frame payload, and continuous frame segments, providing a data foundation that matches the characteristics of vehicle bus communication for subsequent structured masking and directional convolution operations. This invention employs an information-driven multi-mode mask generator, which dynamically selects block-level masks, frame-level masks, or continuous frame masks based on the information content score (pixel variance) of the candidate region. This effectively simulates real-world vehicle bus disturbance scenarios such as missing local fields, single-frame dropping, continuous frame dropping, bus congestion, and continuous malicious injection, enhancing the model's ability to model real abnormal patterns. This invention's self-supervised reconstruction task uses the masked region as the main reconstruction object, forcing the model to rely on the unmasked payload context to infer missing fields, single-frame or multi-frame content, thereby learning more stable and discriminative inter-field correlations and cross-frame context consistency features, avoiding the problem of the model only copying local low-level statistical features. At the same time, through self-supervised mask reconstruction pre-training, this invention enables the model to learn effective features from a large amount of unlabeled CAN data, requiring only a small number of labeled samples to complete the training or fine-tuning of the classification head, greatly reducing the cost of obtaining and labeling vehicular network attack samples, and is suitable for real-world environments where attack samples are sparse. The strip convolution module for CAN frame structure adopted in this invention can capture local byte perturbations, lateral temporal dependencies and longitudinal inter-frame coupling relationships at a low computational cost through local convolution, strip convolution along the time unfolding direction (1×k) and along the cross-field direction (k×1) and channel fusion branch. This significantly improves the anomaly detection accuracy and generalization performance, and enhances the adaptability to operating condition drift. Attached Figure Description

[0017] Figure 1 This is a schematic diagram of the vehicle network intrusion detection method based on masked stripe convolutional autoencoder provided by the present invention; Figure 2 This is a schematic diagram of the intrusion detection method for vehicle networks based on a masked stripe convolutional autoencoder provided by the present invention. Figure 3 A schematic diagram illustrating the conversion of CAN payload bytes into a two-dimensional grayscale image provided by this invention; Figure 4 A schematic diagram of the information-guided multi-mode mask generator process provided by the present invention; Figure 5 A schematic diagram of the training process of the masked stripe convolutional autoencoder provided by the present invention; Figure 6 A schematic diagram of the strip convolution module structure for CAN frame structure provided by the present invention; Figure 7 This is a schematic diagram of the asymmetric encoder-decoder structure provided by the present invention; Figure 8 A schematic diagram of the deployment structure of the encoder and lightweight classification head provided by the present invention; Figure 9 This is a block diagram of the vehicle network intrusion detection system based on a masked stripe convolutional autoencoder provided by the present invention. Detailed Implementation

[0018] To further illustrate the technical means and effects of the present invention in achieving its intended purpose, the following detailed description of the specific implementation methods, structures, features, and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.

[0019] Example 1 like Figure 1 , Figure 2 As shown, this embodiment provides a vehicle network intrusion detection method based on a masked stripe convolutional autoencoder, which can be applied to vehicle gateways, domain controllers, T-Boxes, OBD security monitoring devices, vehicle edge computing devices, or other vehicle intrusion detection devices, and includes the following steps: S1, such as Figure 3As shown in Table 1, the payload data is extracted from each CAN data frame by the vehicle-mounted intrusion detection device, and the data field payload bytes are extracted from the CAN data frame. Table 1. Examples of CAN payloads:

[0020] For a standard CAN data frame, the payload data typically consists of 8 bytes, denoted as... to Each byte can be represented by two hexadecimal digits and can be converted to a decimal value in the range of 0 to 255.

[0021] S2. The payload bytes of consecutive L CAN data frames are arranged into a sliding window sample in chronological order. The sliding window sample is normalized and then rearranged into a CAN payload grayscale image. The correspondence between the pixel position in the CAN payload grayscale image and the payload field number, CAN frame number and cross-line continuation position is determined. S201. Select L consecutive CAN data frames in chronological order to form a sliding window sample. Each CAN data frame includes B payload bytes. Expand the L×B bytes into a one-dimensional vector in chronological order. S202. Normalize all payload byte values ​​by dividing by 255 to obtain the value range. The normalized vector; S203. The normalized vector is rearranged into a two-dimensional grayscale matrix of H×W, where H×W=L×B, to obtain a grayscale image of the CAN payload. In this embodiment, L=128, B=8, H=W=32, that is, the 1024 payload bytes in 128 CAN data frames are converted into a 32×32 grayscale image of the CAN payload. After processing in step S2, each pixel in the CAN payload grayscale image corresponds to a payload byte in a CAN data frame at a certain time. This grayscale image is not an ordinary natural image, but a structured mapping of continuous CAN messages in the time and field dimensions, thereby preserving the payload byte content and the contextual relationship between continuous messages. At the same time, this mapping can be used to determine block-level candidate regions, single-frame payload candidate regions, and continuous multi-frame payload candidate regions, so that the subsequent mask region corresponds to the CAN communication structure. For generating labels for training samples, when all CAN data frames within a sliding window are normal samples, the grayscale image of the CAN payload corresponding to that sliding window is labeled as the normal category; when the sliding window contains attack samples, the grayscale image of the CAN payload corresponding to that sliding window is labeled as the corresponding attack category.

[0022] S3, such as Figure 4 As shown, a mask matrix of the grayscale image of the CAN payload is generated by an information-guided multi-mode mask generator, and the mask matrix is ​​filled with a preset filling strategy to obtain the mask input image. That is, the information-guided multi-mode mask generator takes a pre-processed grayscale image of the CAN payload as input and outputs a mask matrix with the same size as the grayscale image of the CAN payload; the mask matrix is ​​used to indicate the occluded areas in subsequent self-supervised reconstruction training; S301. The grayscale image of the CAN payload is preprocessed and divided into candidate regions to obtain multiple candidate regions to be evaluated; When using block-level masking, the grayscale image of the CAN payload is divided into multiple... Image patches are processed, and each image patch is considered as a block-level candidate region. The side length of the image block is a preset positive integer, determined based on the dimensions H×W of the CAN payload grayscale image and the mask granularity, and is expressed in pixels. Represents a square area composed of rows and columns of pixels; When using frame-level masking or continuous frame masking, the payload byte region corresponding to a CAN data frame is taken as a frame-level candidate region or a continuous candidate region. In a standard CAN scenario, a payload frame consists of 8 bytes, which corresponds to 8 consecutive pixels in a 32×32 CAN payload grayscale image. Therefore, a frame-level candidate region can correspond to a single-frame payload, and a consecutive-frame candidate region can correspond to payload segments of multiple adjacent CAN data frames. S302. Calculate the information content score of each candidate region, and determine the importance of the corresponding candidate region based on the information content score; The variance of pixel values ​​within an image block in the block-level candidate region is calculated as the information content score, and the variance of pixel values ​​within a payload byte region in the frame-level candidate region or continuous candidate region is calculated as the information content score. The higher the information content score, the more significant the change in payload bytes in the corresponding candidate region, and the higher the contribution to the training of recovering the context consistency representation; the information content score is used to construct the subsequent mask sampling probability. S303. The basic sampling probability of the candidate region is obtained by using power-law normalization, and the basic sampling probability is mixed with a uniform distribution to obtain the final sampling probability. The expression for the basic sampling probability is: ; in, Indicates the first The base sampling probability of each candidate region , They represent the first , Information score of each candidate region A parameter that controls the degree of attention given to high-information regions. This represents a constant that prevents division by zero. Indicates the number of candidate regions; The expression for the final sampling probability is: ; in, Indicates the first The final sampling probability of each candidate region This represents a parameter that controls the mixing ratio of uniform sampling. The above sampling method can balance the priority occlusion of high-information areas and training stability, avoid the mask position being concentrated in a few areas for a long time, and also avoid the frequent occlusion of low-information areas by uniform random masks, which would reduce the effectiveness of self-supervised tasks. S304. Select candidate regions to be masked according to the final sampling probability, and generate a mask matrix by combining at least one of block-level masking, frame-level masking, and continuous frame masking. Block-level masks are used to obscure one or more image blocks to simulate missing or contaminated local fields in the payload; frame-level masks are used to obscure consecutive pixels corresponding to a single frame of payload to simulate single-frame loss or single-frame anomalous injection; continuous frame masks are used to obscure regions corresponding to multiple consecutive frames of payload to simulate bus congestion, continuous frame loss, or continuous attack injection. S305. Generate the corresponding mask result according to the selected masking method, output the mask matrix, and fill the mask matrix with a preset filling strategy to obtain the mask input image. The preset filling strategies include zero-value filling, mean filling, random noise filling, and random byte filling; The zero-value padding sets the pixel values ​​of the masked region to 0; The mean filler sets the pixel values ​​of the masked region to the pixel mean of the current CAN payload grayscale image; The random noise filling is to replace the pixel values ​​of the masked area with random noise in the range of 0 to 1. The random byte filling is to generate random byte values ​​in the range of 0 to 255 and fill them into the masked area after normalization.

[0023] S4, such as Figure 5 As shown, the masked input image is input into a masked strip convolutional autoencoder for self-supervised reconstruction training; like Figure 7 As shown, the masked strip convolutional autoencoder adopts an asymmetric encoder-decoder structure, including an encoder and a decoder. The encoder is used to extract latent feature representations from the masked input image, and the decoder is used to reconstruct the original CAN payload grayscale image based on the latent feature representations during the training phase. S401. Input the masked input image into the encoder to obtain the latent feature representation; S402. Input the latent feature representation into the decoder to obtain the reconstructed image; S403. Calculate the reconstruction loss of the masked strip convolutional autoencoder based on the difference between the reconstructed image and the original CAN payload grayscale image in the masked region; The reconstruction loss is mainly calculated based on the masked region, and the masked strip convolutional autoencoder recovers the masked fields, single frames or continuous frame regions based on the unmasked payload context. The reconstruction loss includes the reconstruction loss of the masked region and the weighted reconstruction regularization term of the unmasked region. The expression for the reconstruction loss of the masked region is as follows: ; in, This represents the original CAN payload grayscale image. Represents the mask matrix, Indicates the reconstructed image. This indicates that the corresponding pixel is masked. A constant that prevents division by zero; The total loss expression after adding the weighted reconstruction regularization term for the unmasked region is: ; in, This indicates the weight of the regularization term for the unmasked region, and A constant less than 1; S404. Update the masked strip convolutional autoencoder parameters of the encoder and decoder based on the reconstruction loss, including learnable parameters in the convolutional layer, strip convolutional layer, fusion layer, and normalization layer used for feature extraction, such as convolutional kernel weights. Through the above training objectives, the model will not simply copy the complete input, but will be forced to infer the occluded payload bytes based on the unoccluded context, thereby learning the field correlation and cross-frame context consistency in CAN messages, and enhancing its robustness to disturbances such as dropped frames, noise pollution and continuous anomaly injection. like Figure 6 As shown, the encoder includes at least one strip convolution module oriented towards the CAN frame structure. The strip convolution module includes a local convolution branch, a first-direction strip convolution branch, a second-direction strip convolution branch, and a channel fusion branch. The local convolution branch is used to extract local byte perturbation features in the grayscale image of the CAN payload, and a 3×3 convolution is used. The first directional strip convolution branch is used to extract contextual features along the CAN message time unwinding direction, and a 1×k strip convolution is used. The second directional strip convolution branch is used to extract inter-frame coupling features in the cross-line continuation direction or cross-field direction, and k×1 strip convolution is used. The channel fusion branch is used to fuse the features output by the local convolution branch, the first direction strip convolution branch, and the second direction strip convolution branch, and adopts 1×1 point convolution. In this embodiment, the kernel lengths of the first-direction strip convolution branch and the second-direction strip convolution branch can be determined based on the sliding window length, the number of payload bytes per frame, and the rearrangement method of the two-dimensional grayscale matrix. A larger strip convolution kernel is used in the shallow coding stage to establish a longer range of inter-frame context connections, while a smaller strip convolution kernel is used in the deep coding stage to reduce redundant computation and avoid over-smoothing. Thus, the convolution direction and scale of the strip convolution module are matched to the two-dimensional mapping structure of the CAN payload, rather than directly applying a regular image convolution module. To reduce the number of parameters and computational cost, the 1×k strip convolution and the k×1 strip convolution can be implemented using depthwise separable convolution. Compared with the full k×k large kernel convolution, strip convolution can expand the effective receptive field with lower complexity, making it more suitable for the real-time inference needs of vehicle edge devices. In this embodiment, the encoder includes four stages, with the number of channels increasing progressively, for example, C, 2C, 4C and 8C respectively; the shallow feature maps have higher resolution and can use larger strip convolution kernels to capture a longer range of contextual relationships; the deep feature maps have lower resolution and can use smaller strip convolution kernels to reduce redundant computation and avoid over-smoothing of features. like Figure 7 As shown, the encoder and decoder are used to complete the mask reconstruction during the training phase; the decoder is removed during the deployment phase, and only the encoder is retained as a feature extractor. Since the encoder is trained under the constraints of the CAN frame structure mask and mask region reconstruction task, its output features are used to characterize the payload field association, the continuous change of the time expansion direction, and the inter-frame coupling relationship of the cross-line continuation direction or cross-field direction. This reduces the storage occupation and response latency of the vehicle end while retaining the ability to distinguish CAN context anomalies.

[0024] S5, such as Figure 8 As shown, after completing the self-supervised reconstruction training, the decoder is removed, the encoder obtained by mask reconstruction training is retained and connected to the lightweight classification head, and the lightweight classification head is trained or the encoder and lightweight classification head are fine-tuned using labeled CAN samples. The lightweight classification head includes a global average pooling layer, a first fully connected layer, a ReLU activation layer, and a second fully connected layer. The feature map output by the encoder is converted into a one-dimensional feature vector after global average pooling, and then mapped to the hidden space through the first fully connected layer, and finally output as a classification result through the second fully connected layer. When training or fine-tuning the lightweight classifier head, the encoder parameters can be fixed and only the lightweight classifier head can be trained; alternatively, if the number of labeled samples allows, the encoder and the lightweight classifier head can be jointly fine-tuned to improve the detection performance for specific vehicle models or specific attack scenarios.

[0025] S6. During the vehicle deployment phase, the vehicle gateway or vehicle edge computing device collects CAN data frames in real time, converts the CAN data frame to be detected into a grayscale image of the CAN payload, and then inputs it into the encoder and the lightweight classification head. The encoder extracts the CAN field association and cross-frame context features, and the lightweight classification head outputs the intrusion detection results of normal category or attack category. When the detection result is an attack category, the system generates an alarm message and may further trigger operations such as log recording, bus isolation, abnormal message filtering, security policy updates, or reporting to the superior security management platform.

[0026] Example 2 This embodiment provides a vehicle network intrusion detection system based on a masked stripe convolutional autoencoder, including: The data conversion module is used to acquire continuous CAN data frames on the vehicle CAN bus, extract payload bytes from the CAN data frames, and convert the continuous L frames of payload bytes into a CAN payload grayscale image. A mask generation module is used to generate a mask region based on an information-guided multi-mode mask generator, and to fill the mask region using a preset filling strategy to obtain a mask input image; wherein, the mask region includes at least one of block-level mask, frame-level mask, and continuous frame mask, specifically including: The grayscale image of the CAN payload is divided into candidate regions, and the information content score of each candidate region is calculated. The basic sampling probability is obtained by power-law normalization and then mixed with a uniform distribution to obtain the final sampling probability. Based on the final sampling probability, candidate regions to be masked are selected, and a mask matrix including at least one of block-level mask, frame-level mask, or continuous frame mask is generated. The reconstruction training module is used to perform self-supervised reconstruction training on the masked input image using a masked stripe convolutional autoencoder, and update the encoder and decoder parameters according to the difference between the reconstructed image and the original CAN payload grayscale image; wherein, the encoder includes at least one stripe convolutional module oriented towards the CAN frame structure, the stripe convolutional module includes a local convolutional branch, a first-direction stripe convolutional branch along the CAN message time unrolling direction, a second-direction stripe convolutional branch along the cross-line continuation direction or cross-field direction, and a channel fusion branch; The classification and detection module is used to retain the encoder after completing the self-supervised reconstruction training, connect to a lightweight classification head, and output the normal category or attack category based on the contextual features output by the encoder. The data conversion module, mask generation module, reconstruction training module, and classification detection module are all deployed on the vehicle and can be executed by the same vehicle edge computing device. With the above deployment method, the original CAN data does not need to be uploaded to the cloud or external server. Data conversion, mask generation, self-supervised training, model update, and intrusion detection can be completed locally on the vehicle.

[0027] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.

Claims

1. A vehicle network intrusion detection method based on a masked stripe convolutional autoencoder, characterized in that, Includes the following steps: S1. Obtain continuous CAN data frames on the vehicle CAN bus and extract data field payload bytes from the CAN data frames; S2. The payload bytes of consecutive L CAN data frames are arranged into a sliding window sample in chronological order. The sliding window sample is normalized and then rearranged into a CAN payload grayscale image. The correspondence between the pixel position in the CAN payload grayscale image and the payload field number, CAN frame number and cross-line continuation position is determined. S3. Generate a mask matrix for the grayscale image of the CAN payload using an information-guided multi-mode mask generator, and fill the mask matrix using a preset filling strategy to obtain the mask input image. S4. Input the masked input image into a masked stripe convolutional autoencoder for self-supervised reconstruction training; The mask strip convolutional autoencoder includes an encoder and a decoder. The encoder includes at least one strip convolutional module oriented towards the CAN frame structure. The strip convolutional module includes a local convolutional branch, a first-direction strip convolutional branch, a second-direction strip convolutional branch, and a channel fusion branch. S401. Input the masked input image into the encoder to obtain the latent feature representation; S402. Input the latent feature representation into the decoder to obtain the reconstructed image; S403. Calculate the reconstruction loss of the masked strip convolutional autoencoder based on the difference between the reconstructed image and the original CAN payload grayscale image in the masked region; The reconstruction loss is mainly calculated based on the masked region, and the masked strip convolutional autoencoder recovers the masked fields, single frames or continuous frame regions based on the unmasked payload context. S404. Update the parameters of the masked stripe convolutional autoencoder of the encoder and decoder based on the reconstruction loss; S5. After completing the self-supervised reconstruction training, remove the decoder, retain the encoder obtained by the mask reconstruction training and connect it to the lightweight classification head, and use the labeled CAN samples to train the lightweight classification head or fine-tune the encoder and the lightweight classification head. S6. During the vehicle deployment phase, the CAN data frame to be detected is converted into a grayscale image of the CAN payload and then input into the encoder and the lightweight classification head. The encoder extracts the CAN field association and cross-frame context features, and the lightweight classification head outputs the intrusion detection results of normal category or attack category.

2. The vehicle network intrusion detection method based on masked stripe convolutional autoencoder according to claim 1, characterized in that, The payload data, consisting of 8 bytes, is extracted from each CAN data frame by the vehicle-mounted intrusion detection device.

3. The vehicle network intrusion detection method based on a masked stripe convolutional autoencoder according to claim 1, characterized in that, Obtaining the grayscale image of the CAN payload specifically includes the following steps: S201. Select L consecutive CAN data frames in chronological order to form a sliding window sample. Each CAN data frame includes B payload bytes. Expand the L×B bytes into a one-dimensional vector in chronological order. S202. Normalize all payload bytes to obtain the value range as follows: The normalized vector; S203. The normalized vector is rearranged into a two-dimensional grayscale matrix of H×W, where H×W=L×B, to obtain the grayscale image of the CAN payload.

4. The vehicle network intrusion detection method based on a masked stripe convolutional autoencoder according to claim 1, characterized in that, Generating a masked input image specifically includes the following steps: S301. The grayscale image of the CAN payload is preprocessed and divided into candidate regions to obtain multiple candidate regions to be evaluated; When using block-level masking, the grayscale image of the CAN payload is divided into multiple... Image patches are processed, and each image patch is considered as a block-level candidate region. The side length of the image patch is a preset positive integer, expressed in pixels. Represents a square area composed of rows and columns of pixels; When using frame-level masking or continuous frame masking, the payload byte region corresponding to a CAN data frame is taken as a frame-level candidate region or a continuous candidate region. S302. Calculate the information content score of each candidate region, and determine the importance of the corresponding candidate region based on the information content score; The variance of pixel values ​​within an image block in the block-level candidate region is calculated as the information content score, and the variance of pixel values ​​within a payload byte region in the frame-level candidate region or continuous candidate region is calculated as the information content score. S303. The basic sampling probability of the candidate region is obtained by using power-law normalization, and the basic sampling probability is mixed with a uniform distribution to obtain the final sampling probability. The expression for the basic sampling probability is: ; in, Indicates the first The base sampling probability of each candidate region , They represent the first , Information score of each candidate region A parameter that controls the degree of attention given to high-information regions. This represents a constant that prevents division by zero. Indicates the number of candidate regions; The expression for the final sampling probability is: ; in, Indicates the first The final sampling probability of each candidate region This represents a parameter that controls the mixing ratio of uniform sampling. S304. Select candidate regions to be masked according to the final sampling probability, and generate a mask matrix by combining at least one of block-level masking, frame-level masking, and continuous frame masking. S305. The mask matrix is ​​filled using a preset filling strategy to obtain the mask input image.

5. The vehicle network intrusion detection method based on a masked stripe convolutional autoencoder according to claim 4, characterized in that, The preset filling strategies include zero-value filling, mean filling, random noise filling, and random byte filling; The zero-value padding sets the pixel values ​​of the masked region to 0; The mean filler sets the pixel values ​​of the masked region to the pixel mean of the current CAN payload grayscale image; The random noise filling is to replace the pixel values ​​of the masked area with random noise in the range of 0 to 1. The random byte filling is to generate random byte values ​​in the range of 0 to 255 and fill them into the masked area after normalization.

6. The vehicle network intrusion detection method based on a masked stripe convolutional autoencoder according to claim 1, characterized in that, The reconstruction loss includes the reconstruction loss of the masked region and the weighted reconstruction regularization term of the unmasked region. The expression for the reconstruction loss of the masked region is: ; in, This represents the original grayscale image of the CAN payload. Represents the mask matrix. Indicates the reconstructed image. This indicates that the corresponding pixel is masked. A constant that prevents division by zero; The total loss expression after adding the weighted reconstruction regularization term for the unmasked region is: ; in, This indicates the weight of the regularization term for the unmasked region, and It is a constant less than 1.

7. The vehicle network intrusion detection method based on a masked stripe convolutional autoencoder according to claim 1, characterized in that, The local convolution branch is used to extract local byte perturbation features in the grayscale image of the CAN payload, and a 3×3 convolution is used. The first directional strip convolution branch is used to extract contextual features along the CAN message time unwinding direction, and a 1×k strip convolution is used. The second directional strip convolution branch is used to extract inter-frame coupling features in the cross-line continuation direction or cross-field direction, and k×1 strip convolution is used; The channel fusion branch is used to fuse the features output by the local convolution branch, the first direction strip convolution branch, and the second direction strip convolution branch, and adopts 1×1 point convolution.

8. The vehicle network intrusion detection method based on a masked stripe convolutional autoencoder according to claim 1, characterized in that, The lightweight classification head includes a global average pooling layer, a first fully connected layer, a ReLU activation layer, and a second fully connected layer. The feature map output by the encoder is converted into a one-dimensional feature vector after global average pooling. It is then mapped to the hidden space through the first fully connected layer, and finally output as a classification result through the second fully connected layer.

9. A vehicle network intrusion detection system based on a masked stripe convolutional autoencoder, employing the method described in any one of claims 1-6, characterized in that, include: The data conversion module is used to acquire continuous CAN data frames on the vehicle CAN bus, extract payload bytes from the CAN data frames, and convert the continuous L frames of payload bytes into a CAN payload grayscale image. A mask generation module is used to generate a mask region based on an information-guided multi-mode mask generator, and fill the mask region with a preset filling strategy to obtain a mask input image; wherein, the mask region includes at least one of block-level mask, frame-level mask, and continuous frame mask; The reconstruction training module is used to perform self-supervised reconstruction training on the masked input image using a masked stripe convolutional autoencoder, and update the encoder and decoder parameters according to the difference between the reconstructed image and the original CAN payload grayscale image; wherein, the encoder includes at least one stripe convolutional module oriented towards the CAN frame structure, the stripe convolutional module includes a local convolutional branch, a first-direction stripe convolutional branch along the CAN message time unrolling direction, a second-direction stripe convolutional branch along the cross-line continuation direction or cross-field direction, and a channel fusion branch; The classification and detection module is used to retain the encoder after completing the self-supervised reconstruction training, connect to a lightweight classification head, and output the normal category or attack category based on the contextual features output by the encoder.

10. The vehicle network intrusion detection system based on a masked stripe convolutional autoencoder according to claim 9, characterized in that, The mask generation module is specifically used for: The grayscale image of the CAN payload is divided into candidate regions, and the information content score of each candidate region is calculated. The basic sampling probability is obtained by power-law normalization and then mixed with a uniform distribution to obtain the final sampling probability. Based on the final sampling probability, candidate regions to be masked are selected, and a mask matrix including at least one of block-level mask, frame-level mask, or continuous frame mask is generated.

Citation Information

Patent Citations

  • Internet of vehicles intrusion detection method, system and equipment based on federal auto-encoder

    CN120151071A

  • Robust polyp segmentation method based on improved SAM-Med2D

    CN120510169A