arXiv:2611.07452cs.NINov 2026

Manuscript Offprint

arXiv:2611.07452

Understanding Self-Supervised Representation Learning for Encrypted Traffic

Zongxi Liu, Shuai Mao, Jie Chuai, Hongyang Du

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Zongxi Liu, Shuai Mao, Jie Chuai, and Hongyang Du

Abstract—Self-supervised learning (SSL) has been adopted for encrypted traffic classification to learn representations from unlabeled traces and reduce reliance on manual feature engineering. However, recent studies show that data leakage can inflate reported performance and that pretrained models can underperform shallow classifiers once leakage is controlled. These findings raise fundamental questions about what information SSL can learn from encrypted traffic and how different pretraining mechanisms exploit this information. In this paper, we systematically investigate these questions by examining the sources of learnable information, the effectiveness of contextual pretraining, alternative self-supervision mechanisms, and the limits of representation learning. We first find that visible protocol fields retain contextual dependencies that are strongest between adjacent bytes, while payload interventions establish the classification value of retained plaintext structure. Guided by these insights, we investigate byte-level contextual learning through ByteBERT and TrafficDCNet, showing that aligning prediction granularity with local dependencies produces more discriminative representations than existing contextual pretraining approaches. We further examine cross-view contrastive learning through AlignTraffic and find that complementary supervision improves representation quality beyond contextual prediction alone. Across four public classification tasks, AlignTraffic outperforms shallow learning by 5.97 to 30.70 percentage points in Macro-F1, with additional evaluations on industrial traffic and geographic transfer demonstrating its effectiveness in broader settings. Finally, evaluations on Tor traffic and individual packets reveal limitations when application information is concealed or unevenly distributed. These findings provide a systematic understanding of how observable information and self-supervision mechanisms shape the effectiveness and scope of representation learning for encrypted traffic.

Index Terms—Encrypted traffic classification, self-supervised learning, representation learning, contrastive learning.

I. INTRODUCTION

Traffic classification is an important task in network measurement and security analysis, as it aims to understand system behavior, application usage, and security events by identifying applications or services from their communications. Early systems relied on transport ports and deep packet inspection (DPI), which recognizes signatures in packet contents [1]. However, the widespread adoption of Transport Layer Security (TLS) has made much of that content opaque, reducing the information available to payload inspection [2]. In response, classifiers instead use observable statistical properties of traffic through feature engineering without parsing the encrypted payload [3], [4]. These task-specific approaches relying on feature engineering nevertheless offer limited transferability across classification settings.

More recently, advances in self-supervised pretraining in natural language processing (NLP) and computer vision (CV) have motivated learning traffic representations from unlabeled traces to reduce reliance on feature engineering. ET-BERT adapts BERT-style masked language modeling (MLM) to overlapping two-byte units [5]. Subsequent models, including YaTC and NetMamba, explore different input granularities and contextual pretraining objectives [6], [7]. However, recent analyses question whether encrypted traffic provides the contextual dependencies assumed by these methods. Zhao et al. [8] report weak pretrained representations and show that data leakage from packet-level splitting can inflate downstream classification accuracy. Once these shortcuts are controlled, the advantage of contextual pretraining over shallow classifiers becomes much less evident [9]. These findings motivate us to revisit the basis and effectiveness of pretraining for encrypted traffic.

From a cryptographic perspective, ciphertext produced by secure encryption is expected to offer little exploitable byte-level context [10]. Yet observed TLS traces also contain unencrypted protocol metadata, including record headers and parts of the handshake. These visible fields may retain dependencies that support pretraining even when ciphertext does not. Understanding the effectiveness of encrypted-traffic pretraining therefore requires considering both the remaining observable structure and effective signal sources of self-supervision. We organize this investigation around four questions.

Q1. What information remains learnable in encrypted traffic? Observed encrypted traffic contains both protocol-visible plaintext and ciphertext. Whether the visible fields retain contextual dependencies useful for pretraining is central to establishing what can be learned.

Q2. How can contextual pretraining better exploit the available dependencies? If useful dependencies exist, their range, strength, and distribution determine how they can support prediction. These characteristics should guide the choice of input units and learning objectives.

Q3. Can alternative pretraining paradigms be effective for encrypted traffic? When contextual dependencies are absent or weak, other sources of supervision like contrastive learning may still support representation learning.

Q4. What are the limits of pretraining for encrypted traffic? Traffic settings differ in the application information they expose, and proxy encapsulation can further conceal that information. Whether current pretraining methods remain effective across these settings determines their practical scope.

Zongxi Liu and Hongyang Du are with the Department of Electrical and Computer Engineering, The University of Hong Kong, Hong Kong SAR, China (e-mail: duhy@hku.hk).

Shuai Mao and Jie Chuai are with Huawei Noah's Ark Lab, Hong Kong SAR, China.

headerpayload
AppEncrypted: payload
TLSPlaintext: length, cipher suites, etc.
TCPPlaintext: port, sequence number, etc.
IPPlaintext: IP address, checksum, etc.

Fig. 1. Protocol stack and observable fields in TLS-encrypted traffic. The payload includes visible TLS metadata and encrypted content.

Our findings are as follows.

  • Protocol-visible fields retain useful local contextual dependencies. Their byte dependence is substantially stronger than that measured in ciphertext, and the retained payload structure carries classification-relevant information.

  • Byte dependencies in protocol-visible regions are strongest between adjacent bytes, yet existing contextual pretraining schemes do not fully exploit this local structure. Experiments with ByteBERT and TrafficDCNet show that matching prediction granularity to these dependencies yields more discriminative representations and improves performance over the existing schemes.

  • Cross-view contrastive learning complements contextual prediction. AlignTraffic improves frozen representations over both constituent encoders and exceeds shallow learning in fine-tuned Macro-F1 on the main public tasks. Industrial classification and geographic transfer provide further evidence of its utility, although these gains come with additional computational overhead.

  • The effectiveness of pretraining depends on the available application information and the classification unit. Some encapsulated-traffic and individual-packet settings remain challenging for the evaluated representations.

References (43)