Manuscript Offprint

arXiv:2610.17978

NetCoFi: A Budget-Aware Coarse-Fine Dual-Branch Model for Encrypted Traffic Classification

Zhengyi Ma, Qiming Yu, Chungang Lin, Wentao Cui, Zijia Song, Guozheng Yang

Zhengyi Ma 1,†^{1,\dagger}, Qiming Yu 2,†^{2,\dagger}, Chungang Lin 3,4^{3,4}, Wentao Cui 1^{1}, Zijia Song 2^{2}, Guozheng Yang 2,∗^{2,*}

1^{1}College of Computer Science and Technology, National University of Defense Technology, Changsha 410073, China

2^{2}College of Electronic Engineering, National University of Defense Technology, Hefei 230007, China

3^{3}Institute of Computing Technology, Chinese Academy of Sciences, China

4^{4}University of Chinese Academy of Sciences, China

Abstract—Encrypted traffic classification is critical for network management and security, but practical deployment must balance classification accuracy and inference cost. Existing models typically process fixed flow windows with limited control over computation after training, which can limit the accuracy–efficiency trade-off under constrained resources. To address this problem, we present NetCoFi, a budget-aware classifier that allocates computation at coarse and fine granularities. Using byte representations and observable packet metadata, NetCoFi selects token neighborhoods for fine-grained encoding while compressing the full window into complementary coarse context. Multi-budget training enables the same model to operate at different routing budgets without retraining. Evaluation on six public datasets shows that NetCoFi achieves state-of-the-art classification performance when trained from scratch. Under low-budget settings, NetCoFi improves average Macro-F1 by 7.86 percentage points across three datasets, compared with a same-depth static baseline. In a DPDK–GPU traffic processing pipeline, it increases mean batch throughput from 26.42 to 43.42 Mb/s, a 1.64× improvement over NetMamba.

Index Terms—Encrypted traffic classification, Mamba, adaptive token routing, budget-aware inference

I. INTRODUCTION

Efficient encrypted traffic classification is an important capability for network management and security monitoring, supporting application identification and traffic analysis [1]–[3]. As TLS and encrypted tunnels become widely used, plaintext payload semantics are increasingly unavailable, forcing classifiers to infer traffic classes from observable byte sequences and packet-level metadata [3], [4]. At the same time, practical deployment must meet latency and throughput constraints. This raises a key question: how to ensure that the classifier, given limited inference resources, can retain sufficient traffic information to make accurate predictions while avoiding computational waste?

Recent studies have improved encrypted traffic classification through advances in representation learning and sequence modeling. End-to-end models learn features directly from traffic data and reduce reliance on manual feature design [5]. Pretrained models use unlabeled traffic to learn representations that can be adapted to downstream classification tasks [6]–[8]. More recently, Mamba-based classifiers have improved backbone efficiency with state-space encoders [9], [10]. These

Figure

Fig. 1. Illustration of sparse discriminative regions in encrypted traffic and the localized byte-level semantics that motivate compute-aware routing.

encoders reduce the computational complexity of long-sequence modeling compared with standard self-attention [11], [12].

However, many classifiers still process fixed traffic windows along fixed computation paths. Once trained, these models use a fixed computation path for every prediction, regardless of input complexity or available resources. Shortening the input window can reduce this cost, but it also removes traffic information before the model can assess its value. A more flexible alternative is to adjust the amount of computation within the window instead of relying only on a shorter input.

Such an approach must balance local detail with global context. Regions within a flow window may contribute unequally to classification. Processing all regions at the same granularity can waste computation on those that provide little useful information. However, a region that is less informative on its own may still provide context for other parts of the window. Discarding it entirely can therefore remove information that supports the final prediction. NetCoFi therefore concentrates fine-grained processing on informative regions, while retaining a global summary of the full window.

We propose NetCoFi, a budget-aware coarse-fine dual-branch classifier for fixed-window encrypted traffic classification. It estimates token importance from byte representations and token-aligned side features derived from packet metadata. The

†^{\dagger}These authors contributed equally to this work.

∗^{*}The corresponding author is Guozheng Yang.

fine branch encodes selected token neighborhoods in detail. Including neighboring tokens preserves local context around the selected positions. The coarse branch compresses the full window, including regions not selected by the fine branch. It provides broader context without applying fine-grained encoding to every region. The two branch representations are then fused for classification.

Changing the routing budget also changes the information available to the classifier. A model trained only at full budget may lose accuracy when less detail is retained. We therefore train NetCoFi under multiple routing budgets with shared parameters. This exposes the model to different levels of detail during training. At inference time, the user can choose a budget according to the available computational resources. The same model then provides different accuracy–efficiency choices without retraining.

We evaluate NetCoFi on six public benchmarks and in a DPDK–GPU traffic processing pipeline. In the low-budget comparison, it outperforms a same-depth static token-reduction baseline. The average Macro-F1 gain is 7.86 percentage points across three datasets. In the deployment pipeline, its mean batch throughput reaches 43.42 Mb/s, compared with 26.42 Mb/s for NetMamba. This throughput comparison includes flow aggregation and feature construction, rather than measuring model inference alone.

In summary, this paper makes the following contributions:

  1. We propose NetCoFi, a coarse-fine dual-branch model for encrypted traffic classification. It allocates fine-grained computation to informative local regions, while preserving global context through a coarse branch.

  2. We introduce a budget-aware training strategy. It allows one shared model to operate under different routing budgets without retraining. This provides a flexible accuracy–efficiency trade-off under different resource constraints.

  3. We evaluate NetCoFi on six public datasets and in a DPDK–GPU deployment pipeline. NetCoFi achieves competitive classification performance, stronger low-budget accuracy, and higher deployment throughput than NetMamba.

References (38)