Image-based vehicle-mounted network intrusion detection method

By converting vehicle status data into RGB images and using a lightweight hybrid feature extraction network for detection, the balance between detection accuracy and real-time performance in vehicular network intrusion detection systems is solved, achieving efficient and accurate intrusion detection results.

CN120934847APending Publication Date: 2025-11-11JILIN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511155513.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-18
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing vehicle network intrusion detection systems struggle to balance detection accuracy, real-time performance, and computational resource usage. In particular, in vehicle environments with high real-time requirements, existing methods often require complex models, leading to increased latency.

Method used

An image-based intrusion detection method for vehicular networks is adopted. By collecting vehicle status data and preprocessing it into RGB image format, a lightweight hybrid feature extraction network is used for feature extraction and classification. K-Means clustering and SMOTE algorithm are combined for oversampling to achieve efficient detection of CAN bus data.

Benefits of technology

While meeting real-time requirements, it achieves more accurate and efficient intrusion detection, improves detection accuracy and model robustness, and reduces computational resource requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120934847A_ABST
    Figure CN120934847A_ABST
Patent Text Reader

Abstract

The invention discloses a vehicle-mounted network intrusion detection method based on an image, and relates to the field of vehicle-mounted network communication security, and the method comprises the following steps: S1, collecting vehicle state data, taking the vehicle state data as an original input sample set, carrying out the preprocessing of the original input sample set, and obtaining a vehicle state subset with representative characteristics; s2, mapping the vehicle state subset into an RGB image format to obtain image data; s3, inputting the image data into a lightweight hybrid feature extraction network, performing local feature extraction and global information modeling through reverse residual sub-blocks in the network, and obtaining a feature map through linear mixing; and S4, performing feature analysis and classification processing on the obtained feature map through a classification layer in the network, and outputting prediction probability distribution of each attack type and a normal state, and according to the method, intrusion detection can be performed more accurately and efficiently on the premise of satisfying real-time performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of vehicle network communication security technology, and in particular to an image-based vehicle network intrusion detection method. Background Technology

[0002] With the advent of the 5G era and the advancement of IoT technology, in-vehicle networks (IVNs) have received widespread attention due to their crucial role in intelligent transportation. However, with the increasing number of consumer electronics connected to vehicles, IVNs face numerous potential security vulnerabilities and the risk of malicious attacks. To address these challenges, researchers have proposed three main in-vehicle network security enhancement technologies: data encryption, message authentication, and anomaly-based in-vehicle network intrusion detection. Compared to the first two technologies, intrusion detection systems (IDS) offer advantages such as low bandwidth consumption and ease of deployment, making them more suitable for resource-constrained in-vehicle networks. Existing in-vehicle network intrusion detection systems can be categorized into three main types: feature observation-based methods, statistical analysis-based methods, and machine learning-based methods.

[0003] While these methods have achieved extremely high detection accuracy, further improvements are needed in in-vehicle environments, requiring a trade-off between lightweight design and detection performance. Achieving higher detection accuracy often necessitates more complex models, which in turn leads to increased latency. This trade-off is particularly critical in vehicle intrusion detection systems with high real-time requirements. Even brief system failures can have catastrophic consequences for the vehicle or its passengers. Therefore, balancing detection accuracy, real-time performance, and computational resource utilization remains a key challenge. Summary of the Invention

[0004] In view of the above-mentioned prior art, the present invention provides an image-based intrusion detection method for vehicle networks, which mainly solves the technical problems existing in the background art and can perform intrusion detection more accurately and efficiently while meeting the real-time requirements.

[0005] To achieve the above objectives, the technical solution of this invention is implemented as follows: A method for detecting intrusion into a vehicle network based on an image, the method comprising the following steps: Step S1: Collect vehicle state data and use it as the original input sample set, preprocess the original input sample set to obtain a vehicle state subset with representative characteristics; Step S2: Map the vehicle state subset to RGB image format to obtain image data; Step S3: Input the image data into the lightweight hybrid feature extraction network, perform local feature extraction and global information modeling through the inverse residual sub-block in the network, and obtain the feature map through linear mixing; Step S4: Perform feature analysis and classification on the obtained feature maps through the classification layer in the network, and output the predicted probability distribution of each attack type and normal state.

[0006] As a preferred embodiment of the present invention, the original input sample set obtained in step S1 is a standard CAN bus data frame, which includes: a frame start marker, an arbitration field, a control field, a data field, a cyclic redundancy check field, an acknowledgment field, and a frame end marker, and each data frame has an attack type annotation.

[0007] As a preferred embodiment of the present invention, the specific process of preprocessing the original input data in step S1 to obtain a vehicle state subset with representative characteristics includes introducing the SMOTE algorithm based on K-Means clustering to perform structured sampling of the original dataset: Clustering stage: original input sample set Each sample Apply the K-Means algorithm to the input sample set Perform clustering and generate Feature clusters: Then the centroid of each cluster for:

[0008] Intra-cluster oversampling: For each cluster The SMOTE algorithm is used to generate new samples. For a sample within a cluster... Randomly select one of its neighboring clusters within the cluster. Generate new synthetic samples :

[0009] in, It is a random number between 0 and 1; Sample allocation: Based on the number of samples in each cluster or the intra-cluster density, the number of synthetic samples generated in each cluster is determined. The allocation strategy used is as follows:

[0010] in, It is the total number of samples that we want to generate. It is in the Generate a subset of vehicle states with representative characteristics from each cluster. Indicates the first Clusters.

[0011] As a preferred embodiment of the present invention, step S2 specifically includes: providing The vehicle status data corresponding to each timestamp is represented as follows: , Indicating total time Each data point corresponds to one data point; , express Vehicle status data at any given time. Use a sliding window to capture vehicle status data in real time. Set the size of the sliding window to w and the step size to [value missing]. The data within a sliding window is represented as follows:

[0012] Each sample is composed of It consists of several dimensions, represented as follows:

[0013] in, Indicates the first The values ​​of each dimension; The normalized sample is represented as follows:

[0014] in, The normalization process is represented by the first... To preserve temporal relationships and facilitate graphical representation, a fixed-length w time sliding window is used to extract consecutive samples. These w consecutive normalized samples are then sequentially combined into a sample sequence. :

[0015] The sliding window w is typically 3N, which allows the two-dimensional matrix to be converted into three-channel RGB image data. , is represented as: .

[0016] As a preferred embodiment of the present invention, the lightweight hybrid feature extraction network in step S3 specifically includes an input layer, a downsampling layer, an inverse residual sub-block, and a classification layer; The output of the input layer is connected to the input of the sampling layer. The input layer is used to receive three-channel RGB image data and send it to the downsampling layer. The output of the downsampling layer is connected to the input of the inverse residual sub-block. The downsampling layer is used to extract features from the three-channel RGB image data. The output of the inverse residual sub-block is connected to the input of the classification layer. The inverse residual sub-block is used to perform local feature extraction and global information modeling on the three-channel RGB image data after feature extraction to obtain a feature map. The output of the classification layer is connected to the input of the inverse residual sub-block. The classification layer is used to perform feature compression and classification processing on the feature map and output the predicted probability distribution of each attack type and normal state.

[0017] As a preferred embodiment of the present invention, the inverse residual sub-block includes a token mixing sub-block, a coordinate attention layer, and a channel mixing sub-block. The output of the token mixing sub-block is connected to the input of the coordinate attention layer. The token mixing sub-block is used to extract local spatial features from the three-channel RGB image data and perform feature fusion and compression to obtain an intermediate feature map. The output of the coordinate attention layer is connected to the input of the channel mixing sub-block. The coordinate attention layer is used to enhance the intermediate feature map and map it to the vector space to obtain the enhanced intermediate feature map. The channel mixing sub-block is used to compress and integrate all channel information in the enhanced intermediate feature map, realize linear mixing of information between channels, and output the final feature map.

[0018] As a preferred embodiment of the present invention, the specific process of obtaining a feature map by performing local feature extraction and global information modeling through the inverse residual sub-blocks in the network and obtaining the feature map through linear mixing in step S3 includes: Input image features The image is divided into several fixed-size blocks, which are then linearly projected by the embedding module to obtain the embedded representation: ,

[0019] in, For the embedding sequence, N is the number of image patches, and D is the embedding dimension of each image patch; For embedded sequences The process involves repeated stacking and then feeds into the token mixer module to extract local spatial features. The token mixer module employs depthwise separable convolution operations to capture spatial information in both the horizontal and vertical directions, yielding intermediate features denoted as... intermediate features With image data Perform residual connections to preserve the original feature information, and output the features as follows: Then, the features are fused and compressed through a convolutional layer and a batch normalization layer to output an intermediate feature map. ; Input intermediate feature map Entering the coordinate attention layer:

[0020]

[0021]

[0022]

[0023]

[0024]

[0025] Then, pooling kernels are used to encode each channel along the horizontal and vertical coordinates respectively. Spatial location information and contextual semantics are extracted through encoding to obtain: ,

[0026] in, and They represent heights of Width is The output of the c-th channel; The results are then concatenated and subjected to dimensionality reduction and activation via convolution to generate an attention map.

[0027] Horizontal attention and vertical direction attention Compared with the original input feature map respectively Perform channel-wise weighted multiplication to obtain the output feature map. ; feature map The input is fed into the channel mixer module, where pointwise convolution is performed to reduce the channel dimensionality, compressing and integrating all channel information at each pixel location to achieve linear mixing of channel information. This process is represented as follows:

[0028] Then, a non-linear activation function is input to enhance the feature representation capability. Next, a second pointwise convolution is used to perform a dimensionality increase operation to restore the channel structure, and residual connections are used to output the final feature map.

[0029] As a preferred embodiment of the present invention, the specific process of outputting the predicted probability distributions of each attack type and normal state through a lightweight hybrid feature extraction network in step S4 includes four stages. Each stage contains a varying number of inverse residual sub-blocks to enhance the interaction and modeling capabilities between spatial and channel features. The token mixer models the first stage locally, extracting local features along the horizontal direction using depthwise separable convolutions. These local features are then combined with the global features obtained from channel blending. Finally, the reverse residual sub-block process is repeated through residual connections to obtain the final output of the first stage. ; Each stage is followed by a downsampling layer, using the feature map output from the first stage. The input of the first downsampling layer is used to obtain the input feature map for the next stage. After four stages of iteration, the final feature map is obtained. ; feature map Global average pooling is performed on the spatial dimension, and the average value of all positions in each channel is taken to compress the spatial dimension. Then, a fully connected layer and a Softmax function are used to classify it, and the predicted probability distribution of each attack type and normal state is output.

[0030] The beneficial effects of this invention are as follows: This invention performs feature selection on the dataset and oversampling using the K-Means and SMOTE algorithms, followed by data transformation, converting CAN bus data into RGB images based on timestamp order. To detect malicious CAN packet injection, a lightweight hybrid feature extraction network is integrated, effectively fusing local and global features. This invention outperforms existing intrusion detection models in terms of accuracy, real-time performance, parameter efficiency, and memory usage. Attached Figure Description

[0031] Figure 1 This is a flowchart illustrating the steps of this method; Figure 2 This is a schematic diagram of the format of a vehicle CAN protocol data frame. Figure 3 A schematic diagram illustrating feature extraction from raw data using feature engineering. Figure 4 A framework diagram of an image-based intrusion detection method for vehicle networks provided by the present invention; Figure 5 A schematic diagram of the lightweight hybrid feature extraction subnetwork provided by the present invention; Figure 6 This is a schematic diagram of representative sample images for each category after the data has been converted into images; Figure 7 This is a schematic diagram of the confusion matrix of this method on the Car-Hacking dataset; Figure 8 This is a schematic diagram of the confusion matrix of this method on the CICIDS2017 dataset. Detailed Implementation

[0032] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. In the following description, the expression "some embodiments" refers to a subset of all possible embodiments; however, it should be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict.

[0033] In the following description, numerous specific details are set forth in order to provide a more thorough understanding of the invention. However, it will be apparent to those skilled in the art that the invention can be practiced without one or more of these details. In other instances, certain technical features well-known in the art have not been described in order to avoid obscuring the invention.

[0034] It should be understood that the present invention can be embodied in various forms and should not be construed as being limited to the embodiments set forth herein. Rather, providing these embodiments will make the disclosure thorough and complete, and will fully convey the scope of the invention to those skilled in the art. Furthermore, the terminology used herein is intended only to describe particular embodiments and is not intended to limit the invention. When used herein, the singular forms “a,” “an,” and “the” are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms “compose” and / or “comprising,” when used in this specification, identify the presence of the stated features, integers, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups. When used herein, the term “and / or” includes any and all combinations of the associated listed items.

[0035] It should also be noted that when an element is referred to as being "fixed to" another element, it can be directly attached to the other element or there may be an intervening element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or there may be an intervening element. The terms "vertical," "horizontal," "inner," "outer," "left," "right," and similar expressions used herein are for illustrative purposes only and do not represent the only possible implementation.

[0036] To fully understand this invention, a detailed structure will be presented in the following description to illustrate the technical solution proposed by this invention. Optional embodiments of the invention are described in detail below; however, in addition to these detailed descriptions, the invention may have other embodiments.

[0037] Please refer to the attached document. Figure 1 This application provides an image-based intrusion detection method for vehicle networks, the method comprising the following steps: Step S1: Collect vehicle state data and use it as the original input sample set, preprocess the original input sample set to obtain a vehicle state subset with representative characteristics; In this embodiment, as shown in the appendix Figure 2 The diagram visually illustrates the format of a vehicle CAN protocol data frame. The essence of an in-vehicle network intrusion detection system is to continuously monitor the raw messages transmitted via the CAN bus and construct statistical or learning models based on normal communication patterns. Furthermore, in-vehicle network classification involves labeling each sample in the dataset. Taking the Car-Hacking dataset as an example, data frames are labeled as data types such as Normal, RAM, Gear, DoS, and Fuzzy.

[0038] In this embodiment, as shown in the appendix Figure 3 As shown, three features were selected for feature engineering: timestamp, identifier, and data field. In the original dataset, the identifier and data field were in hexadecimal format; in this example, they were converted to decimal and normalized. After normalization, the original data was processed into a single sample containing nine dimensions (CAN ID and DATA 0 - DATA 7).

[0039] In this embodiment, the framework diagram of the method is attached. Figure 4 As shown, to address the data imbalance problem, this method provides a SMOT algorithm based on K-Means clustering for structured sampling of the original datasets. The structured-sampled Car-Hacking dataset contains 1,929,411 data frames, and the structured-sampled CICIDS2017 dataset contains 4,128,980 data frames. The adjusted class distribution not only improves the data quality but also enhances the model's ability and accuracy in handling imbalanced data.

[0040] Step S2: Map the vehicle state subset to RGB image format to obtain image data; In this embodiment, the method performs intrusion detection classification on two datasets: Car-Hacking and CICIDS2017. Taking the Car-Hacking dataset as an example, 27 consecutive samples are transformed into three-channel images. Each transformed image is a three-channel, square RGB image. Since the images are generated consecutively based on the timestamps of the samples, the inherent temporal relationships in the original data are preserved.

[0041] For the Car-Hacking dataset, the sample size is 99 pixels; for the CICIDS2017 dataset, the sample size is 2020 pixels. In this example, the sample size for both datasets is adjusted to 256×256 pixels.

[0042] Step S3: Input the image data into the lightweight hybrid feature extraction network, perform local feature extraction and global information modeling through the inverse residual sub-block in the network, and obtain the feature map through linear mixing; Step S4: Perform feature analysis and classification on the obtained feature maps through the classification layer in the network, and output the predicted probability distribution of each attack type and normal state.

[0043] As a preferred embodiment of the present invention, the original input sample set obtained in step S1 is a standard CAN bus data frame, which includes: a frame start marker, an arbitration field, a control field, a data field, a cyclic redundancy check field, an acknowledgment field, and a frame end marker, and each data frame has an attack type annotation.

[0044] In this embodiment, the raw input sample set obtained in step S1 is a standard CAN bus data frame. It typically consists of several fields: a 1-bit Start of Frame (SOF) marker, a 12-bit arbitration field (including an 11-bit ID and a 1-bit Remote Transmission Request, RTR), a 6-bit control field (mainly including a 4-bit Data Length Code, DLC), a data field containing 0-8 bytes (determined by the DLC value), a Cyclic Redundancy Check (CRC) field, an Acknowledgment (ACK) field, and a 7-bit End of Frame (EOF) marker. Each data entry also includes an attack type annotation.

[0045] As a preferred embodiment of the present invention, the specific process of preprocessing the original input data in step S1 to obtain a vehicle state subset with representative characteristics includes introducing the SMOTE algorithm based on K-Means clustering to perform structured sampling of the original dataset: Clustering stage: original input sample set Each sample Apply the K-Means algorithm to the input sample set Perform clustering and generate Feature clusters: Then the centroid of each cluster for:

[0046] Intra-cluster oversampling: For each cluster The SMOTE algorithm is used to generate new samples. For a sample within a cluster... Randomly select one of its neighboring clusters within the cluster. Generate new synthetic samples :

[0047] in, It is a random number between 0 and 1; Sample allocation: Based on the number of samples in each cluster or the intra-cluster density, the number of synthetic samples generated in each cluster is determined. The allocation strategy used is as follows:

[0048] in, It is the total number of samples that we want to generate. It is in the Generate a subset of vehicle states with representative characteristics from each cluster. Indicates the first Clusters.

[0049] In this embodiment, the above mechanism can effectively suppress noise while removing redundant data and generating a data subset with reasonable structure and strong representativeness, which significantly enhances the robustness and detection accuracy of the model in processing unbalanced CAN bus attack data.

[0050] As a preferred embodiment of the present invention, step S2 specifically includes: providing... Each timestamp corresponds to , Indicating total time Each data point corresponds to one data point; , express Moment , Use a sliding window to capture vehicle status data in real time. Set the size of the sliding window to w and the step size to [value missing]. The data within a sliding window is represented as follows:

[0051] Each sample is composed of It consists of several dimensions, represented as follows:

[0052] in, Indicates the first The values ​​of each dimension; First, the hexadecimal values ​​for each dimension are converted to decimal values. Then, they are standardized using a quantile-based normalization method to suppress the influence of outliers on the results. The normalized sample representation is as follows:

[0053] in, The normalization process is represented by the first... The data consists of numerical values ​​in each dimension (such as CAN ID or DATA bytes). All dimensions are initially represented in hexadecimal. To preserve temporal relationships and facilitate graphical representation, a fixed-length w time sliding window is used to extract consecutive samples. These w consecutive normalized samples are then sequentially combined into a sample sequence. :

[0054] Convert the two-dimensional matrix into three-channel RGB image data , is represented as: .

[0055] In this embodiment, since the image is constructed based on temporally adjacent samples, the transformed image spatially embeds the temporal dependencies of the original data, making it suitable for subsequent deep neural network processing.

[0056] As a preferred embodiment of the present invention, the lightweight hybrid feature extraction network in step S3 specifically includes an input layer, a downsampling layer, an inverse residual sub-block, and a classification layer; The output of the input layer is connected to the input of the sampling layer. The input layer is used to receive three-channel RGB image data and send it to the downsampling layer. The output of the downsampling layer is connected to the input of the inverse residual sub-block. The downsampling layer is used to extract features from the three-channel RGB image data. The output of the inverse residual sub-block is connected to the input of the classification layer. The inverse residual sub-block is used to perform local feature extraction and global information modeling on the three-channel RGB image data after feature extraction to obtain a feature map. The output of the classification layer is connected to the input of the inverse residual sub-block. The classification layer is used to perform feature compression and classification processing on the feature map and output the predicted probability distribution of each attack type and normal state.

[0057] As a preferred embodiment of the present invention, the inverse residual sub-block includes a token mixing sub-block, a coordinate attention layer, and a channel mixing sub-block. The output of the token mixing sub-block is connected to the input of the coordinate attention layer. The token mixing sub-block is used to extract local spatial features from the three-channel RGB image data and perform feature fusion and compression to obtain an intermediate feature map. The output of the coordinate attention layer is connected to the input of the channel mixing sub-block. The coordinate attention layer is used to enhance the intermediate feature map and map it to the vector space to obtain the enhanced intermediate feature map. The channel mixing sub-block is used to compress and integrate all channel information in the enhanced intermediate feature map, realize linear mixing of information between channels, and output the final feature map.

[0058] As a preferred embodiment of the present invention, the specific process of obtaining a feature map by performing local feature extraction and global information modeling through the inverse residual sub-blocks in the network and obtaining the feature map through linear mixing in step S3 includes: Input image features The image is divided into several fixed-size blocks, which are then linearly projected by the embedding module to obtain the embedded representation: ,

[0059] in, For the embedding sequence, N is the number of image patches, and D is the embedding dimension of each image patch; For embedded sequences The process involves repeated stacking and then feeds into the token mixer module to extract local spatial features. The token mixer module employs depthwise separable convolution operations to capture spatial information in both the horizontal and vertical directions, yielding intermediate features denoted as... intermediate features With image data Perform residual connections to preserve the original feature information, and output the features as follows: Then, the features are fused and compressed through a convolutional layer and a batch normalization layer to output an intermediate feature map. ; Input intermediate feature map Entering the coordinate attention layer:

[0060]

[0061]

[0062]

[0063]

[0064]

[0065] Then, pooling kernels are used to encode each channel along the horizontal and vertical coordinates respectively. Spatial location information and contextual semantics are extracted through encoding to obtain: ,

[0066] in, and They represent heights of Width is The output of the c-th channel; The above transformation effectively obtains the global receptive field and encodes precise location information. The results are then concatenated and subjected to dimensionality reduction and activation via convolution to generate an attention map.

[0067] Horizontal attention and vertical direction attention Compared with the original input feature map respectively Perform channel-wise weighted multiplication to obtain the output feature map. ; In this embodiment, the skip attention mechanism operates as follows: by sharing an attention module between every two inverse residual blocks, the model's feature representation capability is enhanced without significantly increasing computational or parameter costs. Combining the skip attention mechanism with coordinate attention improves detection accuracy by mapping image pixels to a vector space.

[0068] feature map The input is fed into the channel mixer module, where pointwise convolution is performed to reduce the channel dimensionality, compressing and integrating all channel information at each pixel location to achieve linear mixing of channel information. This process is represented as follows:

[0069] The input nonlinear activation function then enhances the feature representation capability. Next, a second pointwise convolution is used to perform dimensionality increase to restore the channel structure. Residual connections are then used to output the final feature map, which contains richer channel interaction information and provides a high-quality representation for subsequent classification or discrimination tasks.

[0070] As a preferred embodiment of the present invention, the specific process of outputting the predicted probability distributions of each attack type and normal state through a lightweight hybrid feature extraction network in step S4 includes four stages. Each stage contains a varying number of inverse residual sub-blocks to enhance the interaction and modeling capabilities between spatial and channel features. The token mixer models the first stage locally, extracting local features along the horizontal direction using depthwise separable convolutions. These local features are then combined with the global features obtained from channel blending. Finally, the reverse residual sub-block process is repeated through residual connections to obtain the final output of the first stage. ; Each stage is followed by a downsampling layer, using the feature map output from the first stage. The input of the first downsampling layer is used to obtain the input feature map for the next stage. After four stages of iteration, the final feature map is obtained. ; feature map Global average pooling is performed on the spatial dimension, and the average value of all positions in each channel is taken to compress the spatial dimension. Then, a fully connected layer and a Softmax function are used to classify it, and the predicted probability distribution of each attack type and normal state is output.

[0071] In this embodiment, please refer to the appendix. Figure 5 , attached Figure 5 This paper visually illustrates the structure of a lightweight hybrid feature extraction network, comprising four parts: an input layer, an inverse residual sub-block, a downsampling layer, and a classification layer. The inverse residual sub-block includes a token mixing sub-block, a channel mixing sub-block, and a coordinate attention layer. The framework model of the image-based vehicular network intrusion detection method converts data frames captured by sensors in the vehicle into images as input. For the Car-Hacking dataset, a feature map F of size 256×256×32 is obtained through a 3×3 convolutional layer, a batch normalization layer (BN), and a ReLU activation function; this feature map is then used as the input to the lightweight hybrid feature extraction sub-network.

[0072] In this embodiment, the lightweight hybrid feature extraction network is mainly divided into four stages, each containing a varying number of inverse residual sub-blocks in a ratio of 2:3:6:3, used to enhance the interaction and modeling capabilities between spatial and channel features. In the first stage, the token mixer models the tokens locally, building dependencies between them to enhance spatial interaction capabilities. Specifically, a depthwise separable convolution first extracts local features along the horizontal direction, then combines these with the global features obtained from channel blending to output a feature map. For feature maps Perform average pooling in both the X and Y directions to obtain and Subsequently, a joint spatial location information representation is obtained by concatenating a 3×3 convolutional layer, a batch normalization layer (BN), and a ReLU activation function. Attention weights are then generated in the X and Y directions, resulting in two attention maps. and .right , and Perform element-wise multiplication to complete weight calibration and obtain intermediate feature maps. This step introduces positional information from the spatial dimension to enhance channel attention. Finally, a 1x1 convolutional layer, a ReLU activation function, and another 1x1 convolutional layer are applied, which is equivalent to a multilayer perceptron (MLP) with non-linearity for channel-dimensional feature mapping. This only enhances the non-linear modeling capability between channels without changing the spatial resolution or output dimension. The process is then repeated through residual connections to obtain the final output of stage one. Each stage is followed by a downsampling layer, containing a depthwise convolution with a stride of 2 and a kernel size of 3x3, a 1x1 convolution, and a channel blending module. The output of stage one is used as an example. As the input to the first downsampling layer, it yields the input feature map for the next stage. After four stages of iteration, the feature map is finally obtained. . Feature map Global average pooling is performed on the spatial dimension, averaging all positions within each channel to compress the spatial dimension, resulting in... Then, a fully connected layer and Softmax were used for classification, resulting in... The output dimension is 1xC, and in this example, C is 5, where 5 represents the 5 data categories in the Car-Hacking dataset.

[0073] For example, to illustrate the technical effects of this method, see the attached diagram. Figure 6 As shown, two datasets were constructed for detecting in-vehicle networks and external networks, respectively. (See attached image.) Figure 6 (a) provides image examples of different categories of data from the Car-Hacking in-vehicle network dataset, with appended images. Figure 6 (b) provides examples of images from different categories in the CICIDS2017 external vehicle network dataset. The vehicle images used for vehicle type classification in this method are derived from the two datasets mentioned above. Taking the Car-Hacking dataset after image transformation as an example, it contains 92,851 normal images, 30,532 RAM attack images, 31,054 Gear attack images, 29,930 DOS attack images, and 29,012 Fuzzy attack images. The CICIDS2017 dataset after structured sampling contains 84,912 normal images, 30,326 DOS attack images, 31,711 Port-Scan attack images, 29,328 Web Attack attack images, and 30,172 Brute-Force attack images.

[0074] The Car-Hacking and CICIDS2017 datasets were used, with samples divided into two parts at a 4:1 ratio for training and testing to verify the effectiveness of the invention. The method was trained and tested using the PyTorch framework and implemented in Python, on a system configured with a 2.50 GHz Intel(R) Core i5-13500HX CPU and an NVIDIA RTX 4060 GPU with 8GB of GPU memory. During training, the Adam optimizer was used to optimize the model parameters, with an initial learning rate of 0.00001, a dropout rate of 0.2, a batch size of 32, and 16 training epochs.

[0075] This invention utilizes accuracy (acc), precision (prec), recall (rec), and F1 score—metrics widely used in pattern recognition tasks such as object detection and image classification—as performance indicators to evaluate its capabilities. Furthermore, parameter count, detection latency, and memory usage are also used to assess the lightweight nature of the intrusion detection task.

[0076] Please refer to Table 1, which compares the performance of our method with existing methods on the Car-Hacking dataset. Lightweight neural networks included MobileNet V3, ShuffleNet V2, and EfficientNet-B0; basic machine learning models such as KNN and SVM were used; for more complex architectures, ResNet54ViT, DCNN, and LSTM were selected; in addition, hybrid deep learning models such as STParNet and DWParNet were also evaluated.

[0077] Table 1. Performance comparison of our method with existing methods on the Car-Hacking dataset.

[0078] Table 2 compares the performance of our method with existing methods on the CICIDS2017 dataset.

[0079] Please refer to Table 2, which compares the performance of our method with existing methods on the CICIDS2017 dataset. A series of deep learning algorithms were selected for comparative experiments, including some of the models used in Table 1. Additionally, some models such as XGBoost and MLP were also included.

[0080] As can be seen from Tables 1 and 2, the results of this invention are superior to other methods in all evaluation metrics, which proves the effectiveness of this invention and can serve as a benchmark for subsequent exploration of image network-based intrusion detection methods.

[0081] Furthermore, our method also demonstrates excellent real-time performance, with an average prediction and analysis time of 0.86 milliseconds for a single vehicle sensor data point. This high real-time performance ensures that the model can quickly identify and respond to potential security threats, providing timely protective measures and effectively safeguarding the safety of autonomous vehicles.

[0082] Please see the appendix Figure 7 and attached Figure 8 , attached Figure 7 This is a schematic diagram of the confusion matrix of this method on the Car-Hacking dataset. Figure 8 This is a schematic diagram of the confusion matrix of our proposed method on the CICIDS2017 dataset. The confusion matrix shows that the intrusion detection method provided by our method can accurately classify normal data and attack categories.

[0083] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. The scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. An image-based intrusion detection method for vehicular networks, characterized in that, The method includes the following steps: Step S1: Collect vehicle status data and use it as the original input sample set; preprocess the original input sample set to obtain a vehicle status subset with representative characteristics. Step S2: Map the vehicle state subset to RGB image format to obtain image data; Step S3: Input the image data into the lightweight hybrid feature extraction network, perform local feature extraction and global information modeling through the inverse residual sub-block in the network, and obtain the feature map through linear mixing; Step S4: Perform feature analysis and classification on the obtained feature maps through the classification layer in the network, and output the predicted probability distribution of each attack type and normal state.

2. The image-based intrusion detection method for vehicular networks according to claim 1, characterized in that, The raw input sample set obtained in step S1 is a standard CAN bus data frame. The data frame includes: frame start marker, arbitration field, control field, data field, cyclic redundancy check field, acknowledgment field and frame end marker, and each data frame has an attack type annotation.

3. The image-based intrusion detection method for vehicular networks according to claim 2, characterized in that, The preprocessing of the original input data in step S1 to obtain a representative subset of vehicle states includes introducing the SMOTE algorithm based on K-Means clustering to perform structured sampling of the original dataset: Clustering stage: Original input sample set Each sample Apply the K-Means algorithm to the input sample set Perform clustering and generate Feature clusters: Then the centroid of each cluster for: Intra-cluster oversampling: For each cluster The SMOTE algorithm is used to generate new samples. For a sample within a cluster... Randomly select one of its neighboring clusters within the cluster. Generate new synthetic samples : in, It is a random number between 0 and 1; Sample allocation: Based on the number of samples in each cluster or the intra-cluster density, the number of synthetic samples generated in each cluster is determined. The allocation strategy used is as follows: in, It is the total number of samples that we want to generate. It is in the Generate a subset of vehicle states with representative characteristics from each cluster. Indicates the first Clusters.

4. The image-based intrusion detection method for vehicular networks according to claim 3, characterized in that, Step S2 specifically includes: setting up The vehicle status data corresponding to each timestamp is represented as follows: , Indicating total time Each data point corresponds to one data point; , express Vehicle status data at any given time. Use a sliding window to capture vehicle status data in real time. Set the size of the sliding window to w and the step size to [value missing]. The data within a sliding window is represented as follows: Each sample is composed of It consists of several dimensions, represented as follows: in, Indicates the first The values ​​of each dimension; The normalized sample is represented as follows: in, The normalization process is represented by the first... To preserve temporal relationships and facilitate graphical representation, a fixed-length w time sliding window is used to extract consecutive samples. These w consecutive normalized samples are then sequentially combined into a sample sequence. : The sliding window w is typically 3N, which allows the two-dimensional matrix to be converted into three-channel RGB image data. , is represented as: 。 5. The image-based intrusion detection method for vehicular networks according to claim 4, characterized in that, The lightweight hybrid feature extraction network in step S3 specifically includes an input layer, a downsampling layer, an inverse residual sub-block, and a classification layer. The output of the input layer is connected to the input of the sampling layer. The input layer is used to receive three-channel RGB image data and send it to the downsampling layer. The output of the downsampling layer is connected to the input of the inverse residual sub-block. The downsampling layer is used to extract features from the three-channel RGB image data. The output of the inverse residual sub-block is connected to the input of the classification layer. The inverse residual sub-block is used to perform local feature extraction and global information modeling on the three-channel RGB image data after feature extraction to obtain a feature map. The output of the classification layer is connected to the input of the inverse residual sub-block. The classification layer is used to perform feature compression and classification processing on the feature map and output the predicted probability distribution of each attack type and normal state.

6. The image-based intrusion detection method for vehicular networks according to claim 5, characterized in that, The inverse residual sub-block includes a token mixing sub-block, a coordinate attention layer, and a channel mixing sub-block. The output of the token mixing sub-block is connected to the input of the coordinate attention layer. The token mixing sub-block is used to extract local spatial features from the three-channel RGB image data and perform feature fusion and compression to obtain an intermediate feature map. The output of the coordinate attention layer is connected to the input of the channel mixing sub-block. The coordinate attention layer is used to enhance the intermediate feature map and map it to the vector space to obtain the enhanced intermediate feature map. The channel mixing sub-block is used to compress and integrate all channel information in the enhanced intermediate feature map, realize linear mixing of information between channels, and output the final feature map.

7. The image-based intrusion detection method for vehicular networks according to claim 6, characterized in that, The specific process of obtaining the feature map by performing local feature extraction and global information modeling through the inverse residual sub-blocks in the network and obtaining the feature map through linear mixing in step S3 includes: Input image features The image is divided into several fixed-size blocks, which are then linearly projected by the embedding module to obtain the embedded representation: , in, For the embedding sequence, N is the number of image patches, and D is the embedding dimension of each image patch; For embedded sequences The process involves repeated stacking and then feeds into the token mixer module to extract local spatial features. The token mixer module employs depthwise separable convolution operations to capture spatial information in both the horizontal and vertical directions, yielding intermediate features denoted as... intermediate features With image data Perform residual connections to preserve the original feature information, and output the features as follows: Then, the features are fused and compressed through a convolutional layer and a batch normalization layer to output an intermediate feature map. ; Input intermediate feature map Entering the coordinate attention layer: Then, pooling kernels are used to encode each channel along the horizontal and vertical coordinates respectively. Spatial location information and contextual semantics are extracted through encoding to obtain: , in, and They represent heights of Width is The output of the c-th channel; The results are then concatenated and subjected to dimensionality reduction and activation via convolution to generate an attention map. Horizontal attention and vertical direction attention Compared with the original input feature map respectively Perform channel-wise weighted multiplication to obtain the output feature map. ; feature map The input is fed into the channel mixer module, where pointwise convolution is performed to reduce the channel dimensionality, compressing and integrating all channel information at each pixel location to achieve linear mixing of channel information. This process is represented as follows: Then, a non-linear activation function is input to enhance the feature representation capability. Next, a second pointwise convolution is used to perform a dimensionality increase operation to restore the channel structure, and residual connections are used to output the final feature map.

8. The image-based intrusion detection method for vehicular networks according to claim 7, characterized in that, The specific process of outputting the predicted probability distributions of each attack type and normal state through the lightweight hybrid feature extraction network in step S4 includes four stages. Each stage contains a varying number of inverse residual sub-blocks to enhance the interaction and modeling capabilities between spatial and channel features. The token mixer models the first stage locally, extracting local features along the horizontal direction using depthwise separable convolutions. These local features are then combined with the global features obtained from channel blending. Finally, the reverse residual sub-block process is repeated through residual connections to obtain the final output of the first stage. ; Each stage is followed by a downsampling layer, using the feature map output from the first stage. The input of the first downsampling layer is used to obtain the input feature map for the next stage. After four stages of iteration, the final feature map is obtained. ; feature map Global average pooling is performed on the spatial dimension, and the average value of all positions in each channel is taken to compress the spatial dimension. Then, a fully connected layer and a Softmax function are used to classify it, and the predicted probability distribution of each attack type and normal state is output.