A Lightweight Vehicle Network Intrusion Detection System and Method Based on Parallel CNN-Mamba Fusion Network
By converting network traffic data into three-channel pseudo-color images through a parallel CNN-Mamba fusion network, and extracting local texture and long-range dependency features in parallel, the problem of feature representation and model complexity in vehicle network intrusion detection is solved, and efficient fine-grained attack identification and lightweight deployment are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHANGCHUN UNIV
- Filing Date
- 2026-03-27
- Publication Date
- 2026-05-26
AI Technical Summary
Existing technologies struggle to effectively and uniformly represent network traffic statistics in vehicle-to-everything (V2X) intrusion detection, especially in scenarios where multiple attack types coexist. In particular, identifying fine-grained attack categories is challenging, and model deployment is highly complex.
A lightweight vehicle network intrusion detection method based on parallel CNN-Mamba fusion network is adopted. The network traffic data is converted into a three-channel pseudo-color image through data preprocessing. The parallel CNN spatial branch and Mamba sequence branch are used for feature extraction and fusion discrimination. Combined with multi-scale spatial features and long-range dependency modeling, lightweight detection is achieved.
While maintaining high detection accuracy, it reduces the complexity of model deployment, can stably identify a variety of fine-grained attack types, is suitable for intrusion detection in complex network environments, and has good engineering application value.
Smart Images

Figure CN121923946B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of vehicle networking, cyberspace security and intelligent intrusion detection technology, specifically relating to a lightweight vehicle networking intrusion detection system and method based on a parallel CNN-Mamba fusion network. Background Technology
[0002] With the rapid development of intelligent connected vehicles, vehicle-road cooperative systems, and vehicle-cloud cooperative systems, information interaction between vehicles and the external environment is becoming increasingly frequent, and the boundaries of in-vehicle networks are constantly expanding. At the same time, open interfaces such as remote diagnostics, OTA upgrades, in-vehicle entertainment systems, and edge gateways also bring more potential intrusion entry points. Controller Area Networks (CAN) and vehicle-to-everything (V2X) networks are typically designed with real-time communication capabilities in mind, rather than authentication, data encryption, and access control. Once attackers gain access, they can launch denial-of-service (DoS) attacks, brute-force attacks, malicious bot control, SQL injection, and various distributed denial-of-service (DDoS) attacks, thereby affecting vehicle control logic, business stability, and travel safety.
[0003] In existing technologies, some studies have attempted to improve the performance of intrusion detection in vehicular networks through image encoding and lightweight neural networks. For example, Z. Xia et al. proposed a lightweight intrusion detection method for connected autonomous vehicles based on ECANet and image encoding (Reference: A lightweight intrusion detection system for connected autonomous vehicles based on ECANet and image encoding). J. Inf. Secur. Appl. (Vol. 92, p. 104082, Jul. 2025) The CAN ID time series is encoded into Markov transition field maps, recursion maps, and Gramian angular field maps, respectively, and then superimposed into a three-channel image input to a lightweight ECACNN model for classification. This method achieves high accuracy on real-world vehicle datasets and has good real-time performance. S. Wang et al. used a combination of shallow convolutional networks and GRU to perform image representation of vehicle CAN traffic before spatiotemporal joint modeling (Reference: A lightweight intrusion detection system for vehicle networks based on shallow CNN and GRU, vol. 92, p. 104082, Jul. 2025). IEEE Access( , vol. 13, pp. 73297–73318, 2025), achieved good detection performance on the Car-hacking dataset and emphasized lightweight metrics such as parameter size, throughput and average processing time. However, the above-mentioned technical solutions still have the following shortcomings: First, the aforementioned literature mainly focuses on CAN ID sequences and their time-coded images, which are suitable for time-series analysis at the bus message level, but their ability to uniformly represent high-dimensional heterogeneous features in Internet traffic statistical features and scenarios where multiple attack types coexist is still limited; Second, although existing schemes based on convolution and recurrent units can take into account some spatiotemporal features, the recurrent structure still presents a trade-off between long-range dependency modeling and deployment complexity; Third, when facing the 11 multi-class classification tasks of CICIDS2018, it is necessary not only to distinguish between normal traffic and attack traffic, but also to further distinguish fine-grained attack categories such as brute-force attacks, denial-of-service attacks, distributed denial-of-service attacks, bot control, cross-site scripting, and SQL injection; however, due to the highly uneven distribution of categories, for example, there are 4,883,142 normal samples, while there are only 87 SQL injection attacks, only 230 cross-site scripting attacks, and only 611 Web brute-force attacks, which makes it easy for minority class features to be submerged by the majority class, further increasing the difficulty of stable multi-class identification. Therefore, a lightweight solution is still needed that can provide a unified image representation of network traffic statistical features, while taking into account local spatial pattern extraction and long-range dependency modeling, and is applicable to 11 types of fine-grained intrusion detection tasks. Summary of the Invention
[0004] In view of the shortcomings and deficiencies of existing technologies, the purpose of this invention is to provide a lightweight vehicle network intrusion detection method based on a parallel CNN-Mamba fusion network. This method takes the CICIDS2018 dataset as the main embodiment and revolves around the technical chain of "traffic feature image representation - multi-scale spatial feature extraction - selective state space sequence modeling - low-overhead fusion discrimination", which reduces the complexity of model deployment while maintaining high detection accuracy.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] A lightweight vehicle network intrusion detection system based on a parallel CNN-Mamba fusion network is disclosed. The system includes a data receiving module for receiving network traffic data, a data preprocessing module for cleaning, encoding, normalizing, and classifying the data, a pseudo-color image construction module for mapping network traffic data into a three-channel pseudo-color image and scaling it, and a parallel dual-branch network consisting of a CNN spatial branch and a Mamba sequence branch for averaging and fusing the outputs of the CNN spatial branch and the Mamba sequence branch to output the final detection category.
[0007] The CNN spatial branch is used to extract local texture patterns and cross-feature coupling relationships. It employs three parallel convolutional sub-paths to extract local features under different receptive fields. The outputs of the three parallel convolutional sub-paths are then concatenated in the channel dimension and sequentially passed through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer, and a fully connected layer to obtain the CNN spatial branch output.
[0008] The Mamba sequence branch is used to extract long-range dependency features, and includes a tensor rearrangement module, a selective state space module, and a fully connected layer arranged sequentially; wherein, the tensor rearrangement module is used to rearrange the input tensor into a sequence of length [missing information]. The sequence is represented and then input into a selective state space module. The selective state space module uses the Mamba module to extract long-range dependency features from the input sequence. After obtaining the sequence features, the extracted features at the last time step are input into a fully connected layer, and finally the classification result of this branch is output.
[0009] As a preferred embodiment of the present invention, the lightweight vehicle network intrusion detection system further includes a detection response module, which is used to execute alarms and linkage protection based on the classification results.
[0010] As a preferred embodiment of the present invention, the CNN spatial branch includes three parallel convolutional sub-paths. The first sub-path uses a 1×1 convolutional layer, a batch normalization layer, and a ReLU6 activation layer, combined with average pooling. The second sub-path uses three consecutive 3×3 convolutional layers, at least one of which uses a 3×3 convolution with a stride of 2. Each 3×3 convolutional layer is followed by a batch normalization layer and a ReLU6 activation layer. The third sub-path uses three consecutive 5×5 convolutional layers, at least one of which uses a 5×5 convolution with a stride of 2. Each convolutional layer is followed by a batch normalization layer and a ReLU6 activation layer. The outputs of the three parallel convolutional sub-paths are concatenated in the channel dimension, and then pass through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer, and a fully connected layer to obtain the CNN spatial branch output.
[0011] As a preferred embodiment of the present invention, the Mamba sequence branch input tensor size is Sequence length in the tensor rearrangement module Then the feature dimension d of a single token is:
[0012] ;
[0013] The tensor rearrangement module will input tensors The rearranged sequence is represented as follows. , represented as:
[0014] ;
[0015] in, This represents a rearrangement operation, which completes the sequence construction through rearrangement operations;
[0016] Sequence representation The input is a Mamba module, which performs sequence feature modeling to obtain long-range dependency feature representations. The extracted features from the last time step are then input into a fully connected layer, which maps the features to the final branch output. .
[0017] As a further preferred embodiment of the present invention, the stride of the three 3×3 convolutional layers in the CNN spatial branch is 2, the stride of the three 5×5 convolutional layers is 2, and the dropout rate of the random deactivation layer is p=0.5.
[0018] As a further preferred embodiment of the present invention, the hidden state dimension of the Mamba module The width of the local convolutional kernel within the module is 16. The channel expansion coefficient is 4. The value is 2.
[0019] This invention also provides a lightweight intrusion detection method for vehicle networks based on a parallel CNN-Mamba fusion network, which specifically includes the following steps:
[0020] Step S1. Obtain network traffic data through the data receiving module, and preprocess the network traffic data using the data preprocessing module;
[0021] Step S2. Perform quantile transformation and normalization on the data preprocessed in step S1, and then map it to the pixel range. After that, the pseudo-color image construction module converts a single network traffic data into a three-channel pseudo-color image according to the preset rearrangement rules.
[0022] Step S3. Input the data obtained in step S2 into the CNN spatial branch and the Mamba sequence branch in parallel. Extract local texture patterns and cross-feature coupling relationships through the CNN spatial branch, and extract long-distance dependent features through the Mamba sequence branch.
[0023] The CNN spatial branch uses three parallel convolutional sub-paths to extract local features under different receptive fields. Then, the outputs of the three parallel convolutional sub-paths are concatenated in the channel dimension, and then sequentially pass through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer, and a fully connected layer to obtain the CNN spatial branch output.
[0024] The Mamba sequence branch includes a tensor rearrangement module, a selective state space module, and a fully connected layer arranged sequentially; wherein, the tensor rearrangement module is used to rearrange the input tensor into a sequence of length [missing information]. The sequence is represented and then input into a selective state space module. The selective state space module uses the Mamba module to extract long-range dependency features from the input sequence. After obtaining the sequence features, the extracted features at the last time step are input into a fully connected layer, and finally the classification result of this branch is output.
[0025] Step S4. The fusion discriminant module outputs the spatial branch of the CNN. With Mamba sequence branch output Logits-level averaging fusion is performed to obtain the final classification vector;
[0026] Step S5. Output the classification detection result based on the classification vector obtained in step S4.
[0027] In a preferred embodiment of the present invention, in step S2, the normalized result is first mapped to the pixel value range [0, 255] to obtain the grayscale encoding value; then, the one-dimensional feature sequence of a single network traffic data is sequentially filled into a two-dimensional grid according to a preset row-first mapping rule; then, the obtained two-dimensional matrix is copied to three channels to construct a three-channel pseudo-color image; finally, the obtained three-channel pseudo-color image is uniformly scaled using bilinear interpolation. Input tensor.
[0028] As a preferred embodiment of the present invention, after obtaining the classification detection result in step S5, the detection response module triggers alarm reporting, abnormal connection marking, log recording, and access interception or policy linkage processing according to the category with the highest probability.
[0029] As a further preferred embodiment of the present invention, in step S2, when the effective feature dimension of a single network traffic data does not exceed 400, it is rearranged into a 20×20 two-dimensional matrix; if the effective feature dimension is less than 400, the empty positions at the tail are filled with zeros; if the effective feature dimension is more than 400, the first 400 numerical features are retained according to the feature importance sorting or the preset field filtering rules, so that each sample is mapped to... A two-dimensional matrix.
[0030] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0031] (1) This invention does not simply input one-dimensional flow features directly into the classifier, but first rearranges the high-dimensional statistical features into a unified two-dimensional grid, and constructs a pseudo-color image through three-channel replication. Compared with the single-channel grayscale image representation, the three-channel pseudo-color representation is more suitable for direct compatibility with existing mature two-dimensional convolutional modeling frameworks without changing the original numerical sorting relationship, and facilitates multi-scale convolutional feature extraction under a unified input interface; compared with directly using natural color mapping or complex temporal encoded image methods, the three-channel replication strategy of this invention is simple to implement, has low computational overhead, and low deployment cost, and is more suitable for lightweight implementation; and after combining image scaling and a unified tensor interface, it can more stably preserve the local adjacency relationship, coupling relationship and abnormal texture changes between the original flow statistical features.
[0032] (2) This invention adopts a parallel CNN-Mamba dual-branch structure instead of single-path modeling. The CNN spatial branch extracts local texture patterns and cross-feature coupling relationships in parallel through 1×1, 3×3, and 5×5 multi-scale convolutions, which is suitable for identifying sudden and local anomalies; the Mamba sequence branch captures long-range dependency changes through selective state space modeling, which is suitable for characterizing temporal evolution features across stages and windows; the two are set in parallel rather than sequentially, which can reduce the problem of information decaying layer by layer in a single path.
[0033] (3) This invention provides a unified image representation of the network traffic statistics features of CICIDS2018 and adopts a structure of "multi-scale CNN spatial branch + single-path Mamba sequence branch + logits-level parameterless averaging fusion". Compared with the applicant's earlier design of "vehicle CAN intrusion detection method based on protocol spatial features and multi-scale Bi-Mamba model", this application does not rely on Bi-Mamba bidirectional stacking or more complex protocol semantic modeling process. Therefore, it has advantages in terms of structural simplicity, direct implementation and engineering deployment friendliness.
[0034] (4) The present invention adopts a logits-level average fusion strategy, which can achieve complementary enhancement of spatial representation and sequence representation without the need to introduce additional attention fusion layer, gating fusion layer or complex interaction module. Thus, the consistency and robustness of classification results are improved without significantly increasing the number of parameters and reasoning burden.
[0035] (5) This invention employs 11 types of fine-grained intrusion detection tasks. This setting can more realistically reflect the actual situation of multiple attacks occurring concurrently in complex network environments, but it also brings higher recognition difficulty: on the one hand, there are problems of local feature similarity and blurred boundaries between different attack types; on the other hand, the class distribution is highly unbalanced, with the number of minority class samples being much lower than that of majority class samples, which easily leads to insufficient learning of the minority class by the model. Therefore, this invention adopts a combination of image representation, multi-scale spatial modeling, and sequence dependency modeling to improve the ability to distinguish fine-grained attack types. Experimental results show that when facing the 11 types of fine-grained multi-class classification tasks of CICIDS2018, the method of this invention can still achieve stable differentiation between normal traffic and multiple attack types under the conditions of extremely unbalanced classes and scarce minority class samples. This indicates that this invention is not only suitable for coarse-grained attack detection, but also for fine-grained recognition in complex scenarios, and has good engineering application value. Attached Figure Description
[0036] Figure 1 This is a general framework diagram of the lightweight vehicle network intrusion detection method in this embodiment of the invention;
[0037] Figure 2 This is a schematic diagram of the CNN spatial branching structure in an embodiment of the present invention;
[0038] Figure 3 This is a schematic diagram of the Mamba sequence branching structure in an embodiment of the present invention;
[0039] Figure 4 This is a graph showing the changes in training accuracy and loss on the CICIDS2018 dataset in an embodiment of the present invention; where (a) is the curve of training accuracy change and (b) is the curve of training loss change.
[0040] Figure 5 This is a confusion matrix diagram on the CICIDS2018 dataset in an embodiment of the present invention;
[0041] Figure 6 This is a comparison chart of the overall performance of different models on the CICIDS2018 dataset in the embodiments of the present invention. Detailed Implementation
[0042] To enable those skilled in the art to better understand the technical solution and advantages of the present invention, the present application will be described in detail below with reference to the accompanying drawings. It should be noted that the following embodiments are only used to explain the present invention and are not intended to limit the scope of protection of the present invention.
[0043] Example 1:
[0044] like Figure 1As shown, this embodiment provides a lightweight vehicle network intrusion detection system based on a parallel CNN-Mamba fusion network. The system includes a data receiving module, a data preprocessing module, a pseudo-color image construction module, a parallel dual-branch network, and a fusion discrimination module.
[0045] The data receiving module is used to receive raw network traffic samples;
[0046] The data preprocessing module is used to clean, encode, normalize, and classify the sample data.
[0047] The pseudo-color image construction module is used to map network traffic samples into a 20×20×3 pseudo-color image and scale it to 96×96×3.
[0048] The parallel dual-branch network consists of a CNN spatial branch and a Mamba sequence branch. The CNN spatial branch is used to extract local texture patterns and cross-feature coupling relationships. It uses three parallel convolutional sub-paths to extract local features under different receptive fields. Then, the outputs of the three parallel convolutional sub-paths are concatenated in the channel dimension, and then sequentially pass through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer, and a fully connected layer to obtain the CNN spatial branch output.
[0049] The Mamba sequence branch is used to extract long-range dependency features, and includes a tensor rearrangement module, a selective state space module, and a fully connected layer arranged sequentially; wherein, the tensor rearrangement module is used to rearrange the input tensor into a sequence of length [missing information]. The sequence is represented and then input into a selective state space module, which uses the Mamba module to extract long-range dependency features from the input sequence. After obtaining the sequence features, the extracted features at the last time step are input into a fully connected layer, and finally the classification result of this branch is output.
[0050] The fusion discrimination module is used to perform logits-level fusion of the CNN spatial branch output and the Mamba sequence branch output to output the final detection category.
[0051] Furthermore, in this embodiment, the lightweight vehicle network intrusion detection system also includes a detection response module, which is used to execute alarms and linkage protection based on the classification results.
[0052] Furthermore, such as Figure 2As shown, in this embodiment, the CNN spatial branch includes three parallel convolutional sub-paths. The first sub-path uses a 1×1 convolutional layer, a batch normalization (BN) layer, and a ReLU6 activation layer, combined with average pooling to achieve channel mixing and fast downsampling. The second sub-path uses three consecutive 3×3 convolutional layers, at least one of which uses a 3×3 convolution with a stride of 2 (in this embodiment, all three 3×3 convolutional layers have a stride of 2) to extract local texture features step by step and compress spatial dimensions. Each 3×3 convolutional layer is followed by a batch normalization layer and a ReLU6 activation layer. The third sub-path uses three consecutive 5×5 convolutional layers, at least one of which uses a 5×5 convolution with a stride of 2 (in this embodiment, all three 5×5 convolutional layers have a stride of 2) to enhance the modeling ability of cross-feature coupling patterns under a large receptive field. Each convolutional layer is also followed by a batch normalization layer and a ReLU6 activation layer. Activation layer; the outputs of the three parallel convolutional sub-paths are concatenated along the channel dimension, and then further processed through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer (Dropout Layer, p=0.5), and a fully connected layer to obtain the CNN spatial branch output. It can be represented as:
[0053]
[0054] It should be noted that in this embodiment, the convolutional fusion layer is used to fuse features of different scales through convolution operations, and the adaptive global average pooling layer can also be replaced by an adaptive average pooling layer or a flattening layer.
[0055] Furthermore, such as Figure 3 As shown, in this embodiment, the size of the Mamba sequence branch input tensor (input image) is... Let the sequence length in the tensor rearrangement module be... Then the feature dimension d of a single token is:
[0056]
[0057] The tensor rearrangement module will input tensors The rearranged sequence is represented as follows. , can be represented as:
[0058]
[0059] in, This represents a rearrangement operation, which completes the sequence construction.
[0060] Sequence representation The input is a selective state-space module (Mamba module), which performs sequence feature modeling to obtain long-range dependency feature representations. The extracted features from the last time step (the last token) are then input into a fully connected layer, which maps the features to the final branch output. .
[0061] Furthermore, in this embodiment, the hidden state dimension of the Mamba module... Preferably, it is 16, which is the width of the local convolution kernel within the module. The preferred value is 4, channel expansion coefficient. The preferred value is 2. The above parameter configuration is used to enhance the ability to model long-range dependencies while maintaining low computational complexity.
[0062] Example 2:
[0063] like Figures 1 to 6 As shown, this embodiment provides a lightweight vehicle network intrusion detection method based on a parallel CNN-Mamba fusion network. The method specifically includes the following steps:
[0064] Step S1. Obtain the original network traffic samples from the CICIDS2018 dataset through the data receiving module, and use the data preprocessing module to perform data cleaning, field filtering, label organization, null value filling and numerical processing on the original network traffic features.
[0065] Specifically, during data preprocessing, only numerical traffic statistics features that can be used for calculation are retained, fields with severe missing values or invalid semantics are deleted, and outliers, null values, and inconsistent formats are uniformly processed. At the same time, the samples are divided into 11 categories, including normal traffic (Benign), FTP brute-force attack (FTP-BruteForce), SSH brute-force attack (SSH-Bruteforce), HOIC distributed denial-of-service attack (DDOSattack-HOIC), bot control attack (Bot), GoldenEye denial-of-service attack (DoSattacks-GoldenEye), Slowloris denial-of-service attack (DoSattacks-Slowloris), LOIC-UDP distributed denial-of-service attack (DDOSattack-LOIC-UDP), Web brute-force attack (BruteForce-Web), cross-site scripting attack (BruteForce-XSS), and SQL injection attack (SQLInjection), to construct a multi-category intrusion detection task, as shown in Table 1.
[0066] Table 1. Category Distribution of the CICIDS2018 Dataset
[0067] category Sample size Normal traffic 4,883,142 FTP brute force attack 193,360 SSH brute-force attack 187,589 HOIC Distributed Denial-of-Service Attack 686,012 Robot control attack 286,191 GoldenEye Denial-of-Service Attack 41,508 Slowloris Denial-of-Service Attack 10,990 LOIC-UDP Distributed Denial-of-Service Attack 1,730 Web brute-force attack 611 Cross-site scripting attack 230 SQL injection attack 87
[0068] Step S2. Perform quantile transformation and normalization on the data preprocessed in step S1, and then map it to the pixel range. After that, the pseudo-color image construction module converts a single sample into a three-channel pseudo-color image according to the preset rearrangement rules.
[0069] Specifically, let the first The first sample The original features are , No. The minimum and maximum values of the original features in the training set are denoted as follows: and The normalization process can then be expressed as:
[0070]
[0071] in, To prevent tiny constants with a denominator of zero, The data is after normalization;
[0072] Mapping the normalized result to the pixel value range [0, 255] yields the grayscale encoded value (pixel grayscale value):
[0073]
[0074] in, Indicates the first The first sample The pixel grayscale value corresponding to the original feature, round(·) represents the rounding operation.
[0075] Subsequently, the one-dimensional feature sequence of a single sample is sequentially filled into the two-dimensional grid according to the preset row priority mapping rule.
[0076] In this embodiment, when the effective feature dimension of a single sample does not exceed 400, it is rearranged into a 20×20 two-dimensional matrix; if the effective feature dimension is less than 400, the empty positions at the end are filled with zeros; if the effective feature dimension is more than 400, the first 400 numerical features are retained according to feature importance sorting or preset field filtering rules. Thus, for the CICIDS2018 dataset, each sample is mapped to... A two-dimensional matrix.
[0077] Then, the resulting two-dimensional matrix is copied to three channels to construct a 20×20×3 pseudo-color image, which can be represented as:
[0078]
[0079] in, Indicates the pseudo-color image in the first... Channels, coordinates Pixel value at; Indicates the first The grayscale value of each sample after mapping; Represented by two-dimensional coordinates The row-first mapping function to the original one-dimensional feature index.
[0080] To maintain consistency with subsequent model input interfaces, the obtained The pseudo-color image is uniformly scaled using bilinear interpolation. Input tensors to ensure compatibility with subsequent parallel two-branch networks.
[0081] After processing in the above manner, this embodiment can explicitly preserve the local feature combination relationship, adjacent feature coupling relationship and local abnormal texture information change between the statistical features of the original traffic sample in the tensor space, so that it can obtain a clearer structured expression in the image space.
[0082] It should be noted that, in this embodiment, in order to avoid information leakage, all normalized statistics are estimated only on the training set and are fixedly applied to the validation set and test set.
[0083] Step S3. Input the 96×96×3 input tensor obtained in step S2 into the CNN spatial branch and the Mamba sequence branch in parallel. Extract local texture patterns and cross-feature coupling relationships through the CNN spatial branch, and extract long-distance dependent features through the Mamba sequence branch.
[0084] Step S4. The fusion discriminant module outputs the spatial branch of the CNN. With Mamba sequence branch output Logits-level averaging fusion is performed to obtain the final classification vector. , can be represented as:
[0085]
[0086] in, This represents the classification logits output by the spatial branch of the CNN. This represents the categorized logits output by Mamba sequence branches. This represents the final classification vector after fusion.
[0087] In this embodiment, the above-mentioned average fusion method is parameter-free fusion, which can achieve complementary enhancement of spatial representation and sequence representation without the need to introduce additional complex attention layers or gated fusion layers. It can improve model stability without significantly increasing the parameter scale, while taking into account structural simplicity and deployment friendliness.
[0088] Step S5. Based on the classification vector obtained in step S4, output 11 types of detection results. The detection response module triggers alarm reporting, abnormal connection marking, log recording, and access interception or policy linkage handling according to the category with the highest probability.
[0089] The intrusion detection method provided by this invention can be used in offline training-online inference mode, or deployed on vehicle gateways, edge security nodes, or cloud-edge collaborative detection platforms.
[0090] Specifically, during model training, stratified sampling was used to divide the CICIDS2018 samples into training, validation, and test sets in a 7:2:1 ratio. The training set was used for parameter updates, the validation set for selecting optimal model parameters, and the test set was used only for independent evaluation after training. The Adam optimizer was used during training. Considering the data size and training stability, the batch size was set to 16, and the number of training epochs was set to 15. Specific training hyperparameter settings are shown in Table 2.
[0091] Table 2. Main training hyperparameter settings in this embodiment
[0092] hyperparameters Setting value illustrate Learning rate 0.0001 A fixed learning rate is used to highlight the impact of network architecture on performance. Batch size 16 Balancing gradient estimation stability and memory usage Number of training rounds 15 Iterate through the training set for 15 epochs. Optimizer Adam Adaptive optimization algorithms converge quickly. loss function Cross-entropy loss function Suitable for multi-class intrusion detection tasks
[0093] In this embodiment, the model training phase employs the cross-entropy loss function for end-to-end optimization. The loss function is expressed as follows:
[0094]
[0095] in, For the real label in the first One-hot encoded values on a class For the model to the first Predicted probability of class This represents the total number of categories.
[0096] Experimental results and effect verification:
[0097] To verify the effectiveness of the present invention, a CNN-only model, a Mamba-only model, a CNNGRU model, and a CNNBiLSTM model were selected as comparison models, and comparative experiments were conducted under the same data partitioning protocol and number of training epochs. The model performance evaluation results are shown in Table 3.
[0098] Table 3 Model Performance Evaluation Table
[0099] Model accuracy Recall rate Accuracy F1 score AUC This invention model 0.9995 0.9995 0.9999 0.9997 0.9999 CNN 0.9899 0.9900 0.9901 0.9899 0.9397 Mamba 0.9988 0.9988 0.9981 0.9985 0.9986 CNNGRU 0.9932 0.9932 0.9931 0.9932 0.9493 CNNBiLSTM 0.9688 0.9688 0.9688 0.9689 0.9643
[0100] Table 3 provides a comprehensive comparison of different models across five dimensions: accuracy, precision, recall, F1 score, and AUC. As shown in Table 3, the model of this invention achieves the best results in key metrics such as accuracy, F1 score, and AUC. Specifically, compared to the CNN model that only uses convolutional spatial modeling, the accuracy of this invention is improved from 0.9899 to 0.9995. Compared to the Mamba model that only uses Mamba sequence modeling, the F1 score of this invention is further improved to 0.9997, indicating that the parallel dual-branch structure can fully leverage the complementary advantages of spatial pattern modeling and long-range dependency modeling.
[0101] Furthermore, this invention also evaluated the storage size, number of parameters, FLOPs (lower FLOPs mean that the model requires less computational resources during inference, which can significantly reduce power consumption and accelerate the inference process), average inference latency, and throughput of the model of this invention (lightweight vehicle network intrusion detection system). The results are shown in the table below:
[0102] Table 4 Performance evaluation results of the lightweight deployment of this invention
[0103] Storage size (MB) Number of parameters (M) FLOPs (GFLOPs) Average inference latency (ms) Throughput (samples / sec) 3.64 0.955 0.211 1.84 3323.76
[0104] As shown in Table 4, the model storage overhead of this invention is approximately 3.64 MB, the number of parameters is approximately 0.955 M, the average inference latency is 1.84 ms, and the equivalent throughput is approximately 3323.76 samples / sec. This indicates that the proposed parallel CNN-Mamba fusion network maintains high detection accuracy while still possessing good lightweight deployment capabilities and real-time inference performance.
[0105] Furthermore, to address the class imbalance problem, this invention statistically analyzes the precision, recall, and F1 score for each class, and the results are shown in Table 5.
[0106] Table 5. Detection performance of this invention on the CICIDS2018 dataset for each category.
[0107] category accuracy Recall rate F1 score Sample size Benign traffic 0.9992 1.0000 0.9996 1294 FTP brute-force attack 1.0000 1.0000 1.0000 175 SSH brute force 1.0000 1.0000 1.0000 174 HOIC Distributed Denial-of-Service Attack (DDOSattack-HOIC) 1.0000 1.0000 1.0000 294 Bot control attack 1.0000 0.9949 0.9975 198 GoldenEye Denial-of-Service Attack (DoSattacks-GoldenEye) 1.0000 1.0000 1.0000 139 Slowloris Denial-of-Service Attack (DoSattacks-Slowloris) 1.0000 1.0000 1.0000 132 LOIC-UDP Distributed Denial-of-Service Attack (DDOSattack-LOIC-UDP) 1.0000 1.0000 1.0000 129 Web brute-force attack (BruteForce-Web) 0.9944 0.9944 0.9944 179 Cross-site scripting attack (BruteForce-XSS) 1.0000 0.9921 0.9960 126 SQL Injection Attack 0.9923 1.0000 0.9961 129 Macro average (Macro avg) 0.9992 0.9983 0.9985 2969
[0108] As shown in Table 5, the present invention achieves a precision and recall rate close to 1.0000 for the vast majority of attack categories; even in categories with fewer samples or those that are more easily confused, it still maintains a high F1 score, indicating that the present invention has strong robustness in complex multi-category network intrusion scenarios with uneven category distribution.
[0109] Figure 4 The training accuracy and loss of this invention are shown on the CICIDS2018 dataset. It can be seen that as the number of training epochs increases, the training accuracy and validation accuracy rise rapidly and then stabilize, while the training loss and validation loss decrease synchronously. This indicates that the proposed model can achieve stable convergence within a limited number of epochs, without significant oscillations or severe overfitting.
[0110] Figure 5 The confusion matrix diagram of this invention on the CICIDS2018 dataset is presented. As shown in the figure, most samples are distributed in the diagonal region, and the number of false positives is extremely small, further verifying that this invention has a strong ability to distinguish between normal traffic and various types of attack traffic.
[0111] To more intuitively demonstrate the differences between the present invention and various comparative models on multiple evaluation indicators, a graph was plotted based on the results in Table 3. Figure 6 . Figure 6 This demonstrates that the present invention leads in overall accuracy, precision, recall, F1 score, and AUC, with particularly significant advantages in F1 score and AUC, reflecting the comprehensive advantages of the present invention in overall classification performance and threshold stability.
[0112] The present invention also provides an electronic device, comprising: one or more processors and a memory; wherein the memory is used to store one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the lightweight vehicle network intrusion detection method based on parallel CNN-Mamba fusion network described in Embodiment 2.
[0113] The present invention also provides a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the lightweight vehicle network intrusion detection method based on a parallel CNN-Mamba fusion network as described in Embodiment 2.
[0114] Those skilled in the art will understand that all or part of the functions of the various methods / modules in the above embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, which may include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the above functions can be implemented by executing the program with a computer. For example, the program can be stored in the memory of a device, and when the program in the memory is executed by the processor, all or part of the above functions can be implemented.
[0115] In addition, when all or part of the functions in the above embodiments are implemented by computer programs, the programs can also be stored in storage media such as servers, other computers, disks, optical discs, flash drives, or portable hard drives. They can be downloaded or copied to the memory of the local device, or the system of the local device can be updated. When the program in the memory is executed by the processor, all or part of the functions in the above embodiments can be implemented.
[0116] The above description is merely a specific embodiment 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 scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of protection described in the claims.
Claims
1. A lightweight Internet of Vehicles intrusion detection system based on a parallel CNN-Mamba fusion network, characterized in that, The system includes a data receiving module for receiving network traffic data, a data preprocessing module for cleaning, encoding, normalizing and classifying the data, a pseudo-color image construction module for mapping network traffic data into a three-channel pseudo-color image and scaling it, a parallel dual-branch network consisting of a CNN spatial branch and a Mamba sequence branch, and a fusion discrimination module for averaging and fusing the outputs of the CNN spatial branch and the Mamba sequence branch to output the final detected category. The CNN spatial branch is used to extract local texture patterns and cross-feature coupling relationships. It employs three parallel convolutional sub-paths to extract local features under different receptive fields. The outputs of the three parallel convolutional sub-paths are then concatenated in the channel dimension and sequentially passed through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer, and a fully connected layer to obtain the CNN spatial branch output. The Mamba sequence branch is used to extract long-range dependence features, comprising a tensor rearrangement module, a selective state space module and a full connection layer arranged in sequence; wherein the tensor rearrangement module is used to rearrange the input tensor into a sequence representation with a length of , and then input the selective state space module; the selective state space module adopts the Mamba module, extracts long-range dependence features from the input sequence through the Mamba module, inputs the last moment features extracted into the full connection layer after obtaining the sequence features, and finally outputs the classification result of the branch.
2. The lightweight vehicle network intrusion detection system based on a parallel CNN-Mamba fusion network according to claim 1, characterized in that, The lightweight vehicle network intrusion detection system also includes a detection response module, which is used to execute alarms and linkage protection based on the classification results.
3. The lightweight vehicle network intrusion detection system based on a parallel CNN-Mamba fusion network according to claim 1, characterized in that, The CNN spatial branch comprises three parallel convolutional sub-paths. The first sub-path uses a 1×1 convolutional layer, a batch normalization layer, and a ReLU6 activation layer, combined with average pooling. The second sub-path uses three consecutive 3×3 convolutional layers, with at least one layer using a stride of 2. Each 3×3 convolutional layer is followed by a batch normalization layer and a ReLU6 activation layer. The third sub-path uses three consecutive 5×5 convolutional layers, with at least one layer using a stride of 2. Each convolutional layer is followed by a batch normalization layer and a ReLU6 activation layer. The outputs of the three parallel convolutional sub-paths are concatenated along the channel dimension, then pass through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer, and a fully connected layer to obtain the CNN spatial branch output.
4. The lightweight vehicle network intrusion detection system based on a parallel CNN-Mamba fusion network according to claim 1, characterized in that, The size of the Mamba sequence branch input tensor is Sequence length in the tensor rearrangement module Then the feature dimension d of a single token is: ; The tensor rearrangement module will input tensors The rearranged sequence is represented as follows. , is represented as: ; in, This represents a rearrangement operation, which completes the sequence construction through rearrangement operations; Sequence representation The input is a Mamba module, which performs sequence feature modeling to obtain long-range dependency feature representations. The extracted features from the last time step are then input into a fully connected layer, which maps the features to the final branch output. .
5. The lightweight vehicle network intrusion detection system based on a parallel CNN-Mamba fusion network according to claim 3, characterized in that, In the CNN spatial branch, the stride of the three 3×3 convolutional layers is 2, the stride of the three 5×5 convolutional layers is 2, and the dropout rate of the random deactivation layer is p=0.
5.
6. The lightweight vehicle network intrusion detection system based on a parallel CNN-Mamba fusion network according to claim 4, characterized in that, The hidden state dimension of the Mamba module The width of the local convolutional kernel within the module is 16. The channel expansion coefficient is 4. The value is 2.
7. A lightweight intrusion detection method for vehicle networks based on a parallel CNN-Mamba fusion network, characterized in that, The method specifically includes the following steps: Step S1. Obtain network traffic data through the data receiving module, and preprocess the network traffic data using the data preprocessing module; Step S2. Perform quantile transformation and normalization on the data preprocessed in step S1, and then map it to the pixel range. After that, the pseudo-color image construction module converts a single network traffic data into a three-channel pseudo-color image according to the preset rearrangement rules. Step S3. Input the data obtained in step S2 into the CNN spatial branch and the Mamba sequence branch in parallel. Extract local texture patterns and cross-feature coupling relationships through the CNN spatial branch, and extract long-distance dependent features through the Mamba sequence branch. The CNN spatial branch uses three parallel convolutional sub-paths to extract local features under different receptive fields. Then, the outputs of the three parallel convolutional sub-paths are concatenated in the channel dimension, and then sequentially pass through a convolutional fusion layer, a batch normalization layer, an adaptive global average pooling layer, a random deactivation layer, and a fully connected layer to obtain the CNN spatial branch output. The Mamba sequence branch includes a tensor rearrangement module, a selective state space module, and a fully connected layer arranged sequentially; wherein, the tensor rearrangement module is used to rearrange the input tensor into a sequence of length [missing information]. The sequence is represented and then input into a selective state space module. The selective state space module uses the Mamba module to extract long-range dependency features from the input sequence. After obtaining the sequence features, the extracted features at the last time step are input into a fully connected layer, and finally the classification result of this branch is output. Step S4. The fusion discriminant module outputs the spatial branch of the CNN. With Mamba sequence branch output Logits-level averaging fusion is performed to obtain the final classification vector; Step S5. Output the classification detection result based on the classification vector obtained in step S4.
8. The lightweight vehicle network intrusion detection method based on parallel CNN-Mamba fusion network according to claim 7, characterized in that, In step S2, the normalized result is first mapped to the pixel value range [0, 255] to obtain the grayscale code value; then, according to the preset row-first mapping rule, the one-dimensional feature sequence of a single network traffic data is sequentially filled into the two-dimensional grid; then, the obtained two-dimensional matrix is copied to the three channels to construct a three-channel pseudo-color image; finally, the obtained three-channel pseudo-color image is uniformly scaled using bilinear interpolation. Input tensor.
9. The lightweight vehicle network intrusion detection method based on parallel CNN-Mamba fusion network according to claim 7, characterized in that, After obtaining the classification detection results in step S5, the detection response module triggers alarm reporting, abnormal connection marking, log recording, and access interception or policy linkage processing based on the category with the highest probability.
10. The lightweight vehicle network intrusion detection method based on a parallel CNN-Mamba fusion network according to claim 8, characterized in that, In step S2, when the effective feature dimension of a single network traffic data point does not exceed 400, it is rearranged into a 20×20 two-dimensional matrix; if the effective feature dimension is less than 400, the remaining positions at the tail are filled with zeros; if the effective feature dimension is more than 400, the first 400 numerical features are retained according to feature importance sorting or preset field filtering rules, so that each sample is mapped to... A two-dimensional matrix.