Internet of vehicles intrusion detection method based on knowledge graph and machine learning
By building a knowledge graph in the Internet of Vehicles system and combining machine learning algorithms to optimize feature selection and model training, the accuracy and false alarm rate problems of the Internet of Vehicles intrusion detection system in complex attack scenarios are solved, and efficient intrusion detection and Quick response ensures the safety and reliability of the Internet of Vehicles system.
Patent Information
- Application Number
- CN202411166572.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-03
AI Technical Summary
The existing Internet of Vehicle Intrusion Detection System has shortcomings in feature selection and dimensionality reduction in complex attack scenarios, resulting in low detection accuracy and high false alarm rate.
Using a knowledge graph and machine learning method, by building high-quality knowledge graphs and combining feature importance analysis and machine learning algorithms, we optimize feature selection, reduce data dimensions, improve the accuracy and interpretability of intrusion detection, and reduce false alarms. Rate. Specific steps include data preprocessing, feature selection, knowledge graph construction and model training, using random forest and lightweight gradient hoist models for training and evaluation.
It improves the accuracy and interpretability of Internet of Vehicle Intrusion Detection, quickly detects and responds to abnormal activities in the vehicle network, ensures the safety and reliability of the Internet of Vehicles system, and significantly reduces the false alarm rate.
Smart Images

Figure CN119071785A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle networking technology, and specifically to a vehicle networking intrusion detection method based on knowledge graph and machine learning. Background Art
[0002] With the rapid development of Internet of Vehicles technology, the connectivity and automation level of vehicles are constantly improving, and the risk of cyber attacks on vehicle networks is also increasing. These cyber attacks mainly include hacker attacks, malware intrusions, and unauthorized access. Hacker attacks may remotely control the vehicle's braking system, acceleration system, or steering system, directly threatening the life safety of drivers and passengers. In addition, attacks may also cause the failure of key components such as the vehicle's navigation system, communication system, and entertainment system, affecting the overall performance and user experience of the vehicle.
[0003] Existing intrusion detection systems (IDS) are mostly based on machine learning or deep learning methods, lacking solutions for feature selection and dimensionality reduction in complex attack scenarios in vehicle networks. There are still problems such as low accuracy and high false alarm rate in detecting network attacks.
[0004] Therefore, how to effectively detect and defend against these network security threats and ensure the security and reliability of the Internet of Vehicles system has become an important issue that needs to be urgently addressed in academia and industry. Summary of the invention
[0005] Therefore, the present invention solves the problem that the intrusion detection systems (IDS) in the prior art are mostly based on machine learning or deep learning methods, lack of feature selection and dimensionality reduction solutions in complex attack scenarios in vehicle networks, and still have low accuracy and high false alarm rate in detecting network attacks. The present invention provides a vehicle network intrusion detection method based on knowledge graph and machine learning, which improves the accuracy and explainability of intrusion detection and reduces the false alarm rate by constructing a high-quality knowledge graph and combining it with a machine learning algorithm. It can quickly detect and respond to abnormal activities in vehicle networks, thereby ensuring the security and reliability of the vehicle network system.
[0006] The present invention provides a vehicle network intrusion detection method based on knowledge graph and machine learning, comprising the following steps:
[0007] S1: Preprocess the CICIDS2017 dataset related to the Internet of Vehicles;
[0008] S2: Perform feature selection on the features in the data set, use feature importance analysis to optimize feature selection, reduce data dimensions, thereby improving the accuracy of intrusion detection and reducing the false alarm rate;
[0009] S3: Knowledge graph construction, based on the features selected in S2, the knowledge graph is constructed. Entities and relationships are extracted from network traffic data through automated tools to form triples of the knowledge graph.
[0010] S4: Model training, using random forest and lightweight gradient boosting machine to train and evaluate the constructed knowledge graph.
[0011] Preferably, the data set preprocessing in S1 includes data cleaning, data conversion and data standardization or normalization.
[0012] Preferably, the construction of the knowledge graph in S3 includes the following steps:
[0013] S21: Entity extraction, extracting entities from network traffic data;
[0014] S22: Relationship extraction, identifying and extracting the relationships between entities to form triples;
[0015] S23: Knowledge graph construction, organizing the extracted entities and relations into a knowledge graph.
[0016] Preferably, the training and evaluation in S4 comprises the following steps:
[0017] S31: data segmentation, dividing the processed data set into a training set and a test set;
[0018] S32: Model training, use the training set to train the random forest and lightweight gradient boosting machine models.
[0019] S33: Model evaluation, evaluate the performance of the model on the test set.
[0020] Preferably, the features that have the greatest impact on the detection results are selected according to the importance score.
[0021] Preferably, a machine learning algorithm is used to calculate the importance score for each feature.
[0022] Preferably, in S1, after the data set is preprocessed, the balance of the data samples is checked.
[0023] Preferably, when the data samples are unbalanced, the SMOTE (Synthetic Minority oversampling Technique) technology is used to oversample the penetration attack samples.
[0024] Optionally, the k_neighbors value is incremented during the sampling process.
[0025] Compared with the prior art, the present invention has the following advantages:
[0026] 1. The vehicle network intrusion detection method based on knowledge graph and machine learning provided by the present invention uses feature importance analysis to optimize feature selection and reduce data dimensions, thereby improving detection accuracy and reducing false alarm rate.
[0027] 2. The vehicle network intrusion detection method based on knowledge graph and machine learning provided by the present invention adopts SHAP (SHapley Additive exPlanations) for feature selection, which improves the interpretability of the machine learning process and makes the decision-making process more transparent.
[0028] 3. The Internet of Vehicles intrusion detection method based on knowledge graph and machine learning provided by the present invention improves the accuracy and interpretability of intrusion detection by constructing a high-quality knowledge graph and combining it with a machine learning algorithm. It can quickly detect and respond to abnormal activities in the vehicle network, thereby ensuring the security and reliability of the Internet of Vehicles system. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0030] Figure 1 The attack scenario and communication model diagram show the schematic diagram of the attacker attacking the Internet of Vehicles;
[0031] Figure 2 This is a data set diagram before SMOTE oversampling of the present invention;
[0032] Figure 3 This is a data set diagram after SMOTE oversampling of the present invention;
[0033] Figures 4a to 4f This is a feature importance analysis diagram of the present invention, showing the process of feature selection;
[0034] Figure 5 This is the interpretability analysis diagram of the present invention, showing the interpretation results of the feature selection by the SHAP method;
[0035] Figure 6 This is a feature importance graph for different attack types of the present invention, using SHAP values to quantify the impact of each feature on the model output;
[0036] Figure 7 For the knowledge graph constructed for the present invention, we only visualized a part of it to make it clear;
[0037] Figure 8 It is a classification diagram of network traffic categories of the present invention;
[0038] FIG9 is a diagram showing the training results of the model of the present invention;
[0039] Figures 10a to 10e This is a diagram of the test results of the present invention. DETAILED DESCRIPTION
[0040] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] Example 1
[0042] like Figure 1 As shown in the figure, in the network communication model, each vehicle has three communication links, namely, vehicle-to-BS (Base Station), vehicle-to-vehicle, and vehicle-to-network. The vehicle-to-BS connection is through the 5G / 6G protocol, the vehicle-to-vehicle connection is through the Dedicated Short-Range Communications (DSRC) protocol, and the vehicle-to-network connection is through the 5G / 6G protocol. 5G / 6G is the standard for the fifth / sixth generation mobile communication technology, providing high data rates, low latency, and large-scale connections. Compared with 5G, 6G provides higher data transmission rates, lower latency, and greater connection capacity. DSRC is a short-range wireless communication technology specifically used for automotive communications. It has the characteristics of low latency and high reliability, and is mainly used to improve traffic safety and efficiency.
[0043] Attackers can attack vehicles directly, or they can attack the communication links between vehicles, vehicles and base stations, and vehicles and networks, such as Figure 1 To achieve this, the attacker must understand the weaknesses within the connected car, such as WiFi, Bluetooth, and cellular networks.
[0044] In the figure, if a vehicle is attacked by a network, it may lose control of the vehicle, cause a traffic accident, etc. It may also make the attacked vehicle become a malicious node, and then attack other vehicles, with serious consequences and endangering social security. Therefore, we propose an IoV intrusion detection method based on knowledge graph and machine learning, and appropriately integrate it into the Internet of Vehicles (IoV) infrastructure, such as gateways, so that network traffic can be fully monitored. In this study, we deploy IDS on the gateway. This strategic deployment ensures that IDS can effectively detect and respond to abnormal activities in the vehicle network, and issue alarms in a timely manner to feedback to the network administrator, who then blocks malicious messages from being sent to the vehicle.
[0045] The vehicle networking intrusion detection method based on knowledge graph and machine learning provided in this embodiment includes the following steps:
[0046] S1: Preprocess the CICIDS2017 dataset related to the Internet of Vehicles;
[0047] We need to preprocess the CICIDS2017 dataset related to the Internet of Vehicles, which contains some missing values, outliers, and non-numerical data. The preprocessing process mainly includes data cleaning, data conversion, and data standardization / normalization.
[0048] Next, we check the balance of the data sample. Figure 2 As shown, the dataset is unbalanced and the penetration attack category accounts for only 0.06% of the total samples.
[0049] To address this imbalance, the SMOTE (Synthetic Minority oversampling Technique) technique is used to oversample the penetration attack samples. To mitigate the risk of overfitting in the SMOTE process, we adjusted the k_neighbors parameter, which determines the number of nearest neighbors for each minority class sample when generating new synthetic samples. By increasing the k_neighbors value, we can generate more diverse synthetic samples, thereby reducing the risk of overfitting. In addition, while oversampling the minority class, we undersample the majority class to achieve a more balanced sample distribution and prevent overfitting. The dataset after SMOTE oversampling is shown below. Figure 3 shown.
[0050] S2: Perform feature selection on the features in the data set, use feature importance analysis to optimize feature selection, reduce data dimensions, thereby improving the accuracy of intrusion detection and reducing the false alarm rate;
[0051] After completing the above data preprocessing steps, we perform feature selection. The dataset includes 79 features, of which the main features are shown in Table 1. In order to reduce the system running time and avoid overfitting, the random forest algorithm is used for feature extraction and to remove redundant features. Figure 4 (af) shows the top 10 important features of various attack and normal traffic obtained by training and predicting using the random forest model.
[0052] Table 1
[0053]
[0054]
[0055] Then, we select the top 5 features from the top 10 important features of each attack category and normal traffic for subsequent knowledge graph construction, as shown in Table 2. In addition, attackers usually use port hopping technology to frequently change the target port to evade detection. In order to enhance the generalization ability of the model, the “destination port” feature is not considered.
[0056] Table 2
[0057]
[0058]
[0059] Use the SHAP (SHapley Additive exPlanations) method to perform feature selection based on feature importance, calculate the SHAP value, and for each feature, calculate its contribution to the model prediction results. Analyze the SHAP value, explain how each feature affects the prediction results, and identify the most important features and their influence mechanisms.
[0060] like Figure 5 As shown in the figure, for the two features "Avg Bwd Segment Size" and "Bwd Packet Length Mean", the higher the feature value, the greater the positive impact on the model output. This is because in DoS or Botnet attacks, the average backward segment size is large, and the attacker will send a large number of data packets to occupy network resources.
[0061] For the feature "Init_Win_bytes_forward", a high feature value has a positive impact on the model output. This is because the feature value is high in PortScan attacks, and the scanning activity may involve a large number of connection attempts, and the initialization window size will appear more significant.
[0062] For the feature "Bwd Packet Length Std", a high feature value has a significant positive impact on the model output. This is because a high standard deviation means that the packet length fluctuates greatly, which is more common in some abnormal attack traffic, such as BruteForce attacks.
[0063] For the feature "Init_Win_bytes_backward", the higher the feature value, the greater the positive impact on the model output. This is because this feature is more significant in some attacks (such as Infiltration), which involve a large amount of two-way data exchange.
[0064] For the feature "Bwd Packets / s", the higher the feature value, the greater the positive impact on the model output. This is because in DoS or Botnet attacks, the rate of sending backward packets is high, and the attacker will send a large number of packets to occupy network resources.
[0065] For the feature "min_seg_size_forward", the higher the feature value, the greater the positive impact on the model output. This indicates that in some attacks (such as WebAttack and BruteForce), the minimum segment size of the forward data packet is large, and the attacker may send a larger request packet to attack.
[0066] For the feature "Fwd IAT Min", the higher the feature value, the smaller the SHAP value, which means the greater the negative impact on the model output. This is because in some attacks (such as DoS and Botnet), the minimum interval between forward packets is small, and the attacker will send packets at a higher frequency to occupy network resources. Therefore, high feature values correspond to fewer attack behaviors, while low feature values are related to more frequent packet sending (such as DoS and Botnet attacks).
[0067] like Figure 6 As shown in the figure, the average SHAP value of each feature for different categories is shown. The horizontal axis represents the size of the SHAP value, and the vertical axis is the feature name. Each bar represents a feature, and the length of the bar represents the average impact of the feature on the model. Different colors represent different attack types. The following is a comparison of Figure 6 Analysis and explanation of some important features:
[0068] Average Bwd Segment Size: This feature shows high importance in Bot and DoS attacks. This is because in these attacks, the average size of the backward segment is large, and the attacker sends a large number of packets to occupy network resources.
[0069] Bwd Packet Length Mean: This feature has a high influence in multiple attack types (such as DoS, Infiltration, Bot), indicating that in these attacks, the average length of the backward packets is larger.
[0070] Initial forward window bytes (Init_Win_bytes_forward): This feature has a significant impact in PortScan and BruteForce attacks. Scanning activities may involve a large number of connection attempts, and the initial window size will appear more significant.
[0071] Initial reverse window bytes (Init_Win_bytes_backward): This feature is very important in WebAttack attacks, indicating that these attacks involve a large amount of two-way data exchange.
[0072] Total Length of Fwd Packets: This feature has a greater impact in Class 5 (Botnet) and Class 6 (DoS), which indicates that the total length of forward packets is larger in these attacks.
[0073] Subflow Fwd Bytes: This feature is more important in PortScan attacks, indicating that in this attack, the number of forward bytes in the subflow is large.
[0074] S3: Knowledge graph construction: construct a knowledge graph based on the features selected in S2, extract entities and relationships from network traffic data through automated tools, and form triples of the knowledge graph;
[0075] Extract entities such as vehicles, sensors, events, etc. from network traffic data. Identify and extract relationships between entities to form triples (entity, attribute, value). Organize the extracted entities and relationships into a knowledge graph to facilitate subsequent analysis and reasoning, such as Figure 7 As shown, it only describes a small part of the entire knowledge graph.
[0076] S4: Model training, using random forest and lightweight gradient boosting machine to train and evaluate the constructed knowledge graph.
[0077] Decision tree models such as Random Forest and Lightweight Gradient Boosting Machine (LightGBM) are used to train and evaluate the constructed knowledge graph.
[0078] The specific process is as follows:
[0079] Data splitting: Divide the processed dataset into training set and test set.
[0080] Model training: Use the training set to train the random forest and LightGBM models.
[0081] Model evaluation: Evaluate the performance of the model on the test set and calculate indicators such as accuracy, recall, and F1 score.
[0082] The training is performed on a knowledge graph consisting of 15 features. In the process of building the knowledge graph, the label column is retained, which requires encoding to convert the label column into a numerical value, such as Figure 8 As shown in the figure. For evaluation, each machine learning model is configured as a multi-classification model. The multi-classification model uses these 15 features and their corresponding labels to classify network traffic into 7 categories: normal network traffic, DoS attack, port scan attack, brute force attack, network attack, botnet attack, and penetration attack.
[0083] Finally, we conducted experiments and evaluations on the above methods, as follows:
[0084] 1. Environment Setup
[0085] The proposed method is implemented using Scikit-learn, LightGBM, Rdflib, Numpy, Matplotlib, and Seaborn libraries in Python. The experiments are conducted on a machine equipped with an Intel(R) Core(TM) i5-9300H processor (4 cores, 2.40GHz) and 16GB of memory, which serves as a server device for model training. The test device is a machine based on x64 architecture with a 64-bit operating system.
[0086] 2. Evaluation Metrics
[0087] To evaluate the detection performance, we define the intrusion detection confusion matrix shown in Table 3.
[0088] Table 3
[0089]
[0090] In Table 3, TP represents the number of network flows that are actually abnormal and predicted to be abnormal, F represents the number of network flows that are actually abnormal but predicted to be normal, FP represents the number of network flows that are actually normal but predicted to be abnormal, and TN represents the number of network flows that are actually normal and predicted to be normal. Based on the confusion matrix, some specific indicators are defined to evaluate the model's ability to predict whether the real network flow is normal or abnormal.
[0091] Accuracy ACC (Accuracy) refers to the ratio of correctly predicted packets to the total number of packets. The larger the value, the better the performance. The calculation formula is shown in Formula 1.
[0092]
[0093] Precision (P) measures the impact of misclassified instances on correctly classified instances. Its calculation formula is as follows:
[0094] As shown in formula 2.
[0095]
[0096] The recall rate (R) is the ratio of correctly predicted attacks to actual attack traffic, and its calculation formula is shown in Formula 3.
[0097]
[0098] The f1 score is the weighted average of precision and recall, and is used as a derived measure of effectiveness. The calculation formula is shown in Equation 4.
[0099]
[0100] The false alarm rate (FAR) refers to the proportion of negative samples that are misclassified as positive, that is, normal traffic or events are misclassified as attacks or anomalies. The calculation formula is shown in Formula 5.
[0101]
[0102] 3. Evaluate the results
[0103] We evaluated our proposed multi-class classification method on the dataset, as shown in Figure 9. Our two models showed high performance, with both accuracy and f1-score exceeding 99.9%. Table 4 gives the performance of the four models based on F1score in detecting each attack type. It is worth noting that the f1-scores of different base ML models are different for detecting different types of attacks. For example, on the dataset, the knowledge graph-based random forest achieved the highest f1-score in detecting Bot, BruteForce, Infiltration, and WebAttack, while the knowledge graph-based LightGBM outperformed the random forest in detecting PortScan attacks.
[0104] Table 4
[0105]
[0106] In addition, the proposed method is compared with four machine learning based methods. Figure 10 shows the multi-class detection results of five ML-based methods. Figure 10(a) shows the results of the KNN algorithm on the dataset we used, Figure 10(b) shows the results of the SVM algorithm, Figure 10 shows the results of the DT algorithm, Figure 10(d) shows the results of the RF algorithm, and Figure 10(e) shows the results of the LightGBM algorithm.
[0107] We summarize the various evaluation indicators of different algorithms on the datasets we used, as shown in Table 5. As can be seen from Table 5, when tested on the intrusion dataset, the RandomForest and LightGBM algorithms based on the knowledge graph used in our system have improved the accuracy by 1.49% and 1.46% respectively relative to the KNN algorithm, and the accuracy by 7.25% and 7.21% respectively relative to the SVM algorithm. In addition, compared with the random forest without the knowledge graph, the various evaluation indicators of the random forest based on the knowledge graph in our proposed system have been improved, with an accuracy increase of 0.8% and a false alarm rate reduction of 98.20%. Similarly, compared with the LightGBM without the knowledge graph, the evaluation indicators of the LightGBM based on the knowledge graph have been improved, with an accuracy increase of 0.75% and a false alarm rate reduction of 72.22%.
[0108] Table 5
[0109]
[0110] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the invention.
Claims
1. A vehicle network intrusion detection method based on knowledge graph and machine learning, It is characterized in that The steps include: S1: Preprocess the CICIDS2017 dataset related to the Internet of Vehicles; S2: Perform feature selection on the features in the data set, use feature importance analysis to optimize feature selection, reduce data dimensions, thereby improving the accuracy of intrusion detection and reducing the false alarm rate; S3: Knowledge graph construction: construct a knowledge graph based on the features selected in step S2, extract entities and relationships from network traffic data through automated tools to form triples of the knowledge graph; S4: Model training, using random forest and lightweight gradient boosting machine to train and evaluate the constructed knowledge graph.
2. According to the method for intrusion detection of Internet of Vehicles based on knowledge graph and machine learning according to claim 1, It is characterized in that The data set preprocessing in step S1 includes data cleaning, data conversion and data standardization or normalization.
3. According to claim 2, the vehicle network intrusion detection method based on knowledge graph and machine learning, It is characterized in that The construction of the knowledge graph in step S3 includes the following steps: S21: Entity extraction, extracting entities from network traffic data; S22: Relationship extraction, identifying and extracting the relationships between entities to form triples; S23: Knowledge graph construction, organizing the extracted entities and relations into a knowledge graph.
4. The vehicle network intrusion detection method based on knowledge graph and machine learning according to claim 1, It is characterized in that The training and evaluation in step S4 includes the following steps: S31: data segmentation, dividing the processed data set into a training set and a test set; S32: Model training, using the training set to train the random forest and lightweight gradient boosting machine models; S33: Model evaluation, evaluate the performance of the model on the test set.
5. The vehicle network intrusion detection method based on knowledge graph and machine learning according to claim 2, It is characterized in that The features that have the greatest impact on the detection results are selected based on the importance score.
6. The vehicle network intrusion detection method based on knowledge graph and machine learning according to claim 5, It is characterized in that An importance score for each feature is calculated using a machine learning algorithm.
7. The vehicle network intrusion detection method based on knowledge graph and machine learning according to claim 1, It is characterized in that In S1, after the data set is preprocessed, the balance of the data samples is checked.
8. The vehicle network intrusion detection method based on knowledge graph and machine learning according to claim 7, It is characterized in that When the data samples are unbalanced, SMOTE technology is used to oversample the penetration attack samples.
9. The vehicle network intrusion detection method based on knowledge graph and machine learning according to claim 8, It is characterized in that The k_neighbors value is increased during the sampling process.
