Many or Few Samples?: Comparing Transfer, Contrastive and Meta-Learning in Encrypted Traffic Classification

Idio Guarino, Chao Wang, Alessandro Finamore, Antonio Pescapè, Dario Rossi · DOI

TL;DR

This paper investigates how to effectively train deep learning models for encrypted traffic classification, a task made challenging by the need for large labeled datasets. The authors find that contrastive learning and transfer learning outperform meta-learning, and that DL models are closing the performance gap with traditional tree-based models, especially when leveraging large datasets.

What Problem Does This Paper Address?

The increasing adoption of encrypted protocols like HTTPS, QUIC, and DNS-SEC has significantly reduced network traffic visibility, making traditional traffic classification (TC) methods less effective. This necessitates the development of new TC techniques that can learn robust representations from limited data, or generalize well across different tasks. While deep learning (DL) has shown promise, it typically requires large, task-specific labeled datasets. This paper addresses the challenge of building effective DL models for TC by comparing three representation learning paradigms: transfer learning, meta-learning, and contrastive learning, against traditional machine learning (ML) tree-based models and monolithic DL models. The goal is to understand how these approaches perform under varying dataset sizes and class complexities, and to identify methods that can learn generalizable representations without relying on massive labeled datasets for every new task.

Methods

The paper compares 16 different methods across three main DL paradigms:

  • Monolithic Training: A standard DL approach where a single model is trained from scratch on a given dataset for a specific task.
  • Transfer Learning: This involves training a model on a source task (Tsource) and then adapting it to a target task (Ttarget). The paper explores two main strategies:
  • Fixed Representation: The feature extractor (trunk) from the source model is frozen, and only a new classifier is trained for the target task.
  • Fine-tuning: The entire model, or parts of it, are retrained on the target task. The paper investigates both monolithic fine-tuning and episodic fine-tuning (as used in meta-learning).
  • Meta-Learning (Few-Shot Learning): This paradigm focuses on learning how to learn. Models are trained on a series of "episodes," each simulating a few-shot learning scenario (e.g., N-way, S-shot). The goal is to train a model that can quickly adapt to new, unseen tasks with very few labeled examples. The paper specifically examines ProtoNet, RelationNet, and MAML.
  • Contrastive Learning: This approach learns representations by maximizing the similarity between augmented versions of the same data point (positive pairs) while minimizing similarity with other data points (negative pairs). The paper investigates both unsupervised (SimCLR) and supervised (SupCon) variants.

The study also includes traditional ML tree-based models (Random Forest) as a baseline.

Datasets

The research utilizes two publicly available datasets:

  • MIRAGE19: Contains per-biflow traffic logs from 40 Android applications. It was collected from real user interactions and includes various features like packet time series and raw packet payload bytes.
  • AppClassNet: A large-scale, commercial-grade dataset from Huawei Technologies, comprising traffic from 500 applications. It uses packet size and direction for the first 20 packets as input features and is labeled using a proprietary DPI tool.

The datasets were partitioned to adhere to meta-learning protocols, with distinct sets of classes for training, validation, and testing to simulate realistic scenarios where target tasks might have different classes than the source tasks.

Key Insights and Ideas

  • Meta-learning's limitations in TC: Contrary to some findings in computer vision, meta-learning methods performed the worst in this traffic classification study. This suggests that the typical episodic training setup for meta-learning might not be as effective for TC tasks, especially when compared to other approaches.
  • The power of large datasets for representation learning: Using DL methods on large datasets (like AppClassNet) leads to more generalizable representations. This highlights the importance of dataset scale in learning robust features.
  • Contrastive learning shines: Supervised contrastive learning emerged as a strong performer, yielding the best results among the DL methods. This indicates its effectiveness in extracting meaningful features from traffic data, even with limited labels.
  • Tree-based models remain relevant for smaller tasks: While DL models are catching up, traditional tree-based models (like Random Forest) still offer superior performance for tasks with a smaller number of classes (e.g., <10) and a moderate number of samples per class. However, their size can become impractical for very large tasks.
  • Transfer learning bridges the gap: Transfer learning, particularly when combined with episodic fine-tuning, shows significant promise. Training source models on large, diverse datasets is crucial for effective transfer to target tasks.
  • Dataset characteristics matter: The performance of transfer learning varied between the two datasets, suggesting that the latent space geometry learned from MIRAGE19 might be less robust than that learned from AppClassNet, even though AppClassNet has a much larger number of classes.

Key Results

  • Best DL performers: Supervised contrastive learning and transfer learning methods generally outperformed meta-learning approaches.
  • Meta-learning performance: Meta-learning methods showed a performance gap of at least 14-18% compared to the best alternatives.
  • Tree-based models: Unbounded Random Forest models achieved the highest performance across scenarios, but their size can be prohibitive (e.g., 416GB for a 500-class model on AppClassNet). For tasks with <10 classes and ~1000 samples/class, they remain practical.
  • DL vs. Trees: DL methods that leverage transfer learning are closing the performance gap with tree-based models, even for smaller tasks.
  • Impact of shots: Increasing the number of "shots" (labeled examples per class) in meta-learning significantly improved performance, but the overall effectiveness of meta-learning remained lower.
  • Contrastive learning cost: While effective, contrastive learning methods incurred significant computational costs, largely attributed to randomized data augmentation.

Limitations and Future Work

  • Fixed representation: The study primarily used a fixed representation approach for evaluating transfer learning and meta-learning, which might not fully capture the potential of fine-tuning.
  • Small architectures: The DL models used were relatively small (CNN-2 and CNN-4), meaning the results might represent lower bounds of performance.
  • Computational cost of contrastive learning: The significant training time for contrastive learning due to data augmentation is a notable limitation.
  • Future work suggestions:
    • Investigate different DL architectures and input types (e.g., time series of flow features).
  • Explore more advanced data augmentation policies for contrastive learning to reduce computational costs.
  • Further optimize transfer learning and contrastive learning strategies.
  • Leverage newly released large-scale datasets for more comprehensive TC research.
  • Explore hybrid approaches that combine the strengths of different learning paradigms.

Summary updated

BibTeX
@inproceedings{guarino2023many,
  author = {Idio Guarino and Chao Wang and Alessandro Finamore and Antonio Pescapè and Dario Rossi},
  title = {{Many or Few Samples?: Comparing Transfer, Contrastive and Meta-Learning in Encrypted Traffic Classification}},
  booktitle = {TMA},
  year = {2023},
  doi = {10.23919/tma58422.2023.10198965},
}
Figure