Abstract: In recent years, sequence features such as packet length have received considerable attention due to their central role in encrypted traffic analysis. Existing sequence modeling approaches can be broadly categorized into flow-level and trace-level methods: the former suffer from high feature redundancy, limiting their discriminative power, whereas the latter preserve complete information but incur substantial computational and storage overhead. To address these limitations, we propose the Up-Down Flow Sequence (UDFS) representation, which compresses an entire trace into a two-dimensional sequence and characterizes each flow by the aggregate of its upstream and downstream traffic, reducing complexity while maintaining high discriminability. Furthermore, to address the challenge of class-specific discriminability differences, we propose an adaptive threshold mechanism that dynamically adjusts training weights and rejection boundaries, enhancing the model's classification performance. Experimental results demonstrate that the proposed method achieves superior classification performance and robustness on both coarse-grained and fine-grained datasets, as well as under concept drift and open-world scenarios. Code and Dataset are available at https://github.com/kid1999/UDFS.
Introduction
Encrypted Traffic Analysis (ETA) is a critical field for network security, yet it faces a persistent "precision-overhead dilemma." Current methodologies generally fall into two categories: flow-level methods, which are efficient but lack macro-context, and trace-level methods, which are accurate but computationally prohibitive due to massive sequence lengths. UDFS (Up-Down Flow Sequence) addresses this by representing network traces as compact sequences of flow-level traffic volumes, combining the efficiency of flow-level analysis with the contextual awareness of trace-level modeling.
Methodology
UDFS Representation
Instead of modeling every individual packet, UDFS abstracts a network trace into a sequence of flows. Each flow is represented by a simple 2D vector consisting of the total upstream and downstream bytes. This captures the "request-response" asymmetry inherent in web traffic. To handle the wide range of flow sizes, a logarithmic smoothing transformation is applied, reducing sequence lengths by over an order of magnitude (e.g., from 5,000 packets to approximately 40 flows).
Transformer-based Extractor
The framework utilizes a 4-layer Transformer Encoder to learn the macro-level temporal relationships between these flows. This allows the model to recognize patterns such as an initial HTML request followed by specific CSS or JavaScript loads, which are characteristic of particular applications or websites.
Adaptive Prototypical Learning
To address the "Open-World Problem"—the ability to identify known applications while rejecting unknown traffic—UDFS learns class-specific "prototypes" in a feature space. Crucially, the model employs a dynamic thresholding mechanism that calculates personalized rejection boundaries for each category based on its internal density and distance to neighboring classes, rather than relying on a single global threshold.
Experimental Setup
The study utilized two primary datasets totaling ~119.5 GB:
- GitHub Dataset: A fine-grained dataset of 10 code repositories, representing a high-difficulty classification task due to similar traffic patterns.
- Baidu Dataset: A coarse-grained dataset of 20 well-known websites.
- Open-World Benchmarks: Mixed in 10,000 unknown websites and 90 unknown repositories to test the model's rejection capabilities.
Key Insights
- Stable Flow-Resource Mapping: While individual packet timings and lengths are volatile due to network jitter, the total volume of a flow is remarkably stable because it corresponds directly to the size of the resource being downloaded (e.g., a specific .js file).
- The "One-Size-Fits-All" Fallacy: Global rejection thresholds are often too conservative for easy classes or too aggressive for hard ones. Adaptive thresholds based on inter-class discriminability significantly improve robustness.
Results
- Massive Speedup: UDFS is approximately 150x faster to train than full-trace attention models and reduces input sequence lengths by an average of 76x.
- Robustness to Concept Drift: In tests where models were trained on one month's data and tested on the next, UDFS maintained an F1-score of 97.63%. In contrast, the ET-BERT model's performance dropped to 8.58%, proving UDFS captures more intrinsic behavioral patterns.
- Superior Open-World Performance: On the challenging GitHub open-world task, UDFS achieved an F1-score of 54.85%, outperforming baselines like OpenMax (44.69%) and kLND (42.36%).
Conclusion
UDFS provides a lightweight and robust solution for encrypted traffic classification. By moving from packet-level to flow-level sequences, the model avoids spurious correlations and captures intrinsic behavioral patterns. Future work will focus on improving model interpretability and addressing challenges in extremely fine-grained scenarios where different applications may produce identical flow signatures.
Summary updated