Vehicle networking intrusion detection method, system and device based on hierarchical classification model

By constructing a hierarchical classification model for vehicle-to-everything (V2X) intrusion detection, and utilizing a global and local convolutional flow architecture and a hierarchical violation penalty loss function, the method solves the problem of imbalanced data in V2X, achieving efficient intrusion detection and a low false detection rate, and is suitable for deployment in vehicle terminals.

CN122120020APending Publication Date: 2026-05-29SOUTHEAST UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTHEAST UNIV
Filing Date
2026-04-22
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

The Internet of Vehicles (IoV) network suffers from data imbalance. Existing data sampling methods lead to decreased model generalization ability or increased false detection rate, making it difficult to effectively detect minority attacks.

Method used

A vehicle network intrusion detection method based on a hierarchical classification model is constructed. By using a dual information flow architecture of global convolutional stream and local convolutional stream, embedding prior knowledge of categories, and designing a hierarchical violation penalty loss function, a high detection rate for minority classes and a low false detection rate for majority classes can be achieved.

Benefits of technology

It improves the detection rate of minority class attacks, reduces the false detection rate of majority class attacks, enhances the model's adaptability to imbalanced data, and has stronger generalization ability and interpretability, making it suitable for resource-constrained vehicle terminal deployments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122120020A_ABST
    Figure CN122120020A_ABST
Patent Text Reader

Abstract

The application discloses a layered classification model-based vehicle networking intrusion detection method, system and device, and relates to the technical field of vehicle networking network security.The application first encodes, normalizes and zero-fills the intrusion detection data for preprocessing to obtain a two-dimensional feature matrix suitable for a convolution layer; then a layered classification model embedding category prior is constructed, a category weight is introduced to construct a composite loss function of violation penalty; then flat data labels are converted into hierarchical labels; finally, the trained model is deployed on a vehicle terminal.The application constructs a layered classification model suitable for the hierarchical structure of vehicle networking attacks, embeds category prior knowledge, realizes the effect of high detection rate of minority class data and low false detection rate of majority class data, and simultaneously adapts to the end-side deployment requirements of limited vehicle networking resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of vehicle network security technology, specifically to a vehicle network intrusion detection method, system, and device based on a hierarchical classification model. Background Technology

[0002] Network intrusion detection, as an effective means of protecting the network security of connected vehicles, is a key technology for resisting malicious intrusions into connected vehicles by analyzing data such as network traffic and node status to identify normal data and various network attack data. However, the relevant datasets suffer from a serious data imbalance problem: normal network interactions and node status data account for a very high proportion in connected vehicles, while attack data accounts for a very low proportion, and the sample size of different types of attack data varies greatly.

[0003] To address this issue, existing technologies primarily employ data sampling methods, including oversampling and undersampling. Oversampling balances the data distribution by generating synthetic minority class samples, but it significantly increases the computational cost of data processing, and synthetic samples are prone to introducing noise, leading to a decrease in the model's generalization ability. Undersampling balances the data distribution by reducing majority class samples, but it loses a large amount of effective majority class information, resulting in an increased false detection rate of the model on normal data, making it difficult to improve the detection rate of minority class attacks.

[0004] Therefore, this invention proposes a method, system, and device for vehicle network intrusion detection based on a hierarchical classification model. Summary of the Invention

[0005] The purpose of this invention is to provide a method, system and device for vehicle network intrusion detection based on a hierarchical classification model. By constructing a hierarchical classification model adapted to the attack hierarchy of vehicle networks and embedding prior knowledge of categories, the invention achieves the effect of high detection rate for minority class data and low false detection rate for majority class data.

[0006] According to a first aspect of the present invention, in order to achieve the above-mentioned objective, the present invention provides the following technical solution: a vehicle network intrusion detection method based on a hierarchical classification model, comprising the following steps: Receive raw intrusion detection data from the vehicle network and preprocess it to output a two-dimensional feature matrix; Based on the hierarchical structure of vehicle network attack types, a hierarchical classification model is constructed, which includes a global convolutional stream, a local convolutional stream, and an output layer. The global convolutional stream takes a two-dimensional feature matrix as input and learns global features across layers layer by layer. The local convolutional stream is used to extract local features from the corresponding layer of the global convolutional stream. The output layer fuses the global features output by the global convolutional stream and the local features output by the local convolutional stream into an intrusion category probability prediction vector. Based on the hierarchical structure of vehicle network attack types, the preprocessed original flat intrusion labels are mapped to a set of hierarchical sub-labels that match the hierarchical structure of the hierarchical classification model. Construct a joint loss function that includes local loss, global loss and hierarchical violation penalty loss, use hierarchical sub-labels as training labels, and train the hierarchical classification model with the goal of minimizing the joint loss function to obtain the trained hierarchical classification model; This is used to input the two-dimensional feature matrix to be detected into the trained hierarchical classification model to obtain the intrusion detection result.

[0007] Furthermore, the system receives and preprocesses raw intrusion detection data from the vehicle network, specifically including: Feature filtering: Remove redundant, invalid, and missing values ​​from the original data to obtain a feature set to be processed, which includes character features and numerical features; Feature encoding: The character features are converted into numerical values ​​using binary one-hot encoding. The encoded numerical features are then concatenated with the retained original numerical features to obtain a one-dimensional original feature vector. Numerical normalization: Normalizing the original one-dimensional feature vector using the following formula: in, The feature elements are the original one-dimensional feature vector. The minimum value among the characteristic elements. The maximum value among the characteristic elements; Zero-padding transformation: The normalized one-dimensional feature vector is filled into a pre-defined two-dimensional empty matrix in row-major order, and zero-padding is applied to the unfilled positions to obtain the final two-dimensional feature matrix. , is a positive integer representing the number of rows and columns of the two-dimensional feature matrix.

[0008] Furthermore, a hierarchical classification model is constructed, as follows: Based on the attack type definition for vehicle network intrusion detection, the attack hierarchy is divided, with the total number of levels set as follows: , No. The set of layer categories is The model specifically includes: Global convolutional stream: contains Each convolutional layer learns global intrusion features across layers, and each layer explicitly concatenates and reuses the original two-dimensional feature matrix. The activation formula for the first layer global convolution is: in, This represents the feature activation matrix of the first-layer global convolutional flow. The convolution kernel for the first layer of global convolutional flow. This is a two-dimensional convolution operation. It is a ReLU nonlinear activation function. This is the bias vector of the first-layer global convolutional flow; No. The global convolution activation formula for a layer is: in, For the first Feature activation matrix of the global convolutional flow of the layer, For the first The kernel parameters of the global convolutional flow of the layer. Explicit splicing operations characterized by [feature name]. For the first The bias vector of the global convolutional flow of the layer; Local convolutional flow: contains There are 3 independent convolutional branches, each corresponding to an attack level. The formula for local convolution activation in a layer is: in, For the first Feature activation matrix of local convolutional flow in layer, For the first Convolution kernel parameters for global-to-local layer transformation. For the first Bias vector from global to local layer; Output layer: Based on the last layer of global convolutional activation, it maps to a probability vector of the total number of categories through convolutional layers, achieving global intrusion detection. The formula is: in, This is the global output class probability vector. To connect the kernel parameters of the last global convolutional layer with the global output layer, It is the Sigmoid activation function. This is the bias vector for the global output layer; Each level corresponds to a local output layer, which is mapped to the probability vector of this layer's category through convolutional layers, achieving level-specific intrusion detection. The formula is as follows: in, For the first The class probability vector output locally by the layer. For the first The output convolution kernel parameters of the local convolutional flow of the layer, For the first The bias vector of the local output layer; Finally, the local prediction vectors from all levels are concatenated and weighted with the global prediction vector to obtain the final invasion category probability prediction vector of the model, as shown in the formula: in, This is the final class probability vector that the model fuses and predicts. is the local-global prediction fusion coefficient, with a value range of [0,1].

[0009] Furthermore, based on the hierarchical structure of vehicle network attack types, the preprocessed original flat intrusion labels are mapped to a set of hierarchical sub-labels that match the hierarchical structure of the hierarchical classification model, as follows: The original vehicle network intrusion detection tags are flat binary vectors. , For the original flat intrusion tag, This represents the total number of categories across all levels. An element in the vector is 1 if the sample belongs to that intrusion category, and 0 if it does not. Based on the hierarchical relationship of attack types, the original flat labels are... Mapped to The hierarchical sub-tag, the first h The formula for layered sub-tags is: in, For the first Layered sub-tags of layers, For the first h Number of layer categories; If a category in the original tag is a positive example, then all its parent categories are positive examples. This applies to all enhanced hierarchical sub-tags. Explicitly concatenate to obtain global tags The formula is: .

[0010] Furthermore, the formula for the composite loss function is: in, The total loss of the model, For localized losses, For the overall loss, Penalties for violations at different levels; Local loss The binary cross-entropy loss is used to calculate the error between local predictions at all levels and hierarchical sub-labels. The calculation formula is as follows: in, This is the batch size for mini-batch training. For the first Class of samples The actual label value, Represents the output vector The element corresponding to the middle tag 'c'; Global loss The binary cross-entropy loss is used to calculate the error between the global prediction and the global label. The calculation formula is as follows: in, For the first Class of samples The global true label value; Level violation penalties To apply L2 penalties to predictions that violate the attack hierarchy, the formula is: in, This is the penalty coefficient, which takes the value of a positive real number. Predict probabilities for subcategories. The penalty value is generated only when the probability of the child class is higher than that of the parent class, corresponding to the predicted probability of the parent class.

[0011] Furthermore, the training and deployment process of the hierarchical classification model is as follows: The preprocessed two-dimensional feature matrix is ​​input into the hierarchical classification model, and the prediction result is obtained through forward propagation. The model parameters are then optimized through backpropagation based on the composite loss function. Perform lightweight processing, including model pruning and / or quantization, on the best trained model; The lightweight model is converted into a model format adapted to in-vehicle terminals and deployed for intrusion detection of real-time collected vehicle network data.

[0012] According to a second aspect of the present invention, the present invention provides a vehicle network intrusion detection system based on a hierarchical classification model, for implementing the vehicle network intrusion detection method based on a hierarchical classification model described in the first aspect, comprising: The data preprocessing module is used to receive raw intrusion detection data from the vehicle network and preprocess it to output a two-dimensional feature matrix. The model building module is used to construct a hierarchical classification model based on the hierarchical structure of vehicle network attack types. It includes a global convolutional stream, a local convolutional stream, and an output layer. The global convolutional stream takes a two-dimensional feature matrix as input and learns global features across layers layer by layer. The local convolutional stream is used to extract local features from the corresponding layer of the global convolutional stream. The output layer fuses the global features output by the global convolutional stream and the local features output by the local convolutional stream into an intrusion category probability prediction vector. The tag reconstruction module is used to map the preprocessed original flat intrusion tags to a set of hierarchical sub-tags that match the hierarchical structure of the hierarchical classification model, based on the hierarchical structure of the vehicle network attack type. The model training module is used to construct a joint loss function that includes local loss, global loss, and hierarchical violation penalty loss. Using hierarchical sub-labels as training labels, the hierarchical classification model is trained with the goal of minimizing the joint loss function, resulting in the trained hierarchical classification model. The output module takes the two-dimensional feature matrix to be detected and inputs it into the trained hierarchical classification model to obtain the intrusion detection results.

[0013] According to a third aspect of the present invention, a terminal device is provided, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor. The memory stores the computer program capable of running on the processor, and when the processor loads and executes the computer program, it employs the vehicle network intrusion detection method based on a hierarchical classification model described in the first aspect.

[0014] According to a fourth aspect of the present invention, the present invention provides a storage medium containing computer-executable instructions, wherein the computer-executable instructions, when executed by a computer processor, are used to perform the vehicle network intrusion detection method based on a hierarchical classification model as described in the first aspect.

[0015] According to a fifth aspect of the present invention, the present invention provides a computer program product, characterized in that the computer program product includes a computer program, which, when executed by a processor, is used to load and execute the vehicle network intrusion detection method based on a hierarchical classification model as described in the first aspect.

[0016] This invention has at least the following beneficial effects: 1. This invention constructs a hierarchical classification model adapted to the attack hierarchy of the Internet of Vehicles (IoV), embedding prior knowledge of categories into the model architecture and the entire training process. This fundamentally improves the insufficient detection capability of traditional methods for minority class attacks. This method avoids the noise and reduced generalization ability introduced by oversampling to generate synthetic samples; it also avoids discarding majority class samples through undersampling, thus preserving the complete information of normal data and reducing the false detection rate. Ultimately, it achieves a significant improvement in the detection rate of minority class attacks while ensuring a low false detection rate for normal majority class data, comprehensively enhancing the model's adaptability to imbalanced data.

[0017] 2. This invention introduces a hierarchical structure of attack types and incorporates a hierarchical violation penalty term into the loss function. This penalty mechanism constrains prediction results that violate the logical relationship between parent and child categories, ensuring, for example, that the model will not predict unreasonable results such as "attack" for a child category when the parent category is "normal". This design effectively guarantees the hierarchical consistency of prediction results, improves the interpretability and reliability of the model output, and better aligns with the actual business logic of vehicle network security detection.

[0018] 3. This invention approaches the problem from the model architecture level. Through the design of a dual information flow (global convolutional flow and local convolutional flow), the model can learn global intrusion features across layers while focusing on fine-grained distinguishing features at each layer. This architectural innovation makes the model naturally robust to data imbalance problems, independent of the distribution characteristics of a specific dataset, and therefore has stronger generalization ability, flexibly adapting to attack type definitions and hierarchical divisions in different vehicle networking scenarios.

[0019] 4. This invention employs a hierarchical classification model architecture, which has a significantly lower number of parameters and computational cost compared to traditional model ensemble methods. This fundamentally overcomes the limitation of ensemble models being difficult to deploy on vehicle-side devices due to the linear growth of parameters. Furthermore, this invention performs lightweight processing such as pruning and quantization on the trained model, significantly reducing storage space, computational overhead, and memory usage while ensuring acceptable performance loss. This enables the intrusion detection method of this invention to be efficiently deployed on resource-constrained edge devices such as vehicle terminals and roadside units, meeting the stringent requirements of vehicle-to-everything (V2X) networks for real-time performance and low power consumption.

[0020] Of course, any product implementing this invention does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a schematic flowchart of the detection method described in this invention; Figure 2 This is a schematic diagram of the hierarchical sub-tag structure of the present invention; Figure 3 This is a schematic diagram of the hierarchical classification model of the present invention. Detailed Implementation

[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0024] Example 1: Please see Figure 1 This invention provides a technical solution: a vehicle network intrusion detection method based on a hierarchical classification model, comprising the following steps: Step 1: Receive and preprocess the raw intrusion detection data from the vehicle network, and output a two-dimensional feature matrix, as follows: The raw intrusion detection data consists of network traffic logs from a vehicle-to-everything (V2X) communication scenario. Specifically, it includes communication message characteristics and traffic statistics between vehicles, between vehicles and roadside units (RSUs), and between vehicles and cloud servers. This data is used to train a hierarchical classification model for intrusion detection. The raw V2X intrusion detection data undergoes feature filtering, feature encoding, numerical normalization, and zero-padding to convert the raw features into a two-dimensional feature matrix suitable for the model input. Simultaneously, the numerical consistency of the features is ensured, eliminating the influence of dimensions on model training. Specific steps include: Step 1-1 Feature Filtering: Remove redundant, invalid, and missing values ​​from the original data, and retain the core features related to vehicle network intrusion detection, such as the data packet length, connection duration, and protocol type of network traffic, to obtain a feature set to be processed containing character and numerical features; Step 1-2 Feature Encoding: The character features are converted into numerical values ​​using binary one-hot encoding. The encoded numerical features are then concatenated with the retained original numerical features to obtain a one-dimensional original feature vector. Steps 1-3: Numerical Normalization: Normalize the original one-dimensional feature vector using the following formula: (1) in, The feature elements are the original one-dimensional feature vector. The minimum value among the characteristic elements. The maximum value among the feature elements is used for normalization to eliminate numerical differences between features, thereby improving the convergence speed and training stability of the model. Steps 1-4 Zero-padding transformation: According to the input requirements of the convolutional layer of the hierarchical classification model, the normalized one-dimensional feature vector is filled into the preset two-dimensional empty matrix in row-major order, and zero-padding is performed on the unfilled positions to finally obtain the two-dimensional feature matrix that can be directly input into the convolutional layer. , is a positive integer representing the number of rows and columns of the two-dimensional feature matrix; Step 2: Based on the hierarchical structure of vehicle network attack types, a hierarchical classification model is constructed to embed prior class probabilities into the model, addressing the data imbalance problem at the model architecture level. The model adopts a dual-information-flow architecture of global convolutional flow and local convolutional flow, including an input layer, convolutional feature learning layer, global output layer, multiple local output layers, and prediction fusion layer, such as... Figure 3 As shown, the input to the hierarchical classification model is the two-dimensional feature matrix obtained in step 1. The output is a probability prediction vector for the vehicle network intrusion category; Based on the attack type definition for vehicle network intrusion detection, the attack hierarchy is divided, with the total number of levels set as follows: , No. The set of layer categories is The model is as follows: Step 2-1 Global Convolutional Flow: Contains Each convolutional layer learns global intrusion features across layers, and each layer explicitly concatenates and reuses the original two-dimensional feature matrix. The activation formula for the first layer global convolution is: (2) in, This represents the feature activation matrix of the first-layer global convolutional flow. The convolution kernel for the first layer of global convolutional flow. This is a two-dimensional convolution operation. It is a ReLU nonlinear activation function. This is the bias vector of the first-layer global convolutional flow; No. The global convolution activation formula for a layer is: (3) in, For the first Feature activation matrix of the global convolutional flow of the layer, For the first The kernel parameters of the global convolutional flow of the layer. Explicit splicing operations characterized by [feature name]. For the first The bias vector of the global convolutional flow of the layer; Step 2-2 Local Convolutional Flow: Contains Each branch has an independent convolutional branch, and each branch corresponds to an attack level. Local features are extracted from the corresponding level of the global convolutional flow to specifically learn the class discrimination features of that level. The formula for local convolution activation in a layer is: (4) in, For the first Feature activation matrix of local convolutional flow in layer, For the first Convolution kernel parameters for global-to-local layer transformation. For the first Bias vector from global to local layer; Step 2-3 Output Layer: Based on the last layer of global convolutional activation, the probability vector of the total number of categories is mapped through the convolutional layer to achieve global intrusion detection. The formula is as follows: (5) in, This is the global output class probability vector. To connect the kernel parameters of the last global convolutional layer with the global output layer, It is the Sigmoid activation function. This represents the bias vector for the global output layer. Furthermore, each layer corresponds to a local output layer, which is mapped to a probability vector for that layer's category via a convolutional layer, achieving layer-specific intrusion detection. The formula is: (6) in, For the first The class probability vector output locally by the layer. For the first The output convolution kernel parameters of the local convolutional flow of the layer, For the first The bias vector of the local output layer; Finally, the local prediction vectors from all levels are concatenated and weighted with the global prediction vector to obtain the final invasion category probability prediction vector of the model, as shown in the formula: (7) in, This is the final class probability vector that the model fuses and predicts. This is the local-global prediction fusion coefficient, with a value range of [0,1] and a default value of 0.5. It is used to balance the weights of local hierarchical features and global cross-hierarchical features. Step 3: Based on the vehicle network attack hierarchy structure defined in Step 2, the original flat intrusion labels are converted into a set of hierarchical sub-labels that match the hierarchy structure, so that the label structure is adapted to the model architecture and class priors, and the model's ability to learn minority class attacks is further improved. The original vehicle network intrusion detection tags are flat binary vectors. , For the original flat intrusion tag, This represents the total number of categories across all levels. An element in the vector is 1 if the sample belongs to that intrusion category, and 0 if it does not. like Figure 2 As shown, based on the hierarchical relationship of attack types, the original flat labels are... Mapped to The hierarchical sub-tag, the first h The formula for layered sub-labels is: , For the first Layered sub-tags of layers, For the first h The number of categories in a layer: if a category in the original tag is a positive example, then all its parent categories are positive examples. This applies to all enhanced layered sub-tags. Explicitly concatenate to obtain global tags The formula is: (8); Step 4: Design of the composite loss function: Step 4-1: The formula for the composite loss function is: (9) in, The total loss of the model, For localized losses, For the overall loss, Penalties for violations at different levels; Step 4-2: Local Loss The binary cross-entropy loss is used to calculate the error between local predictions and hierarchical sub-labels at all levels, adapting to the non-mutually exclusive characteristics of multi-class intrusion detection. The formula is as follows: (10) in, This is the batch size for mini-batch training. For the first Class of samples The actual label value; Step 4-3: Global Loss The error between the global prediction and the global label is calculated using the binary cross-entropy loss formula: (11) in, For the first Class of samples The global true label value, Represents the output vector The element corresponding to the middle tag 'c'; Step 4-4: Hierarchical Violation Penalties To apply L2 penalties to predictions that violate the attack hierarchy structure and ensure the consistency of the prediction results (e.g., if the second layer detects attack 2, then the first layer must first detect non-attack 1), the formula is as follows: (12) in, This is the penalty coefficient, which takes the value of a positive real number, with a default value of 0.1. Predict probabilities for subcategories. The penalty value is generated only when the probability of the child class is higher than that of the parent class, corresponding to the predicted probability of the parent class. Step 5: Training and Deployment of the Hierarchical Classification Model: Based on the preprocessed two-dimensional feature matrix and the constructed hierarchical labels, the hierarchical classification model is trained and the model parameters are optimized. At the same time, considering the limited resources of the Internet of Vehicles, the trained model is lightweighted to meet the deployment requirements of the vehicle terminal. Step 5-1: Input the two-dimensional feature matrix of the training set into the hierarchical classification model, perform forward propagation to obtain the intrusion category probability prediction vector, and calculate the composite loss function. The model optimizes all learnable parameters through backpropagation; after each training epoch, the model's precision, recall, F1 score, and minority class recall are evaluated on the validation set, and the model with the best minority class recall on the validation set is saved. Step 5-2: In view of the limited resources of vehicle-mounted terminals in the Internet of Vehicles, the optimal model is lightweighted (including model pruning and quantization) to reduce the number of model parameters, computational load and storage space while ensuring detection performance; Step 5-3: Convert the lightweight model to a model format compatible with vehicle-to-everything (V2X) terminals (such as ONNX, TensorRT, TFLite) to deploy the model. The V2X data to be detected, after preprocessing in Step 1, is input into the deployed model to obtain the intrusion detection results.

[0025] The technical solution of this invention will be further elaborated below with specific simulation examples: This embodiment uses the classic network intrusion detection NSL-KDD dataset as the experimental basis. Targeting the traffic characteristics of the Internet of Vehicles, it sets 5-class detection targets, constructs a 4-layer hierarchical structure, and uses the Python+PyTorch deep learning framework to implement the model development.

[0026] In this embodiment, the NSL-KDD dataset, after being adapted for the vehicle-to-everything (V2X) scenario, retains five types of samples: Normal, DoS (DoS) attack, Probe (Port Probing) attack, R2L (Remote to Local) attack, and U2R (User to Root) attack. It exhibits typical data imbalance characteristics: Normal data accounts for 88.2%, DoS attack for 7.5%, Probe attack for 3.1%, R2L attack for 1.0%, and U2R attack for 0.2%, which highly matches the actual data distribution of V2X intrusion detection. Simultaneously, a four-layer attack hierarchy structure is defined, with the hierarchy aligning with the severity of the attack, detection priority, and type classification, achieving refined intrusion identification layer by layer. The hierarchy is defined as follows: First layer : Normal / Abnormal (Core level, first distinguish whether it is an intrusion behavior); Second floor Abnormal DoS attack / Non-DoS attack; Third layer Probe attack under non-DoS attack / non-Probe attack; Fourth floor R2L attack / U2R attack without a Probe attack.

[0027] Step 1: Data Preprocessing The NSL-KDD dataset adapted for the vehicle-to-everything (V2X) scenario undergoes feature selection, feature encoding, numerical normalization, and zero-padding to eliminate redundant features and the influence of dimensions, ultimately yielding a 12×12 two-dimensional feature matrix suitable for the input of the convolutional layer. The specific operations are as follows: (1) Feature selection: The original NSL-KDD dataset contains 41-dimensional features. Redundant features with missing values ​​and variances close to 0 are removed to form a feature set to be processed. (2) Feature encoding: The character features are converted into numerical values ​​using binary one-hot encoding to generate a one-hot feature vector; this vector is then concatenated with the original numerical features column by column to obtain a 122-dimensional one-dimensional original feature vector. (3) Numerical normalization: According to formula (1), the one-dimensional original feature vector is subjected to minimum-maximum normalization to map all feature values ​​to the interval [0,1], eliminate the numerical differences between features, and improve the convergence speed and stability of model training. (4) Zero-padding transformation: Based on the input requirements of the convolutional layer of the hierarchical classification model, the dimension of the two-dimensional feature matrix is ​​set. The normalized one-dimensional feature vectors are sequentially filled into a 12×12 two-dimensional empty matrix according to the row priority rule. The unfilled positions are padded with zeros to finally obtain a two-dimensional feature matrix that can be directly input into the convolutional layer, thus completing the data preprocessing. Step 2: Building a hierarchical classification model Based on a four-layer attack hierarchy, a dual-information-flow hierarchical classification model is constructed. The model includes an input layer, a convolutional feature learning layer, a global output layer, four local output layers, and a prediction fusion layer. The input is a 12×12 two-dimensional feature matrix obtained in step 1, and the output is a five-class invasion category probability prediction vector. The model architecture and parameters strictly follow the technical solution of this invention, and the specific implementation is as follows: (1) Construction of global convolutional flow Global intrusion features across layers are learned through four convolutional layers. Each layer explicitly concatenates and reuses the original 12×12 two-dimensional feature matrix using the `concat()` operation. Each convolutional kernel is 3×3 in size, with the number of kernels being 32, 64, 128, and 256 respectively, a stride of 1, and SAME padding. Feature activation is achieved according to formulas (2) and (3). It is a ReLU nonlinear activation function; (2) Construction of local convolutional flow Four independent convolutional branches are set up, each corresponding to one of the four attack levels. Local features are extracted from the corresponding level of the global convolutional flow to specifically learn the class discrimination features of that level. The kernel size of each branch is 3×3, the number of kernels is 128, the stride is 1, and the padding method is SAME. Feature activation is achieved according to formula (4). (3) Output layer and prediction fusion The output layer consists of one global output layer and four local output layers, which respectively implement global intrusion detection and hierarchical specific intrusion detection. Finally, the model's final prediction result is obtained through weighted fusion. (4) Composite loss function, the calculation rules for each loss term are as follows: Local loss The errors of all four layers of local prediction and hierarchical sub-labels are calculated according to formula (10) to adapt to the non-mutually exclusive characteristics of multi-class intrusion detection; global loss Calculate the error between the global prediction and the global label using formula (11); hierarchical violation penalty loss. Calculate according to formula (12) and set the penalty coefficient. L2 penalty is applied to prediction results that violate the hierarchical structure to ensure prediction consistency (e.g., if the fourth layer detects a U2R attack, the first three layers must be detected as "abnormal, non-DoS, non-Probe" in sequence).

[0028] Step 3: Building Hierarchical Tags Based on the 4-layer attack hierarchy, the 5-dimensional original flat binary labels (normal, DoS, Probe, R2L, U2R, where 1 in the vector element indicates belonging to the category and 0 indicates not belonging) of the NSL-KDD dataset are converted into 4 layers of 2-dimensional hierarchical sub-labels. Then, an 8-dimensional global label is obtained by concatenation, achieving complete adaptation between the label structure and the model architecture and category prior knowledge. Specifically, if a category in the original label is a positive example, then all its parent categories are positive examples; each layer of hierarchical sub-labels is a 2-dimensional binary vector, with elements defined as [negative example, positive example] (e.g., the first layer, normal, is [1,0], and abnormal is [0,1]). For a 5-category target, there are 4 layers of hierarchical sub-labels. The generation rules are as follows: First layer : Normal [1,0], Abnormal [0,1]; Second floor DoS attack [0,1], non-DoS attack [1,0]; Third layer : Probe attack [0,1], non-Probe attack [1,0]; Fourth floor : R2L attack [0,1], U2R attack [1,0].

[0029] According to formula (8), the four layers of 2D sub-labels are explicitly concatenated to obtain an 8D global binary label. , serving as the true label for calculating the global loss of the model.

[0030] Step 4: Model Training and Deployment The preprocessed 12×12 two-dimensional data was divided into training and testing sets in an 8:2 ratio. After model training and lightweight optimization, it was deployed on the vehicle to achieve full-scene intrusion detection. The specific operations are as follows: (1) Model training Training hyperparameter settings, batch size The training run consisted of 100 epochs. The optimizer used was Adam, with an initial learning rate of 0.001, which decreased to 0.5 every 20 epochs. The training device was an NVIDIA 4060 GPU. The two-dimensional feature matrix of the training set was input into the hierarchical classification model. Forward propagation yielded an 8-dimensional probability prediction vector. The composite loss function was calculated, and all learnable parameters of the model were optimized through backpropagation. Finally, the model with the best minority class recall on the validation set was saved as the baseline model.

[0031] (2) Model Deployment To address the resource constraints of in-vehicle systems, the baseline model undergoes channel pruning and FP16 quantization for lightweighting. While ensuring a detection performance loss of ≤5%, this significantly reduces the number of model parameters, computational load, and storage space. Specifically, L1 regularization is used to filter convolutional kernel weights, redundant channels are removed, a pruning rate of 20% is applied, and meaningless feature learning branches are deleted. The 32-bit floating-point parameters in the model are converted to 16-bit half-precision floating-point parameters to reduce model storage space and inference computation.

[0032] The lightweight design reduces the number of model parameters by more than 50%, adapting to the hardware resource limitations of deployment terminals.

[0033] Example 2: This embodiment provides a vehicle network intrusion detection system based on a hierarchical classification model, used to implement the vehicle network intrusion detection method based on a hierarchical classification model described in Embodiment 1, including: The data preprocessing module is used to receive raw intrusion detection data from the vehicle network and preprocess it to output a two-dimensional feature matrix. The model building module is used to construct a hierarchical classification model based on the hierarchical structure of vehicle network attack types. It includes a global convolutional stream, a local convolutional stream, and an output layer. The global convolutional stream takes a two-dimensional feature matrix as input and learns global features across layers layer by layer. The local convolutional stream is used to extract local features from the corresponding layer of the global convolutional stream. The output layer fuses the global features output by the global convolutional stream and the local features output by the local convolutional stream into an intrusion category probability prediction vector. The tag reconstruction module is used to map the preprocessed original flat intrusion tags to a set of hierarchical sub-tags that match the hierarchical structure of the hierarchical classification model, based on the hierarchical structure of the vehicle network attack type. The model training module is used to construct a joint loss function that includes local loss, global loss, and hierarchical violation penalty loss. Using hierarchical sub-labels as training labels, the hierarchical classification model is trained with the goal of minimizing the joint loss function, resulting in the trained hierarchical classification model. The output module takes the two-dimensional feature matrix to be detected and inputs it into the trained hierarchical classification model to obtain the intrusion detection results.

[0034] Example 3: The present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor. The memory stores the computer program capable of running on the processor. When the processor loads and executes the computer program, it adopts the vehicle network intrusion detection method based on a hierarchical classification model described in Embodiment 1.

[0035] It should be noted that the terminal device can be a computer device such as a desktop computer, a laptop computer, or a cloud server, and the terminal device includes, but is not limited to, a processor and a memory. For example, the terminal device may also include input / output devices, network access devices, and buses.

[0036] Furthermore, the processor can be a central processing unit (CPU). Of course, depending on the actual use, other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. can also be used. The general-purpose processor can be a microprocessor or any conventional processor, etc., and this application does not limit it in this regard.

[0037] Example 4: The present invention provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the vehicle network intrusion detection method based on a hierarchical classification model described in Embodiment 1.

[0038] The computer program can be stored in a computer-readable medium. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or certain middleware. The computer-readable medium includes any entity or device capable of carrying computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the computer-readable medium includes, but is not limited to, the above-mentioned components.

[0039] Example 5: The present invention provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it is used to load and execute the vehicle network intrusion detection method based on a hierarchical classification model described in Embodiment 1.

[0040] In the description of this specification, the references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0041] The foregoing has shown and described the basic principles, main features, and advantages of this application. Those skilled in the art should understand that this application is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of this application. Various changes and modifications can be made to this application without departing from the spirit and scope thereof, and all such changes and modifications fall within the scope of the claims of this application.

Claims

1. A vehicle network intrusion detection method based on a hierarchical classification model, characterized in that, Includes the following steps: Receive raw intrusion detection data from the vehicle network and preprocess it to output a two-dimensional feature matrix; Based on the hierarchical structure of vehicle network attack types, a hierarchical classification model is constructed, which includes a global convolutional stream, a local convolutional stream, and an output layer. The global convolutional stream takes a two-dimensional feature matrix as input and learns global features across layers layer by layer. The local convolutional stream is used to extract local features from the corresponding layer of the global convolutional stream. The output layer fuses the global features output by the global convolutional stream and the local features output by the local convolutional stream into an intrusion category probability prediction vector. Based on the hierarchical structure of vehicle network attack types, the preprocessed original flat intrusion labels are mapped to a set of hierarchical sub-labels that match the hierarchical structure of the hierarchical classification model. Construct a joint loss function that includes local loss, global loss and hierarchical violation penalty loss, use hierarchical sub-labels as training labels, and train the hierarchical classification model with the goal of minimizing the joint loss function to obtain the trained hierarchical classification model; This is used to input the two-dimensional feature matrix to be detected into the trained hierarchical classification model to obtain the intrusion detection result.

2. The vehicle network intrusion detection method based on a hierarchical classification model according to claim 1, characterized in that: Receive raw intrusion detection data from the vehicle network and perform preprocessing, specifically including: Feature filtering: Remove redundant, invalid, and missing values ​​from the original data to obtain a feature set to be processed, which includes character features and numerical features; Feature encoding: The character features are converted into numerical values ​​using binary one-hot encoding. The encoded numerical features are then concatenated with the retained original numerical features to obtain a one-dimensional original feature vector. Numerical normalization: Normalizing the original one-dimensional feature vector using the following formula: in, The feature elements of the one-dimensional original feature vector The minimum value among the characteristic elements. The maximum value among the characteristic elements; Zero-padding transformation: The normalized one-dimensional feature vector is filled into a pre-defined two-dimensional empty matrix in row-major order, and zero-padding is applied to the unfilled positions to obtain the final two-dimensional feature matrix. , is a positive integer representing the number of rows and columns of the two-dimensional feature matrix.

3. The vehicle network intrusion detection method based on a hierarchical classification model according to claim 1, characterized in that: The hierarchical classification model is constructed as follows: Based on the attack type definition for vehicle network intrusion detection, the attack hierarchy is divided, with the total number of levels set as follows: , No. The set of layer categories is The model specifically includes: Global convolutional stream: contains Each convolutional layer learns global intrusion features across layers, and each layer explicitly concatenates and reuses the original two-dimensional feature matrix. The activation formula for the first layer global convolution is: in, This represents the feature activation matrix of the first-layer global convolutional flow. The convolution kernel for the first layer of global convolutional flow. This is a two-dimensional convolution operation. It is a ReLU nonlinear activation function. This is the bias vector of the first-layer global convolutional flow; No. The global convolution activation formula for a layer is: in, For the first Feature activation matrix of the global convolutional flow of the layer, For the first The kernel parameters of the global convolutional flow of the layer. Explicit splicing operations characterized by [feature name]. For the first The bias vector of the global convolutional flow of the layer; Local convolutional flow: contains There are 3 independent convolutional branches, each corresponding to an attack level. The formula for local convolution activation in a layer is: in, For the first Feature activation matrix of local convolutional flow in layer, For the first Convolution kernel parameters for global-to-local layer transformation. For the first Bias vector from global to local layer; Output layer: Based on the last layer of global convolutional activation, it maps to a probability vector of the total number of categories through convolutional layers, achieving global intrusion detection. The formula is: in, This is the global output class probability vector. To connect the kernel parameters of the last global convolutional layer with the global output layer, It is the Sigmoid activation function. This is the bias vector for the global output layer; Each level corresponds to a local output layer, which is mapped to the probability vector of this layer's category through convolutional layers, achieving level-specific intrusion detection. The formula is as follows: in, For the first The class probability vector output locally by the layer. For the first The output convolution kernel parameters of the local convolutional flow of the layer, For the first The bias vector of the local output layer; Finally, the local prediction vectors from all levels are concatenated and weighted with the global prediction vector to obtain the final invasion category probability prediction vector of the model, as shown in the formula: in, This is the final class probability vector that the model fuses and predicts. is the local-global prediction fusion coefficient, with a value range of [0,1].

4. The vehicle network intrusion detection method based on a hierarchical classification model according to claim 1, characterized in that: Based on the hierarchical structure of vehicle network attack types, the preprocessed original flat intrusion labels are mapped to a set of hierarchical sub-labels that match the hierarchical structure of the hierarchical classification model, as follows: The original vehicle network intrusion detection tags are flat binary vectors. , For the original flat intrusion tag, This represents the total number of categories across all levels. An element in the vector is 1 if the sample belongs to that intrusion category, and 0 if it does not. Based on the hierarchical relationship of attack types, the original flat labels are... Mapped to The first hierarchical sub-tag, the... h The formula for layered sub-tags is: in, For the first Layered sub-tags of layers, For the first h Number of layer categories; If a category in the original tag is a positive example, then all its parent categories are positive examples. This applies to all enhanced hierarchical sub-tags. Explicitly concatenate to obtain global tags The formula is: .

5. The vehicle network intrusion detection method based on a hierarchical classification model according to claim 4, characterized in that: The formula for the composite loss function is: in, The total loss of the model, For localized losses, For the overall loss, Penalties for violations at different levels; Local loss The binary cross-entropy loss is used to calculate the error between local predictions at all levels and hierarchical sub-labels. The calculation formula is as follows: in, This is the batch size for mini-batch training. For the first Class of samples The actual label value, Represents the output vector The element corresponding to the middle tag 'c'; Global loss The binary cross-entropy loss is used to calculate the error between the global prediction and the global label. The calculation formula is as follows: in, For the first Class of samples The global true label value; Level violation penalties To apply L2 penalties to predictions that violate the attack hierarchy, the formula is: in, This is the penalty coefficient, which takes the value of a positive real number. Predict probabilities for subcategories. The penalty value is generated only when the probability of the child class is higher than that of the parent class, corresponding to the predicted probability of the parent class.

6. The vehicle network intrusion detection method based on a hierarchical classification model according to claim 1, characterized in that: The training and deployment process of the hierarchical classification model is as follows: The preprocessed two-dimensional feature matrix is ​​input into the hierarchical classification model, and the prediction result is obtained through forward propagation. The model parameters are then optimized through backpropagation based on the composite loss function. Perform lightweight processing, including model pruning and / or quantization, on the best trained model; The lightweight model is converted into a model format adapted to in-vehicle terminals and deployed for intrusion detection of real-time collected vehicle network data.

7. A vehicle-to-everything (V2X) intrusion detection system based on a hierarchical classification model, used to implement the V2X intrusion detection method based on a hierarchical classification model as described in any one of claims 1 to 6, characterized in that, include: The data preprocessing module is used to receive raw intrusion detection data from the vehicle network and preprocess it to output a two-dimensional feature matrix. The model building module is used to construct a hierarchical classification model based on the hierarchical structure of vehicle network attack types. It includes a global convolutional stream, a local convolutional stream, and an output layer. The global convolutional stream takes a two-dimensional feature matrix as input and learns global features across layers layer by layer. The local convolutional stream is used to extract local features from the corresponding layer of the global convolutional stream. The output layer fuses the global features output by the global convolutional stream and the local features output by the local convolutional stream into an intrusion category probability prediction vector. The tag reconstruction module is used to map the preprocessed original flat intrusion tags to a set of hierarchical sub-tags that match the hierarchical structure of the hierarchical classification model, based on the hierarchical structure of the vehicle network attack type. The model training module is used to construct a joint loss function that includes local loss, global loss, and hierarchical violation penalty loss. Using hierarchical sub-labels as training labels, the hierarchical classification model is trained with the goal of minimizing the joint loss function, resulting in the trained hierarchical classification model. The output module takes the two-dimensional feature matrix to be detected and inputs it into the trained hierarchical classification model to obtain the intrusion detection results.

8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, The memory stores a computer program that can run on a processor. When the processor loads and executes the computer program, it employs the end-to-end vehicle network intrusion detection method based on a learnable mask, as described in any one of claims 1 to 6.

9. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the vehicle network intrusion detection method based on a hierarchical classification model as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, is used to load and execute the vehicle network intrusion detection method based on a hierarchical classification model as described in any one of claims 1 to 6.