Internet of vehicles intrusion detection model construction method based on federated learning
Through federated learning technology, the model of the vehicle client is decoupled and the similarity matrix is used to select similar vehicles for feature extractor aggregation to build a global prediction head, which solves the problems of data privacy leakage and attack mode changes in traditional Internet of Vehicles intrusion detection methods, and achieves for efficient and accurate intrusion detection.
Patent Information
- Application Number
- CN202410880915.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-10-15
AI Technical Summary
Traditional IoV intrusion detection methods are based on a centralized architecture, which leads to the risk of data privacy leakage, high communication overhead, and difficulty in responding to changing attack patterns. The detection accuracy is low and the false alarm rate is high.
The federated learning-based intrusion detection model construction method for the Internet of Vehicles is used to decouple the local model of the vehicle client into a feature extractor and a classifier, and use the similarity matrix to select similar vehicle clients for knowledge transfer and feature extractor aggregation to form a global Predict the head to reduce data sharing and reduce communication costs.
A more comprehensive and accurate intrusion detection model is achieved, data privacy is guaranteed, communication costs are reduced, the robustness and adaptability of the model are enhanced, and the accuracy and sustainability of detection are improved.
Smart Images

Figure CN118784305A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of Internet of Vehicles, and specifically relates to a method for constructing an Internet of Vehicles intrusion detection model based on federated learning. Background Art
[0002] With the rapid development of the Internet of Vehicles, network security issues have become increasingly prominent. The increasing interconnection between vehicles and transportation infrastructure has made it possible to realize autonomous driving, remote monitoring and intelligent traffic management functions. However, this convenience is also accompanied by challenges in security and privacy protection. As the automotive industry continues to change and develop, the attack methods of illegal attackers are also evolving, from simple hacking to more sophisticated and covert attack methods. According to the report data, almost all automotive attack threats (97%) are carried out remotely, and 70% of remote attacks are carried out at a long distance, which allows attackers to launch attacks without approaching the target vehicle.
[0003] In addition, attackers are constantly improving their attack methods. For example, when criminals obtain critical digital infrastructure information for a particular car, they will use it to extort high ransoms from automakers and may also illegally sell private data. In the process, there is a high probability of large-scale data leaks, denial of service (DoS) attacks, and production interruptions that affect the entire supply chain. This problem has already been very prominent in 2022, and as the degree of digitalization of automobiles continues to increase, attacks on the automotive industry are expected to become more common.
[0004] Therefore, intrusion detection technology has become crucial. The intrusion detection system monitors the communication and behavior of the Internet of Vehicles system, identifies and defends various network attacks, such as malware injection, data tampering, and denial of service attacks, to ensure the security and reliability of the Internet of Vehicles system. If the IDS detects suspicious activities, it can take action to stop malicious attacks and prevent road accidents. The security of the Internet of Vehicles and intrusion detection form a complementary relationship. An effective intrusion detection system can not only ensure the safe operation of the Internet of Vehicles system, but also provide a broader application scenario and challenge for intrusion detection technology. In the Internet of Vehicles, a large amount of distributed data is involved, including sensor data from different vehicles, control information, and real-time status data of traffic infrastructure. These data are usually stored in different vehicles and devices and are subject to strict privacy protection restrictions. Traditional intrusion detection methods are usually based on a centralized architecture and require the collection and analysis of a large amount of raw data, which not only brings huge communication overhead and storage costs, but also has the risk of data privacy leakage. In addition, traditional intrusion detection methods are usually difficult to cope with the ever-changing attack patterns, resulting in low detection accuracy and high false alarm rate. Summary of the invention
[0005] In order to solve the above-mentioned technical problems, cope with the ever-changing attack patterns, and improve the accuracy of intrusion detection, the present invention provides a method for constructing an Internet of Vehicles intrusion detection model based on federated learning.
[0006] The technical solutions adopted are as follows:
[0007] A method for constructing an Internet of Vehicles intrusion detection model based on federated learning includes the following steps:
[0008] Decouple the local model in the vehicle into feature extractors and classifiers;
[0009] Randomly select clients participating in the training, and use the similarity matrix to select other vehicle clients with high similarity to each vehicle client participating in the training;
[0010] The server collects the local feature extractors of each vehicle client, and distributes the collected feature extractor parameters of the vehicle client and the global classifier obtained in the previous round to each vehicle client;
[0011] Aggregate the local classifier of each vehicle client participating in the training with the feature extractors of other vehicle clients distributed by the server to form an evaluation model containing multiple feature extractors;
[0012] The obtained evaluation model is evaluated on each vehicle client local model, and the weight of the similarity matrix is updated to obtain the updated vehicle client local feature extractor
[0013] The updated vehicle client local feature extractor And the global classifier θ of the previous round t-1 Combined, the local model is updated by performing the gradient descent method of the loss function on the local model of the vehicle client
[0014] After aggregating the feature representations extracted from the local dataset using the local feature extractors of the vehicle client before and after the update, the current feature representation R is obtained. t,s agg ;
[0015] The server collects all current feature representations Train the global classifier θ t , and distributed to the vehicle clients participating in the next round of training.
[0016] Preferably, an N-dimensional vehicle-client similarity matrix M is constructed N , evaluate n+1 models on the vehicle client local model to update the similarity matrix M NThe weight update expression is:
[0017]
[0018] in: The local model of the vehicle client before weight update The loss function value of
[0019] The vehicle client local model after weight update The loss function value of
[0020] The vehicle client local model feature extractor before weight update;
[0021] Vehicle client local model feature extractor after weight update.
[0022] Preferably, the similarity matrix M N The specific method of updating is:
[0023] Use normalization operation to set the sum of all weights to 1;
[0024]
[0025] Using normalized weights Client feature extractor for similar vehicles Compared with the feature extractor in the previous round The difference is weighted summed to update the local model Feature extractor Its expression:
[0026]
[0027] The weights of n vehicle clients with high similarity to vehicle client k After the update is completed, the weight vector of vehicle client k is Make updates;
[0028] The server collects the updated weights of each vehicle client participating in the training And the similarity matrix M N to update.
[0029] Preferably, all current feature representations collected by the server are used to train a global classifier, and the specific method is:
[0030] The feature extractor of the previous round and the new feature extractor after weight update are used to extract features from the local data set of the vehicle client, respectively, to obtain the corresponding historical feature representation and current feature representation;
[0031] Classifying the obtained current feature representation and historical feature representation of the vehicle client by data category;
[0032] The maximum mean difference statistical method is used to calculate the distribution difference between the current feature representation and the historical feature representation, and the maximum mean difference between the historical feature representation and the current feature representation distribution is obtained;
[0033] The normalized maximum mean difference is used as the weight to aggregate the historical feature representation and the current feature representation to obtain the feature representation R that combines the historical information and the current information. t,s agg ;
[0034] The server collects the feature representation R aggregated by all vehicle clients participating in the training in the current round t t,s agg Train the global prediction head by calculating the loss function l about the global prediction head θ t-1 The gradient of is calculated to obtain the new global classifier θ t .
[0035] Preferably, the historical feature extractor using the previous round and the new feature extractor after weight update Feature extraction is performed on the local data set of the vehicle client to obtain the corresponding feature representation, which is specifically represented as follows:
[0036]
[0037] in:
[0038] For the kth vehicle client, use the new feature extractor For local datasets A sample subset x i Perform feature extraction;
[0039] For the kth vehicle client, use the historical feature extractor For local datasets A sample subset x i Perform feature extraction;
[0040] and are the average feature representations of each category for vehicle k in rounds t-1 and t, respectively.
[0041] Preferably, the maximum mean difference statistical method is used to calculate the distribution difference between the current feature representation and the historical feature representation, and the maximum mean difference between the distribution of the historical feature representation and the current feature representation is obtained, and the distance is expressed as follows:
[0042]
[0043] represents the internal self-similarity of the historical features of round t-1;
[0044] represents the internal self-similarity of the current feature representation of round t; Represents the cross-similarity between the historical feature representation and the current feature representation data distribution;
[0045] P and Q represent historical feature representations respectively and the current feature representation The probability distribution of
[0046] n old and n new Respectively represent historical features and the current feature representation The number of samples;
[0047] k(·,·) is a Gaussian kernel function, which is used to measure the similarity between two samples.
[0048] Preferably, the normalized maximum mean difference is used as the weight W, and its expression is:
[0049]
[0050] MMD value The maximum mean difference between the distribution of the calculated historical feature representation and the current feature representation;
[0051] MMD max is the maximum value among the calculated MMD values;
[0052] MMD min is the minimum value among the calculated MMD values.
[0053] The technical solution of the present invention has the following advantages:
[0054] A. The present invention uses federated learning to integrate security logs and event data from different vehicles and traffic infrastructure to build a more comprehensive and accurate intrusion detection model. Through federated learning, each vehicle client in the Internet of Vehicles can jointly learn and improve the intrusion detection model without sharing sensitive raw data, thereby ensuring data privacy and security. It provides strong technical support for the security and privacy protection of the Internet of Vehicles, and at the same time provides a more effective and sustainable solution for intrusion detection.
[0055] B. The present invention places the training process of federated learning on the local device and communicates only by sharing model parameters instead of directly sharing original data, thereby effectively protecting data privacy. Since only model parameters need to be uploaded instead of the entire data set, the communication cost is also significantly reduced.
[0056] C. The global prediction head generated by the method of the present invention can retain historical information and avoid losing useful features and patterns. This helps to maintain the memory of previously learned information during the model update process, thereby better utilizing past experience and knowledge. At the same time, since the training data is distributed across multiple vehicle clients, the model's dependence on a single data point is reduced, thereby enhancing the robustness of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the specific embodiments of the present invention, the drawings required for use in the specific embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0058] Figure 1 This is the overall framework diagram of the vehicle networking intrusion detection model construction method provided by the present invention;
[0059] Figure 2 It is a flow chart of the method for constructing an Internet of Vehicles intrusion detection model provided by the present invention;
[0060] Figure 3 The performance of the four strategies under practical non-IID scenario and pathological non-IID scenario when the number of clients is 10 and 100 respectively, (a) for MNIST, (b) for FashionMNIST, (c) for Cifar10 and (d) for Cifar100.
[0061] Figure 4It is a performance result diagram of the four control strategies provided by the present invention and the strategy of the present invention when facing the network intrusion detection data set NSL-KDD;
[0062] Figure 5 It is a performance result diagram of the four control strategies provided by the present invention and the strategy of the present invention when facing the network intrusion detection data set UNSW_NB15. DETAILED DESCRIPTION
[0063] 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.
[0064] like Figure 1 As shown, the present invention provides a method for constructing an intrusion detection model for an Internet of Vehicles based on federated learning, wherein the local model of a vehicle client is divided into feature extractors and classifiers. For the update of the feature extractor, the similarity between the local clients is quantified by constructing a similarity matrix between the vehicle clients, and the similarity is used to realize knowledge transmission between the clients and aggregate the local feature extractors. The feature representation extracted by the feature extractor is used to train the global classifier. In each round of iteration, the feature extractor is used to extract features from the local data set of the vehicle client and collect the average feature representation of the local categories of the previous round and the current round. The distribution difference between the historical feature representation and the current feature representation is then calculated by the maximum mean difference (MMD). The distribution difference is used as a weight to aggregate a new feature representation and upload it to the server. The server uses the feature representation that balances the historical feature representation and the current feature representation to train the global prediction head and transmit it to the client. The global prediction head generated by the method of the present invention can retain historical information and avoid losing useful features and patterns. This helps to keep the memory of previously learned information during the model update process, thereby better utilizing past experience and knowledge and improving the robustness of the model. In addition, the vehicle client only uploads the aggregated feature representation instead of the entire model, which reduces the communication cost.
[0065] In order to achieve efficient recognition of heterogeneous data, the present invention adopts a personalized federated learning strategy, allowing each vehicle client to adjust the global model according to its own needs and characteristics to better adapt it to the local data distribution. The goal is to minimize the sum of the losses of all client local models on the local data set, that is:
[0066]
[0067] like Figure 2As shown, the specific steps are as follows:
[0068]
S01
[0069] Decouple the model ω for feature extraction and classification as and θ, expressed as:
[0070]
[0071] in as a feature extractor, θ as a classifier, Representation model concatenation. Aggregation using enhanced strategy with feature extraction capability And a global classifier θ is trained to enhance the generalization performance of the system.
[0072] [S02] Randomly select clients participating in the training, and use the similarity matrix to select other vehicle clients with high similarity to each vehicle client participating in the training.
[0073] Before the iteration begins, the heterogeneous local models and the global classifier θ 0 Perform random initialization and initialize M N is a diagonal matrix. In the tth iteration, K = max(C·N,1) vehicles are randomly selected to participate in the training, which is expressed as For each vehicle client selected to participate in training According to the similarity matrix M N The weight size selects the first n vehicle clients and collects their feature extractors
[0074] [S03] The server collects the local feature extractors of each vehicle client, and distributes the collected feature extractor parameters of the vehicle client and the global classifier obtained in the previous round to each vehicle client. The server receives the feature extractors of the sampled vehicles. The feature representation parameters are distributed to the selected sampled vehicle k.
[0075] [S04] The local classifier of each vehicle client participating in the training is concatenated and aggregated with the feature extractors of other vehicle clients distributed by the server to form an evaluation model containing multiple feature extractors. Its expression is as follows:
[0076]
[0077] At this point, each sampled vehicle contains a local model There are a total of n+1 models including .
[0078] [S05] Evaluate the obtained evaluation model on each vehicle client local model, and update the weight of the similarity matrix to obtain the updated vehicle client local feature extractor
[0079] These n+1 models are evaluated on the local model of the vehicle to update the correlation matrix M N First, calculate the local model The loss function value is recorded as Then iterate and calculate The loss function value The weight update formula is as follows:
[0080]
[0081] The new weights are represented as local models The loss function value With the received model The loss function value The difference between the two feature extractor parameters The L2 norm of . When the difference is large, it means that the local model Performance on the local validation set compared to the received model The performance is worse, so it should be given Higher weights, the positive or negative difference represents the received model The positive and negative contributions that can be brought. and When the difference between them is small, it means that the parameter difference between the two feature extractors is small. At this time, a large gain can be obtained by sharing knowledge, and it should be given Higher weight; when and When the difference between them is large, it means that the parameters of the two feature extractors are quite different, and the weight assigned will be relatively small because its improvement on the local model is limited.
[0082] To prevent instability caused by weights that are too large or too small, a normalization operation is used to ensure that the sum of all weights is 1:
[0083]
[0084] The normalized weights are then used to update the local model Feature extractor The update process is as follows:
[0085]
[0086] The weights of n clients with high similarity to vehicle k After the update is completed, the weight vector of vehicle k To update:
[0087]
[0088] The server collects the updated weights of each vehicle participating in the training And the similarity matrix M N to update.
[0089] Update the local feature extractor of the vehicle using the updated weights
[0090]
[0091] Local Feature Extractor The update method is based on the normalized weights Feature extractor for similar vehicles Compared with the feature extractor in the previous round The differences are weighted summed.
[0092]
S06
[0093] The updated local feature extractor And the global classifier θ of the previous round t-1 Combine to get a temporary local model Update the local model by performing the gradient descent of the loss function locally This process is represented as follows:
[0094]
[0095] Where D k is the local dataset held by vehicle k, and the update amplitude is determined by the local learning rate η ω control.
[0096] The present invention considers the model updates provided by other vehicle clients and updates the local feature extractor according to their relative contributions, so that the local feature extractor can learn useful information more quickly, thereby accelerating the convergence speed of the model and improving training efficiency.
[0097]
S07
[0098] In order to further improve the generalization and adaptability of the system, the global prediction head is trained by collecting and using the feature representations extracted by the feature extractor. For the kth vehicle, it contains the feature extractor of the previous round And the new feature extractor updated using the weights These two feature extractors are used to extract new and old feature representations respectively. Feature representation It is a set of digital vectors that captures the essential information of a piece of data.
[0099] The specific method is:
[0100] [S071] Use the historical feature extractor from the previous round and the new feature extractor after weight update to extract features from the local data set of the vehicle client, respectively, and obtain the corresponding historical feature representation and current feature representation.
[0101] Classify the feature representation according to the data category. For the local dataset D of vehicle k k The process is expressed as follows:
[0102]
[0103] in: For the kth vehicle client, use the new feature extractor For local datasets A sample subset x i Perform feature extraction;
[0104] For the kth vehicle client, use the historical feature extractor For local datasets A sample subset x i Perform feature extraction;
[0105] and are the average feature representations of each category for vehicle k in rounds t-1 and t, respectively.
[0106] [S072] Classify the current feature representation and historical feature representation of the obtained vehicle client according to data category.
[0107] [S073] The maximum mean difference statistical method is used to calculate the distribution difference between the current feature representation and the historical feature representation, and the maximum mean difference between the distribution of the historical feature representation and the current feature representation is obtained.
[0108] In order to coordinate the relationship between new and old features, the present invention uses the maximum mean difference (MMD) as a tool to measure the distribution difference. The calculated distribution difference is further used to guide the feature aggregation process to better integrate the feature representations from the new and old perspectives. The distance between the extracted current feature representation and the historical feature representation distribution is expressed as follows:
[0109]
[0110] The above formula can be broken down into the following three parts:
[0111] Part I: represents the internal self-similarity of the historical features of round t-1;
[0112] Part II: represents the internal self-similarity of the current feature representation of round t;
[0113] Part III: Represents the cross-similarity between the current feature representation and the historical feature representation data distribution.
[0114] P and Q represent historical feature representations respectively and the current feature representation The probability distribution of
[0115] n old and n new Respectively represent historical features and the current feature representation The number of samples;
[0116] k(·,·) is a kernel function used to measure the similarity between two samples. For two given vectors x and y, the formula of the Gaussian kernel function k(x,y) is defined as follows:
[0117]
[0118] Among them, σ is the bandwidth parameter of the Gaussian kernel function, which is used to control the local range of the Gaussian kernel function. The larger the bandwidth σ, the larger the local range of the Gaussian kernel function. The Gaussian kernel function measures the similarity between two vectors x and y by calculating the Euclidean distance ‖xy‖ between them.
[0119]
S074
[0120] Get historical feature representation and the current feature representation After averaging the maximum mean difference of the distribution, the weight W is assigned according to the distribution difference with the global feature representation. The weight W reflects the relative importance of each local feature representation in capturing the underlying data distribution. The formula is as follows:
[0121]
[0122] Through MMD value Perform a normalization operation to limit its value range to [0,1], and the weight W is used to balance the historical feature representation and the current feature representation Then, we use weighted average to aggregate and To ensure that those with historical characteristics Current feature representation with high consistency Aggregate feature representation The contribution of is greater. Its formula is expressed as follows:
[0123]
[0124] That is, the average feature representation of vehicle k in each local category after aggregation over t rounds, which is used to train the global prediction head. Containing feature information at different times, uploading feature representations is more efficient than transmitting the entire model, especially in resource-constrained environments. During the aggregation process, clients corresponding to feature distributions that deviate significantly from the historical feature distribution will be given lower weights to ensure that the unified feature representation is not overly affected by outliers or domain-specific biases. By aggregating historical feature representations and current feature representations, historical information can be retained to avoid losing useful features and patterns. Doing so helps maintain memory of previously learned information during model updates, thereby better leveraging past experience and knowledge.
[0125]
S08
[0126] The server collects the feature representations of all vehicles k participating in the training in the current round t. Train the global prediction head by calculating the loss function l about the global prediction head θ t-1 The gradient of is calculated to update the parameters. The update formula is as follows:
[0127]
[0128] Among them, η θ is the learning rate of the global prediction head, is the loss function l for the global prediction head θ t-1 Gradient of, based on aggregated feature representation And label data s. The new global classifier θ t It will be distributed to the selected vehicle clients in the next iteration.
[0129] The global prediction head can integrate information from the output of multiple models to improve the accuracy of the overall prediction. By comprehensively considering the prediction results of multiple models, the bias of a single model can be reduced, the robustness of the model can be improved, and the risk of overfitting can be reduced, thereby improving the generalization ability of the model.
[0130] The present invention conducts experimental evaluation on four image datasets MNIST, FashionMNIST, Cifar10, and Cifar100, respectively, and the comparison method adopts four strategies: FedAvg, FedProx, SCAFFOLD and MOON. All methods use the same hyperparameters. The model adopts a common convolutional neural network model built by two convolutional layers and two fully connected layers. The local learning rate is set to 0.01, the learning rate of the server-side global classifier is set to 0.01, the batchsize is set to 10, the client participation rate is set to 1, μ in FedProx and MOON is set to 0.01, and τ in MOON is set to 1. The accuracy under different numbers of clients (10, 100) and different distribution modes is tested on each dataset, such as Figure 3 shown.
[0131] The number of categories of these four datasets are 10, 10, 10, and 100. Their complexity from small to large is MNIST, FashionMNIST, Cifar10, and Cifar100. Figure 3 (a) shows the relationship curve between the test accuracy and the communication rounds under the MNIST dataset. It can be seen that in the task of recognizing the simplest MNIST dataset, each federation strategy can converge to a good result, and finally achieve an accuracy of more than 0.98. The method of the present invention is superior to the other four strategies in terms of accuracy by a small difference, but has the fastest convergence speed among all methods. Figure 3(b) It can be seen that on the FashionMNIST dataset, the accuracy of the other four algorithms has dropped significantly due to the increased complexity of the dataset. The strategy of the present invention still maintains the highest test accuracy and convergence speed in the four cases. Figure 3 (c) shows the relationship curve between the test accuracy and communication rounds of each strategy under the Cifar10 dataset. When the number of clients is equal to 10 in the Dirichlet distribution, FedAvg, FedProx, SCAFFOLD and MOON show similar performance, and the accuracy finally reaches 0.6. The strategy of the present invention achieves an accuracy of more than 0.8 under faster convergence, which is significantly ahead of the comparison method. When the number of clients increases to 100, the accuracy of the comparison strategy drops below 0.5, and the convergence speed is greatly reduced. The method of the present invention still remains above 0.8 and maintains the performance of high-speed convergence. When the number of clients in the pathological distribution is 10, the accuracy of FedAvg, FedProx and MOON is maintained at around 0.6, and the curve of SCAFFOLD begins to oscillate. At the same time, the strategy of the present invention still maintains an accuracy of more than 0.8. When the number of clients increases to 100, the curve of SCAFFOLD oscillates more violently and drops significantly compared with the other methods. This may be because SCAFFOLD is more sensitive to hyperparameters. Figure 3 (d) shows the relationship curve between the test accuracy and communication rounds of each strategy under the Cifar100 dataset. In the four scenarios, the method of the present invention improves the accuracy by about 10% compared with the control method.
[0132] Through the above experiments, the robustness and stability of the method of the present invention when facing non-IID data have been confirmed. The method of the present invention has the advantages of rapid convergence and high recognition rate. This is because before each round of training, the client will collect similar client information based on the similarity matrix. This knowledge sharing design accelerates the convergence speed of the system. The combination of personalized feature extractor and global classifier has demonstrated excellent performance when facing strongly heterogeneous different client data. The advantage of this combination is that it separates the two tasks of feature extraction and classification, so that each task can be optimized for specific needs. The personalized feature extractor can be designed specifically for a specific data structure or domain knowledge to extract the most informative features, while the global classifier can optimize the classification of the extracted features, thereby improving the overall classification performance.
[0133] Figure 4The performance of different strategies on the NSL-KDD dataset is shown. It is observed that each federated learning strategy has achieved a relatively ideal recognition accuracy on the NSL-KDD dataset, which is mainly due to the characteristics of the dataset. After mapping, the categories of the NSL-KDD dataset have a total of five categories, of which Normal and Dos account for 90% of the entire dataset. Since the dataset has fewer categories, recognition is relatively easy. Figure 4 It can be seen that each strategy can achieve relatively ideal recognition accuracy. Figure 4 (a) shows the performance of the practical non-IID scenario when the number of clients is 10. FedAvg and MOON experienced large fluctuations before 20 rounds and then maintained small fluctuations. FedProx, SCAFFOLD, and the present invention all gradually stabilized after small fluctuations. The present invention achieved the highest recognition accuracy. Figure 4 In the three cases (b), (c), and (d), the present invention has a small fluctuation, and the gap with the best strategy is within 0.02. In the recognition of simple tasks, although the present invention can maintain ideal accuracy, it cannot open up a gap with other strategies. This is because the NSL-KDD dataset is relatively simple, and each strategy can learn data features well, so there is not much difference in performance.
[0134] Figure 5 The performance of different strategies on the UNSW-NB15 dataset is shown. Compared with NSL-KDD, the UNSW-NB15 dataset is more complex and has more categories. Figure 5 (a) shows that in a realistic non-IID distribution scenario when the number of clients is 10, all strategies have experienced varying degrees of oscillation. The present invention achieves an accuracy of more than 0.8, and has slight oscillations within this accuracy range. Among the comparison methods, FedProx performs best, achieving an accuracy of 0.6 with the smallest oscillation amplitude. This is because FedProx introduces additional penalty terms in the optimization function to encourage the participant model to converge with the global model and better reflect the characteristics of the overall data set. Other strategies have experienced larger oscillations, and the recognition accuracy is less than 0.6. When the number of clients increases to 100, as shown in Figure 2, the accuracy of the proposed method is 0.6, which is slightly lower than that of the global model. Figure 5 As shown in (b), the oscillation amplitude of the curve of the comparison model further increases, and FedProx also shows obvious oscillation. In contrast, although the convergence speed of the strategy of the present invention slows down in the first 30 rounds, it can still maintain a recognition accuracy of 0.85 and is the most stable in this case. The SCAFFOLD strategy has the largest oscillation in this case, and oscillates repeatedly in the second half of the rounds, and ultimately fails to converge. In the pathological non-independent and identically distributed scenario, such as Figure 5As shown in (c) and (d), the control strategies did not oscillate significantly, and reached the upper limit of recognition performance in the early rounds. This is because in the case of pathological distribution, the present invention sets each client to contain only two categories. The extreme imbalance of sample distribution makes the characteristics of the smaller number of categories not fully learned, and only the characteristics of the larger number of categories are learned, so the performance upper limit is reached quickly. Unlike the traditional federated learning strategy, the present invention is no longer limited to generating only one global model, but generates its own personalized model for each client. After quickly reaching an accuracy of 0.9, the present invention still has slight fluctuations, because the design of knowledge sharing and global classifier breaks through the performance upper limit of traditional federated learning. Compared with the traditional federated learning strategy, the present invention fully considers the heterogeneity between clients. In traditional methods, for clients with highly heterogeneous distribution data sets, it is difficult to learn information that is beneficial to themselves from the models of other clients, which will lead to a decrease in accuracy. However, the present invention first uses the similarity between models to select a part of clients for enhanced aggregation of feature extractors to ensure that the collected information of other clients has a positive contribution to their own personalized models. Then, the feature representations of these clients are used to train the global classifier, fully considering the global information. Since the features are extracted by a personalized feature extractor, the present invention is not limited by the traditional federated learning strategy. On the UNSW-NB15 dataset with high complexity and strong heterogeneity, the performance difference of this design compared with the traditional federated learning strategy is particularly significant.
[0135] Anything not described in the present invention is applicable to the prior art.
[0136] 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. However, the obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A method for building an intrusion detection model for Internet of Vehicles based on federated learning. It is characterized in that The steps include: Decouple the local model in the vehicle into feature extractors and classifiers; Randomly select clients participating in the training, and use the similarity matrix to select other vehicle clients with high similarity to each vehicle client participating in the training; The server collects the local feature extractors of each vehicle client, and distributes the collected feature extractor parameters of the vehicle client and the global classifier obtained in the previous round to each vehicle client; Aggregate the local classifier of each vehicle client participating in the training with the feature extractors of other vehicle clients distributed by the server to form an evaluation model containing multiple feature extractors; The obtained evaluation model is evaluated on each vehicle client local model, and the weight of the similarity matrix is updated to obtain the updated vehicle client local feature extractor The updated vehicle client local feature extractor And the global classifier θ of the previous round t-1 Combined, the local model is updated by performing the gradient descent method of the loss function on the local model of the vehicle client After aggregating the feature representations extracted from the local dataset using the local feature extractors of the vehicle client before and after the update, the current feature representation R is obtained. t,s agg ; The server collects all current feature representations Train the global classifier θ t , and distributed to the vehicle clients participating in the next round of training.
2. According to the method for constructing an intrusion detection model for Internet of Vehicles based on federated learning according to claim 1, It is characterized in that Construct N-dimensional vehicle-client similarity matrix M N , evaluate n+1 models on the vehicle client local model to update the similarity matrix M N The weight update expression is: in: The local model of the vehicle client before weight update The loss function value of The vehicle client local model after weight update The loss function value of The vehicle client local model feature extractor before weight update; Vehicle client local model feature extractor after weight update.
3. According to the method for constructing an Internet of Vehicles intrusion detection model based on federated learning according to claim 2, It is characterized in that Similarity matrix M N The specific method of updating is: Use normalization operation to set the sum of all weights to 1; Using normalized weights Client feature extractor for similar vehicles Compared with the feature extractor in the previous round The difference is weighted summed to update the local model Feature extractor Its expression: The weights of n vehicle clients with high similarity to vehicle client k After the update is completed, the weight vector of vehicle client k is Make updates; The server collects the updated weights of each vehicle client participating in the training And the similarity matrix M N to update.
4. The method for constructing an Internet of Vehicles intrusion detection model based on federated learning according to any one of claims 1 to 3, It is characterized in that The global classifier is trained using all current feature representations collected by the server. The specific method is: The feature extractor of the previous round and the new feature extractor after weight update are used to extract features from the local data set of the vehicle client, respectively, to obtain the corresponding historical feature representation and current feature representation; Classifying the obtained current feature representation and historical feature representation of the vehicle client by data category; The maximum mean difference statistical method is used to calculate the distribution difference between the current feature representation and the historical feature representation, and the maximum mean difference between the historical feature representation and the current feature representation distribution is obtained; The normalized maximum mean difference is used as the weight to aggregate the historical feature representation and the current feature representation to obtain the feature representation R that combines the historical information and the current information. t,s agg ; The server collects the feature representation R aggregated by all vehicle clients participating in the training in the current round t t,s agg Train the global prediction head by using the loss function About the global prediction head θ t-1 The gradient of is calculated to obtain the new global classifier θ t .
5. According to the method for constructing an Internet of Vehicles intrusion detection model based on federated learning according to claim 4, It is characterized in that The above-mentioned historical feature extractor using the previous round and the new feature extractor after weight update Feature extraction is performed on the local data set of the vehicle client to obtain the corresponding feature representation, which is specifically represented as follows: in: For the kth vehicle client, use the new feature extractor For local datasets A sample subset x i Perform feature extraction; For the kth vehicle client, use the historical feature extractor For local datasets A sample subset x i Perform feature extraction; and are the average feature representations of each category for vehicle k in rounds t-1 and t, respectively.
6. The method for constructing an intrusion detection model for Internet of Vehicles based on federated learning according to claim 4, It is characterized in that The maximum mean difference statistical method is used to calculate the distribution difference between the current feature representation and the historical feature representation, and the maximum mean difference between the historical feature representation and the current feature representation distribution is obtained. The distance is expressed as follows: represents the internal self-similarity of the historical features of round t-1; represents the internal self-similarity of the current feature representation of round t; Represents the cross-similarity between the historical feature representation and the current feature representation data distribution; P and Q represent historical feature representations respectively and the current feature representation The probability distribution of n old and n new Respectively represent historical features and the current feature representation The number of samples; k(·,·) is a Gaussian kernel function, which is used to measure the similarity between two samples.
7. The method for constructing an Internet of Vehicles intrusion detection model based on federated learning according to claim 4, It is characterized in that The normalized maximum mean difference is used as the weight W, and its expression is: Among them: MMD value The maximum mean difference between the distribution of the calculated historical feature representation and the current feature representation; MMD max is the maximum value among the calculated MMD values; MMD min is the minimum value among the calculated MMD values.
Citation Information
Cited By
Internet of vehicles behavior detection method based on block chain-driven reward and punishment mechanism and federated learning
CN119363469A
Internet of vehicles federal learning method based on vehicle client selection
CN119729547A
Urban traffic detection system and method based on bidirectional memory federated learning, medium and electronic equipment
CN119989111A
City traffic detection system, method, medium and electronic device based on bidirectional memory federated learning
CN119989111B
