A network intrusion detection method based on self-attention residual generative adversarial network

By using self-attention residual generative adversarial networks and temporal attention detection models, high-quality pseudo-data is generated, which solves the problems of data imbalance and temporal dependence in network intrusion detection and improves detection performance and accuracy.

CN120825317BActive Publication Date: 2026-11-24ZHENGZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510989487.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-17
Publication Date
2026-11-24
Estimated Expiration
2045-07-17

AI Technical Summary

Technical Problem

Existing network intrusion detection methods suffer from performance degradation when dealing with complex network traffic, especially under imbalanced data conditions and with a scarcity of minority attack samples. Furthermore, existing GAN models fail to effectively handle mixed-type features and temporal dependencies, resulting in low-quality generated data.

Method used

High-quality pseudo data is generated using a self-attention residual generative adversarial network (FARD-WGAN-GP). Combined with a temporal attention detection model, discrete and continuous features are processed through self-attention mechanism and residual blocks. A bidirectional LSTM module is constructed to capture temporal dependencies, and the model is optimized using real-time detection results.

Benefits of technology

It improves the quality of generated data, accurately captures complex temporal dependencies in network traffic, enhances detection accuracy and has dynamic adaptability, solves the data imbalance problem, and enhances the detection capability for minority class samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120825317B_ABST
    Figure CN120825317B_ABST
Patent Text Reader

Abstract

This application discloses a network intrusion detection method based on self-attention residual generative adversarial networks (GANs), belonging to the field of network intrusion detection technology. The method involves collecting network traffic data and preprocessing it to obtain real training data; constructing and training a FARD-WGAN-GP model, and generating hybrid pseudo-data based on the trained FARD-WGAN-GP model; constructing a temporal attention detection model; training the temporal attention detection model based on the real training data and pseudo-data; performing real-time network intrusion detection based on the trained temporal attention detection model; optimizing the FARD-WGAN-GP model based on the real-time detection results, and further optimizing the temporal attention detection model based on the optimized FARD-WGAN-GP model; and finally performing network intrusion detection based on the optimized temporal attention detection model. This method improves the quality of the generated data and enhances the accuracy of detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network intrusion detection technology, and in particular to a network intrusion detection method based on self-attention residual generative adversarial networks. Background Technology

[0002] Network intrusion detection is a key technology in the field of cybersecurity, aiming to identify anomalous network behavior to protect systems from attacks. Traditional methods, such as rule-based detection and machine learning models (e.g., support vector machines, random forests), face challenges when handling complex network traffic, especially in cases of imbalanced data, such as the NSL-KDD dataset where minority class attacks (e.g., U2R) have few samples, leading to degraded detection performance.

[0003] Generative Adversarial Networks (GANs) have been used in recent years to generate synthetic data to enhance training sets. However, existing GAN models (such as standard GANs or Wasserstein GANs) are generally not optimized for the mixed-type features of cybersecurity data (discrete features such as protocol type, continuous features such as traffic volume) and lack handling of temporal dependencies. Furthermore, existing methods often produce low-quality minority class samples, making it difficult to effectively improve detection performance. For example, existing techniques use standard GANs to generate network traffic but do not consider the differences between discrete and continuous features, nor do they incorporate temporal modeling, resulting in limited quality of the generated data.

[0004] Therefore, there is an urgent need for a network intrusion detection method that can handle mixed-type data, generate high-quality minority class samples, and combine temporal features to improve detection performance and address the problem of data imbalance. Summary of the Invention

[0005] To address the aforementioned shortcomings in existing technologies, this application provides a network intrusion detection method based on self-attention residual generative adversarial networks, which solves the problems of lack of mixed-type data, lack of temporal features, data imbalance, and low detection performance in existing technologies.

[0006] To achieve the aforementioned objectives, the technical solution adopted in this application is as follows: This application provides a network intrusion detection method based on self-attention residual generative adversarial networks, including: S1: Collect network traffic data and preprocess the network traffic data to obtain real training data; S2: Construct and train the FARD-WGAN-GP model, and generate hybrid pseudo-data based on the trained FARD-WGAN-GP model; S3: Construct a temporal attention detection model; S4: Train a temporal attention detection model based on real training data and mixed pseudo-data; S5: Real-time network intrusion detection based on a trained temporal attention detection model; S6: Based on real-time detection results, optimize the FARD-WGAN-GP model, and based on the optimized FARD-WGAN-GP model, optimize the temporal attention detection model; S7: Network intrusion detection based on the optimized temporal attention detection model.

[0007] Further, S1 includes: S101: Use network mirroring technology to collect network traffic data from the core switch and store the network traffic data in pcap format to obtain a pcap file; S102: Use Bro-IDS technology to parse the pcap file, extract basic features from the parsed pcap file, and generate real training data based on the extracted basic features; S103: Perform sample balancing on the real training data.

[0008] Furthermore, the FARD-WGAN-GP model includes a generator and a discriminator; The generator takes random noise as input, extracts features through a three-layer shared feature extraction layer, and enhances the feature representation through residual blocks and a self-attention mechanism. Based on the enhanced features, it uses a dual-branch output to generate hybrid pseudo-data containing discrete and continuous features. The residual blocks adopt a bilinear layer and ReLU structure, and the self-attention mechanism combines the QKV mechanism with the residual block connection to model long-distance dependencies. The discriminator determines the difference between the hybrid pseudo data generated by the generator and the real training data, and outputs a true / false score; The generator optimizes the loss function based on the discriminator's true / false scores.

[0009] Furthermore, the dual-branch output includes a Softmax discrete branch and a Tanh continuous branch.

[0010] Furthermore, the loss function is:

[0011] in, As expected, For the discriminator to score the mixed pseudo-data, For the discriminator's scoring of the real training data, For the generated hybrid pseudo-data, For real training data, It is a random noise vector.

[0012] Furthermore, the training of the FARD-WGAN-GP model includes: A1: Initialize training parameters, including generator learning rate, discriminator learning rate, training size, and number of training epochs; A2: Based on the Adam optimizer and the initialized training parameters, the discriminator is trained using real training data and mixed pseudo-data, and the discriminator loss is calculated. The discriminator parameters are updated by backpropagation based on the discriminator loss. A3: Based on the Adam optimizer and the initialized training parameters, a generator is trained using hybrid pseudo-data generated by a generator optimized according to the true / false scores of the discriminator after training. The generator loss is calculated, and the generator parameters are updated by backpropagation based on the generator loss.

[0013] Furthermore, the temporal attention detection model in S3 adopts a bidirectional LSTM module, a temporal attention module, and a fully connected classifier structure; The bidirectional LSTM module obtains the temporal dependencies of network traffic, obtains temporal features, and forms a temporal feature matrix; the temporal attention module obtains the attention weights of the temporal dependencies between temporal features, and aggregates the temporal features based on the attention weights; the fully connected classifier obtains the aggregated temporal features.

[0014] Further, S4 includes: S401: Combine real training data and mixed pseudo-data to construct a hybrid dataset; S402: Merge the real labels corresponding to the real training data and the labels corresponding to the mixed pseudo data to construct a mixed label set; S403: Based on the mixed label set, the cross-entropy loss function is used to guide the fully connected layer classifier of the temporal attention detection model to learn the decision boundary between normal traffic and attack traffic; S404: Input the mixed dataset into the temporal attention detection model, perform temporal feature modeling through the bidirectional LSTM module, and after feature aggregation by the temporal attention module, feed the aggregated temporal features into the learned fully connected classifier for network intrusion identification.

[0015] Further, S5 includes: S501: Deploy the trained temporal attention detection model on edge computing nodes and detect real-time network traffic through a stream processing framework; S502: Record the detection results. When the intrusion probability in the detection results exceeds the set threshold, trigger an alarm and record the attack feature samples of the intrusion.

[0016] Further, S6 includes: S601: Collect new attack feature samples and generate new hybrid pseudo-data based on the FARD-WGAN-GP model; S602: Train the temporal attention detection model based on the new hybrid pseudo-data and update the feature library of the temporal attention detection model.

[0017] The beneficial effects of this application are: This application provides a network intrusion detection method based on self-attention residual generative adversarial networks (GANs). It generates high-quality, diverse pseudo-attack data using the FARD-WGAN-GP model, effectively addressing the problems of data scarcity and imbalance, thus improving the quality of the generated data. Furthermore, it utilizes a temporal attention detection model to accurately capture complex long-distance temporal dependencies in network traffic, focusing on key information. In addition, real-time detection results are fed back to continuously improve the FARD-WGAN-GP model and the temporal attention detection model, making the entire detection process dynamically adaptive and improving detection accuracy. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0019] Figure 1 This is a schematic flowchart of a network intrusion detection method based on a self-attention residual generative adversarial network provided in an embodiment of this application. Detailed Implementation

[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.

[0021] This application provides a network intrusion detection method based on a self-attention residual generative adversarial network. This method can be found in [reference needed]. Figure 1 , Figure 1 The diagram shown is a flowchart of a network intrusion detection method based on a self-attention residual generative adversarial network provided in an embodiment of this application, including: S1: Collect network traffic data and preprocess the network traffic data to obtain real training data.

[0022] Further, S1 includes: S101: Use network mirroring technology to collect network traffic data from the core switch and store the network traffic data in pcap format to obtain a pcap file; S102: Use Bro-IDS technology to parse the pcap file, extract basic features from the parsed pcap file, and generate real training data based on the extracted basic features; S103: Perform sample balancing on the real training data.

[0023] In one embodiment of this application, multi-source traffic can be collected by using network mirroring technology to collect full traffic data from the core switch. The tcpdump tool is used to capture data packets at 5-minute intervals and store them in pcap format. The collection scope covers critical nodes such as server zones and perimeter firewalls, ensuring the inclusion of complete TCP / UDP protocol session data.

[0024] Bro-IDS was used to parse the pcap file and extract 41 basic features (such as categorical features like protocol_type, service, and flag, and continuous features like duration and bytes) to generate a structured dataset. One-Hot encoding (ohe) was used for categorical features, and continuous features were normalized to [0,1] using MinMaxScaler. Finally, real training data with feature matrix X and labels Y (1 for U2R, 0 for normal) was generated.

[0025] Sample balancing: For high-risk, extremely imbalanced malicious traffic, such as U2R (user-to-root) sample ratios of less than 0.1%, firstly, through... After screening the target categories, FARD-WGAN-GP was used to generate pseudo-samples, resulting in 5000 high-risk, highly imbalanced samples. This represents the dataset after sample extraction. Indicates a sample, Represents the original dataset. Indicates sample The tag, and To extract the target labels for the samples from the original dataset, This is normal traffic. Attack the target.

[0026] S2: Build and train the FARD-WGAN-GP model, and generate hybrid pseudo-data based on the trained FARD-WGAN-GP model.

[0027] In one embodiment of this application, the generator FARD-WGAN-GPGenerator and the discriminator FARD-WGAN-GPDiscriminator are the core components of FARD-WGAN-GP. The generator takes 100-dimensional noise input and extracts features through a three-layer shared mapping (1024→512→256). It enhances feature representation by combining residual blocks (res_block1, res_block2) and a self-attention mechanism. Finally, it outputs hybrid pseudo-data containing 3-dimensional discrete features (protocol type, etc.) and continuous features (traffic byte count, etc.) through a two-branch structure. The residual blocks adopt a bilinear layer and ReLU structure, and the self-attention mechanism combines the QKV mechanism with the residual block connections to model long-distance dependencies, solving the problem of minority class feature generation. The discriminator takes real data and generated pseudo-data as input, processes discrete and continuous features through a two-branch structure, and outputs a true / false score. Each time the generator produces pseudo-data, the discriminator judges it. The discriminator evaluates the difference based on WGAN-GP loss and gradient penalty, so the generator improves by optimizing the loss function, trying to make the pseudo-data closer to the real data distribution. The discriminator and generator enhance each other in the adversarial process. The discriminator improves its discrimination ability, forcing the generator to generate more realistic data. Both sides iterate and optimize, ultimately improving the quality and detection performance of the U2R samples generated by FARD-WGAN-GP.

[0028] The dual-branch output includes a Softmax discrete branch and a Tanh continuous branch, which fundamentally avoids feature type confusion.

[0029] The loss function is:

[0030] in, As expected, For the discriminator to score the mixed pseudo-data, For the discriminator's scoring of the real training data, For the generated hybrid pseudo-data, For real training data, It is a random noise vector.

[0031] Furthermore, the training of the FARD-WGAN-GP model includes: A1: Initialize training parameters, including generator learning rate 0.0004, discriminator learning rate 0.0001, training size 128, and number of training epochs 100; A2: Based on the Adam optimizer and the initialized training parameters, the discriminator is trained using real training data and mixed pseudo-data, and the discriminator loss is calculated. The discriminator parameters are updated by backpropagation based on the discriminator loss. A3: Based on the Adam optimizer and the initialized training parameters, a generator is trained using hybrid pseudo-data generated by a generator optimized according to the true / false scores of the discriminator after training. The generator loss is calculated, and the generator parameters are updated by backpropagation based on the generator loss.

[0032] In one embodiment of this application, the FARD-WGAN-GP model achieves a G-mean of 0.4349, significantly improving performance by 25.6% compared to direct classification, 25.6% compared to SMOTE, and 58.8% compared to WGAN-GP. Specifically, by modeling the relationships between samples within a batch, this mechanism captures global feature patterns from rare U2R (user-to-root) attacks. This enhances the generator's ability to learn contextual dependencies, improves the quality of generated samples, and strengthens minority class detection. This performance leap effectively balances the detection capabilities of positive and negative classes, addressing the challenges of imbalanced datasets. Furthermore, residual blocks alleviate gradient vanishing, ensuring stable training. The dual-branch structure handles discrete and continuous features separately, simplifying computation and accelerating inference while maintaining sample diversity. Compared to models like CTGAN, which are specifically designed for generating tabular data, the optimized architecture reduces computational overhead and achieves fast inference while improving accuracy. Furthermore, for U2R classes, the model captures global patterns of rare U2R attacks, enabling the generator to generate realistic samples and improving the detection sensitivity and recall of low-frequency events. Independent branches for different feature types (e.g., discrete and continuous) enhance the discriminator's ability to distinguish subtle U2R attack patterns.

[0033] S3: Construct a temporal attention detection model.

[0034] In one embodiment of this application, the temporal attention detection model employs a bidirectional LSTM module, a temporal attention module, and a fully connected classifier structure. The bidirectional LSTM module acquires the temporal features of network traffic to form a temporal feature matrix. The temporal attention module captures the temporal dependencies between the temporal feature matrices, taking the temporal expansion of the feature matrix X as input and aggregating the temporal features based on the temporal dependencies. The fully connected classifier obtains the aggregated temporal features and performs binary classification through three fully connected layers (200→1024→512→2). The activation function is ReLU, and the output layer uses Softmax to generate attack probabilities. The specific detection process involves processing the input network traffic time-series data using a bidirectional LSTM module. This module captures temporal dependencies in both forward and backward directions, generating a feature matrix rich in temporal information. A temporal attention module then processes the feature matrix, calculating the importance score for each time step using a fully connected layer and a Tanh activation function. Softmax normalization is then applied to obtain attention weights representing temporal dependencies. Finally, these weights are used to weighted aggregate the temporal features, forming a comprehensive context vector. The aggregated feature vector is then input into a fully connected classifier, which progressively extracts high-level features through a multi-layer neural network and outputs the final classification prediction result, thus completing the network traffic detection task.

[0035] S4: Train the temporal attention detection model based on real training data and pseudo data.

[0036] Further, S4 includes: S401: Vertically concatenate the real training data and the mixed pseudo-data to form a mixed dataset Xc; S402: Merge the real labels corresponding to the real training data and the labels corresponding to the hybrid pseudo data to construct a hybrid label set Yc. The real training data retains the original labels (normal traffic is marked as 0, and U2R attack is marked as 1), while all the labels corresponding to the hybrid pseudo data created by the generator are uniformly marked as attack class 1. S403: The mixed label set is used as a supervision signal to help the detection network complete training and classification. The cross-entropy loss function is used to guide the fully connected layer classifier of the temporal attention detection model to learn the decision boundary between normal traffic and attack traffic. S404: The mixed dataset is input into the temporal attention detection model, and the temporal features are modeled by the bidirectional LSTM module. After the features are aggregated by the temporal attention module, the aggregated temporal features are fed into the learned fully connected classifier for network intrusion identification, and finally the accurate identification of network intrusion is achieved.

[0037] In one embodiment of this application, based on a mixed dataset and a mixed label set, a cross-entropy loss function is used, along with an Adam optimizer (learning rate 0.001), and training is performed for 20 epochs. An early stopping strategy is employed in each epoch to avoid overfitting. The cross-entropy loss function can be expressed as follows:

[0038] In the formula, For batch size, For the first The true labels of each sample (0 represents normal, 1 represents U2R attack). For the model to predict the first Each sample represents the score of the normal class. For the model to predict the first Each sample represents the score for the attack class.

[0039] S5: Real-time network intrusion detection based on a trained temporal attention detection model.

[0040] In one embodiment of this application, the trained temporal attention detection model is deployed on an edge computing node. Real-time traffic is preprocessed using a stream processing framework (such as Flink) according to the transform_test process, with a single-sample inference time of ≤0.0006ms (based on an RTX 4060 GPU). Detection results are recorded, and when the intrusion probability in the detection results is ≥ a threshold, an alarm is triggered and attack feature samples (such as high-frequency root command calls and abnormal port connection sequences) are recorded.

[0041] S6: Based on real-time detection results, optimize the FARD-WGAN-GP model, and based on the optimized FARD-WGAN-GP model, optimize the temporal attention detection model.

[0042] In one embodiment of this application, new attack samples are collected periodically (weekly), new pseudo data is incrementally generated through the FARD-WGAN-GP model, a temporal attention detection model is trained based on the new pseudo data, and the feature library of the temporal attention detection model is updated (such as adding traffic features of ransomware variants).

[0043] S7: Network intrusion detection based on the optimized temporal attention detection model.

[0044] This application provides a network intrusion detection method based on self-attention residual generative adversarial networks (GANs). It generates high-quality, diverse pseudo-attack data using the FARD-WGAN-GP model, effectively addressing the problems of data scarcity and imbalance, thus improving the quality of the generated data. Furthermore, it utilizes a temporal attention detection model to accurately capture complex long-distance temporal dependencies in network traffic, focusing on key information. In addition, real-time detection results are fed back to continuously improve the FARD-WGAN-GP model and the temporal attention detection model, making the entire detection process dynamically adaptive and improving detection accuracy.

[0045] It should be noted that those skilled in the art will recognize that the embodiments described herein are for the purpose of helping readers understand the principles of this application, and should be understood as not limiting the scope of protection of this application to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this application without departing from the essence of this application, and these modifications and combinations are still within the scope of protection of this application.

Claims

1. A network intrusion detection method based on self-attention residual generative adversarial networks, characterized in that, include: S1: Collect network traffic data and preprocess the network traffic data to obtain real training data; S2: Construct and train the FARD-WGAN-GP model, and generate hybrid pseudo-data based on the trained FARD-WGAN-GP model; S3: Construct a temporal attention detection model; S4: Train a temporal attention detection model based on real training data and mixed pseudo-data; S5: Real-time network intrusion detection based on a trained temporal attention detection model; S6: Based on real-time detection results, optimize the FARD-WGAN-GP model, and based on the optimized FARD-WGAN-GP model, optimize the temporal attention detection model; S7: Network intrusion detection based on the optimized temporal attention detection model; The FARD-WGAN-GP model includes a generator and a discriminator; The generator takes random noise as input, extracts features through a three-layer shared feature extraction layer, and enhances the feature representation through residual blocks and a self-attention mechanism. Based on the enhanced features, it uses a dual-branch output to generate hybrid pseudo-data containing discrete and continuous features. The residual blocks adopt a bilinear layer and ReLU structure, and the self-attention mechanism combines the QKV mechanism with the residual block connection to model long-distance dependencies. The discriminator determines the difference between the hybrid pseudo data generated by the generator and the real training data, and outputs a true / false score; The generator optimizes the loss function based on the discriminator's true / false score; The temporal attention detection model in S3 adopts a structure of bidirectional LSTM module, temporal attention module and fully connected classifier; The bidirectional LSTM module obtains the temporal dependencies of network traffic, obtains temporal features, and forms a temporal feature matrix; the temporal attention module obtains the attention weights of the temporal dependencies between temporal features, and aggregates the temporal features based on the attention weights; the fully connected classifier obtains the aggregated temporal features.

2. The network intrusion detection method based on self-attention residual generative adversarial networks according to claim 1, characterized in that, S1 includes: S101: Use network mirroring technology to collect network traffic data from the core switch and store the network traffic data in pcap format to obtain a pcap file; S102: Use Bro-IDS technology to parse the pcap file, extract basic features from the parsed pcap file, and generate real training data based on the extracted basic features; S103: Perform sample balancing on the real training data.

3. The network intrusion detection method based on self-attention residual generative adversarial networks according to claim 1, characterized in that, The dual-branch output includes a Softmax discrete branch and a Tanh continuous branch.

4. The network intrusion detection method based on self-attention residual generative adversarial networks according to claim 3, characterized in that, The loss function is: in, As expected, For the discriminator to score the mixed pseudo-data, For the discriminator's scoring of the real training data, For the generated hybrid pseudo-data, For real training data, It is a random noise vector.

5. The network intrusion detection method based on self-attention residual generative adversarial networks according to claim 4, characterized in that, The training of the FARD-WGAN-GP model includes: A1: Initialize training parameters, including generator learning rate, discriminator learning rate, training size, and number of training epochs; A2: Based on the Adam optimizer and the initialized training parameters, the discriminator is trained using real training data and mixed pseudo-data, and the discriminator loss is calculated. The discriminator parameters are updated by backpropagation based on the discriminator loss. A3: Based on the Adam optimizer and the initialized training parameters, a generator is trained using hybrid pseudo-data generated by a generator optimized according to the true / false scores of the discriminator after training. The generator loss is calculated, and the generator parameters are updated by backpropagation based on the generator loss.

6. The network intrusion detection method based on self-attention residual generative adversarial networks according to claim 1, characterized in that, S4 includes: S401: Combine real training data and mixed pseudo-data to construct a hybrid dataset; S402: Merge the real labels corresponding to the real training data and the labels corresponding to the mixed pseudo data to construct a mixed label set; S403: Based on the mixed label set, the cross-entropy loss function is used to guide the fully connected layer classifier of the temporal attention detection model to learn the decision boundary between normal traffic and attack traffic; S404: Input the mixed dataset into the temporal attention detection model, perform temporal feature modeling through the bidirectional LSTM module, and after feature aggregation by the temporal attention module, feed the aggregated temporal features into the learned fully connected classifier for network intrusion identification.

7. The network intrusion detection method based on self-attention residual generative adversarial networks according to claim 1, characterized in that, S5 includes: S501: Deploy the trained temporal attention detection model on edge computing nodes and detect real-time network traffic through a stream processing framework; S502: Record the detection results. When the intrusion probability in the detection results exceeds the set threshold, trigger an alarm and record the attack feature samples of the intrusion.

8. The network intrusion detection method based on self-attention residual generative adversarial networks according to claim 7, characterized in that, S6 includes: S601: Collect new attack feature samples and generate new hybrid pseudo-data based on the FARD-WGAN-GP model; S602: Train the temporal attention detection model based on the new hybrid pseudo-data and update the feature library of the temporal attention detection model.

Citation Information

Patent Citations

  • Semi-supervised malicious traffic detection method based on improved WGAN-GP

    CN115314254A

  • Network intrusion detection method based on GAN-CNN-BiLSTM

    CN116582309A