Paper · 2023-07-31 · cs.LG, cs.AI
TFE-GNN: A Temporal Fusion Encoder Using Graph Neural Networks for Fine-grained Encrypted Traffic Classification
TFE-GNN turns each packet's bytes into a small graph (nodes are byte values, edges where PMI is positive), encodes header and payload graphs with separate GraphSAGE stacks, fuses them with cross-gating, and classifies 50-packet segments with a bidirectional LSTM. Author-reported F1 is 0.9855 on ISCX-Tor and 0.9649 on the self-collected Telegram set.
Graph neural networkLong short-term memory (LSTM)Pointwise mutual informationnetwork-securitytraffic-classificationgraph-neural-network
arXivPDFCodeMarkdown18 min read
AI-compiled by claude-haiku-5-5 on 2026-11-13, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Encrypted network traffic hides what is inside each packet, so a classifier has to work from the raw bytes. Earlier methods mostly summarised a whole connection with statistics such as average packet size. Those numbers are unreliable for short connections, and the bytes themselves were often used without care.
This paper treats the bytes of each packet as a small graph. Each distinct byte value is a node, and two values are linked when they tend to appear near each other across the packet, using a standard word-association score. The packet's header and its payload get separate graphs, because the same byte value means different things in each. A graph neural network turns each graph into one vector, the two vectors are blended with learned gates, and a sequence model reads the packet vectors in order to name the user action.
The paper's pitch is that the model learns from the bytes directly, so it does not depend on flow statistics that are unreliable for short connections.
TL;DR
- Byte-level graphs per packet, with an edge where PMI is positive §3.1.
- Separate header and payload encoders, each four GraphSAGE layers with JKN-style concatenation §3.2 §3.3.
- Cross-gated fusion, then a bidirectional LSTM over a segment and a cross-entropy loss §3.3 §3.4.
- Author-reported: highest F1 on every set in Tables 1 and 2. On ISCX-nonVPN the margin is 0.0005 over ET-BERT tab. 1 tab. 2.
- Cost: 44.0 M parameters and 2.2 GFLOPs in the authors' count, below ET-BERT's tab. 4.
Problem
Flow-level statistics are unreliable when flows are short, because short flows have higher deviation, and flow lengths follow a long-tailed distribution §1 app. B fig. 4. Graph methods built on packet correlations inherit the same statistics problem. Byte-based methods either treat header and payload alike or use each packet's raw bytes only as node features §1.
Assumptions: a passive observer that sees packets but cannot decrypt them app. A. The task is segment-level classification of in-app user actions, such as sending a text or a picture §2.2.
Method
Notation: a traffic segment is an ordered list of packets with timestamps §2.1 eq. 1. Each sample keeps at most 50 packets §4.1.3; the code pads shorter samples with empty packet slots utils.py. Each packet keeps its header bytes and payload bytes as separate inputs §4.1.2 §3.2.
1. Byte-level traffic graph per packet §3.1
A packet's bytes become a graph G = (V, E, X) §3.1. Each node is a byte value, so there are at most 256 nodes, and each node's initial feature is its byte value §3.1. Edges come from point-wise mutual information (PMI) between byte values. The paper keeps an edge when PMI is positive §3.1 eq. 3 and treats the graph as undirected, because PMI is symmetric §3.1.
The paper names PMI but gives no formula. The reference code computes it over sliding windows of 5 bytes (default), inside one packet's bytes, using the window counts described in the Paper vs code section utils.py.
# Byte-level graph for one packet [§3.1] [eq. 3]
# Input: byte_values: list of ints in 0..255 (header or payload bytes)
# Output: edges between distinct byte values with positive PMI
def byte_graph(byte_values, window_size):
# Slide a window of w consecutive bytes over the packet [§3.1]
windows = sliding_windows(byte_values, window_size)
num_windows = len(windows)
# Count the windows that contain each byte value [§3.1]
window_count = count_windows_per_value(windows)
# Count co-occurring pairs of distinct values in one window [§3.1]
pair_count = count_pairs_per_window(windows)
edges = []
for (value_i, value_j), count in pair_count.items():
# PMI from window probabilities; formula from the code, not the
# paper [code: utils.py#L263-L278]
pmi = log(count * num_windows
/ (window_count[value_i] * window_count[value_j]))
# Keep only pairs with positive PMI [§3.1] [eq. 3]
if pmi > 0:
edges.append((value_i, value_j))
return edges2. Dual embedding §3.2
Header and payload each get their own embedding table of K byte values by d0 dimensions, E_header and E_payload, which do not share parameters §3.2. The paper's reason is that one byte value can mean different things in a header and in a payload §3.2.
3. Traffic graph encoder §3.3
Each graph is encoded by stacked GraphSAGE layers with mean aggregation. Per node, the neighbour message is the sum of neighbour vectors divided by the neighbour count. The message and the node's own vector are concatenated, then passed through a linear map, a PReLU and batch normalisation §3.3 eq. 4. The stack is at most 4 layers, because deeper GNNs over-smooth §3.3. The four layer outputs are concatenated per node, as in a Jumping Knowledge Network §3.3 eq. 5. The packet vector g is the mean over nodes §3.3 eq. 6. The header and payload encoders have the same architecture and separate parameters §3.3.
4. Cross-gated feature fusion §3.3
Header vector g_h and payload vector g_p each pass through a filter of two linear layers with a PReLU between them, then a sigmoid gives a gate in [0, 1] §3.3 eq. 7 eq. 8. The header gate filters the payload vector, and the payload gate filters the header vector, then the two are concatenated §3.3 eq. 9. The paper's reasoning is that the header describes the packet, so it should decide what in the payload matters §3.3. Figure 1 shows the architecture fig. 1.
# Cross-gated fusion of one segment's packet vectors [§3.3]
# Inputs: header_vecs, payload_vecs: (B, n, d) packet vectors
# (d = 512 and n = 50 in the reference code [code: model.py#L14])
def fuse(header_vecs, payload_vecs):
# Each gate is a two-layer filter followed by a sigmoid [eq. 7] [eq. 8]
header_gate = sigmoid(header_filter(header_vecs))
payload_gate = sigmoid(payload_filter(payload_vecs))
# The header gate filters the payload and the reverse [eq. 9]
fused = concat(header_gate * payload_vecs,
payload_gate * header_vecs) # (B, n, 2d)
return fused5. Temporal model and loss §3.4
The n fused packet vectors of a segment form a sequence. A bidirectional two-layer LSTM reads it, and a two-layer linear classifier with PReLU gives the class logits. The loss is cross-entropy against the label §3.4 eq. 10. The paper also tried a transformer layer in place of the LSTM §3.4 and reports it in the ablation tab. 3.
# Segment-level prediction [§3.4] [eq. 10]
# Inputs: fused: (B, n, 2d) fused packet vectors from the step above
def predict(fused):
# Bidirectional two-layer LSTM over the packet sequence [§3.4]
states = bidirectional_lstm(fused)
# Two-layer classifier with PReLU [§3.4]
logits = classifier(states)
# Training minimises cross-entropy against the label [eq. 10]
return logitsHyperparameters
Paper values come from the text §4.1.3 unless stated. Code values are per dataset in the order ISCX-VPN / ISCX-nonVPN / ISCX-Tor / ISCX-nonTor config.py. "not stated" means the paper does not give the value.
| Name | Paper | Code (VPN / nonVPN / Tor / nonTor) | Where |
|---|---|---|---|
| Packets per segment | 50 §4.1.3 | 50 (all) | config.py |
| Payload bytes per packet | 150 §4.1.3 | 150 (all) | config.py |
| Header bytes per packet | 40 §4.1.3 | 40 (all) | config.py |
| Overlong segment cut-off | over 10000 packets dropped §4.1.2 | 10000 (all) | config.py utils.py |
| PMI window size | 5 default §4.1.3 §4.6 | 5 | config.py |
| Node embedding size | 50 default §4.6 | 64 / 64 / 64 / 64 | config.py config.py config.py config.py |
| GraphSAGE layers | up to 4 §3.3 | 4 | model.py |
| GNN hidden width | not stated | 128 (all) | config.py config.py config.py config.py |
| Packet vector width | not stated | 512 (4 layers x 128) | model.py model.py |
| Dropout on GNN inputs | 0.2 §4.1.3 | 0.2 / 0.1 / 0.0 / 0.05 | config.py config.py config.py config.py |
| Dropout placement | not stated | on inputs of the first three layers only | model.py |
| LSTM dropout | not stated | 0.0 / 0.15 / 0.0 / 0.1 | config.py config.py config.py config.py |
| LSTM | bidirectional, 2 layers §3.4 | bidirectional, 2 layers, hidden 1024 per direction | model.py |
| Classifier | 2 linear layers with PReLU §3.4 | 2048 → 512 (PReLU) → classes | model.py |
| Activation in the filters | PReLU §3.3 | PReLU with 50 learned slopes, one per packet slot | model.py model.py |
| Loss | cross-entropy §3.4 eq. 10 | cross-entropy | train.py |
| Label smoothing | not stated | 0 / 0.01 / 0 / 0 | config.py config.py config.py config.py |
| Batch size | 512 §4.1.3 | 32 / 102 / 32 / 102 | config.py config.py config.py config.py |
| Gradient accumulation | not stated | 1 / 5 / 1 / 5 | config.py config.py config.py config.py train.py |
| Epochs | 120 maximum §4.1.3 | 20 / 120 / 100 / 120 | config.py config.py config.py config.py |
| Optimiser | Adam §4.1.3 | Adam, weight decay 0 | train.py config.py |
| Initial learning rate | 1e-2 §4.1.3 | 1e-2 (all) | config.py config.py config.py config.py |
| Final learning rate | 1e-4, decays "gradually" §4.1.3 | 1e-4 / 1e-5 / 1e-4 / 1e-4 | config.py config.py config.py config.py |
| Warm-up | ratio 0.1 §4.1.3 | 0.1, linear, over 10% of mini-batches | config.py train.py optim.py |
| Schedule shape after warm-up | not stated | cosine annealing | train.py |
| Random seed | not stated | 32 | config.py utils.py |
| Repetitions | 10 runs, averaged §4.1.3 | one run per call of train.py | train.py |
| Classes | VPN and nonVPN 6, Tor and nonTor 8 §4.1.1 | 6 / 6 / 8 / 8 | config.py config.py config.py config.py |
| Train/test split | 9:1, stratified §4.1.1 | per class: first floor(n/10)+1 segments to test, rest to train | preprocess.py |
| Max segments per class | not stated | 9999 | config.py config.py config.py config.py |
| Tor segment blocks | 60 s non-overlapping blocks, ISCX-Tor only §4.1.1 | 60 s blocks for iscx-tor only | preprocess.py utils.py |
| Embedding rows | K byte values §3.2 | 257 (256 values plus a pad index) | model.py config.py |
Results
Author-reported. Setup: seven result sets from two datasets, the self-collected WWT data (WeChat, WhatsApp, Telegram) and the public ISCX VPN-nonVPN and Tor-nonTor data §4.1.1, 9:1 train/test split §4.1.1, each experiment run 10 times and averaged on one RTX 3080 with PyTorch §4.1.3. Baselines are listed in §4.1.3; the paper does not say whether baseline numbers were re-run or copied. The tables show single values with no spread.
Table 1, WWT (self-collected), tab. 1. The paper's F1 for TFE-GNN is 0.9946 (WeChat), 0.9961 (WhatsApp) and 0.9649 (Telegram).
| Model | WeChat AC | WeChat PR | WeChat RC | WeChat F1 | WhatsApp AC | WhatsApp PR | WhatsApp RC | WhatsApp F1 | Telegram AC | Telegram PR | Telegram RC | Telegram F1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AppScanner | 0.9927 | 0.9908 | 0.9904 | 0.9905 | 0.9790 | 0.9688 | 0.9601 | 0.9628 | 0.8379 | 0.8154 | 0.8653 | 0.8304 |
| K-FP | 0.9741 | 0.9665 | 0.9630 | 0.9645 | 0.9710 | 0.9589 | 0.9515 | 0.9526 | 0.8797 | 0.8378 | 0.8990 | 0.8567 |
| FlowPrint | 0.7429 | 0.5302 | 0.6380 | 0.5532 | 0.6197 | 0.3820 | 0.4934 | 0.3880 | 0.4833 | 0.4025 | 0.5000 | 0.4311 |
| CUMUL | 0.9472 | 0.9497 | 0.9412 | 0.9390 | 0.9855 | 0.9835 | 0.9699 | 0.9756 | 0.8330 | 0.7980 | 0.8471 | 0.8053 |
| GRAIN | 0.9404 | 0.9366 | 0.9369 | 0.9251 | 0.9724 | 0.9685 | 0.9475 | 0.9550 | 0.8003 | 0.7615 | 0.7903 | 0.7407 |
| FAAR | 0.9873 | 0.9863 | 0.9847 | 0.9854 | 0.9790 | 0.9683 | 0.9566 | 0.9597 | 0.8184 | 0.7884 | 0.8507 | 0.8018 |
| ETC-PS | 0.9863 | 0.9864 | 0.9831 | 0.9846 | 0.9833 | 0.9743 | 0.9685 | 0.9703 | 0.8477 | 0.8295 | 0.8710 | 0.8382 |
| FS-Net | 0.9223 | 0.9446 | 0.9196 | 0.8964 | 0.9942 | 0.9949 | 0.9919 | 0.9933 | 0.8469 | 0.8161 | 0.8744 | 0.8272 |
| DF | 0.9800 | 0.9757 | 0.9751 | 0.9751 | 0.8978 | 0.7954 | 0.8406 | 0.8143 | 0.8251 | 0.8206 | 0.8542 | 0.7960 |
| EDC | 0.9746 | 0.9653 | 0.9625 | 0.9620 | 0.9732 | 0.9589 | 0.9526 | 0.9546 | 0.8153 | 0.8118 | 0.8372 | 0.7896 |
| FFB | 0.9675 | 0.9691 | 0.9661 | 0.9644 | 0.9350 | 0.8957 | 0.8767 | 0.8708 | 0.7990 | 0.7630 | 0.8169 | 0.7802 |
| MVML | 0.9643 | 0.9519 | 0.9540 | 0.9526 | 0.9456 | 0.9302 | 0.9009 | 0.8971 | 0.7943 | 0.7413 | 0.7636 | 0.7340 |
| ET-BERT | 0.9505 | 0.9368 | 0.9285 | 0.9266 | 0.9107 | 0.8934 | 0.8697 | 0.8439 | 0.7679 | 0.8712 | 0.7989 | 0.7858 |
| GraphDApp | 0.8763 | 0.8368 | 0.8378 | 0.8330 | 0.8753 | 0.7615 | 0.8060 | 0.7791 | 0.7766 | 0.7575 | 0.7627 | 0.7227 |
| ECD-GNN | 0.9863 | 0.9847 | 0.9830 | 0.9835 | 0.9811 | 0.9722 | 0.9647 | 0.9672 | 0.1810 | 0.0353 | 0.1641 | 0.0528 |
| TFE-GNN | 0.9956 | 0.9953 | 0.9939 | 0.9946 | 0.9971 | 0.9957 | 0.9966 | 0.9961 | 0.9586 | 0.9584 | 0.9742 | 0.9649 |
Table 2, public ISCX sets, tab. 2. Columns: AC, PR, RC, F1 for each set.
| Model | VPN AC | VPN PR | VPN RC | VPN F1 | nonVPN AC | nonVPN PR | nonVPN RC | nonVPN F1 | Tor AC | Tor PR | Tor RC | Tor F1 | nonTor AC | nonTor PR | nonTor RC | nonTor F1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AppScanner | 0.8889 | 0.8679 | 0.8815 | 0.8722 | 0.7576 | 0.7594 | 7465 (as printed) | 0.7486 | 0.7543 | 0.6629 | 0.6042 | 0.6163 | 0.9153 | 0.8435 | 0.8140 | 0.8273 |
| K-FP | 0.8713 | 0.8750 | 0.8748 | 0.8747 | 0.7551 | 0.7478 | 0.7354 | 0.7387 | 0.7771 | 0.7417 | 0.6209 | 0.6313 | 0.8741 | 0.8653 | 0.7792 | 0.8167 |
| FlowPrint | 0.8538 | 0.7451 | 0.7917 | 0.7566 | 0.6944 | 0.7073 | 0.7310 | 0.7131 | 0.2400 | 0.0300 | 0.1250 | 0.0484 | 0.5243 | 0.7590 | 0.6074 | 0.6153 |
| CUMUL | 0.7661 | 0.7531 | 0.7852 | 0.7644 | 0.6187 | 0.5941 | 0.5971 | 0.5897 | 0.6686 | 0.5349 | 0.4899 | 0.4997 | 0.8605 | 0.8143 | 0.7393 | 0.7627 |
| GRAIN | 0.8129 | 0.8077 | 0.8109 | 0.8027 | 0.6667 | 0.6532 | 0.6664 | 0.6567 | 0.6914 | 0.5253 | 0.5346 | 0.5234 | 0.7895 | 0.6714 | 0.6615 | 0.6613 |
| FAAR | 0.8363 | 0.8224 | 0.8404 | 0.8291 | 0.7374 | 0.7509 | 0.7121 | 0.7252 | 0.6971 | 0.5915 | 0.4876 | 0.4814 | 0.9103 | 0.8253 | 0.7755 | 0.7959 |
| ETC-PS | 0.8889 | 0.8803 | 0.8937 | 0.8851 | 0.7273 | 0.7414 | 0.7133 | 0.7208 | 0.7486 | 0.6811 | 0.5929 | 0.6033 | 0.9365 | 0.8700 | 0.8311 | 0.8486 |
| FS-Net | 0.9298 | 0.9263 | 0.9211 | 0.9234 | 0.7626 | 0.7685 | 0.7534 | 0.7555 | 0.8286 | 0.7487 | 0.7197 | 0.7242 | 0.9278 | 0.8368 | 0.8254 | 0.8285 |
| DF | 0.8012 | 0.7799 | 0.8152 | 0.7921 | 0.6742 | 0.6857 | 0.6717 | 0.6701 | 0.6514 | 0.4803 | 0.4767 | 0.4719 | 0.8568 | 0.8003 | 0.7415 | 0.7590 |
| EDC | 0.7836 | 0.7747 | 0.8108 | 0.7888 | 0.6970 | 0.7153 | 0.7000 | 0.6978 | 0.6400 | 0.4980 | 0.4528 | 0.4504 | 0.8692 | 0.7994 | 0.7411 | 0.7451 |
| FFB | 0.8304 | 0.8714 | 0.8149 | 0.8335 | 0.7020 | 0.7274 | 0.6945 | 0.7050 | 0.6343 | 0.4870 | 0.5203 | 0.4952 | 0.8954 | 0.7545 | 0.7430 | 0.7430 |
| MVML | 0.6491 | 0.7231 | 0.6198 | 0.6151 | 0.5126 | 0.5751 | 0.4707 | 0.4806 | 0.6343 | 0.3914 | 0.4104 | 0.3752 | 0.7235 | 0.5488 | 0.5512 | 0.5457 |
| ET-BERT | 0.9532 | 0.9436 | 0.9507 | 0.9463 | 0.9167 | 0.9245 | 0.9229 | 0.9235 | 0.9543 | 0.9242 | 0.9606 | 0.9397 | 0.9029 | 0.8560 | 0.8217 | 0.8332 |
| GraphDApp | 0.6491 | 0.5668 | 0.6103 | 0.5740 | 0.4495 | 0.4230 | 0.3647 | 0.3614 | 0.4286 | 0.2557 | 0.2509 | 0.2281 | 0.6936 | 0.5447 | 0.5398 | 0.5352 |
| ECD-GNN | 0.1111 | 0.0185 | 0.1667 | 0.0333 | 0.0606 | 0.0101 | 0.1667 | 0.0190 | 0.0571 | 0.0071 | 0.1250 | 0.0135 | 0.9078 | 0.8015 | 0.8168 | 0.7977 |
| TFE-GNN | 0.9591 | 0.9526 | 0.9593 | 0.9536 | 0.9040 | 0.9316 | 0.9190 | 0.9240 | 0.9886 | 0.9792 | 0.9939 | 0.9855 | 0.9390 | 0.8742 | 0.8335 | 0.8507 |
The paper's text says TFE-GNN is best on all ISCX sets except nonVPN, where ET-BERT is "similar" §4.2. The printed F1 gap there is 0.9240 against 0.9235.
Ablation, tab. 3. Each cell is ISCX-VPN | ISCX-Tor. "H" is header, "P" is payload, "DUAL" is dual embedding, "JKN" is the concatenation over layers, "CGFF" is cross-gated fusion, and "A&N" is activation and batch normalisation §4.3.
| Variant | AC | PR | RC | F1 |
|---|---|---|---|---|
| w/o P (header only) | 0.8713 | 0.9874 | 0.8261 | 0.9788 | 0.8228 | 0.9934 | 0.8230 | 0.9806 |
| w/o H (payload only) | 0.8051 | 0.8726 | 0.8232 | 0.7780 | 0.7957 | 0.7809 | 0.7980 | 0.7700 |
| w/o DUAL | 0.9310 | 0.9829 | 0.9149 | 0.9747 | 0.9209 | 0.9801 | 0.9173 | 0.9760 |
| w/o JKN | 0.9474 | 0.9790 | 0.9365 | 0.9736 | 0.9397 | 0.9879 | 0.9374 | 0.9795 |
| w/o CGFF | 0.9445 | 0.9800 | 0.9329 | 0.9717 | 0.9371 | 0.9847 | 0.9339 | 0.9770 |
| w/o A&N | 0.6105 | 0.2212 | 0.5576 | 0.0555 | 0.5487 | 0.1180 | 0.5289 | 0.0548 |
| w/ SUM aggregation | 0.8497 | 0.8194 | 0.8549 | 0.7287 | 0.8380 | 0.6986 | 0.8426 | 0.6891 |
| w/ MAX aggregation | 0.8480 | 0.9870 | 0.8328 | 0.9752 | 0.8115 | 0.9778 | 0.8094 | 0.9751 |
| w/ GRU downstream | 0.8550 | 0.8932 | 0.8489 | 0.8702 | 0.8287 | 0.8664 | 0.8294 | 0.8610 |
| w/ Transformer downstream | 0.6754 | 0.9777 | 0.5706 | 0.9753 | 0.5992 | 0.9820 | 0.5658 | 0.9828 |
| TFE-GNN (default) | 0.9591 | 0.9886 | 0.9526 | 0.9792 | 0.9593 | 0.9939 | 0.9536 | 0.9855 |
The paper's own reading: headers matter more than payloads, and the gap is 2.5 F1 points on VPN and 21.06 on Tor (the "w/o P" row minus the "w/o H" row, see the Pitfalls) §4.3. Dual embedding adds 3.63 and 0.95 F1 points §4.3.
GNN variants, fig. 2. On Telegram, ISCX-VPN and ISCX-Tor, GraphSAGE gives the best F1 of GAT, GIN, GCN, SGC and GraphSAGE. Values are only in the figure, so no numbers are given here §4.4.
Complexity, tab. 4. FLOPs in millions and parameters in millions.
| Model | FLOPs (M) | Parameters (M) |
|---|---|---|
| FS-Net | 1.0e+2 | 3.2e+0 |
| DF | 2.8e+0 | 9.3e-1 |
| EDC | 2.2e+1 | 2.2e+1 |
| FFB | 2.6e+2 | 1.7e+0 |
| MVML | 7.2e-4 | 3.7e-4 |
| ET-BERT | 1.1e+4 | 8.6e+1 |
| GraphDApp | 3.8e-2 | 1.1e-2 |
| ECD-GNN | 2.9e+1 | 1.4e+0 |
| TFE-GNN | 2.2e+3 | 4.4e+1 |
The paper says ET-BERT needs about five times TFE-GNN's FLOPs and twice its parameters, and that ET-BERT's pre-training is costly §4.5.
Sensitivity, fig. 3. Embedding dimension: F1 rises quickly below 100 and then levels off, so 50 is the default for cost reasons §4.6. PMI window: a smaller window gives better F1, because larger windows make graphs too dense §4.6. Segment length: shorter gives better F1 §4.6. The figure values are not given in the text.
Paper vs code
Code: github.com/ViktorAxelsen/TFE-GNN at code_commit above, Apache-2.0.
The owner's GitHub profile is named Haozhen Zhang, the paper's first author,
and the README calls the repository the official implementation. The paper
and arXiv do not link it; the arXiv comment says code "will be available"
later. I accepted it because the owner is an author. Reading the code, I found
the following differences. Each line gives the paper's statement and the code's.
- Embedding size. Paper default is 50 §4.6. Code uses 64 for all four datasets config.py config.py config.py config.py.
- Batch size. Paper states 512 §4.1.3. Code uses 32 on VPN and Tor config.py config.py, and 102 with 5-step gradient accumulation on nonVPN and nonTor config.py config.py config.py config.py. The optimiser step thus sees 510 segments on nonVPN and nonTor train.py. This is derived from the code, not stated.
- Epochs. Paper states a maximum of 120 §4.1.3. Code uses 20 on VPN config.py, 120 on nonVPN config.py, 100 on Tor config.py, and 120 on nonTor config.py.
- Dropout. Paper states 0.2 §4.1.3. Code uses 0.2 / 0.1 / 0.0 / 0.05 config.py config.py config.py config.py, applied to the inputs of the first three GraphSAGE layers only model.py. The LSTM dropout, which the paper does not mention, is 0.0 / 0.15 / 0.0 / 0.1 config.py config.py config.py config.py.
- Final learning rate. Paper states 1e-4 §4.1.3. Code uses 1e-5 on nonVPN config.py and 1e-4 on the others config.py config.py config.py.
- Schedule. Paper says "gradually decays" with no shape §4.1.3. Code uses linear warm-up over 10% of mini-batches, then cosine annealing train.py optim.py. The scheduler steps after every mini-batch, not after every optimiser step train.py, so the warm-up counts batches.
- Label smoothing. Not in the paper. Code uses 0.01 on nonVPN only config.py; the others use 0 config.py config.py config.py.
- Train/test split. Paper says stratified 9:1 §4.1.1. Code keeps the first 9999 segments per class in directory-listing order, then sends the first floor(n/10)+1 to test and the rest to train, with no shuffling preprocess.py config.py.
- Packet filtering. Paper says bad packets and retransmissions are removed §4.1.2. Searching the repository for "retrans" and "bad packet" finds nothing. Among the filters in the paper, the code drops payload-less packets and overlong segments utils.py utils.py; no retransmission filter appears.
- Header bytes. Paper says the Ethernet header, IP addresses and ports are removed §4.1.2.
remove()is written for bytes that start at the IP header utils.py, butpcap2npy.pystores the whole frame from the Ethernet header on pcap2npy.py pcap2npy.py. Counting slice offsets by hand for an Ethernet frame:remove()keeps bytes 0–11 (the two MAC addresses) and bytes 24 onward, so it drops the EtherType and IP bytes 0–9 and keeps the IP addresses and the ports. It does not strip the Ethernet header. I did not run this. - Header and payload alignment. For header samples, the code filters the header list by header length, which is non-zero for every captured frame, and the payload list by payload length. Payload samples drop packets with no payload, but header samples keep them. The two 50-packet samples can therefore cover different packets utils.py utils.py utils.py. The paper does not state this and the code does not check it. The same pattern is in the Tor path.
- PMI formula. Paper gives none §3.1. Code uses log( count × N / (f_i × f_j) ), where N is the number of windows, f_i is the number of windows containing value i, and count is the number of co-occurring position pairs utils.py. Edges with PMI ≤ 0 are dropped utils.py.
- Nodes. Paper says each distinct byte value is one node, at most 256 §3.1. Code builds nodes only from values that have a positive-PMI edge utils.py, and the pad value 256 can be a node, giving up to 257 config.py model.py.
- Self-loops. Code adds a self-loop to every graph utils.py. Paper does not mention them.
- Window scope. Code applies the sliding window within one packet's byte row, so each packet gets its own graph preprocess.py utils.py. Section 1 says there is one vector per packet §1, but Section 3 does not say whether windows may cross packet boundaries.
- PReLU slopes. Code's gate filters use PReLU with 50 learned slopes, one per packet slot, not one per channel model.py model.py. Paper says only "PReLU" §3.3.
- LSTM width. Paper does not state the hidden size. Code uses 1024 per direction, so 2048 concatenated states feed the classifier model.py model.py.
- GraphSAGE details. Code passes mean aggregation, PReLU and batch norm to DGL's
SAGEConvmodel.py. The order of the linear map, activation and norm lives inside DGL, not in this repository. - Tor blocks. Paper says 60-second non-overlapping blocks, for ISCX-Tor §4.1.1. Code does that for iscx-tor only preprocess.py. Code drops a trailing partial minute utils.py. Not stated in the paper.
- Runs. Paper says 10 runs averaged §4.1.3. The repository sets one seed, 32 config.py utils.py, and
train.pyruns once per call train.py. - Evaluation. The paper's "macro F1" matches the macro average that scikit-learn's
classification_reportprints test.py. This is an inference from the code. The model is the last epoch's checkpoint train.py; no validation split appears in the code. - WWT data. The paper's self-collected WWT data §4.1.1 has no configuration here. The repository configures only the four ISCX sets config.py.
- Matches. Segment and packet truncation (50 / 150 / 40) and the 10000-packet cut-off agree with the paper §4.1.3 §4.1.2 config.py. Cross-gated fusion follows eqs. 7–9 model.py. Dual embedding, JKN concatenation and mean pooling match model.py model.py.
Pitfalls
- "10.82%" and "4.58%" are absolute F1 gaps, not relative. Telegram: 0.9649 − 0.8567 (K-FP, the best baseline there) = 0.1082. ISCX-Tor: 0.9855 − 0.9397 (ET-BERT) = 0.0458 §1 tab. 1 tab. 2.
- Ablation cells are ISCX-VPN | ISCX-Tor. The text's header-vs-payload gap of 2.5 points on VPN equals 0.8230 − 0.7980, which fits the VPN-first reading tab. 3 §4.3.
- Table typo. AppScanner's ISCX-nonVPN recall is printed as "7465" tab. 2. Read it as a transcription error, not a value; the paper does not say what it should be.
- Padding creates empty graphs. Segments shorter than 50 packets are padded at the end with whole packets of byte value 256 utils.py utils.py. A packet of one repeated value has no pairs, so its graph has no edges and no nodes utils.py utils.py. How DGL pools a zero-node graph was not checked here.
- The LSTM reads the padding. Code feeds all 50 slots without packing model.py dataloader.py. For short segments, the forward final state comes after the padding slots model.py.
- The pad value is a graph node. In a packet shorter than 150 bytes, pad value 256 is counted like any byte value, so it can form PMI edges with real byte values utils.py model.py.
- Warm-up counts batches.
num_stepsis batches × epochs train.py, so the 10% warm-up is a share of mini-batches, not of optimiser steps. - No validation set. The paper does not say which split the ablation and sensitivity runs use. The code has no validation split, so any tuning on those runs is not separated from the test split §4.3 §4.6 preprocess.py.
- No spread. Tables show one value per cell although the paper says 10 averaged runs §4.1.3.
- Baseline provenance is not stated. Whether the baseline rows were re-run is not stated; ECD-GNN's near-zero rows on several sets are reported as is tab. 1 tab. 2.
- Model size. The paper's 44.0 M parameters and 2.2 GFLOPs tab. 4 are the authors' figures. The widest layer in the code is the LSTM, at 1024 per direction model.py. I did not count parameters.
- Graph topology is fixed before training. The paper lists this as a limitation, along with byte-level noise and no use of byte timing §6.
Lineage
- Builds on: GraphSAGE (mean aggregation and concatenation) §3.3; Jumping Knowledge Networks for the layer concatenation §3.3; PReLU and batch normalisation §3.3; message-passing GNNs §2.3; PMI, a word-association measure from NLP §3.1; and BLJAN, which uses cosine similarity between bytes §3.1.
- Compared against: flow-statistic methods (AppScanner, CUMUL, K-FP, FlowPrint, GRAIN, FAAR, ETC-PS), deep methods (FS-Net, EDC, FFB, MVML, DF, ET-BERT), and GNN methods (GraphDApp, ECD-GNN) §4.1.3. The paper calls ET-BERT a large model with heavy pre-training §4.2 §4.5.
- Superseded by: not known from wiki content. The repository README names two follow-up works from the same owner, CLE-TFE and MH-Net, which I did not read.
Source and license
Adapted from “TFE-GNN: A Temporal Fusion Encoder Using Graph Neural Networks for Fine-grained Encrypted Traffic Classification” by Haozhen Zhang, Le Yu, Xi Xiao, Qing Li, Francesco Mercaldo, Xiapu Luo, Qixu Liu (arXiv:2307.16713), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/ViktorAxelsen/TFE-GNN at commit e62cb9f1e8b5 (Apache-2.0). Any quoted code is shown under that license.