A Lightweight Network for Encrypted Traffic Classification Based on Convolutional Positional Encoding and Efficient Multi-Scale Attention
Abstract
1. Introduction
- The EMA mechanism is successfully migrated to traffic classification through the design of an Efficient Multi-scale Attention Adapter (EMAAdapter). By reconstructing 1D traffic sequences into a pseudo-2D spatial representation, the adapter captures multi-scale dependencies across both horizontal and vertical dimensions, thereby significantly enhancing feature extraction efficiency.
- A novel Convolutional Positional Encoding and Efficient Multi-scale Attention Block (CEMA Block) is designed, featuring a sandwich structure with depthwise positional encodings (CPE) at both entry and exit stages. This configuration injects local spatial inductive bias into the Transformer-like architecture, effectively compensating for the inherent limitations of pure attention in modeling fine-grained, short-term packet dependencies.
- By leveraging directional pooling and cross-dimension feature reweighting, the proposed method achieves representational capacity comparable to deep 2D CNNs (e.g., ResNet-101) while incurring only a fraction of the computational cost, making it perfectly tailored for real-time deployment within environments with resource constraints.
2. Related Work
2.1. Traditional Methodologies for Network Traffic Classification
2.2. Machine Learning Methodologies for Network Traffic Classification
2.3. Deep Learning Methodologies for Network Traffic Classification
2.4. Summary and Motivation
3. CEMA-Net Traffic Classification Model
3.1. Model Architecture
3.2. Data Preprocessing
3.3. CEMA Block
EMAAdapter Module
3.4. Convolutional Positional Encoding
3.5. Multi-Layer Perceptron
4. Experiments
4.1. Experimental Setup
4.1.1. Datasets
4.1.2. Evaluation Metrics and Experimental Parameter Settings
4.2. Comparative Experiments
4.2.1. Evaluation Against Current Encrypted Traffic Categorization Baselines
4.2.2. Evaluation Against Conventional Traffic Classification Baselines
4.2.3. Ablation Studies
4.2.4. Training Convergence Analysis
4.2.5. Model Performance Analysis
5. Discussion
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Nguyen, T.T.T.; Armitage, G. A survey of techniques for internet traffic classification using machine learning. IEEE Commun. Surv. Tutor. 2008, 10, 56–76. [Google Scholar] [CrossRef]
- Zhang, J.; Xiang, Y.; Wang, Y.; Zhou, W.; Xiang, Y.; Guan, Y. Network traffic classification using correlation information. IEEE Trans. Parallel Distrib. Syst. 2012, 24, 104–117. [Google Scholar] [CrossRef]
- Rezaei, S.; Liu, X. Deep Learning for Encrypted Traffic Classification: An Overview. IEEE Commun. Mag. 2019, 57, 76–81. [Google Scholar] [CrossRef]
- Sheikh, M.S.; Peng, Y. Procedures, criteria, and machine learning techniques for network traffic classification: A survey. IEEE Access 2022, 10, 61135–61158. [Google Scholar] [CrossRef]
- Azab, A.; Khasawneh, M.; Alrabaee, S.; Choo, K.-K.R.; Sarsour, M. Network traffic classification: Techniques, datasets, and challenges. Digit. Commun. Netw. 2024, 10, 676–692. [Google Scholar] [CrossRef]
- Cheng, G.; Wang, S. Traffic classification based on port connection pattern. In Proceedings of the 2011 International Conference on Computer Science and Service System (CSSS), Nanjing, China, 27–29 June 2011; IEEE: New York, NY, USA, 2011; pp. 914–917. [Google Scholar] [CrossRef]
- Sirinam, P.; Imani, M.; Juarez, M.; Wright, M. Deep fingerprinting: Undermining website fingerprinting defenses with deep learning. In Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security, Toronto, ON, Canada, 15–19 October 2018; pp. 1928–1943. [Google Scholar]
- Liu, C.; He, L.; Xiong, G.; Cao, Z.; Li, Z. FS-NET: A Flow Sequence Network for Encrypted Traffic Classification. In Proceedings of the IEEE INFOCOM 2019-IEEE Conference on Computer Communications, Paris, France, 29 April–2 May 2019; IEEE: New York, NY, USA, 2019; pp. 1171–1179. [Google Scholar] [CrossRef]
- Tahaei, H.; Afifi, F.; Asemi, A.; Zaki, F.; Anuar, N.B. The rise of traffic classification in IoT networks: A survey. J. Netw. Comput. Appl. 2020, 154, 102538. [Google Scholar] [CrossRef]
- Getman, A.I.; Ikonnikova, M.K. A survey of network traffic classification methods using machine learning. Program. Comput. Softw. 2022, 48, 413–423. [Google Scholar] [CrossRef]
- Aceto, G.; Ciuonzo, D.; Montieri, A.; Persico, V.; Pescapé, A. AI-powered internet traffic classification: Past, present, and future. IEEE Commun. Mag. 2023, 62, 168–175. [Google Scholar] [CrossRef]
- Rachmawati, S.M.; Kim, D.S.; Lee, J.M. Machine learning algorithm in network traffic classification. In Proceedings of the 2021 International Conference on Information and Communication Technology Convergence (ICTC), Jeju Island, Republic of Korea, 20–22 October 2021; IEEE: New York, NY, USA, 2021; pp. 1010–1013. [Google Scholar] [CrossRef]
- Usama, M.; Qadir, J.; Raza, A.; Arif, H.; Yau, K.-L.A.; Elkhatib, Y.; Hussain, A.; Al-Fuqaha, A. Unsupervised machine learning for networking: Techniques, applications and research challenges. IEEE Access 2019, 7, 65579–65615. [Google Scholar] [CrossRef]
- Bayat, N.; Jackson, W.; Liu, D. Deep learning for network traffic classification. arXiv 2021, arXiv:2106.12693. [Google Scholar] [CrossRef]
- Aafa, J.S.; Salim, S. A survey on network traffic classification techniques. Int. J. Eng. Res. Technol. 2014, 3, 2015–2019. Available online: https://www.ijert.org/research/a-survey-on-network-traffic-classification-techniques-IJERTV3IS031570.pdf (accessed on 20 May 2026).
- Bar-Yanai, R.; Langberg, M.; Peleg, D.; Roditty, L. Realtime classification for encrypted traffic. In Proceedings of the International Symposium on Experimental Algorithms, Ischia Island, 20–22 May 2010; Springer: Berlin/Heidelberg, Germany, 2010; pp. 373–385. [Google Scholar] [CrossRef]
- Wang, W.; Zhu, M.; Wang, J.; Zeng, X.; Yang, Z. End-to-end encrypted traffic classification with one-dimensional convolution neural networks. In Proceedings of the 2017 IEEE International Conference on Intelligence and Security Informatics (ISI), Beijing, China, 22–24 July 2017; IEEE: New York, NY, USA, 2017; pp. 43–48. [Google Scholar] [CrossRef]
- Lotfollahi, M.; Jafari Siavoshani, M.; Shirali Hossein Zade, R.; Saberian, M. Deep packet: A novel approach for encrypted traffic classification using deep learning. Soft Comput. 2020, 24, 1999–2012. [Google Scholar] [CrossRef]
- Zhang, J.; Zhao, H.; Feng, Y.; Cai, Z.; Zhu, L. NetST: Network Encrypted Traffic Classification Based on Swin Transformer. Comput. Mater. Contin. 2025, 84, 5279–5298. [Google Scholar] [CrossRef]
- Babaria, R.; Madanapalli, S.C.; Kumar, H.; Sivaraman, V. Flowformers: Transformer-based models for real-time network flow classification. In Proceedings of the 2021 17th International Conference on Mobility, Sensing and Networking (MSN), Exeter, UK, 13–15 December 2021; IEEE: New York, NY, USA, 2021; pp. 231–238. [Google Scholar] [CrossRef]
- Ouyang, D.; He, S.; Zhang, G.; Luo, M.; Guo, H.; Zhan, J.; Huang, Z. Efficient multi-scale attention module with cross-spatial learning. In Proceedings of the ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), Rhodes Island, Greece, 4–10 June 2023; IEEE: New York, NY, USA, 2023; pp. 1–5. [Google Scholar] [CrossRef]
- Wang, T.; Xie, X.; Wang, W.; Wang, C.; Zhao, Y.; Cui, Y. Netmamba: Efficient network traffic classification via pre-training unidirectional Mamba. In Proceedings of the 2024 IEEE 32nd International Conference on Network Protocols (ICNP), Charleroi, Belgium, 28–31 October 2024; IEEE: New York, NY, USA, 2024; pp. 1–11. [Google Scholar] [CrossRef]
- Zhang, H.; Yu, L.; Xiao, X.; Li, Q.; Mercaldo, F.; Luo, X.; Liu, Q. TFE-GNN: A Temporal Fusion Encoder Using Graph Neural Networks for Fine-Grained Encrypted Traffic Classification. In Proceedings of the ACM Web Conference 2023, Austin, TX, USA, 30 April–4 May 2023; pp. 2066–2075. [Google Scholar] [CrossRef]
- Lin, X.; Xiong, G.; Gou, G.; Li, Z.; Shi, J.; Yu, J. ET-BERT: A Contextualized Datagram Representation with Pre-training Transformers for Encrypted Traffic Classification. In Proceedings of the ACM Web Conference 2022, Lyon, France, 25–29 April 2022; pp. 633–642. [Google Scholar] [CrossRef]
- Zhao, R.; Zhan, M.; Deng, X.; Wang, Y.; Wang, Y.; Gui, G.; Xue, Z. Yet another traffic classifier: A masked autoencoder based traffic transformer with multi-level flow representation. Proc. AAAI Conf. Artif. Intell. 2023, 37, 5420–5427. [Google Scholar] [CrossRef]







| Task | Dataset | Class | Train Set | Validation Set | Test Set |
|---|---|---|---|---|---|
| Task1 | Cross Platform-Android | 181 | 44,700 | 4655 | 4656 |
| Cross Platform-iOS | 124 | 40,379 | 4203 | 4205 | |
| Task2 | USTC-TFC2016 | 20 | 37,323 | 6692 | 6662 |
| Task3 | ISCXVPN2016 | 7 | 13,281 | 1383 | 1384 |
| Parameter | Setting |
|---|---|
| Batch size | 64 |
| Epoch | 100 |
| Learning Rate Scheduler | Cosine Annealing Learning Rate |
| Optimizer | AdamW |
| Method | USTC-TFC2016 | ISCXVPN2016 | Cross Platform-Android | Cross Platform-iOS | ||||
|---|---|---|---|---|---|---|---|---|
| AC (%) | F1 (%) | AC (%) | F1 (%) | AC (%) | F1 (%) | AC (%) | F1 (%) | |
| FlowPrint [20] | 79.92 | 79.92 | 96.66 | 96.81 | 87.39 | 87.00 | 87.12 | 86.03 |
| TFE-GNN [23] | 97.47 | 97.34 | 84.28 | 84.47 | 81.41 | 80.67 | 82.41 | 81.30 |
| ET-BERT [24] | 99.10 | 99.10 | 95.66 | 95.65 | 93.86 | 94.01 | 94.01 | 94.01 |
| YaTC [25] | 99.47 | 97.34 | 98.19 | 98.19 | 90.42 | 90.42 | 90.42 | 90.42 |
| CEMA-Net | 99.94 | 99.53 | 98.19 | 97.48 | 97.40 | 97.20 | 97.47 | 96.88 |
| Method | Cross Platform-Android | Cross Platform-iOS | ||||||
|---|---|---|---|---|---|---|---|---|
| AC (%) | PR (%) | RC (%) | F1 (%) | AC (%) | PR (%) | RC (%) | F1 (%) | |
| ResNet101 | 97.14 | 97.16 | 97.06 | 96.92 | 97.54 | 97.01 | 97.15 | 97.02 |
| MobileNetV2 | 88.31 | 90.27 | 88.46 | 88.92 | 93.10 | 93.47 | 92.74 | 92.95 |
| CNN + LSTM | 81.78 | 88.51 | 81.41 | 83.80 | 90.24 | 91.67 | 89.76 | 90.16 |
| CEMA-Net | 97.40 | 97.26 | 97.30 | 97.20 | 97.47 | 96.80 | 97.19 | 96.88 |
| Method | ISCXVPN2016 | USTC-TFC2016 | ||||||
|---|---|---|---|---|---|---|---|---|
| AC (%) | PR (%) | RC (%) | F1 (%) | AC (%) | PR (%) | RC (%) | F1 (%) | |
| ResNet101 | 98.04 | 97.43 | 96.57 | 96.98 | 99.92 | 99.38 | 99.29 | 99.33 |
| MobileNetV2 | 97.03 | 96.90 | 95.92 | 96.38 | 99.92 | 99.11 | 99.11 | 99.11 |
| CNN + LSTM | 97.32 | 96.86 | 95.63 | 96.20 | 99.86 | 99.14 | 99.11 | 99.12 |
| CEMA-Net | 98.19 | 97.70 | 97.27 | 97.48 | 99.94 | 99.62 | 99.48 | 99.53 |
| Method | Params (M) | Accuracy (%) | FLOPs (GMac) |
|---|---|---|---|
| ResNet101 | 47.25 | 98.04 | 0.281 |
| MobileNetV2 | 2.23 | 97.03 | 0.083 |
| CNN + LSTM | 1.96 | 97.32 | 0.034 |
| CEMA-Net | 0.66 | 98.19 | 0.037 |
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. |
© 2026 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.
Share and Cite
Feng, Y.; Ren, Y.; Zhang, J.; Cai, Z.; Yang, J.; Zhu, L. A Lightweight Network for Encrypted Traffic Classification Based on Convolutional Positional Encoding and Efficient Multi-Scale Attention. Electronics 2026, 15, 2248. https://doi.org/10.3390/electronics15112248
Feng Y, Ren Y, Zhang J, Cai Z, Yang J, Zhu L. A Lightweight Network for Encrypted Traffic Classification Based on Convolutional Positional Encoding and Efficient Multi-Scale Attention. Electronics. 2026; 15(11):2248. https://doi.org/10.3390/electronics15112248
Chicago/Turabian StyleFeng, Yuan, Yifan Ren, Jianwei Zhang, Zengyu Cai, Juncheng Yang, and Liang Zhu. 2026. "A Lightweight Network for Encrypted Traffic Classification Based on Convolutional Positional Encoding and Efficient Multi-Scale Attention" Electronics 15, no. 11: 2248. https://doi.org/10.3390/electronics15112248
APA StyleFeng, Y., Ren, Y., Zhang, J., Cai, Z., Yang, J., & Zhu, L. (2026). A Lightweight Network for Encrypted Traffic Classification Based on Convolutional Positional Encoding and Efficient Multi-Scale Attention. Electronics, 15(11), 2248. https://doi.org/10.3390/electronics15112248

