PLM-NIDS: A Protocol-Language Model for Network Intrusion Detection from Raw Packet Sequences Using RWKV State-Space Models (Without Deep Packet Inspection)

Vivek Kumar Sharma · 2026

Read PLM-NIDS: A Protocol-Language Model for Network Intrusion Detection from Raw Packet Sequences Using RWKV State-Space Models (Without Deep Packet Inspection) by Vivek Kumar Sharma (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2606-00155.txt.

Introduction

Sharma treats web traffic as a tongue with its own grammar. Guards face a bind in web defense work. The flows that hide the most risk are locked by strong codes. Byte checks inside those flows yield nothing. He asks if the beat of a flow can betray an attack.

His tool, PLM-NIDS, reads just head data from each packet. That means length, gaps, flags, and port hashes. A state-space model learns the shape of clean flows from a large set of plain runs. Attack flows break that shape, and a doubt score flags them. The score sorts clean from bad flows with strong marks. It needs no attack tags to learn, and it runs packet by packet.

Catalog record

CREATORVivek Kumar Sharma
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE40 KB
LICENSEhttp://creativecommons.org/licenses/by-sa/4.0/
RIGHTSCC BY SA
SOURCEarXiv

Source: https://arxiv.org/abs/2606.00155

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

PLM-NIDS: A Protocol-Language Model for Network Intrusion Detection from Raw Packet Sequences Using RWKV State-Space Models (Without Deep Packet Inspection) Vivek Kumar Sharma Abstract Modern network intrusion detection systems (NIDS) are caught in a structural contradiction: the protocols carrying the highest threat intelligence are precisely those encrypted under TLS 1.3 and QUIC, where payload inspection yields nothing. We ask a simpler question— what if the attack signature is not in the bytes, but in the rhythm? —and answer it by treating network flows as a language whose grammar is written entirely in L3/L4 packet metadata: length, inter-arrival time, TTL, TCP flags, and hashed port numbers. We present PLM-NIDS , which proves three claims in sequence. (1) The grammar exists and is learnable : a RWKV-4 state-space model trained on 344,232 unlabelled Monday flows achieves a causal LM validation loss of 0.204, demonstrating that benign traffic has predictable, statistically consistent structure. (2) Attacks violate this grammar : the per-flow perplexity score cleanly separates benign from attack flows with PR-AUC = 0.93 using zero attack labels at training time . (3) This separation is architecturally non-trivial : an LSTM trained on identical token sequences degenerates to a majority-class predictor (ROC-AUC ≈ \approx 0.50, F1 = 0.91 by always predicting “attack”), proving that RWKV’s causal pre-training provides an inductive bias unavailable to direct classifiers. Supervised fine-tuning further raises PR-AUC to 0.94 and ROC-AUC to 0.75, with a precision of 97.7% at the calibrated operating threshold. The RWKV backbone’s O(T) recurrent inference enables per-packet streaming without flow buffering, making PLM-NIDS operationally viable at line rate. Because it reads only IP/TCP/UDP headers, it is inherently encryption-agnostic: TLS 1.3, QUIC, and future encrypted protocols are handled transparently. Keywords: network intrusion detection, state-space models, RWKV, protocol language model, DPI-free, anomaly detection, CIC-IDS-2017 1 Introduction 1.1 The Problem: DPI Is Structurally Broken for Encrypted Traffic Deep Packet Inspection has served as the backbone of commercial NIDS for two decades. But its fundamental assumption—that payloads carry the distinguishing signature of an attack—is increasingly invalid. TLS 1.3 now accounts for over 90% of HTTPS connections [ 2 ] , and QUIC is displacing TCP for high-throughput applications. When payloads are encrypted, DPI-based signatures simply do not fire. The attacker’s traffic looks identical to the defender’s legitimate data at the byte level. The standard ML response—extract statistical features with tools like CICFlowMeter [ 1 ] and train a classifier—suffers from the same underlying problem. CICFlowMeter performs application-layer parsing to compute its 80+ features; it is a DPI tool wrapped in a Python interface. Systems built on it inherit its brittleness: they break on protocol version changes, require maintenance as traffic evolves, and cannot extract meaningful features from truly opaque encrypted streams. 1.2 Our Insight: Protocol Grammar Lives in the Metadata Our central observation is that the behavioural signature of a protocol—and of an attack—is encoded in packet metadata, not in payload bytes. Consider: • A TCP handshake produces a stereotyped SYN \to SYN-ACK \to ACK timing and flag sequence. • A bulk HTTP/2 download generates large forward packets with small backward ACKs in a characteristic rhythm. • A DoS Slowloris attack holds connections open with tiny, infrequent packets—a pattern visible purely in inter-arrival times and lengths. • An SSH brute-force produces many short, symmetrical flows to port 22 with a metronomic cadence. None of these signatures require reading a single application byte. The grammar of normal and abnormal behaviour is inscribed in the timing, sizing, and flag patterns of packets. 1.3 Our Approach: Language Modelling on Protocol Tokens We formalise this insight as a language modelling problem. Each packet is converted to a 9-token tuple encoding direction, binned length, binned inter-arrival time, binned TTL, L4 protocol, and hashed source/destination ports—all derivable from standard NIC headers. A network flow becomes a token sequence, and the problem of modelling normal traffic becomes the problem of training a language model on these sequences. We choose RWKV-4 [ 7 ] as the backbone for two reasons. First, its O(T) recurrent computation versus the O(T 2 ) attention of Transformers [ 10 ] is critical for long flows (DoS attacks can exceed 1,000 tokens per flow). Second, its streaming step() API processes each packet the instant it arrives, updating a compact per-flow hidden state without requiring the complete flow to be buffered—a fundamental requirement for line-rate detection. 1.4 What We Claim and Prove This paper makes and empirically validates three claims on 2.7 million real-world flows from CIC-IDS-2017 [ 9 ] : C1. Benign traffic grammar is learnable from unlabelled data. A RWKV causal LM trained on benign-only flows converges to validation loss = 0.204 within 10 epochs, demonstrating statistically consistent structure in normal enterprise traffic. C2. Attacks violate this grammar in a detectable way. Per-flow perplexity scores—computed without any attack labels—achieve PR-AUC = 0.93, with precision = 0.977 at the calibrated operating threshold. C3. The RWKV architecture is essential; the tokens alone are insufficient. An LSTM trained on the same token sequences achieves ROC-AUC = 0.50 (equivalent to random), exposing that its apparent F1 = 0.91 is an artefact of majority-class prediction. RWKV’s causal pre-training provides an inductive bias—an anchor in “what normal looks like”—that prevents this collapse. Contributions. (1) A DPI-free, 9-token-per-packet tokenisation scheme derived purely from L3/L4 headers, forming a compact closed vocabulary of 227 tokens. (2) A two-phase training strategy: unsupervised causal LM pre-training on benign-only traffic (Phase 1), followed by optional supervised fine-tuning (Phase 2). (3) Empirical proof that RWKV’s causal pre-training is architecturally necessary —not just beneficial—through the LSTM collapse experiment. (4) A streaming per-flow inference pipeline with O(1) memory per active flow and O(T) compute per flow, enabling deployment at network line rate. 2 Background and Related Work 2.1 Signature-Based NIDS and the DPI Bottleneck Systems such as Snort [ 8 ] and Suricata maintain curated rule databases and match packet payloads against known attack signatures. They achieve high precision on known threats but are blind to zero-day attacks by construction, and fail completely when payloads are encrypted. Their rule bases require continuous expert maintenance as protocols evolve—a cost that scales with the diversity of the network. 2.2 Feature-Engineered ML: DPI in Disguise The dominant ML approach to NIDS uses CICFlowMeter or equivalent tools to extract 80+ per-flow statistical features (packet lengths, inter-arrival times, flag counts, etc.) from raw PCAPs [ 1 , 9 ] . Random Forest and XGBoost classifiers trained on these features achieve strong results on standard benchmarks. However, this approach has three fundamental limitations: (i) features require a complete flow before classification, precluding early detection; (ii) CICFlowMeter performs application-layer parsing internally, making these “DPI-free” claims misleading; and (iii) the feature set requires re-engineering as protocols change. 2.3 Deep Learning on Raw Traffic CNNs operating on raw packet bytes [ 12 ] and LSTMs on packet-length sequences [ 5 ] have been proposed as parser-free alternatives. Both approaches suffer from the same fundamental limitation: they depend on payload bytes that are unavailable under encryption. Header-restricted approaches—such as traffic fingerprinting from timing and size side-channels—are closer in spirit to our work but do not frame the problem as language modelling. 2.4 Transformer-Based Pre-training for Network Security ET-BERT [ 4 ] applies BERT pre-training to the first bytes

Read the complete text