Journal of Shanghai University(Natural Science Edition) ›› 2025, Vol. 31 ›› Issue (4): 719-734.doi: 10.12066/j.issn.1007-2861.2594

• Information Engineering • Previous Articles     Next Articles

Few-shot encrypted traffic classification model incorporating MAML and contrastive learning

JIN Yanliang1,2, FANG Jie1,2, GAO Yuan1,2   

  1. 1. School of Communication and Information Engineering, Shanghai University, Shanghai 200444, China;
    2. Shanghai Institute for Advanced Communication and Data Science, Shanghai University, Shanghai 200444, China
  • Received:2024-01-29 Online:2025-08-31 Published:2025-09-16

Abstract: In order to address the current challenge of limited labeled encrypted traffic and rapidly adapt to the classification tasks of emerging traffic, this paper proposed a few-shot encrypted traffic classification model incorporating model-agnostic meta-learning (MAML) and contrastive learning. Specifically, it improved the inner-loop optimization of the MAML by incorporating supervised contrastive loss, thereby enabling the embedding representations generated by the feature encoding network during the conversation flow to be more distinguishable in the label space. Consequently, general meta-knowledge across multiple tasks was obtained. Leveraging this meta-knowledge, the adaptation phase for new tasks requires only a small amount of labeled data, enabling rapid learning and satisfactory performance on the target task. Results on the public dataset ISCXVPN-NonVPN2016 and a private dataset show that the proposed method exceeds the existing few-shot classification methods. In the 2way-10shot task, the proposed method achieves 97.46% accuracy and 97.12% F1-score on the public dataset, as well as 95.19% accuracy and 94.96% F1-score on the private dataset, respectively. In addition, the proposed model can alleviate the problems of inter-class similarity and intra-class difference that MAML is difficult to deal with. Compared to MAML, its accuracy and F1-score improve by 3.62% and 3.70% on the 5way-10shot task in the public dataset, respectively.

Key words: encrypted traffic classification, few-shot, MAML, meta-learning, contrastive learning

CLC Number: