Diffusion–Attention Traffic Generation: Traffic Generation Based on the Fusion of a Diffusion Model and a Self-Attention Mechanism
Abstract
:1. Introduction
- Traffic Generation Based on a Diffusion Model: This study employs a diffusion model for traffic generation, ensuring both the stability of the generation process and the diversity of the generated data through a stepwise generation approach. This approach provides an effective solution for the traffic generation task.
- Integration of a Diffusion Model and a Self-Attention Mechanism: By integrating the self-attention mechanism with the diffusion model, the DATG introduces global dependency modeling at each step of the generation process, effectively capturing the complex temporal characteristics of traffic sequences and further enhancing the quality of the generated traffic.
- Improvement in Traffic Quality and Diversity: Experimental validation confirms that the framework combining the diffusion model and self-attention mechanism demonstrates significant advantages over traditional methods in terms of dynamic variation, temporal consistency, and data diversity.
2. Related Work
2.1. Traffic Generation Based on GAN
2.2. Emergence of Diffusion Model
3. Prerequisite Knowledge
3.1. Diffusion Model
3.2. Self-Attention Mechanism
3.3. Evaluation Metrics
3.3.1. JSD
3.3.2. CRPS
4. Proposed Method
4.1. Overall Architecture
4.2. Diffusion Model and Self-Attention Fusion Mechanism
4.2.1. Data Preprocessing
4.2.2. Diffusion Model Initialization
4.2.3. Diffusion Processes Combined with a Self-Attention Mechanism
- Step 1.
- The diffusion model denoising process is conducted as follows:
- Step 2.
- The self-attention mechanism is introduced to calculate the attention weights as follows:
- Step 3.
- Data weighted summation and global dependency fusion are performed as follows:
- Step 4.
- The iterative optimization and generation process is as follows:
Algorithm 1: DATG Generation Process |
Input: Initial noise data, , total diffusion steps, , denoising network, , self-attention parameters, Output: Generated traffic data, 1: Initialization: Generate noise data, ∼, from a Gaussian distribution 2: for down to 1 as follows: 3: a. Denoising step: 4: Predict mean and covariance via the denoising network as follows: 5: 6: Sample the denoised result as follows: 7: ∼ 8: b. Self-attention mechanism: 9: Compute the query, key, and value matrices as follows: 10: 11: Compute the attention matrix as follows: 12: 13: Layer normalization and residual connection: 14: 15: c. Update input: 16: 17: return |
Algorithm 2: DATG Training Process |
Input: Real traffic data, , total diffusion steps, , denoising network, , self-attention parameters, , , , noise schedule, Output: Trained model parameters , , , 1: Initialization: Initialize , , , and with Xavier; set the noise schedule, 2: for each training batch, do: 3: a. Forward Diffusion: 4: Sample from real data 5: Randomly select 6: Compute 7: Add noise: 8: b. Reverse Denoising with Self-Attention: 9: Predict noise: 10: Compute self-attention matrices: 11: , , 12: Compute attention: 13: 14: Fuse features: 15: c. Loss Calculation: 16: Compute MSE loss: 17: d. Parameter Update: 18: Update , , , via Adam 19: end for |
5. Experiment
5.1. Dataset
5.2. Experimental Environment and Parameter Settings
5.3. Experimental Result
6. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Goodfellow, I.; Pouget-Abadie, J.; Mirza, M.; Xu, B.; Warde-Farley, D.; Ozair, S.; Courville, A.; Bengio, Y. Generative Adversarial Networks. Commun. ACM 2020, 63, 139–144. [Google Scholar] [CrossRef]
- Kingma, D.P.; Welling, M. Auto-Encoding Variational Bayes. arXiv 2013, arXiv:1312.6114. [Google Scholar]
- Ho, J.; Jain, A.; Abbeel, P. Denoising Diffusion Probabilistic Models. Adv. Neural Inf. Process. Syst. 2020, 33, 6840–6851. [Google Scholar]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention Is All You Need. arXiv 2017, arXiv:1706.03762. [Google Scholar]
- Xiao, C.; Li, B.; Zhu, J.-Y.; He, W.; Liu, M.; Song, D. Generating Adversarial Examples with Adversarial Networks. arXiv 2019, arXiv:1801.02610. [Google Scholar]
- Dong, Y.; Liao, F.; Pang, T.; Su, H.; Zhu, J.; Hu, X.; Li, J. Boosting Adversarial Attacks with Momentum. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018; pp. 9185–9193. [Google Scholar]
- Nichol, A.; Achiam, J.; Schulman, J. On First-Order Meta-Learning Algorithms. arXiv 2018, arXiv:1803.02999. [Google Scholar]
- Ring, M.; Schlör, D.; Landes, D.; Hotho, A. Flow-Based Network Traffic Generation Using Generative Adversarial Networks. Comput. Secur. 2019, 82, 156–172. [Google Scholar] [CrossRef]
- Wu, D.; Fang, B.; Wang, J.; Liu, Q.; Cui, X. Evading Machine Learning Botnet Detection Models via Deep Reinforcement Learning. In Proceedings of the ICC 2019–2019 IEEE International Conference on Communications (ICC), Shanghai, China, 20–24 May 2019; pp. 1–6. [Google Scholar]
- Dowoo, B.; Jung, Y.; Choi, C. PcapGAN: Packet Capture File Generator by Style-Based Generative Adversarial Networks. In Proceedings of the 2019 18th IEEE International Conference On Machine Learning And Applications (ICMLA), Boca Raton, FL, USA, 16–19 December 2019; pp. 1149–1154. [Google Scholar]
- Fathi-Kazerooni, S.; Rojas-Cessa, R. GAN Tunnel: Network Traffic Steganography by Using GANs to Counter Internet Traffic Classifiers. IEEE Access 2020, 8, 125345–125359. [Google Scholar] [CrossRef]
- Du, L.; He, J.; Li, T.; Wang, Y.; Lan, X.; Huang, Y. DBWE-Corbat: Background Network Traffic Generation Using Dynamic Word Embedding and Contrastive Learning for Cyber Range. Comput. Secur. 2023, 129, 103202. [Google Scholar] [CrossRef]
- Li, H.; Yang, Y.; Chang, M.; Chen, S.; Feng, H.; Xu, Z.; Li, Q.; Chen, Y. Srdiff: Single Image Super-Resolution with Diffusion Probabilistic Models. Neurocomputing 2022, 479, 47–59. [Google Scholar] [CrossRef]
- Sasaki, H.; Willcocks, C.G.; Breckon, T.P. UNIT-DDPM: UNpaired Image Translation with Denoising Diffusion Probabilistic Models. arXiv 2021, arXiv:2104.05358. [Google Scholar]
- Wang, W.; Bao, J.; Zhou, W.; Chen, D.; Chen, D.; Yuan, L.; Li, H. Semantic Image Synthesis via Diffusion Models. arXiv 2022, arXiv:2207.00050. [Google Scholar]
- Li, X.; Thickstun, J.; Gulrajani, I.; Liang, P.S.; Hashimoto, T.B. Diffusion-Lm Improves Controllable Text Generation. Adv. Neural Inf. Process. Syst. 2022, 35, 4328–4343. [Google Scholar]
- Gong, S.; Li, M.; Feng, J.; Wu, Z.; Kong, L. DiffuSeq: Sequence to Sequence Text Generation with Diffusion Models. arXiv 2023, arXiv:2210.08933. [Google Scholar]
- Tashiro, Y.; Song, J.; Song, Y.; Ermon, S. Csdi: Conditional Score-Based Diffusion Models for Probabilistic Time Series Imputation. Adv. Neural Inf. Process. Syst. 2021, 34, 24804–24816. [Google Scholar]
- LeCun, Y.; Bottou, L.; Bengio, Y.; Haffner, P. Gradient-Based Learning Applied to Document Recognition. Proc. IEEE 1998, 86, 2278–2324. [Google Scholar] [CrossRef]
- Hochreiter, S.; Schmidhuber, J. Long Short-Term Memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef]
- Wu, H.; Xiao, B.; Codella, N.; Liu, M.; Dai, X.; Yuan, L.; Zhang, L. Cvt: Introducing Convolutions to Vision Transformers. In Proceedings of the 2021 IEEE/CVF International Conference on Computer Vision, Montreal, QC, Canada, 10–17 October 2021; pp. 22–31. [Google Scholar]
- Chu, X.; Tian, Z.; Zhang, B.; Wang, X.; Shen, C. Conditional Positional Encodings for Vision Transformers. arXiv 2023, arXiv:2102.10882. [Google Scholar]
- Dong, X.; Bao, J.; Chen, D.; Zhang, W.; Yu, N.; Yuan, L.; Chen, D.; Guo, B. Cswin Transformer: A General Vision Transformer Backbone with Cross-Shaped Windows. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, New Orleans, LA, USA, 18–24 June 2022; pp. 12124–12134. [Google Scholar]
- Dai, Z.; Liu, H.; Le, Q.V.; Tan, M. Coatnet: Marrying Convolution and Attention for All Data Sizes. Adv. Neural Inf. Process. Syst. 2021, 34, 3965–3977. [Google Scholar]
- Howard, A.G.; Zhu, M.; Chen, B.; Kalenichenko, D.; Wang, W.; Weyand, T.; Andreetto, M.; Adam, H. MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications. arXiv 2017, arXiv:1704.04861. [Google Scholar]
- Elman, J.L. Finding Structure in Time. Cogn. Sci. 1990, 14, 179–211. [Google Scholar] [CrossRef]
- Gil, G.D.; Lashkari, A.H.; Mamun, M.; Ghorbani, A.A. Characterization of Encrypted and VPN Traffic Using Time-Related Features. In Proceedings of the 2nd International Conference on Information Systems Security and Privacy (ICISSP 2016), Rome, Italy, 19–21 February 2016; SciTePress: Setúbal, Portugal, 2016; pp. 407–414. [Google Scholar]
- Moustafa, N.; Slay, J. UNSW-NB15: A Comprehensive Data Set for Network Intrusion Detection Systems (UNSW-NB15 Network Data Set). In Proceedings of the 2015 Military Communications and Information Systems Conference (MilCIS), Canberra, Australia, 10–12 November 2015; pp. 1–6. [Google Scholar]
Parameter | DATG | DM | GAN |
---|---|---|---|
Diffusion Steps | 1000 | 1000 | — |
Model Layers | 4 | 4 | 4 |
Neurons per Layers | 64 | 64 | 64 |
Noise Scheduling | — |
Model | JSD (IV) | JSD (UN) | CRPS (IV) | CRPS (UN) |
---|---|---|---|---|
GAN | 0.31 | 0.38 | 0.19 | 0.24 |
DM | 0.24 | 0.29 | 0.17 | 0.21 |
DATG | 0.18 | 0.22 | 0.13 | 0.16 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Wang, Z.; Guan, Z.; Liu, X.; Qiao, M.; Sun, X.; Li, J. Diffusion–Attention Traffic Generation: Traffic Generation Based on the Fusion of a Diffusion Model and a Self-Attention Mechanism. Electronics 2025, 14, 1977. https://doi.org/10.3390/electronics14101977
Wang Z, Guan Z, Liu X, Qiao M, Sun X, Li J. Diffusion–Attention Traffic Generation: Traffic Generation Based on the Fusion of a Diffusion Model and a Self-Attention Mechanism. Electronics. 2025; 14(10):1977. https://doi.org/10.3390/electronics14101977
Chicago/Turabian StyleWang, Ziyi, Zhenyu Guan, Xu Liu, Mengyan Qiao, Xuan Sun, and Jun Li. 2025. "Diffusion–Attention Traffic Generation: Traffic Generation Based on the Fusion of a Diffusion Model and a Self-Attention Mechanism" Electronics 14, no. 10: 1977. https://doi.org/10.3390/electronics14101977
APA StyleWang, Z., Guan, Z., Liu, X., Qiao, M., Sun, X., & Li, J. (2025). Diffusion–Attention Traffic Generation: Traffic Generation Based on the Fusion of a Diffusion Model and a Self-Attention Mechanism. Electronics, 14(10), 1977. https://doi.org/10.3390/electronics14101977