Method for constructing network intrusion model based on meta-learning
By building a meta-learning-based model in the network intrusion detection system, using GAN to generate simulated attack samples and dynamic inter-class constraints, combined with an irrelevant meta-algorithm optimization model, the problem of category imbalance and rapid adaptation to new attacks is solved, and efficient network intrusion detection is achieved.
Patent Information
- Application Number
- CN202510514633.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-04-23
AI Technical Summary
In existing network intrusion detection systems, the category imbalance of model training samples leads to insufficient detection capabilities for a few types of attacks, and it is difficult to quickly adapt to new types of attacks.
The network intrusion model construction method based on meta-learning is adopted to build multiple customer nodes through a global server. The customer nodes regularly collect local multivariate heterogeneous data and use the GAN network to generate simulated attack samples. The model is trained and optimized in combination with dynamic inter-class constraints and irrelevant meta-algorithm, and generate global detection models and deployed to the drone for detection.
It effectively solves the problem of category imbalance, improves the detection ability of a few types of attacks, and can quickly adapt to new types of cyber attacks, maintains good intrusion detection capabilities.
Smart Images

Figure CN120378162A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network security technology, and in particular, to a method for constructing a network intrusion model based on meta-learning. Background Art
[0002] The function of a network intrusion detection system is to identify network traffic, mainly classifying network traffic into normal traffic and traffic with intrusion attacks. In order to cope with the rapidly changing network space environment, current network intrusion detection systems need to use intelligent algorithms represented by machine learning to achieve traffic identification. In traditional machine learning, the machine focuses on a specific task T. In the field of network intrusion detection, a basic task is to use a classifier to judge the attributes of network traffic samples, that is, we have K samples and labels for this task. Our purpose is to construct a classifier model f, whose input is a certain sample xi and the output is an estimated value of the corresponding label yi of the sample. In general supervised learning scenarios, the larger the number of samples K, the better the detection effect on malicious samples. However, when training the model, usually normal data dominates and attack samples are scarce, resulting in insufficient detection ability of the detection model for minority-class attacks. In addition, after the model is trained, it will only have a relatively good detection effect on the attack samples used for model training, and has poor detection ability for newly emerging network attacks. Even if the model has a self-learning function, due to the small number of intrusion attack samples, it is difficult to adapt quickly. Summary of the Invention
[0003] Aiming at the deficiencies in the prior art, the present invention provides a method for constructing a network intrusion model based on meta-learning, which solves the problems of unbalanced class of model training samples in the prior art, resulting in insufficient detection ability of the detection model for minority-class attacks and difficulty in quickly adapting to newly emerging network attacks.
[0004] According to an embodiment of the present invention, a method for constructing a network intrusion model based on meta-learning includes:
[0005] The global server constructs multiple client nodes based on the federated learning framework and constructs node detection models in each client node;
[0006] The client node collects local heterogeneous data at fixed time intervals, generates simulated attack samples using the GAN network according to the local heterogeneous data, and then forms training data with the simulated attack samples, original attack samples and normal samples;
[0007] The client node introduces dynamic inter-class constraints into the node detection model, and then uses the training data to iteratively train the node detection model;
[0008] The client node performs meta-optimization on the trained node detection model using an irrelevant meta-algorithm;
[0009] The global server dynamically assigns an aggregation weight to each client node according to the data volume ratio of the local heterogeneous data of the client node and the model parameters of the node detection model, performs model aggregation in a weighted average manner to generate a global detection model, and deploys the global detection model to the drone for network intrusion detection.
[0010] Preferably, after the client node collects local heterogeneous data, it sequentially standardizes and feature-encodes the local heterogeneous data to generate feature data in the same format, and then uses the GAN network to generate simulated attack samples according to the feature data.
[0011] Preferably, the method of introducing dynamic inter-class constraints into the node detection model and then iteratively training the node detection model using training data includes:
[0012] S1: Divide the training data into a training set and a validation set, use the training set to iteratively train the node detection model, and use the validation set to evaluate the node detection model of the current iteration batch;
[0013] S2: Count the number of samples of the attack samples identified by the node detection model in the current iteration batch, and assign a weight coefficient to the attack samples;
[0014] S3: Calculate the F1 score of the attack samples of the node detection model on the validation set in the current iteration batch, and adjust the weight coefficient according to the F1 score;
[0015] S4: Adjust the loss function of the node detection model according to the weight coefficient, and then repeat steps S2 - S4 until the model converges.
[0016] Preferably, in S3, the formula for adjusting the weight coefficient is as follows:
[0017]
[0018] Where, is the weight coefficient before adjustment, γ is the correction coefficient, c is the class serial number, and C is the total number of classes.
[0019] In S3, if the F1 score continuously decreases in consecutive iterative trainings, then decrease γ, and if the F1 score continuously increases in consecutive iterative trainings, then increase γ.
[0020] Preferably, the method of performing meta-optimization on the trained node detection model using an irrelevant meta-algorithm includes:
[0021] Divide the local heterogeneous data according to the data type to obtain multiple task classes;
[0022] Each task class is divided into a support set and a query set, and the original model parameters of the node detection model are updated using the loss of the support set to obtain the support model parameters;
[0023] The support model parameters of the node detection model are updated using the loss of the query set to obtain the generalization model parameters.
[0024] Preferably, the update formula for the support model parameters is as follows:
[0025] θ′=θ-α▽ θ L support (θ)
[0026] The update formula for the generalization model parameters is as follows:
[0027] θ meta =θ-β▽ θ L query (θ′)
[0028] Where θ is the original model parameter, both α and β are learning rates, Lsupport is the loss function of the support set, Lquery is the loss function of the query set, and ▽ θ is the gradient vector of the data in the task class.
[0029] Preferably, after the node detection model is trained, each client node needs to upload the local multi-source heterogeneous data collected by the client node and the generalization model parameters of the node detection model to the global server.
[0030] Preferably, when the client node uploads data, privacy protection processing needs to be performed on the uploaded data. The processing methods include:
[0031] Calculate the gradient vector of the feature data, and then perform L2 norm clipping on the feature data according to the gradient vector to obtain the clipped data;
[0032] Inject Laplace noise into the clipped data according to the preset privacy budget.
[0033] Preferably, the calculation formula for the aggregation weight of each client node is as follows:
[0034]
[0035] Where r i is the proportion of the local multi-source heterogeneous data collected by the i-th client node in the total data volume of all client nodes, A i is the F1 score of the i-th client node, A j is the F1 score of the j-th client node, η is the exponential adjustment factor, whose initial value is set by experience, and K is the number of client nodes.
[0036] Preferably, the method for determining the exponential adjustment factor is as follows:
[0037] Randomly extract some samples from the local heterogeneous data uploaded by each client node and combine them into global verification data;
[0038] Use the initial η for aggregation to obtain a global detection model, and verify the global detection model with the global verification data. Then calculate the proportion of the number of correctly recognized samples in the total amount of global verification data to obtain the current model accuracy;
[0039] Calculate the difference between the current model accuracy and the accuracy of the global detection model obtained from the previous aggregation. If the difference is less than the preset value, increase η. If the difference is greater than the preset value, keep it unchanged.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] Based on the collected local heterogeneous data, the present invention uses the GAN network to generate simulated attack samples to expand the number of attack samples, avoid the problem of class imbalance in training samples, and improve the detection ability for minority-class attacks. In addition, at fixed intervals, the client nodes will re-collect the local heterogeneous data and re-train the node detection models. Therefore, the global detection model for UAV network intrusion detection will also be updated together to jointly update the global detection model, so that it always maintains a relatively good intrusion detection ability. At the same time, the small-sample data training model of the irrelevant element algorithm is combined to quickly adapt to new network attacks with a small number of samples and improve the detection accuracy for new network attacks. Description of the Drawings
[0042] Figure 1 It is a flowchart of the method for constructing the network intrusion model according to the embodiment of the present invention. Detailed Embodiment
[0043] The technical solutions in the present invention will be further described below with reference to the drawings and embodiments.
[0044] As Figure 1 shown, the embodiment of the present invention proposes a method for constructing a network intrusion model based on meta-learning, including:
[0045] The global server constructs multiple client nodes connected to the global server based on the federated learning framework. Each client node regularly uploads relevant data to the global server, and then constructs a node detection model in each client node;
[0046] The client node collects local multi-source heterogeneous data at fixed time intervals (usually at weekly intervals, which can be extended or shortened as needed), and uses the GAN network to generate simulated attack samples based on the local multi-source heterogeneous data.
[0047] Each client node collects local multi-source heterogeneous data through sensors, communication interfaces, and flight controllers, including: sensor data (such as GPS coordinates, accelerometer readings, gyroscope data, etc.), network traffic data (TCP / UDP packet header information, packet size distribution, etc.), and system log data (such as abnormal process startup records, permission change events, etc.).
[0048] Since the formats of these data are different, it is necessary to process these local multi-source heterogeneous data and convert them into feature data of the same format for subsequent data analysis. The processing methods include:
[0049] (1) Standardize the original data:
[0050]
[0051] where μ is the feature mean and σ is the standard deviation.
[0052] (2) Perform feature encoding on the multi-source heterogeneous data to generate a unified feature representation:
[0053] F = Encoder(X1, X2,..., X M ) ∈ i D
[0054] where X i , i ∈ i[1, M] are M types of heterogeneous data sources, Encoder is the feature encoding network, and D is the feature dimension.
[0055] After that, the processed feature data is imported into the GAN generative adversarial network for data augmentation. The GAN network is used to expand the attack samples and generate simulated attack samples to avoid the problem of class imbalance in the training samples and improve the detection ability for minority-class attacks:
[0056] ① The generator receives the random noise z and the encoded feature F and outputs a synthetic sample:
[0057] X syn = G(z, F)
[0058] ② The discriminator distinguishes the real sample X real from the synthetic sample X syn , and optimizes the generator and discriminator through the adversarial loss function.
[0059] The discriminator loss is updated as follows:
[0060]
[0061] The generator loss is updated as follows:
[0062]
[0063] Among them, λ fm represents the feature matching weight, and φ represents the discriminator intermediate layer features.
[0064] After that, the generated simulated attack samples, original attack samples, and normal samples are combined to form training data to train the node detection model.
[0065] Introduce dynamic inter-class constraints in the node detection model, and then use the training data to iteratively train the node detection model;
[0066] The training data is divided into a training set and a validation set, where the training set accounts for 70% of all data, and the validation set accounts for 30%. The training set is used for the iterative training of the node detection model, and the validation set is used to evaluate and verify the node detection model of the current iteration batch.
[0067] For any iteration batch, count the sample number N c of each attack sample in the current iteration batch, and assign an initial weight to it:
[0068]
[0069] Among them, ε is a numerical stability coefficient, which is a very small constant used to prevent the denominator from being zero. λ is a dynamic weight scaling factor used to adjust the sensitivity to class imbalance.
[0070] In the present invention, the training data is divided into normal samples and attack samples according to the binary classification principle. Of course, for the training data, it can also be divided into normal samples and attack samples of different attack forms according to the multi-classification principle. In the case of multi-classification, N c represents the sample number of the c-th class of attack samples, and C represents the total number of classes.
[0071] λ is determined according to the sample number N c In the majority class (such as normal samples), the sample number N c is large, and λ needs to be appropriately reduced to suppress overfitting; in the minority class (such as rare attack samples): the sample number N c is small, and increasing λ can enhance the model's attention to the tail classes.
[0072] After that, smooth the weight distribution through the temperature coefficient:
[0073]
[0074] Among them, γ∈(0,1] represents the correction coefficient for dynamic adjustment of class weights, which is dynamically adjusted according to the F1 score of the corresponding attack samples of the model on the validation set during the training process. If, when validating on the validation set, the F1 score of the corresponding attack samples continuously decreases during multiple iterative trainings, then γ is reduced according to γ←γ×0.9 to strengthen the weight difference; conversely, it is increased according to γ←γ×1.1 to smooth the weight distribution.
[0075] The node detection model uses the softmax cross-entropy loss function:
[0076]
[0077] Among them, z i,c represents the logits output of the i-th sample in class c, and y i,c represents whether the true label of the i-th sample is class c, and one-hot encoding is used: when sample i belongs to class c, y i,c = 1, otherwise it is 0.
[0078] To make the node detection model adapt to extremely few attack samples, the irrelevant element algorithm is used to perform meta-optimization on the node detection model after training:
[0079] ① Inner layer update (adapting to new tasks): The training data is divided into multiple task classes according to the data type (such as by task task), and then each task class is divided into a support set and a query set. Among them, the support set (Support Set) randomly samples a small number of samples (such as 5 for each class) to simulate "quick adaptation with few samples" and guides the model to quickly adapt to new attack patterns (similar to few-shot learning). The support set loss is used to adjust the model parameters to simulate "quick learning with few samples". The model is updated through the support set samples to make the support model parameters θ′ initially adapt to the current task. The inner layer update method is as follows:
[0080] θ′ = θ - α▽ θ L support (θ)
[0081] Among them, θ represents the original model parameters of the node detection model, and the model is made to adapt to different intrusion detection tasks by adjusting θ. θ includes convolutional kernel weights, fully connected layer parameters, etc., which determine the model's ability to extract traffic features and classification boundaries. In meta-learning, θ is the global initialization parameter, and through multi-task training optimization, the model is made to have the potential to quickly adapt to new attack tasks. θ′ updates and adjusts the weights of the feature extraction layer and the classification layer to make the model quickly adapt to the attack pattern of the current task. α represents the learning rate of the inner layer update of meta-learning, which controls the parameter adjustment step size of the model on the support set. L support represents the loss function calculated by the model on the support set, which is used for quick adaptation of intra-task parameters, ▽ θThe gradient vector of the data in the task class.
[0082] ② Outer layer update (meta-optimize global parameters): Evaluate the performance of the adapted model using the query set loss and optimize the meta-parameters. The query set is used to evaluate the generalization of the model, ensuring that the model can still maintain its discriminative ability for unknown samples after adaptation, preventing overfitting, ensuring that the model maintains generalization on the query set after fine-tuning with the support set, and then output the final generalized model parameters:
[0083] θ meta = θ - β▽ θ L query (θ′)
[0084] where β represents the learning rate of the outer layer update of meta-learning, controlling the meta-optimization step size of the global model parameters. L query represents the loss function calculated by the model on the query set and is used for cross-task meta-optimization.
[0085] The global server dynamically assigns aggregation weights to each node according to the data volume ratio of the local heterogeneous data of the client nodes and the model parameters of the node detection models, aggregates the models in a weighted average manner to generate a global detection model, and deploys the global detection model to the drone for network intrusion detection.
[0086] After the node detection model is trained, each client node needs to upload the local heterogeneous data collected by the client node and the generalized model parameters of the node detection model to the global server. When the client node uploads data, privacy protection processing needs to be performed on the uploaded data. The processing methods include:
[0087] (1) Calculate the gradient vector ▽ θ of the current batch of training data and perform L2 norm clipping on it based on a preset threshold C, that is, when ||▽ θ ||2 > C, scale the gradient to to limit the sensitivity of the gradient amplitude and prevent the features of the training data from being reverse-inferred due to gradient leakage. The specific formula is as follows:
[0088]
[0089] (2) Laplace noise injection:
[0090]
[0091] where Δf is the sensitivity of the gradient amplitude.
[0092] Generate Laplace distribution satisfying p according to the preset privacy budget ε Random noise, the noise is directly superimposed on the clipped gradient vector to form the perturbed privacy gradient
[0093] After that, the global server dynamically assigns the aggregation weight α to each node according to the proportion of the data volume of the local heterogeneous data of the client node and the model parameters of the node detection model i :
[0094]
[0095] Among them, r i is the proportion of the local heterogeneous data collected by the i-th client node in the total data volume of all client nodes, A i is the F1 score of the i-th client node, A j is the F1 score of the j-th client node, and η is the exponential adjustment factor of r i The initial value is set by experience, and K is the number of client nodes
[0096] Since the initial value of the exponential adjustment factor η is set manually, in order to ensure the accuracy of the aggregation weight, the exponential adjustment factor η needs to be adjusted
[0097] (1) Randomly select part of the samples from the local heterogeneous data uploaded by each client node to form global verification data, including normal samples and various attack samples, to ensure the balance of the class distribution (or retain the natural imbalance according to the actual scenario).
[0098] The global verification data needs to cover known attack types and some unknown attack variants (simulated through data augmentation) to comprehensively evaluate the model generalization
[0099] (2) Use the initial η for aggregation to obtain the global detection model, and use the global verification data to verify the global detection model, and then calculate the proportion of the number of correctly identified samples in the total global verification data to obtain the current model accuracy
[0100]
[0101] (3) Calculate the difference Δ between the current model accuracy Acc and the accuracy of the global detection model obtained by the previous aggregation acc , if the difference Δ acc is less than the preset value, then increase η according to the following formula, if the difference is greater than the preset value, then keep it unchanged
[0102]
[0103] Increasing η will make the weight α i more biased towards the client nodes with large data volume (r iThe proportion is increased), thereby suppressing the noise influence of low-quality models.
[0104] After adjusting the aggregation weights, the global model parameter θ global is the generalization model parameter of each node detection model Weighted average:
[0105]
[0106] Then, use this global model parameter to construct a global detection model and deploy the global detection model to the drone for network intrusion detection. At fixed intervals, the client node will re-collect local heterogeneous data and re-train the node detection model. Therefore, the global detection model used for drone network intrusion detection will also be updated together, so as to jointly update the global detection model, making it always maintain a relatively good intrusion detection ability. At the same time, combine the small-sample data training model of the irrelevant element algorithm to quickly adapt to new network attacks with a small number of samples and improve the detection accuracy of new network attacks.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not restrictive. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the purpose and scope of the technical solutions of the present invention, and they should all be covered by the scope of the claims of the present invention.
Claims
1. A method for constructing a network intrusion model based on meta-learning, characterized in that: Including: The global server constructs multiple client nodes based on the federated learning framework and constructs a node detection model within each client node; The client node collects local heterogeneous data at fixed time intervals, generates simulated attack samples using the GAN network according to the local heterogeneous data, and then forms training data by combining the simulated attack samples, original attack samples, and normal samples; The client node introduces dynamic inter-class constraints into the node detection model and then iteratively trains the node detection model using the training data; The client node performs meta-optimization on the trained node detection model using the irrelevant element algorithm; The global server dynamically assigns aggregation weights to each client node according to the data volume ratio of the local heterogeneous data of the client node and the model parameters of the node detection model, performs model aggregation by weighted averaging to generate a global detection model, and deploys the global detection model to the drone for network intrusion detection.
2. A method for constructing a network intrusion model based on meta-learning according to claim 1, characterized in that: After the client node collects local heterogeneous data, it normalizes and feature-encodes the local heterogeneous data to generate feature data in the same format, and then generates simulated attack samples using the GAN network according to the feature data.
3. A method for constructing a network intrusion model based on meta-learning according to claim 2, characterized in that: The method of introducing dynamic inter-class constraints into the node detection model and then iteratively training the node detection model using the training data includes: S1: Divide the training data into a training set and a validation set, iteratively train the node detection model using the training set, and evaluate the node detection model of the current iteration batch using the validation set; S2: Count the number of samples of the attack samples identified by the node detection model in the current iteration batch and assign a weight coefficient to the attack samples; S3: Calculate the F1 score of the attack samples of the node detection model on the validation set in the current iteration batch and adjust the weight coefficient according to the F1 score; S4: Adjust the loss function of the node detection model according to the weight coefficient, and then repeat steps S2 - S4 until the model converges.
4. A method for constructing a network intrusion model based on meta-learning according to claim 3, characterized in that: In S3, the formula for adjusting the weight coefficient is as follows: Among them, is the weight coefficient before adjustment, γ is the correction coefficient, c is the class serial number, and C is the total number of classes. In S3, if the F1 score continuously decreases in consecutive iterative trainings, then γ is decreased; if the F1 score continuously increases in consecutive iterative trainings, then γ is increased.
5. A method for constructing a network intrusion model based on meta-learning according to claim 1, characterized in that: The method of performing meta-optimization on the trained node detection model using the irrelevant element algorithm includes: Dividing the local heterogeneous data according to the data type to obtain multiple task classes; Dividing each task class into a support set and a query set, and updating the original model parameters of the node detection model using the loss of the support set to obtain support model parameters; Updating the support model parameters of the node detection model using the loss of the query set to obtain generalization model parameters.
6. The construction method of a network intrusion model based on meta - learning according to claim 5, characterized in that: The update formula for the support model parameters is as follows: The update formula for the generalization model parameters is as follows: Among them, θ is the original model parameter, both α and β are learning rates, Lsupport is the loss function of the support set, and Lquery is the loss function of the query set. is the gradient vector of the data in the task class.
7. The construction method of a network intrusion model based on meta - learning according to claim 5, characterized in that: After the node detection model is trained, each client node needs to upload the local multi - heterogeneous data collected by the client node and the generalization model parameters of the node detection model to the global server.
8. The construction method of a network intrusion model based on meta - learning according to claim 7, characterized in that: When the client node uploads data, privacy protection processing needs to be performed on the uploaded data. The processing methods include: Calculating the gradient vector of the feature data, and then performing L2 - norm clipping on the feature data according to the gradient vector to obtain the clipped data; Injecting Laplace noise into the clipped data according to the preset privacy budget.
9. The construction method of a network intrusion model based on meta - learning according to claim 1, characterized in that: The calculation formula for the aggregation weight of each client node is as follows: where r i is the proportion of the local heterogeneous data collected by the i-th client node to the total data volume of all client nodes, A i is the F1 score of the i-th client node, A j is the F1 score of the j-th client node, η is the exponential adjustment factor, whose initial value is set by experience, and K is the number of client nodes.
10. The construction method of a network intrusion model based on meta - learning according to claim 9, characterized in that: The determination method of the exponential adjustment factor: Randomly extracting some samples from the local multi - heterogeneous data uploaded by each client node to form global validation data; Using the initial η for aggregation to obtain a global detection model, and validating the global detection model with the global validation data, and then calculating the proportion of the number of correctly recognized samples of the model in the total amount of the global validation data to obtain the current model accuracy; Calculating the difference between the current model accuracy and the accuracy of the global detection model obtained by the previous aggregation. If the difference is less than the preset value, then increase η. If the difference is greater than the preset value, then keep it unchanged.
Citation Information
Patent Citations
Network traffic abnormity detection method based on model-free federated element learning
CN113469234A
Network intrusion detection method based on federated learning
CN116708009A
Void filling device and construction method using the same
KR102788772B1
System and method for DNN-based cyber-security using federated learning-based generative adversarial network
US20230308465A1
Cited By
Communication replay attack detection model training method and system based on deep learning
CN121098633A