Lens: A Knowledge-Guided Foundation Model for Network Traffic

Xiaochang Li, Chen Qian, Qineng Wang, Jiangtao Kong, Yuchen Wang, Ziyu Yao, Bo Ji, Long Cheng, Gang Zhou, Huajie Shao

TL;DR

This paper introduces Lens, a novel foundation model for network traffic analysis that leverages "network knowledge" during pre-training to better understand traffic patterns. Lens excels at both classifying network traffic, even for new, unseen categories, and generating realistic network traffic for simulations, outperforming existing methods.

What Problem Does This Paper Address?

Analyzing network traffic is crucial for security and management, but it's challenging due to the mix of readable headers and encrypted payloads. While Transformer-based models have shown promise, they often overlook specific network knowledge (like the structure of port numbers) and struggle to adapt to new traffic types after initial training. This leads to incomplete understanding and difficulty in generalizing to evolving network landscapes.

Methods

Lens employs an encoder-decoder T5 architecture. Its core innovation lies in two areas:

  • Knowledge-Guided Mask Span Prediction (KG-MSP): Instead of random masking of tokens (common in NLP pre-training), KG-MSP intentionally masks entire network metadata units (like full port numbers or protocol names) based on their importance. This forces the model to learn more semantically rich representations.
  • Context-Aware Finetuning: For classification, Lens reframes the task as a generation problem. By providing task context (e.g., a list of potential application labels) during finetuning, Lens can adapt to new, unseen classes without needing to retrain from scratch. This approach also helps bridge the gap between network traffic data and natural language descriptions.

Datasets

The paper uses six publicly available datasets for evaluation: ISCX-VPN, ISCX-Tor, USTC-TFC-2016, Cross Platform (Android and iOS), CIC-DoHBrw-2020, and CIC-IoT-2023. These datasets are used to create 12 classification tasks and 5 generation tasks. The Cross Platform datasets were specifically excluded from pre-training to evaluate generalization capabilities.

Key Insights and Ideas

  • Network Knowledge is Key: Simply masking random tokens isn't enough. Masking semantically meaningful network units (like entire port numbers) significantly improves the model's understanding of network traffic.
  • Classification as Generation: Reframing traffic classification as a generation task, where the model predicts a label from a given context, is a powerful way to handle distribution shifts and enable seamless extension to new classes.
  • Bridging Modalities: Incorporating textual descriptions of network traffic alongside the raw data helps the model learn more robust representations and improves its ability to understand different traffic types.

Key Results

  • Classification Performance: Lens outperforms competitive baselines on 8 out of 12 classification tasks, achieving an average accuracy of 96.33%.
  • Extensibility to New Classes: Lens demonstrates significantly better performance when extending to novel classes, showing accuracy and F1 improvements of up to 31.31% and 42.59%, respectively, compared to baselines.
  • Generation Fidelity: For network traffic generation, Lens produces high-fidelity traffic that leads to improved performance in fuzzing tests, with accuracy and F1 gains of up to 30.46% and 33.3% over baselines.
  • Ablation Studies: Both KG-MSP pre-training and context-aware finetuning were shown to be crucial for Lens's superior performance in both classification and generation tasks.

Limitations and Future Work

  • Continual Learning: While Lens excels at extending to new classes, the paper notes that it doesn't implement explicit continual learning methods. Future work could explore integrating these to further enhance its adaptability.
  • Real-World Deployment: The authors plan to test Lens in real-world computer systems to evaluate its performance in practical scenarios.

Summary updated

BibTeX
@article{li2025lens,
  author = {Xiaochang Li and Chen Qian and Qineng Wang and Jiangtao Kong and Yuchen Wang and Ziyu Yao and Bo Ji and Long Cheng and Gang Zhou and Huajie Shao},
  title = {{Lens: A Knowledge-Guided Foundation Model for Network Traffic}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=cGDwTgnJIR},
}
Figure