Network intrusion detection and classification method based on twin Transformer
The features of traffic data are extracted through the sliding time window correlation coefficient matrix and sparse filtering network, and combined with the multi-level twin Transformer for intrusion detection, which solves the problem of data set category imbalance in traditional methods, achieves higher detection accuracy and efficiency, and improves Improve the model's robustness and generalization ability.
Patent Information
- Application Number
- CN202411008654.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-10-01
AI Technical Summary
Traditional deep learning methods face the problems of data set category imbalance and computing resource limitations in network intrusion detection, making it difficult to balance detection accuracy and efficiency.
A network intrusion detection classification method based on Twin Transformer is used to extract low-dimensional features of traffic data through sliding time window correlation coefficient matrix data set and sparse filtering network, and multi-level Twin Transformer is used to identify intrusion categories and types, combined with self-attention Mechanisms and regularization constraints improve the robustness and generalization ability of the model.
It effectively reduces the false alarm rate under unbalanced data categories, improves detection accuracy and efficiency, enhances the robustness and generalization ability of the model, and can better extract the essential features of network traffic data.
Smart Images

Figure CN118740502A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network security technology, and in particular to a network intrusion detection classification method based on twin Transformer. Background Art
[0002] With the rapid growth of Internet usage, sensitive data on the global network has exploded and become a major target for attackers. They steal data by exploiting security vulnerabilities, threatening the normal operation of the system and the availability and confidentiality of data. Therefore, network security has become crucial, and intrusion detection systems (IDS) play a core role in it.
[0003] IDS is mainly divided into host-based IDS and network-based IDS. Host-based IDS focuses on monitoring data packets of specific devices to identify suspicious operations and behaviors that violate security policies. However, this approach requires installing an IDS on each host and may increase the processing burden of the host. In contrast, network-based IDS is deployed throughout the entire network and is responsible for monitoring, capturing and analyzing network traffic to detect malicious activities. Previously, the two main detection methods, anomaly-based and signature-based, were used more often, working by searching for known attack features or behavioral patterns that deviate from normal activities.
[0004] Signature-based IDS identifies malicious activities by maintaining a database of known attack signatures. This method has a low false positive rate for known attacks, but it is difficult to detect new attacks. Anomaly-based IDS, on the other hand, creates a model of the normal behavior of the system to identify activities that deviate from the model. It can detect new attacks but has a high false positive rate.
[0005] In general, IDS is a key link in network security. It helps network administrators detect and respond to potential security threats in a timely manner by monitoring network traffic and identifying suspicious activities.
[0006] Network traffic time series data refers to a collection of network traffic data arranged in chronological order. These data usually include information such as the number of packets in the network, transmission speed, and traffic patterns, reflecting the activity status of the network at different time points. Time series-based network intrusion detection technology, by analyzing the time series characteristics of network traffic data, helps to discover abnormal activity patterns and potential threats in the network, and provides rich information for detecting network attack behaviors.
[0007] In order to accurately identify the types of attacks in the network, researchers have been looking for more efficient intrusion detection system (IDS) methods. Early IDS mainly relied on technology based on feature and rule matching. In recent years, the research focus has gradually shifted to methods based on anomaly detection, especially the use of artificial intelligence methods, especially deep learning and machine learning technologies to detect network intrusions.
[0008] Although considerable progress has been made in this field using traditional artificial intelligence or machine learning methods in the past 20 years, it still faces problems of high false alarm rates and low detection rates, which greatly limits the effective application of traditional intelligent methods in real network environments.
[0009] To overcome these challenges, researchers have focused on deep learning, trying to improve the performance of IDS through deep learning technology. However, deep learning methods are also plagued by problems such as limited computing resources and imbalanced data categories. How to balance the accuracy and efficiency of IDS, and how to overcome these limitations and challenges, are important research directions in this field. Summary of the invention
[0010] The purpose of this invention is to provide a network intrusion detection classification method based on twin Transformer, which has high model robustness and strong generalization ability, and can effectively solve the problem of data set category imbalance that is difficult to solve in traditional deep learning methods when training network intrusion detection models.
[0011] In order to achieve the above object, the present invention provides the following technical solution: a network intrusion detection classification method based on twin Transformer, the specific steps are as follows:
[0012] Step 1: Perform data preprocessing on the network traffic dataset for intrusion detection and construct a network traffic time series dataset suitable for machine learning;
[0013] Step 2: Based on the normalized network traffic data set constructed in the previous step, establish a sliding time window Pearson correlation coefficient matrix data set;
[0014] Step 3: Input the Pearson correlation coefficient training data set of traffic data obtained in step 2 into the sparse filtering network to learn the low-dimensional features of the input samples, so that the sparse filtering learning model can capture the intrinsic features of the traffic data and obtain the traffic feature time series data set;
[0015] Step 4: Input the feature sequence obtained by the sparse filtering network into the twin Transformer for intrusion category detection to determine whether the traffic data is normal or under attack;
[0016] Step 5: Input the traffic feature sequence under attack into a new twin Transformer for intrusion detection. By successively using the binary classification twin network, the attack type is discriminated hierarchically until the discrimination model training of all attack types is completed.
[0017] Preferably, the specific method of step 1 is as follows:
[0018] Since the network traffic data set contains multiple category attributes, some attributes are usually expressed in string form and cannot be directly calculated. These string-form category attributes need to be converted into numerical data. This patent uses the One-hot encoding method for numerical conversion:
[0019] Convert the value of each non-numeric attribute discrete feature into a new binary vector, where only one position is 1 and the rest are 0;
[0020] Furthermore, the Min-Max normalization method is used to scale the range of numerical attribute data to the specified interval [0,1] to eliminate the scale differences between data attribute features;
[0021] The normalization process is:
[0022]
[0023] Among them, x in is the original data value of the input, x max and x min are the minimum and maximum values of the attribute data of this dimension in the data set, respectively. out is the value of the normalized output;
[0024] Sorting by log time, we get the normalized network traffic time series dataset X = {x 1 ,x 2 ,…,x L}, where x t =[x 1,t ,x 2,t ,...,x N,t ] T ∈R N is the flow data at time t, x i,t is the flow data x t The characteristic attribute data on the i-th dimension, 1≤i≤N, 1≤t≤L, L is the time series length of network traffic, and N is the characteristic dimension of traffic data.
[0025] Preferably, the specific method of step 2 is as follows:
[0026] Using the sliding time window method, the Pearson correlation coefficient is calculated for the normalized network traffic time series dataset X;
[0027] The data segment of the i-th attribute feature of the traffic data within the time window w is expressed as:
[0028] TS i,w ={x i,t |w≤t<w+W S},w∈[1,LW S ](2)
[0029] The flow data segment within the time window w is expressed as:
[0030]
[0031] Among them, W S For a given time window length, TS i,w is the data segment of the i-th attribute feature of the traffic data within the time window w, t represents the time, x i,t is the mean of the i-th and j-th attribute features of the traffic data at time point t;
[0032] The Pearson correlation coefficient of the flow data in the time window w is calculated as:
[0033]
[0034] Among them, x w,t,i and x w,t,j They are the flow data x at time t in time window w. w,t The i-th and j-th attribute features of and are the means of the flow data in the time window w respectively;
[0035] Thus, a set of Pearson correlation coefficient matrix time series data sets is obtained:
[0036]
[0037] in,
[0038] In the formula, is the Pearson correlation coefficient between the i-th and j-th attribute features of the traffic data in time window w;
[0039] The traffic data training sets under normal conditions and various attack conditions are constructed with a time window size of W. s The sliding time window Pearson correlation coefficient matrix of the time series data set:
[0040] Normal condition:
[0041] Attack k condition:
[0042] Among them, L Normal , Represents the number of traffic data set samples under normal conditions and attack conditions respectively; the Pearson correlation coefficient matrix of the normal condition is the time series data set Sample coefficient matrix in Attack k status Pearson correlation coefficient matrix time series data set Sample coefficient matrix in There are K attack types in total;
[0043] The Pearson correlation coefficient matrix in the sliding time window time series data set (6) and (7) is column-vectorized, and the time series traffic data training set containing normal conditions and k types of attack conditions is established. It includes:
[0044] Normal condition:
[0045] Attack k condition:
[0046] Among them, M Normal , They represent the number of time series traffic data samples under normal conditions and attack conditions k respectively. There are K types of attacks in total, and the number of training set samples is is the sample vector in the time series training dataset under normal conditions is the sample vector in the time series training dataset under attack k
[0047] Preferably, the specific method of step 3 is as follows:
[0048] The sparse filter network is composed of a stack of a sparse filter layer and a fully connected layer. The error between the sparse filter network prediction output and the sample category label is used to guide the joint optimization of the network weight parameters.
[0049] Given a training set in, Dimensional column vector is the mth input training sample, M is the total number of training samples, and sample After sparse filtering, and the weight matrix Function, mapped to D-dimensional feature vector f m ∈R D ,Right now:
[0050]
[0051] in, is the feature vector f m The d-th eigenvalue in is the d-th row vector of the weight matrix W, σ() is the neuron activation function, which is generally chosen
[0052] All training samples The obtained sparse filtering eigenvalues form the feature matrix Among them, the mth column vector f m ∈R D×1 (m=1,2,...,M) represents the feature vector of the mth sample, and the dth row vector f d ∈R 1×M (d=1,2,...,D) represents the d-th feature row vector learned from all M samples;
[0053] First, each eigenvector is normalized:
[0054]
[0055] is the normalized vector of the d-th eigenrow vector;
[0056] Next, the feature vector of each sample is normalized:
[0057]
[0058] is the normalized vector of the feature vector of the mth sample;
[0059] Finally, use l 1 The norm penalty imposes sparsity constraints on the feature matrix F of all training sets and constructs the objective function of sparse filtering:
[0060]
[0061] In order to enhance the specificity of the feature matrix generated by sparse filter learning and ensure that it can more accurately express the unique properties of traffic data under different conditions, a fully connected layer is added after the feature output of the sparse filter layer. The output of the fully connected layer is used to predict the state of the traffic data, and the prediction error is used to guide the optimization of the sparse filter weights.
[0062] Consider the training set categories, establish sample pairs Among them, the One-Hot label l m ∈R K+1 Represented as the category of sample data, namely normal state and K attack states;
[0063] From the above, we know that it depends on the sample input Feature vector learned through sparse filtering Enter the fully connected layer and get:
[0064]
[0065] in, is the activation function, which predicts the output value y m ∈R K+1 Restricted to the interval [0,1]; H∈R (K+1)×D is the projection matrix;
[0066] In order to avoid data overflow, minimize data loss, and improve the generalization ability of the model, we further consider regularizing the weight matrix W and use the following loss function to jointly optimize the network parameters:
[0067]
[0068] The L-BFGS algorithm is used to solve the optimization problem and obtain a characteristic matrix with good representation ability.
[0069] Preferably, the specific method of step 4 is as follows:
[0070] Method for classification using a multi-level twin Transformer network:
[0071] First, the feature sequence It is divided into two parts: normal data features and attacked data features, F = {F Normal ,F Attack},in, is the normal status data feature set; is the feature set of the attacked data, is the i-th feature vector of the k-th attack type,
[0072] Using the self-attention mechanism, two sets of inputs of the twin network are established respectively:
[0073] Normal condition: Q Normal =F Normal W Q , K Normal =F Normal W K , V Normal =F Normal W V (16) Attack status: Q Attack =F Attack W Q , K Attack =F Attack W K , V Attack =F Attack W V (17)
[0074] Among them, {Q Normal ,K Normal,V Normal} and {Q Attack ,K Attack ,V Attack} are the input matrices, W Q , W K , W V To fit the shared weight matrix, its parameters are trained through learning;
[0075] The calculation formulas for the two sets of input attention are:
[0076]
[0077] Among them, Softmax(.) is the normalized exponential function, d k For {Q Normal , K Normal} and {Q Attack , K Attack}Dimensions of the matrix;
[0078] The output loss function of the twin Transformer network is defined as:
[0079]
[0080] in, Used to represent the classification label of the mth input, 0 represents normal situation, 1 represents attacked situation, is the predicted probability of the corresponding category;
[0081] Through this loss function, the twin Transformer is trained to establish a classification and discrimination model.
[0082] Preferably, the specific method of step 5 is as follows:
[0083] The traffic feature sequence F under attack Attack Enter a new twin Transformer for intrusion detection and identify the attack type:
[0084] Select the attacked training dataset F Attack The type with the largest number of samples is used as the discriminant type in the next stage. The training sample set of this attack type and the remaining training sample sets containing other attack types are respectively input into the new twin Transformer for model training to obtain the discriminant model of this attack type. This process is repeated until the discriminant model training of all attack types is completed.
[0085] In the above technical solution, the technical effects and advantages provided by the present invention are:
[0086] 1. The sliding time window correlation coefficient method is used to expand the multidimensional traffic data. Through the correlation between the attribute features, the dimension of the abnormal attribute data is expanded; the sparse filtering method is used to reduce the dimension of the high-dimensional data set. The sparsity constraint is to retain the key features most relevant to the task, ignore other irrelevant features, and reduce the amount of redundant data. By increasing the dimension first and then reducing the dimension, the impact of abnormal data is highlighted.
[0087] 2. Traditional sparse filtering shows its unique advantages in the field of unsupervised feature learning. It can effectively distinguish features from different samples by accurately stimulating specific features, making sample identification more accurate. The present invention considers two constraints, classification prediction error and weight parameter minimization, when designing the optimization function. This mechanism ensures that each type of sample can extract its unique essential features, thereby showing excellent performance in feature learning.
[0088] 3. Use the twin Transformer for intrusion category detection. The twin neural network has good performance under resource constraints such as computing and data set availability. The twin neural network model training is more robust to class imbalanced data sets. In the case of data imbalance, traditional classifiers may be biased towards the majority class, resulting in reduced recognition rates for the minority class. The twin neural network classifies by comparing the similarity of two inputs and is not directly affected by the number of categories. Therefore, it has an advantage in processing unbalanced data. Compared with other neural networks, the Transformer can utilize the global context information of the input data, retain more semantic information, and better extract the essential characteristics of traffic data. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] Figure 1 This is a flow chart of a network intrusion detection classification method based on twin Transformer of the present invention;
[0090] Figure 2 It is the technical roadmap of the present invention;
[0091] Figure 3 It is a data preprocessing flow chart of the present invention. DETAILED DESCRIPTION
[0092] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.
[0093] The present invention provides Figure 1-3 A network intrusion detection classification method based on twin Transformer is shown in the figure. The specific steps are as follows:
[0094] Step 1: Perform data preprocessing on the network traffic dataset for intrusion detection and construct a network traffic time series dataset suitable for machine learning, including:
[0095] Since the network traffic data set contains multiple category attributes, some attributes are usually expressed in string form and cannot be directly calculated. These string-form category attributes need to be converted into numerical data. This patent uses the One-hot encoding method for numerical conversion:
[0096] Convert the value of each non-numeric attribute discrete feature into a new binary vector, where only one position is 1 and the rest are 0;
[0097] Furthermore, in the data set, the value ranges of different features may vary significantly. In order to prevent certain features with a large value range from dominating the model training, these features need to be normalized. This patent adopts the Min-Max normalization method to scale the range of numerical attribute data to the specified [0,1] interval to eliminate the scale differences between data attribute features.
[0098] The normalization process is shown in formula (1):
[0099]
[0100] Among them, x in is the original data value of the input, x max and x min are the minimum and maximum values of the attribute data of this dimension in the data set, respectively. out is the value of the normalized output. Normalization ensures that all data have the same weight in model training, thus preventing certain feature attributes from dominating model performance due to their large value range.
[0101] Sorting by log time, we get the normalized network traffic time series dataset X = {x 1 ,x 2 ,…,x L}, where x t =[x 1,t ,x 2,t ,...,x N,t ] T ∈R N is the flow data at time t, x i,t is the flow data x t The characteristic attribute data on the i-th dimension, 1≤i≤N, 1≤t≤L, L is the time series length of network traffic, and N is the characteristic dimension of traffic data.
[0102] Step 2: Based on the normalized network traffic data set constructed in the previous step, establish a sliding time window Pearson correlation coefficient matrix data set, specifically:
[0103] The Pearson correlation coefficient is calculated for the normalized network traffic time series dataset X using the sliding time window method.
[0104] The data segment of the i-th attribute feature of traffic data within the time window w can be expressed as:
[0105] TS i,w ={x i,t |w≤t<w+W S},w∈[1,LW S ] (2)
[0106] The flow data segment within the time window w can be expressed as:
[0107]
[0108] Among them, W S is the length of a given time window. TS i,w is the data segment of the ith attribute feature of the traffic data within the time window w, and t represents the time. i,t It is the i-th attribute characteristic value of the traffic data at time point t.
[0109] The Pearson correlation coefficient of the flow data in the time window w is calculated as shown in formula (4):
[0110]
[0111] Among them, x w,t,i and x w,t,j They are the flow data x at time t in time window w. w,t The i-th and j-th attribute features of and are the means of the i-th and j-th attribute features of the traffic data in the time window w, respectively.
[0112] Thus, a set of Pearson correlation coefficient matrix time series data sets is obtained:
[0113]
[0114] in,
[0115] In the formula, is the Pearson correlation coefficient between the i-th and j-th attribute features of the traffic data in time window w.
[0116] The traffic data training sets under normal conditions and various attack conditions are constructed with a time window size of W. s The sliding time window Pearson correlation coefficient matrix of the time series data set:
[0117] Normal condition:
[0118] Attack k condition:
[0119] Among them, L Normal , Represents the number of traffic data set samples under normal conditions and attack conditions respectively; the Pearson correlation coefficient matrix of the normal condition is the time series data set Sample coefficient matrix in Attack k status Pearson correlation coefficient matrix time series data set Sample coefficient matrix in There are K attack types in total.
[0120] Furthermore, the Pearson correlation coefficient matrices in the sliding time window time series data sets (6) and (7) are column-vectorized and combined to establish a time series traffic data training set containing normal conditions and k types of attack conditions. It includes:
[0121] Normal condition:
[0122] Attack k condition:
[0123] Among them, M Normal , They represent the number of time series traffic data samples under normal conditions and attack conditions k respectively. There are K types of attacks in total, and the number of training set samples is is the sample vector in the time series training dataset under normal conditions is the sample vector in the time series training dataset under attack k
[0124] Step 3: Input the Pearson correlation coefficient training data set of traffic data obtained in step 2 into the sparse filtering network to learn the low-dimensional features of the input samples, so that the sparse filtering learning model can capture the intrinsic features of the traffic data and obtain the traffic feature time series data set:
[0125] Sparse filtering is a representation learning method that has unique advantages in the field of unsupervised feature learning. Traditional sparse filtering is a two-layer neural network that can accurately stimulate specific features and effectively distinguish features from different samples, making sample identification more accurate. The sparse filtering mechanism ensures that each sample can extract its unique features, thereby showing excellent performance in feature learning. Especially when processing complex data sets, sparse filtering can better capture the essential characteristics of the data and improve the generalization ability of the model.
[0126] The established sparse filter network is composed of a stack of a sparse filter layer and a fully connected layer. The error between the predicted output of the sparse filter network and the sample category label is combined to guide the joint optimization of the network weight parameters.
[0127] Given a training set in, Dimensional column vector is the mth input training sample, M is the total number of training samples. After sparse filtering, and the weight matrix Function, mapped to D-dimensional feature vector f m ∈R D ,Right now:
[0128]
[0129] in, is the feature vector f m The d-th eigenvalue in is the d-th row vector of the weight matrix W, σ() is the neuron activation function, which is generally chosen
[0130] All training samples The obtained sparse filtering eigenvalues form the feature matrix Among them, the mth column vector f m ∈R D×1 (m=1,2,...,M) represents the feature vector of the mth sample, and the dth row vector f d ∈R 1×M (d=1,2,...,D) represents the d-th feature row vector obtained by learning all M samples.
[0131] First, each eigenvector is normalized:
[0132]
[0133] is the normalized vector of the dth eigenrow vector.
[0134] Next, the feature vector of each sample is normalized:
[0135]
[0136] is the normalized vector of the feature vector of the mth sample.
[0137] Finally, use l 1 The norm penalty imposes sparsity constraints on the feature matrix F of all training sets and constructs the objective function of sparse filtering:
[0138]
[0139] In order to further enhance the specificity of the feature matrix generated by sparse filter learning and ensure that it can more accurately express the unique properties of traffic data under different conditions, a fully connected layer is added after the feature output of the sparse filter layer, and the output of the fully connected layer is used to predict the state of the traffic data, and the prediction error is used to guide the optimization of the sparse filter weights.
[0140] Consider the training set categories, establish sample pairs Among them, the One-Hot label l m ∈R K+1 Represented as the category of sample data, namely normal state and K attack states.
[0141] From the above, we know that it depends on the sample input Feature vector learned through sparse filtering Enter the fully connected layer and get:
[0142]
[0143] in, is the activation function, which predicts the output value y m ∈R K+1 Restricted to the interval [0,1]; H∈R (K+1)×D is the projection matrix.
[0144] In order to avoid data overflow, minimize data loss, and improve the generalization ability of the model, we further consider regularizing the weight matrix W and use the following loss function to jointly optimize the network parameters:
[0145]
[0146] The L-BFGS algorithm is used to solve the optimization problem and obtain a characteristic matrix with good representation ability.
[0147] Step 4: Input the feature sequence obtained by the sparse filtering network into the multi-level twin Transformer for intrusion category detection to determine whether the traffic data is normal or under attack:
[0148] Considering that under normal circumstances, there are many types of attacks, some of which are less common. Compared with normal situations, data samples under attack are more difficult to obtain. The difficulty of obtaining traffic data under various attack conditions is also different, and the amount of training sample data for various attack types is different, which leads to the problem of data imbalance in training samples.
[0149] In order to solve this problem, a multi-level twin Transformer network classification method will be adopted.
[0150] First, the feature sequence It is divided into two parts: normal data features and attacked data features, F = {F Normal ,F Attack},in, is the normal status data feature set; is the feature set of the attacked data, is the i-th feature vector of the k-th attack type,
[0151] Using the self-attention mechanism, two sets of inputs of the twin network are established respectively:
[0152] Normal condition: Q Normal =F Normal W Q , K Normal =F Normal W K , V Normal =F Normal W V (16)
[0153] Attack status: Q Attack =F Attack W Q , K Attack =F Attack W K , V Attack =F Attack W V (17)
[0154] Among them, {Q Normal ,K Normal ,V Normal} and {Q Attack ,K Attack ,V Attack} are the input matrices, W Q , WK , W V To fit the shared weight matrix, its parameters are trained through learning;
[0155] The calculation formulas for the two sets of input attention are:
[0156]
[0157] Among them, Softmax(.) is the normalized exponential function, d k For {Q Normal , K Normal} and {Q Attack , K Attack}Dimensions of the matrix;
[0158] The output loss function of the twin Transformer network is defined as:
[0159]
[0160] in, Used to represent the classification label of the mth input, 0 represents normal situation, 1 represents attacked situation, is the predicted probability of the corresponding category;
[0161] Through this loss function, the twin Transformer is trained to establish a classification and discrimination model.
[0162] Step 5: The traffic feature sequence F under attack Attack Enter a new twin Transformer for intrusion detection:
[0163] Select the attacked training dataset F Attack The type with the largest number of samples is used as the next stage of discrimination type. The training sample set of this attack type and the remaining training sample sets containing other attack types are respectively input into the new twin Transformer for model training. The discrimination model of this attack type can be obtained.
[0164] In this way, the attack types are discriminated in stages by successively adopting the binary classification twin networks until the training of the discrimination models for all attack types is completed.
[0165] The test data set with the same format as the training data set is input into the models trained in the above steps in sequence to realize the intrusion detection classification prediction evaluation of network traffic data.
[0166] The above description is only by way of illustration of certain exemplary embodiments of the present invention. It is undoubted that those skilled in the art can modify the described embodiments in various ways without departing from the spirit and scope of the present invention. Therefore, the above drawings and descriptions are illustrative in nature and should not be construed as limiting the scope of protection of the claims of the present invention.
Claims
1. A network intrusion detection classification method based on twin Transformer, characterized in that: The specific steps are as follows: Step 1: Perform data preprocessing on the network traffic dataset for intrusion detection and construct a network traffic time series dataset suitable for machine learning; Step 2: Based on the normalized network traffic data set constructed in the previous step, establish a sliding time window Pearson correlation coefficient matrix data set; Step 3: Input the Pearson correlation coefficient training data set of traffic data obtained in step 2 into the sparse filtering network to learn the low-dimensional features of the input samples, so that the sparse filtering learning model can capture the intrinsic features of the traffic data and obtain the traffic feature time series data set; Step 4: Input the feature sequence obtained by the sparse filtering network into the twin Transformer for intrusion detection to determine whether the traffic data is normal or under attack; Step 5: Input the traffic feature sequence under attack into the new twin Transformer for intrusion detection. By successively using the binary classification twin network, the attack type is discriminated hierarchically until the discrimination model training of all attack types is completed.
2. According to claim 1, a network intrusion detection classification method based on twin Transformer is characterized in that: The specific method of step 1 is as follows: Since the network traffic dataset contains multiple category attributes, some attributes are usually expressed in string form and cannot be directly calculated. These string-based category attributes need to be converted into numerical data. One-hot encoding method is used for numerical conversion: Convert the value of each non-numeric attribute discrete feature into a new binary vector, where only one position is 1 and the rest are 0; The Min-Max normalization method is used to scale the range of numerical attribute data to the specified interval [0,1] to eliminate the scale differences between data attribute features; The normalization process is: Among them, x in is the original data value of the input, x max and x min are the minimum and maximum values of the attribute data of this dimension in the data set, respectively. out is the value of the normalized output; Sorting by log time, we get the normalized network traffic time series data set X = {x1, x2, …, x L }, where x t =[x 1,t ,x 2,t ,...,x N,t ] T ∈R N is the flow data at time t, x i,t is the flow data x t The characteristic attribute data on the i-th dimension, 1≤i≤N, 1≤t≤L, L is the time series length of network traffic, and N is the characteristic dimension of traffic data.
3. According to claim 2, a network intrusion detection classification method based on twin Transformer is characterized in that: The specific method of step 2 is as follows: Using the sliding time window method, the Pearson correlation coefficient is calculated for the normalized network traffic time series dataset X; The data segment of the i-th attribute feature of the traffic data within the time window w is expressed as: TS i,w ={x i,t |w≤t<w+W S },w∈[1,L-W S ] (2) The flow data segment within the time window w is expressed as: Among them, W S For a given time window length, TS i,w is the data segment of the i-th attribute feature of the traffic data within the time window w, t represents the time, x i,t is the i-th attribute characteristic value of the traffic data at time point t; The Pearson correlation coefficient of the flow data in the time window w is calculated as: Among them, x w,t,i and x w,t,j They are the flow data x at time t in time window w. w,t The i-th and j-th attribute features of and are the means of the i-th and j-th attribute features of the traffic data in the time window w, respectively; Thus, a set of Pearson correlation coefficient matrix time series data sets is obtained: in, In the formula, is the Pearson correlation coefficient between the i-th and j-th attribute features of the traffic data in time window w; The traffic data training sets under normal conditions and various attack conditions are constructed with a time window size of W. s The sliding time window Pearson correlation coefficient matrix of the time series data set: Normal condition: Attack k condition: Among them, L Normal , Represents the number of traffic data set samples under normal conditions and attack conditions respectively; the Pearson correlation coefficient matrix of the normal condition is the time series data set Sample coefficient matrix in Attack k status Pearson correlation coefficient matrix time series data set Sample coefficient matrix in There are K attack types in total; The Pearson correlation coefficient matrix in the sliding time window time series data set (6) and (7) is column-vectorized, and the time series traffic data training set containing normal conditions and k types of attack conditions is established. It includes: Normal condition: Attack k condition: Among them, M Normal , They represent the number of time series traffic data samples under normal conditions and attack conditions k respectively. There are K types of attacks in total, and the number of training set samples is is the sample vector in the time series training dataset under normal conditions is the sample vector in the time series training dataset under attack k 4. According to claim 3, a network intrusion detection classification method based on twin Transformer is characterized in that: The specific method of step 3 is as follows: The sparse filter network is composed of a stack of a sparse filter layer and a fully connected layer. The error between the sparse filter network prediction output and the sample category label is used to guide the joint optimization of the network weight parameters. Given a training set in, Dimensional column vector is the mth input training sample, M is the total number of training samples, and sample After sparse filtering, and the weight matrix Function, mapped to D-dimensional feature vector f m ∈R D ,Right now: in, is the feature vector f m The d-th eigenvalue in is the d-th row vector of the weight matrix W, σ() is the neuron activation function, which is generally chosen All training samples The obtained sparse filtering eigenvalues form the feature matrix Among them, the mth column vector f m ∈R D×1 (m=1,2,...,M) represents the feature vector of the mth sample, and the dth row vector f d ∈R 1×M (d=1,2,...,D) represents the d-th feature row vector learned from all M samples; First, each eigenvector is normalized: is the normalized vector of the d-th eigenrow vector; Next, the feature vector of each sample is normalized: is the normalized vector of the feature vector of the mth sample; Finally, the l1 norm penalty is used to constrain the sparsity of the feature matrix F of the entire training set, and the objective function of sparse filtering is constructed: In order to enhance the specificity of the feature matrix generated by sparse filter learning and ensure that it can more accurately express the unique properties of traffic data under different conditions, a fully connected layer is added after the feature output of the sparse filter layer. The output of the fully connected layer is used to predict the state of the traffic data, and the prediction error is used to guide the optimization of the sparse filter weights. Consider the training set categories, establish sample pairs Among them, the One-Hot label l m ∈R K+1 Represented as the category of sample data, namely normal state and K attack states; From the above, we know that it depends on the sample input Feature vector learned through sparse filtering Enter the fully connected layer and get: in, is the activation function, which predicts the output value y m ∈R K+1 Restricted to the interval [0,1]; H∈R (K +1)×D is the projection matrix; In order to avoid data overflow, minimize data loss, and improve the generalization ability of the model, we further consider regularizing the weight matrix W and use the following loss function to jointly optimize the network parameters: The L-BFGS algorithm is used to solve the optimization problem and obtain a characteristic matrix with good representation ability.
5. According to claim 4, a network intrusion detection classification method based on twin Transformer is characterized in that: The specific method of step 4 is as follows: Method for classification using a multi-level twin Transformer network: First, the feature sequence It is divided into two parts: normal data features and attacked data features, F = {F Normal ,F Attack },in, is the normal status data feature set; is the feature set of the attacked data, is the ith feature vector of the kth attack type, k=1,...K, i=1,...,M Attackk ; Using the self-attention mechanism, two sets of inputs of the twin network are established respectively: Normal condition: Q Normal =F Normal W Q , K Normal =F Normal W K , V Normal =F Normal W V (16) Attack status: Q Attack =F Attack W Q , K Attack =F Attack W K , V Attack =F Attack W V (17) Among them, {Q Normal ,K Normal ,V Normal } and {Q Attack ,K Attack ,V Attack } are the input matrices, W Q , W K , W V To fit the shared weight matrix, its parameters are trained through learning; The calculation formulas for the two sets of input attention are: Among them, Softmax(.) is the normalized exponential function, d k For {Q Normal K Normal } and {Q Attack K Attack },,the dimension of the matrix; The output loss function of the twin Transformer network is defined as: in, Used to represent the classification label of the mth input, 0 represents normal situation, 1 represents attacked situation, is the predicted probability of the corresponding category; Through this loss function, the twin Transformer is trained to establish a classification and discrimination model.
6. According to claim 5, a network intrusion detection classification method based on twin Transformer is characterized in that: The specific method of step 5 is as follows: The traffic feature sequence F under attack Attack Enter a new twin Transformer for intrusion detection and identify the attack type: Select the attacked training dataset F Attack The type with the largest number of samples is used as the discriminant type in the next stage. The training sample set of this attack type and the remaining training sample sets containing other attack types are respectively input into the new twin Transformer for model training to obtain the discriminant model of this attack type. This process is repeated until the discriminant model training of all attack types is completed.
Citation Information
Cited By
Advanced measurement system network intrusion detection method based on twin neural network
CN119254506A
Twin neural network based advanced measurement system network intrusion detection method
CN119254506B
Network traffic anomaly detection method based on Transform generative adversarial network
CN119496638A
A Network Traffic Anomaly Detection Method Based on Transformer Generative Adversarial Network
CN119496638B
Industrial equipment carbon emission measuring and calculating method and device based on running state dynamic monitoring
CN119623823A
