Yet Another Traffic Classifier: A Masked Autoencoder Based Traffic Transformer with Multi-Level Flow Representation

Ruijie Zhao, Mingwei Zhan, Xianwen Deng, Yanhao Wang, Yijun Wang, Guan Gui, Zhi Xue

Introduction

Classifying network traffic—identifying whether a flow is a YouTube video, a VPN connection, or a piece of malware—is vital for modern network security and resource management. However, the widespread adoption of encryption has rendered traditional Deep Packet Inspection (DPI) methods increasingly obsolete.

Current Deep Learning (DL) approaches for traffic classification often suffer from three major flaws:

  1. Information Imbalance: Raw byte sequences can lead to large packets "drowning out" smaller, more informative packets.
  2. Structural Ignorance: Models frequently fail to account for the natural hierarchy of network data (bytes to packets, packets to flows).
  3. The Labeling Bottleneck: High-performing models typically require massive amounts of human-labeled data, which is expensive and slow to produce.

To address these challenges, we present YaTC (Yet Another Traffic Classifier), a novel framework that treats network traffic as a hierarchical "image" rather than a simple stream of bytes. By combining a structured Multi-Level Flow Representation (MFR) with a Masked Autoencoder (MAE) pre-training strategy, YaTC achieves state-of-the-art accuracy while requiring significantly less labeled data.

Methodology

Multi-Level Flow Representation (MFR)

Instead of processing traffic as a flat list of bytes, YaTC organizes flow data into a formatted 2D matrix. It captures the first $M$ packets of a flow, with each packet allocated a fixed number of rows for its header and payload. This "grid" structure ensures that every packet is represented equally, preventing long payloads from overwhelming critical header information.

The MFR process transforms raw traffic into a structured 2D matrix.

The Traffic Transformer Architecture

YaTC utilizes a specialized Transformer architecture designed to exploit the hierarchical nature of the MFR. The model operates in two distinct stages:

  • Packet-Level Attention: The model first analyzes patches within a single packet to understand the relationship between its header and payload.
  • Flow-Level Attention: It then employs "row pooling" to aggregate packet features and analyzes the relationships between different packets in the sequence.

This hierarchical approach is computationally more efficient than global attention, achieving $O(N)$ complexity compared to the standard $O(N^2)$.

Masked Autoencoder (MAE) Pre-training

The core innovation of YaTC is its self-supervised pre-training strategy. Before fine-tuning on labeled data, the model is trained on a massive volume of unlabeled raw traffic. The researchers mask out 90% of the traffic matrix and task the model with reconstructing the missing data.

While Natural Language Processing models typically mask 15% of tokens and Computer Vision models mask 75% of image patches, YaTC found that a 90% masking rate yielded the best results. This suggests that network traffic is highly redundant, and forcing the model to reconstruct data from a tiny fraction of the original input builds a robust feature extractor.

Evaluation and Results

YaTC was evaluated on five diverse, real-world encrypted traffic datasets: ISCXVPN2016, ISCXTor2016, USTC-TFC2016, and CICIoT2022.

Performance and Data Efficiency

YaTC outperformed all baselines, including ET-BERT and PERT. On the challenging ISCXTor2016 dataset, YaTC achieved a 99.72% F1-score, significantly higher than ET-BERT's 64.98%.

A key strength of YaTC is its performance with limited labeled data. As shown in the figure below, even when trained on only 10% of the labeled samples, YaTC maintained high accuracy, whereas other models experienced significant performance degradation.

F1-score performance of YaTC compared to baselines across varying labeled data sizes.

Transfer Learning

The model also demonstrated strong generalizability. When pre-trained on one set of datasets and tested on a separate "Cross-Platform" dataset, YaTC's F1-score improved from 69.93% (without pre-training) to 82.35%, indicating that it learns fundamental, generalizable network patterns.

Conclusion

YaTC demonstrates that network traffic is effectively modeled as a structured image. By leveraging a hierarchical representation and aggressive self-supervised masking, it sets a new benchmark for encrypted traffic classification. Future work will focus on adapting the model for real-time "line-rate" implementation and evaluating its robustness against adversarial traffic designed to evade deep learning classifiers.

Summary updated

BibTeX
@inproceedings{zhao2023yet,
  author = {Ruijie Zhao and Mingwei Zhan and Xianwen Deng and Yanhao Wang and Yijun Wang and Guan Gui and Zhi Xue},
  title = {{Yet Another Traffic Classifier: A Masked Autoencoder Based Traffic Transformer with Multi-Level Flow Representation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i4.25674},
}
Figure