Revolutionizing Encrypted Traffic Classification with MH-Net: A Multi-View Heterogeneous Graph Model

Haozhen Zhang, Haodong Yue, Xi Xiao, Le Yu, Qing Li, Zhen Ling, Ye Zhang

Abstract

As encryption protocols like VPNs and Tor become standard, traditional Deep Packet Inspection (DPI) methods have become increasingly ineffective for network management and security. While machine learning approaches have emerged to classify encrypted traffic, they often rely on rigid byte-level analysis and fail to distinguish between the distinct functional roles of packet headers and payloads. This paper introduces MH-Net, a Multi-View Heterogeneous Graph Model designed to overcome these limitations. By utilizing variable-length traffic units and modeling their relationships through heterogeneous graph neural networks (HGNN), MH-Net captures multi-granular features and complex structural correlations. Coupled with a dual-level contrastive learning framework, MH-Net achieves state-of-the-art performance across multiple public benchmarks, significantly outperforming existing flow-level and packet-level classification models.

Introduction

The proliferation of encryption is a double-edged sword: while it protects user privacy, it also provides a veil for malicious activities. Modern traffic classification must therefore rely on statistical patterns and structural features rather than plaintext inspection. However, current deep learning models for traffic analysis suffer from two primary "blind spots."

First is the issue of rigid granularity. Most models treat the 8-bit byte as the fundamental unit of information. This ignores the fact that network data contains information at various scales—for instance, a single English character may be 8 bits, while a Chinese character or specific protocol flag might span different lengths. Second is the homogeneous treatment of data. Existing models often process all bytes identically, failing to account for the fact that a byte in a packet header (metadata) serves a fundamentally different purpose than a byte in the payload (content).

Methodology

To address these challenges, the MH-Net architecture introduces several innovations in how network traffic is represented and processed.

Multi-View Traffic Units

Instead of adhering strictly to 8-bit boundaries, MH-Net aggregates raw bits into variable-length "traffic units" (e.g., 4-bit and 8-bit units). This multi-view approach allows the model to analyze the same traffic stream from different perspectives, capturing discriminative features that a single-view, byte-level model would likely miss.

Heterogeneous Traffic Graphs

The core of the model is the construction of a heterogeneous graph. Using Point-wise Mutual Information (PMI), the model calculates the co-occurrence frequency of specific traffic units to define edges. Unlike previous models that treat all correlations as equal, MH-Net defines three distinct edge types:

  1. Header-Header: Correlations between metadata elements.
  2. Payload-Payload: Correlations within the encrypted content.
  3. Header-Payload: The crucial relationship between metadata and the content it describes.

Architectural Pipeline

The model employs a Heterogeneous Graph Neural Network (HGNN) based on the GraphSAGE architecture to extract features at the packet level. These packet-level features are then fed into a Long Short-Term Memory (LSTM) network to capture the temporal dependencies of the overall traffic flow.

Dual-Level Contrastive Learning

To enhance robustness and feature representation, MH-Net incorporates supervised contrastive learning at two levels:

  • Packet Level: Data is augmented via random walks on the graph and feature flipping.
  • Flow Level: Data is augmented by randomly dropping packets within a flow. This dual-level approach ensures the model learns invariant features that are resistant to noise and minor traffic fluctuations.

Experimental Evaluation

MH-Net was evaluated against dozens of state-of-the-art baselines, including TFE-GNN, YaTC, and ET-BERT, using several standard benchmarks:

  • CIC-IoT: Traffic from diverse Internet of Things devices.
  • ISCX VPN-nonVPN: A dataset distinguishing between encrypted tunnel traffic and regular traffic.
  • ISCX Tor-nonTor: Traffic routed through the Tor anonymity network.
  • CrossPlatform (Android): Used to verify the model's generalizability across different operating systems.

Key Results

MH-Net achieved the top average rank across all datasets. Notable performance metrics include:

  • Flow-level Classification: Achieved an F1-score of 0.9896 on CIC-IoT and 0.9941 on ISCX-VPN.
  • Packet-level Classification: Reached an F1-score of 0.9800 on CIC-IoT and 0.9766 on ISCX-VPN.

An ablation study highlighted the importance of the heterogeneous structure. When the model was forced to treat all edge types as homogeneous, the flow-level F1-score on the ISCX-VPN dataset dropped from 0.9941 to 0.9120, confirming that the distinction between header and payload relationships is a critical driver of accuracy.

Discussion and Future Work

While MH-Net sets a new benchmark for accuracy, it faces certain constraints. The computational complexity of the traffic graph scales exponentially ($2^N$) with the bit-length of the traffic units, making 16-bit or 32-bit units currently impractical. Furthermore, the random packet-dropping mechanism used in flow-level contrastive learning can occasionally introduce excessive noise.

Future research will focus on "learnable augmentation" modules that can adaptively determine which packets to drop, as well as optimizing the graph construction process to support larger traffic units without prohibitive computational costs. By moving beyond the byte and recognizing the inherent heterogeneity of network data, MH-Net provides a robust foundation for the next generation of encrypted traffic analysis.

Summary updated

BibTeX
@inproceedings{zhang2025revolutionizing,
  author = {Haozhen Zhang and Haodong Yue and Xi Xiao and Le Yu and Qing Li and Zhen Ling and Ye Zhang},
  title = {{Revolutionizing Encrypted Traffic Classification with MH-Net: A Multi-View Heterogeneous Graph Model}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i1.32091},
}
Figure