An abnormal traffic intrusion detection method based on stacked autoencoder and KNN Gaussian optimization algorithm

By using the intrusion detection method of stacked automatic encoder and KNN Gaussian optimization algorithm in the fog computing environment, the problem of insufficient detection efficiency and accuracy in the prior art is solved, and higher detection accuracy and shorter training are achieved Time, suitable for real-time detection and identification of new attacks.

CN114897079BActive Publication Date: 2024-11-08LIAONING UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210548650.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-20
Publication Date
2024-11-08
Estimated Expiration
2042-05-20

AI Technical Summary

Technical Problem

The existing intrusion detection technology is difficult to effectively detect malicious data packets in fog computing environments, and the accuracy and complexity of traditional KNN classification algorithms are insufficient, which affects the detection efficiency and accuracy.

Method used

The abnormal traffic intrusion detection method based on stacked automatic encoder and KNN Gaussian optimization algorithm is adopted to process data through information entropy discretization, one-hot encoding and z-score standardization, and feature selection is used by stacked automatic encoder, combined with KNN Gaussian optimization algorithm is used for training and detection.

Benefits of technology

It improves the accuracy and operation speed of intrusion detection, shortens training time, is suitable for real-time detection and identification of new attacks, enhances the scalability and noise immunity of the system, and avoids the losses caused by false traffic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114897079B_ABST
    Figure CN114897079B_ABST
Patent Text Reader

Abstract

An abnormal traffic intrusion detection method based on a stacked autoencoder and a KNN Gaussian optimization algorithm belongs to the intersection of deep learning and computer networks. The present invention first uses a stacked autoencoder to extract features, and then uses the KNN Gaussian optimization algorithm to classify samples to obtain the final sample detection results. After multiple experimental verifications, the KNN Gaussian optimization algorithm has lower time complexity and improved accuracy than the traditional KNN algorithm. This method can improve the operating rate and scalability of anomaly detection technology, and is more suitable for solving the current anomaly detection problem of new attack types emerging in an endless stream.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This patent belongs to the field of information security technology, and specifically relates to an abnormal traffic intrusion detection method based on stacked autoencoders and KNN Gaussian optimization algorithm. Background Art

[0002] Fog computing has become an extension of cloud computing, which provides an efficient infrastructure to support the Internet of Things. Fog computing acts as an intermediary to provide local processing of end-user requests and reduce the communication latency between end-users and the cloud through fog devices. Therefore, the authenticity of incoming network traffic on fog devices is very important. These devices are vulnerable to malicious attacks. Especially financial and health information. Attackers target these devices by sending malicious packets. It is imperative to detect these intrusions to provide safe and reliable services to users. Therefore, an effective intrusion detection system is essential for the safe operation of fog devices without compromising efficiency. In this patent, we propose a deep learning-based intrusion detection method using an abnormal traffic intrusion detection method based on stacked autoencoders and KNN Gaussian optimization algorithm in a fog environment. This method only performs binary classification on incoming packets, because fog devices are committed to detecting attacks from normal packets in real time. We validate the proposed method on the benchmark NSL-KDD dataset. Compared with many intrusion detection techniques, our intrusion detection technique achieves higher accuracy. Summary of the invention

[0003] The present invention aims to provide an abnormal traffic intrusion detection method based on a stacked autoencoder and a KNN Gaussian optimization algorithm, improve the traditional KNN classification algorithm, improve the classification accuracy and shorten the algorithm complexity.

[0004] In order to achieve the above purpose, the technical solution adopted by the present invention is:

[0005] An abnormal traffic intrusion detection method based on stacked autoencoder and KNN Gaussian optimization algorithm, the steps are:

[0006] 1) Training:

[0007] 1.1) The NSL-KDD dataset is discretized using a data discretization method based on information entropy.

[0008] 1.2) One-hot encoding is used to process discrete features and the z-score method is used to normalize the data;

[0009] 1.3) Using stacked autoencoder feature selection method to reduce the dimension of data;

[0010] 1.4) Import the processed data into the classifier and train it using the KNN Gaussian optimization algorithm;

[0011] 1.5) Establish the trained model and test the model multiple times to prove that the model has higher accuracy and shorter training time than the traditional KNN model;

[0012] 2) Detection:

[0013] 2.1) Input the data to be trained into the model, and use the binary classification of attack data and normal data as the output mechanism;

[0014] 2.2) Training model. Through multiple test models, it is proved that the model has higher accuracy and shorter training time than the traditional KNN model.

[0015] It is characterized in that the discretization method in 1.1) is:

[0016] The data discretization algorithm based on information entropy is a supervised learning algorithm. When using this method to discretize data, the data needs to have corresponding labels.

[0017] It is characterized in that the pretreatment method in 1.2) is:

[0018] First, the discrete features of the collected data are digitized by one-hot encoding. The method is to use an N-bit state register to encode N states. Each state has its own independent register bit, and at any time, only one of them is valid.

[0019] Secondly, the encoded data should be standardized and the data ratio should be scaled so that the feature data falls into a specific numerical space to facilitate subsequent calculations. The present invention adopts z-score standardization, and the formula is as follows:

[0020]

[0021] Where μ is the mean of the original data x, and σ is the standard deviation of the original data x.

[0022] It is characterized in that the feature selection method described in step 1.3) includes a stacked automatic encoder, specifically:

[0023] First, each single hidden layer denoising autoencoder unit is pre-trained in an unsupervised manner, then stacked, and finally the overall reverse tuning training is performed to obtain a stacked autoencoder with a two-hidden layer structure;

[0024] The specific steps of constructing the above two-layer hidden layer structure of denoising autoencoder are as follows: First, the first DA unit is pre-trained, where is the restored input data or feature, X is the original input data or feature not contaminated by noise, y is the input data or feature contaminated by noise, and σ(·) is the sigmoid function:

[0025] The output of the first autoencoder can be represented as follows:

[0026] h(y)=σ(W1y+b1)

[0027] X=W1 T h(y)+b2

[0028] The minimum mean square error is used as the cost function, and the gradient descent method is used to update the weight value W and the bias value b:

[0029]

[0030] (W1,b1,b2)←argmin(J(W1,b1,b2))

[0031] The specific calculation method of the gradient descent method is as follows:

[0032]

[0033]

[0034]

[0035] After pre-training, remove the output layer and its corresponding weights and biases, and only keep W1 and b1 of the input layer and hidden layer; then use the hidden layer of the first DA unit as the input of the second DA unit to pre-train the second DA unit:

[0036] The output of the second denoising autoencoder can be represented as follows:

[0037] h(h(y))=σ(W2h(y)+b2)

[0038] h(X)=W2 T h(h(y))+b3

[0039] The minimum mean square error is used as the cost function, and the gradient descent method is used to update the weight value W and the bias value b:

[0040]

[0041] (W2,b2,b3)←argmin(J(W2,b2,b3))

[0042] The specific calculation method of the gradient descent method is as follows:

[0043]

[0044]

[0045]

[0046] Stack it on the first DA unit, and finally, add an output layer on top of the hidden layer of the second DA unit for decoding recovery;

[0047] After the pre-training of the two DA units is completed, the last step is the overall reverse tuning training. The cost function of the tuning training adopts the cost function mentioned above, and the gradient descent method is used to update the weights and bias values ​​from top to bottom.

[0048] The classifier KNN Gaussian optimization algorithm described in step 1.4) is specifically:

[0049] The weighted function can be inverted by adding a constant to the distance when taking the inverse of the distance:

[0050] weight = 1 / (distance+const)

[0051] The weighting function can also use a Gaussian function, which is in the form of:

[0052] where a,b,c∈R

[0053] The shape of the Gaussian function is like an upside-down bell; a is the height of the curve, b is the offset of the center line of the curve on the x-axis, and c is the half-peak width;

[0054] The Gaussian function above has a weight of 1 when the distance is 0. As the distance increases, the weight decreases, but it will not become 0. The following is the difference between the Gaussian function and several other functions. When the distance increases to a certain extent, the weight of other functions drops to 0 or below 0.

[0055] The calculation process is as follows:

[0056] Weighted kNN first obtains the sorted distance values ​​and then takes the k elements with the closest distance;

[0057] 1. When processing discrete data, treat these k data differently with weights, and predict the probability that the result is the same as the label of the nth data:

[0058]

[0059] 2. When processing numerical data, it is not a simple average of these k data, but a weighted average: multiply the distance value of each item by the corresponding weight, then add up the results, and after finding the total, divide it by the sum of all weights;

[0060]

[0061] Di represents the distance between the nearest neighbor i and the value to be predicted x, Wi represents its weight, and f(x) is the numerical result of the prediction. Every time a new sample is predicted to belong to a certain category, the entire sample will be traversed.

[0062] Beneficial effects of the present invention:

[0063] The present invention can improve the operating rate and scalability of anomaly detection technology, and is more suitable for solving the anomaly detection problem of the endless emergence of new attack types; the present invention avoids unnecessary losses for advertisers by identifying the increasingly rampant false traffic; the present invention can help enterprises purify global marketing advertising detection data, thereby helping enterprises make correct decisions; the present invention can help enterprises eliminate general invalid traffic and complex invalid traffic in the process of digital marketing, and alleviate the trust crisis of digital advertising. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 It is a flow chart of abnormal traffic intrusion detection of the present invention.

[0065] Figure 2 It is a diagram of the stacked autoencoder structure.

[0066] Figure 3 It is the first DA unit pre-training graph.

[0067] Figure 4 It is the second DA unit pre-training graph. DETAILED DESCRIPTION

[0068] The specific implementation of the present invention is described in detail below with reference to examples and drawings.

[0069] The present invention provides an abnormal traffic intrusion detection method based on a stacked autoencoder and a KNN Gaussian optimization algorithm. The intrusion detection method flow chart of the present invention is as follows: Figure 1 As shown, the following steps are included:

[0070] (1) Training process:

[0071] 1.1) First, the original data is discretized. The original data used is the NSL-KDD dataset, which has the following advantages: it does not contain redundant records, so the classifier will not favor more frequent records. There are no duplicate records in the test set of the NSL-KDD dataset, which makes the detection rate more accurate; the number of selected records from each difficulty level group is inversely proportional to the percentage of records in the original KDD dataset; the classification rates of different machine learning methods vary in a wider range, which makes it more effective to accurately evaluate different learning techniques; the number of records in training and testing is set reasonably, which makes it inexpensive to run experiments on the entire set of experiments without randomly selecting a small part; therefore, the evaluation results of different research works will be consistent and comparable. The discretization method used is a data discretization algorithm based on information entropy, which belongs to a supervised learning algorithm. When using this method to discretize data, the data needs to have corresponding labels. To process the discretized data, first of all, in order to solve the problem of disorder and random distribution of the data to be classified, the discrete features of the collected data are one-hot encoded and digitized. The method is to use an N-bit state register to encode N states. Each state has its own independent register bit, and at any time, only one of them is valid. Normalize the extracted feature subset. The method used is the z-score standardization method. The encoded data should be standardized in order to scale the data so that the feature data falls into a specific numerical space for subsequent calculations. The formula is as follows: Where μ and σ are the mean and standard deviation of the original data x respectively; the processed data is then subjected to dimensionality reduction, and the feature selection method used is a stacked autoencoder. For a single hidden layer autoencoder, one of the many variants of the backpropagation algorithm is usually used for training (the most typical method is the stochastic gradient descent method), which can achieve very effective results. However, if it is still applied to a network with multiple hidden layers, the backpropagation training method will cause some problems: after the first few layers, the error becomes extremely small, and the training becomes invalid. Although more advanced backpropagation methods have alleviated this problem to a certain extent, they still cannot solve the problem of slow learning speed, especially when the amount of training data is limited. This problem is more obvious. As mentioned earlier, if each layer can be pre-trained as a simple self-decoder and then stacked, the training efficiency will be greatly improved. As Figure 2 As shown in Figure 1, each single hidden layer denoising autoencoder unit is first pre-trained unsupervised, then stacked, and finally the overall reverse tuning training is performed to obtain a stacked autoencoder with a two-layer hidden layer structure, as shown in Figure 1. Figure 2The stacked autoencoder structure is shown in Figure 2. The specific steps of constructing the denoising autoencoder with two hidden layers are described in detail below. First, the first DA (Denoise AutoEncoder) unit is pre-trained, as shown in Figure 2. Figure 3 As shown, is the restored input data or feature, X is the original input data or feature not contaminated by noise, y is the input data or feature contaminated by noise, and σ(·) is the sigmoid function:

[0072] The output of the first autoencoder can be represented as follows:

[0073] h(y)=σ(W1y+b1)

[0074] X=W1 T h(y)+b2

[0075] The minimum mean square error is used as the cost function, and the gradient descent method is used to update the weight value W and the bias value b:

[0076]

[0077] (W1,b1,b2)←argmin(J(W1,b1,b2))

[0078] The specific calculation method of the gradient descent method is as follows:

[0079]

[0080]

[0081]

[0082] After pre-training, remove the output layer and its corresponding weights and biases, and only keep W1 and b1 of the input layer and hidden layer. Then use the hidden layer of the first DA unit as the input of the second DA unit and pre-train the second DA unit. Figure 4 As shown:

[0083] The output of the second denoising autoencoder can be represented as follows:

[0084] h(h(y))=σ(W2h(y)+b2)

[0085] h(X)=W2 T h(h(y))+b3

[0086] The minimum mean square error is used as the cost function, and the gradient descent method is used to update the weight value W and the bias value b:

[0087]

[0088] (W2,b2,b3)←argmin(J(W2,b2,b3))

[0089] The specific calculation method of the gradient descent method is as follows:

[0090]

[0091]

[0092]

[0093] Just stack it on the first DA unit. Finally, add an output layer on top of the hidden layer of the second DA unit (randomly initialize the weight value W3 and bias b3 of the output layer) for decoding and recovery. After the pre-training of the two DA units is completed, the last thing to do is the overall reverse tuning training. The cost function of the tuning training can also use the cost function mentioned above, and use the gradient descent method from top to bottom (the reverse error propagation during pre-training has only two layers, while the error back propagation here has three layers) to update the weights and bias values; finally, import the preprocessed data into the classifier for training. The classification method used is the KNN Gaussian optimization algorithm. The weighting function can use an inverse function. The simplest form of this function is to return the inverse of the distance, such as distance d, weight 1 / d. Sometimes, the weights of exactly the same or very close products can be very large or even infinite. For this reason, when taking the inverse of the distance, add a constant to the distance:

[0094] weight = 1 / (distance+const)

[0095] The potential problem with this approach is that it assigns large weights to nearby neighbors, and the weights for more distant neighbors decay quickly. While this is desirable, it can sometimes make the algorithm more sensitive to noisy data.

[0096] The weighting function can also use the Gaussian function. The Gaussian function is more complicated, but it overcomes the shortcomings of the aforementioned function. Its form is:

[0097] where a,b,c∈R

[0098] The shape of the Gaussian function is like an upside-down bell. a is the height of the curve, b is the offset of the center line of the curve on the x-axis, and c is the half-peak width (the width of the function at half the peak).

[0099] The Gaussian function above has a weight of 1 when the distance is 0. As the distance increases, the weight decreases, but it does not become 0. The figure below shows the difference between the Gaussian function and several other functions. When the distance increases to a certain extent, the weight of other functions drops to 0 or below 0.

[0100] The calculation process is as follows:

[0101] Weighted kNN first obtains the sorted distance values ​​and then takes the k elements with the closest distance.

[0102] 1. When processing discrete data, treat these k data differently with weights, and predict the probability that the result is the same as the label of the nth data:

[0103]

[0104] 2. When processing numerical data, we do not simply average these k data, but weighted average: multiply the distance value of each item by the corresponding weight, and then add up the results. After finding the sum, divide it by the sum of all weights.

[0105]

[0106] Di represents the distance between the nearest neighbor i and the value to be predicted x, Wi represents its weight, and f(x) is the numerical result of the prediction. Every time a new sample is predicted to belong to a category, the entire sample is traversed;

[0107] 1.2) Establish the trained model and test the model multiple times to prove that the model has higher accuracy and shorter training time than the traditional KNN model;

[0108] The original data set is: NSL-KDD data set. The discretization method includes: data discretization method based on information entropy. The preprocessing method includes: one-hot encoding and z-score standardization. The feature selection method includes: feature extraction method based on stacked autoencoder. The classifier includes: KNN Gaussian optimization algorithm.

[0109] (2) Detection process:

[0110] 2.1) Input the data to be trained into the model, with binary classification as the output mechanism;

[0111] 2.2) Training model: Through multiple test models, it is proved that the model has higher accuracy and shorter training time than the traditional KNN model;

[0112] The detection results of the entire test sample can be obtained through the anomaly detection classification module. We can compare the results predicted by the intrusion detection classification module with the actual type of the test sample to obtain evaluation indicators of the intrusion detection system such as accuracy, precision, recall rate and F1 value, and adjust the above steps and parameters according to the results.

[0113] The above invention describes an abnormal traffic detection method based on an autoencoder network. However, for those skilled in the art, without departing from the concept of the invention, the autoencoder and KNN Gaussian optimization algorithm can be combined with other classification algorithms, such as Gaussian Bayesian algorithm, decision tree algorithm and BP neural network with voting mechanism to perform intrusion detection on the data set. In addition, for the present invention, several improvements and variations can be made to the method for other application scenarios.

[0114] The above invention describes an abnormal traffic detection method based on an autoencoder network. However, for those skilled in the art, without departing from the concept of the invention, the autoencoder and KNN Gaussian optimization algorithm can be combined with other classification algorithms, such as Gaussian Bayesian algorithm, decision tree algorithm and BP neural network with voting mechanism to perform intrusion detection on the data set. In addition, for the present invention, several improvements and variations can be made to the method for other application scenarios.

Claims

1. An abnormal traffic intrusion detection method based on stacked autoencoder and KNN Gaussian optimization algorithm, It is characterized in that The steps are: 1) Training: 1.1) The NSL-KDD dataset is discretized using a data discretization method based on information entropy; 1.2) One-hot encoding is used to process discrete features and the z-score method is used to normalize the data; 1.3) The stacked autoencoder feature selection method is used to reduce the dimension of the data, specifically: First, each single hidden layer denoising autoencoder unit is pre-trained in an unsupervised manner, then stacked, and finally the overall reverse tuning training is performed to obtain a stacked autoencoder with a two-hidden layer structure; The specific steps of constructing the above two-layer hidden layer structure of denoising autoencoder are: first pre-train the first DA unit, where is the restored input data or feature, X is the original input data or feature not contaminated by noise, y is the input data or feature contaminated by noise, and σ(·) is the sigmoid function: The output of the first autoencoder can be represented as follows: h(y)=σ(W 1 y+b 1 ) X=W 1 T h(y)+b2 The minimum mean square error is used as the cost function, and the gradient descent method is used to update the weight value W and the bias value b: (W 1 ,b 1 ,b 2 )←argmin(J(W 1 ,b 1 ,b 2 )) The specific calculation method of the gradient descent method is as follows: After pre-training, remove the output layer and its corresponding weights and biases, and only keep the input layer and the hidden layer W 1 and b 1 Then use the hidden layer of the first DA unit as the input of the second DA unit to pre-train the second DA unit: The output of the second denoising autoencoder can be represented as follows: h(h(y))=σ(W 2 h(y)+b 2 ) h(X)=W 2 T h(h(y))+b3 The minimum mean square error is used as the cost function, and the gradient descent method is used to update the weight value W and the bias value b: (W 2 ,b 2 ,b 3 )←argmin(J(W 2 ,b 2 ,b 3 )) The specific calculation method of the gradient descent method is as follows: Stack it on the first DA unit, and finally, add an output layer on top of the hidden layer of the second DA unit for decoding recovery; After the pre-training of the two DA units is completed, the last step is the overall reverse tuning training. The cost function of the tuning training adopts the cost function mentioned above, and the weights and bias values ​​are updated from top to bottom using the gradient descent method; 1.4) Import the processed data into the classifier and use the KNN Gaussian optimization algorithm for training, specifically: The weighting function is an inverse function. When taking the inverse of the distance, a constant is added to the distance: weight = 1 / (distance+const) Alternatively, the weighting function is a Gaussian function of the form: where a,b,c∈R The shape of the Gaussian function is like an upside-down bell; a is the height of the curve, b is the offset of the center line of the curve on the x-axis, and c is the half-peak width; The Gaussian function above has a weight of 1 when the distance is 0. As the distance increases, the weight decreases, but it will not become 0. The following is the difference between the Gaussian function and several other functions. When the distance increases to a certain extent, the weight of other functions drops to 0 or below 0. The calculation process is as follows: Weighted KNN first obtains the sorted distance values ​​and then takes the k elements with the closest distance; 1. When processing discrete data, treat these k data differently with weights, and predict the probability that the result is the same as the label of the nth data:

2. When processing numerical data, it is not a simple average of these k data, but a weighted average: multiply the distance value of each item by the corresponding weight, then add up the results, and after finding the total, divide it by the sum of all weights; Di represents the distance between the nearest neighbor i and the value to be predicted x, Wi represents its weight, and f(x) is the numerical result of the prediction; each time a new sample is predicted to belong to a category, the entire sample will be traversed; 1.5) Establish the trained model and test the model multiple times to prove that the model has higher accuracy and shorter training time than the traditional KNN model; 2) Detection: 2.1) Input the data to be trained into the model, and use the binary classification of attack data and normal data as the output mechanism; 2.2) Training model. Through multiple test models, it is proved that the model has higher accuracy and shorter training time than the traditional KNN model.

2. According to claim 1, a method for detecting abnormal traffic intrusion based on stacked autoencoder and KNN Gaussian optimization algorithm, It is characterized in that 1.1) The discretization method is: The data discretization algorithm based on information entropy is a supervised learning algorithm. When using this method to discretize data, the data needs to have corresponding labels.

3. According to claim 1, a method for detecting abnormal traffic intrusion based on stacked autoencoder and KNN Gaussian optimization algorithm, It is characterized in that 1.2) The preprocessing method is: First, the discrete features of the collected data are digitized by one-hot encoding. The method is to use an N-bit state register to encode N states. Each state has its own independent register bit, and at any time, only one of them is valid. Secondly, the encoded data should be standardized and the data ratio should be scaled so that the feature data falls into a specific numerical space for subsequent calculations. The z-score standardization is used, and the formula is as follows: Where μ is the mean of the original data x, and σ is the standard deviation of the original data x.