STNet: Multi-Scale Spatiotemporal Learning and Adaptive Fusion for Few-Shot Tor Traffic Classification
Abstract
The Tor network’s anonymity is increasingly exploited for cybercrime, creating a demand for accurate traffic classification under strict few-shot constraints. While recent efforts like WF-Transformer demonstrate strong temporal modeling capabilities, they still require abundant labeled data and struggle to generalize under defense-induced distortions and open-world unknown traffic. To address these gaps, we propose STNet (SpatioTemporal Multi-scale Augmentation and fusion Network), an episode-based few-shot learning architecture for Tor traffic classification. Unlike simple module stacking, STNet adopts a modular decoupling design: 1) a Multi-Scale Spatiotemporal Feature Fusion (MSMF) module captures packet-level and flow-level patterns to resist obfuscation; 2) scenario-adaptive modules tackle domain shifts in closed-world settings and feature scarcity in open-world settings; and 3) a Hierarchical Layer Attention (HLA) mechanism dynamically fuses heterogeneous features from different deployment positions. Extensive experiments on real-world Tor traffic show that STNet consistently outperforms representative baselines including WF-Transformer. In closed-world settings, it limits the accuracy drop under WalkieTalkie obfuscation to 13.6 percentage points. In open-world 10-shot evaluation, it achieves 92.1% AUC-OVR and 79.1% unknown-class F1-score, surpassing the best baseline by 4.9 and 6.0 percentage points, respectively. These results demonstrate the effectiveness of decoupling universal feature extraction from scenario-specific adaptation in few-shot Tor traffic analysis.