An Encrypted Anomaly Traffic Detection Method Integrating Adversarial Training and Multi-scale Contrastive Learning
摘要
With the widespread use of encrypted transmission and increasingly sophisticated network attacks, ensuring encrypted traffic security has become a major challenge. This paper proposes a deep contrastive learning-based anomaly detection model to address limitations in multi-scale feature extraction, adversarial robustness, and imbalanced traffic. The model combines a Transformer with channel and sequence attention, and a multi-scale 1D dilated convolution module to capture both local and global traffic features. To defend against adversarial samples, we introduce an optimization framework integrating FreeLB adversarial training and Barlow Twins contrastive learning with Double Positive Loss. Moreover, combining CB Loss and Focal Loss improves performance on imbalanced data. Experiments on the CICIDS-2017 dataset show the model achieves an F1-score of 97.72%, a 1.45% gain over the baseline. With CB and Focal Loss, the F1-score improves by 0.42%, and the false alarm rate is reduced by 10% under strong adversarial conditions, demonstrating the model’s robustness and effectiveness.