Protocol Fields as Tokens, Not Pixels: Pooling-Free Traffic Grids with Row–Column Attention

A common way to classify network traffic with deep learning is to turn a flow into a picture. Each row is a packet, each column is a byte or bit position, and an ordinary image classifier (a convolutional network that slides small filters over the picture and repeatedly shrinks it) labels the result. This picture has two very different axes, and current pipelines treat them as if they were the same. Down the rows, time moves forward, and a pattern can appear at packet 3 or packet 9 with the same meaning. Across the columns, every position is a fixed protocol field once packets are aligned to a standard header layout: the TTL, a TCP window size, a flag bit. Sliding one filter across columns assumes that "TTL next to checksum" means the same thing as any other neighboring pair. Shrinking the image with pooling (averaging or max-ing neighboring cells) merges unrelated fields and nearby packets.

We propose to build the classifier around this asymmetry. The protocol specification, which is expert knowledge, is used to cut each packet into named fields. Each field becomes a token with its own learned identity. The packet-by-field grid is never downsampled. Convolution runs only along the time axis, and global context comes from attention restricted to rows and columns: one step lets each field look at the other fields in its packet, and another lets it look at the same field across the whole flow. The claim is that, at matched compute, this layout beats both pixel-style 2D CNNs and flattened tabular models on tasks that need evidence spread over many packets. It should also hold up better under concept drift, and it yields per-field importance scores that analysts can check against the fields experts already trust.

Where the directions meet, and what is missing

The traffic-to-image literature shows that end-to-end image models beat handcrafted statistics. On CIC IoT 2023, Hamidouche, Popko & Ouni fold 784 payload bytes into a 23×23 grayscale image and train a LeNet-style CNN. They report 93.28% F1 on 34 attack classes, against 71.00% for Random Forest on manual features, with feature extraction falling from 26 ms to 0.3 ms per packet. SPIN-IDS stacks packets as rows in an RGB grid, with forward and backward directions in separate channels, and reaches 97.7–99% detection on CIC-IDS2017 at about 1.04 ms. Chen et al. supply the most direct warning: shrinking a 39×39 byte matrix to 20×20 cuts compute by 63% but pushes application-level accuracy well below the >85% of the full matrix. All three papers motivate this proposal. Each uses pooling or downsampling, and each packs bytes in a way that creates neighbor relations with no meaning.

nPrint and nPrintML supply the representation we reuse. Every bit is mapped to a fixed header offset, so variable-length headers no longer shift fields between samples. Automated models trained on this layout rediscover TTL, window size and TCP option order, and reach 92.1 F1 on active device fingerprinting against Nmap's 92.2. The same authors name cross-packet temporal modeling as the open problem, and that problem is our target. NetDiffusion already renders nPrint as packet-by-field images, but only for generating synthetic traffic, not for classification.

On the architecture side, TabNet, which classifies the structure of HTML web tables, found that pooling destroys row/column alignment. Removing pooling was needed to reach 91.05% macro-F1, compared with 81.65% for handcrafted features. Isometric networks show that the resolution of the network's internal feature maps, more than the input resolution, governs accuracy. Steganalysis work such as Pibre et al. shows that pooling erases faint pixel-level signals. These results constrain the design: no downsampling anywhere.

The cost of dropping pooling is the receptive field, meaning how much of the input each unit can see. Small filters grow it by only about two cells per layer, the dilution problem described by Li et al.. MeshNet grows the receptive field with a symmetric dilation schedule instead, using filters with gaps between their taps. It reaches DICE 0.876 with 147k parameters on stroke segmentation, but it reports trouble on irregular boundaries. CCNet supplies the routing operator we use. Each position attends only along its own row and column, and two passes give every position a path to every other. It needs 11× less memory than non-local attention and reaches 81.9% mIoU on Cityscapes, but it has never been used on traffic.

DigTraffic is the closest competitor on long-range flow context. It builds message-level interaction graphs and runs a graph transformer, reaching 98.14% accuracy and 97.96% F1 on ISCX-VPN2016. It discards packet contents entirely, using only lengths and timing, and its cost grows quadratically with flow size.

Core Claim

The obvious combination at this intersection is "nPrint image, pooling-free CNN, criss-cross attention." It is not done, but we think it is subtly wrong, because it still treats bit columns as pixels. Our claim is sharper. The right unit on the column axis is the protocol field, embedded by a field-specific encoder with its own identity, so that sharing weights across positions happens only along time. Under that layout, row–column attention plays clean roles: row attention models how fields interact within a packet, and column attention models how a single field evolves across the flow. Pooling is removed because it is semantically wrong on both axes, not merely because it is lossy. We expect this design to outperform pixel-grid CNNs, with or without pooling, on multi-packet tasks. It should also generalize better across time splits. Its column-attention maps should recover the fields that expert tools such as p0f and Nmap rely on, which gives a concrete answer to the interpretability concern Hamidouche et al. raise for security operations centers.

Research Program

The input is the first $P$ packets of a flow. For CIC-IDS2017, SPIN-IDS reports peak accuracy within 4–9 packets, so we sweep $P$ from 1 to 64. Each packet is parsed into nPrint fields for IPv4, TCP and UDP, plus a fixed-length payload block treated as a group of byte fields. Fields absent from a packet are marked by a learned "missing" value rather than zeros. Source and destination addresses are masked, so the model cannot shortcut by memorizing hosts.

Each of the $F$ fields has its own small linear encoder from its bits to a $d$-dimensional vector, plus a learned field-identity embedding. Direction (forward or backward), the inter-arrival time and the packet index are added as row features. The result is a $P \times F \times d$ grid that keeps its full size through every layer. Each block applies a depthwise 1D convolution along the packet axis, a row-attention step and a column-attention step in the criss-cross pattern, and a per-cell feed-forward layer. The final classifier pools only at the very end, across the whole grid.

The cost of one layer is

$$C_{\text{rc}} = O\big(PF(P+F)\,d\big) \quad\text{versus}\quad C_{\text{full}} = O\big((PF)^2 d\big),$$

where $C_{\text{rc}}$ is row–column attention and $C_{\text{full}}$ is full self-attention over all $PF$ cells. The difference follows because each cell attends to $P+F$ others instead of $PF$. For realistic sizes, such as $P=32$ and $F\approx 150$ field tokens, this is roughly a 25× reduction. That matters for gateway-class hardware, but full attention is still feasible on a GPU, so we treat efficiency as secondary and measure it rather than assume it.

The analysis has two strands. First, we read column-attention mass and gradient attributions per field, and test whether the top-ranked fields match the fields that nPrintML's automated selection recovered (TTL, window size, option order) and those that p0f and Nmap use. Second, a column-permutation diagnostic applies one fixed random reordering of field columns to all data. A field-tokenized model with identity embeddings should be essentially unaffected. A pixel CNN that depends on arbitrary column adjacency should change. This tells us whether pixel CNNs exploit meaningful structure or layout artefacts.

Baselines

The naive reference point is a majority-class predictor, together with Random Forest on classic statistical flow features (lengths, inter-arrival times, duration). This reproduces the manual-feature condition of Hamidouche et al., who report 71.00% F1 on CIC IoT 2023 34-class.

The strongest tabular competitor is nPrintML-style AutoML, meaning Random Forest or gradient boosting on flattened nPrint for the same $P$ packets, following Holland et al.. It sees the identical aligned bits, and it reports 92.1 F1 on active fingerprinting.

The strongest image competitors are the 23×23 LeNet-style CNN of Hamidouche et al. (93.28% F1 on CIC IoT 2023 34-class) and SPIN-IDS (97.7–99% on CIC-IDS2017), both reimplemented. The strongest long-range competitor is DigTraffic (98.14% accuracy, 97.96% F1 on ISCX-VPN2016). For ISCX-Tor2016 and QUIC2019, DigTraffic only claims to outperform prior methods, and there is no reported number found on Lacuna for those datasets.

Reported figures come from differing splits and preprocessing. We therefore rerun every baseline on our splits with the same packet budget $P$, the same address masking, and the same hyperparameter search budget, measured in trials and GPU-hours. We also report parameters, FLOPs, and CPU latency per flow.

The ablations isolate the key ingredients. The first keeps our architecture but feeds bit-pixels with shared 2D convolution instead of field tokens; this tests whether field tokenization is the key. The second inserts pooling along the packet axis, the field axis, or both. The third replaces row–column attention with full self-attention at matched FLOPs, with MeshNet-style dilation, and with nothing. Beating the field is defined as a macro-F1 gain over the best rerun baseline that exceeds seed variance across five seeds on at least two multi-packet benchmarks, plus a smaller drop on the time-shifted split. Matching accuracy at lower latency is a weaker but still reportable result.

Why not just…?

Why not just run gradient boosting on flattened nPrint? Fully connected and tree models already treat each column as its own feature, with no false adjacency and no pooling. On single-packet fingerprinting tasks they are near the ceiling: 92.1 F1 and 100% on DTLS handshakes per nPrintML. This is a real threat, and we concede those tasks. Our claim is limited to multi-packet regimes, where flattening $P\times F$ fields loses the information that column $j$ at packet 2 and at packet 9 are the same field. The packet-count sweep settles it. If boosting matches us at every $P$, the architectural claim fails.

Why not just remove pooling from an existing traffic CNN? This is the cheapest version of the idea and is our first ablation. TabNet's result suggests it will help. But the CNN still shares filters across field boundaries, and dilation-only receptive fields degrade on irregular structure, per MeshNet. The permutation diagnostic and the pixel-versus-token ablation show whether removing pooling alone captures most of the gain. If it does, we report that simpler finding.

Why not just use a full transformer over packet-field tokens, or DigTraffic's graph? At these grid sizes full attention is affordable, so CCNet's efficiency argument is weak here, and full attention may match row–column attention in accuracy. We compare the two at matched FLOPs and report both accuracy and gateway latency. If full attention wins, the contribution reduces to field tokenization plus pooling-free design, and we say so. DigTraffic ignores header and payload contents entirely, so a gain from content fields on ISCX-VPN2016 at equal $P$ would show what that omission costs.

Proposed Experiments

The benchmarks are ISCX-VPN2016 at application level, which is the regime where Chen et al. saw downsampling hurt; CIC-IDS2017, with CIC-IDS2018 as a cross-year transfer target; CIC IoT 2023 34-class; and the nPrint active-fingerprinting set as a single-packet control where we expect no advantage. Metrics are macro-F1, accuracy, latency per flow, and activation memory.

We run three decisive checks. The first is the packet-count sweep, which tests whether our margin over flattened-nPrint boosting grows with $P$. A flat or absent margin falsifies the temporal-structure claim. The second is a time-ordered split, training on early capture days and testing on later ones, plus a 2017→2018 transfer to probe the drift Kolcun et al. documents. Field-identity models should degrade less than pixel CNNs. The third combines the column-permutation test with the field-attribution comparison against expert-tool fields. Agreement there would give operators a field-level explanation they can audit, and disagreement would point to fields that the experts' tools ignore.