# 流量分类（计算机网络）

流量分类的任务是将网络流量归入应用、协议或服务类别——可以逐包进行，也可以逐流进行——以便网络运营者实施服务质量策略、安全监控和流量管理。通常的分析单元是流：在一个时间窗口内共享同一五元组（源 IP 地址、目的 IP 地址、源端口、目的端口，以及 TCP 或 UDP 等传输协议）的所有数据包。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> 输出通常是逐流或逐包的标签，有时归入应用类别。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> 随着基于载荷的方法在加密环境下式微，对加密后仍可观测的统计模式进行建模的机器学习方法得到了越来越多的采用。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup>

| 关键事实 | 数值 |
|---|---|
| 流键 | 五元组：源 IP、目的 IP、源端口、目的端口、传输协议<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> |
| 基于端口的准确率 | 逐流 50–70%；约 69% 的字节分类正确<sup>[2](https://doi.org/10.1145/1071690.1064220)</sup><sup> • </sup><sup>[3](https://www.cl.cam.ac.uk/research/srg/netos/papers/2005-moore2005toward.pdf)</sup> |
| 深度包检测上限 | 载荷不超过 1 KB 时约 79% 的字节；解析 FTP 控制通道时达 98%<sup>[3](https://www.cl.cam.ac.uk/research/srg/netos/papers/2005-moore2005toward.pdf)</sup> |
| 早期统计机器学习 | 朴素贝叶斯逐流约 65%；结合核估计与 FCBF 精化后超过 95%<sup>[2](https://doi.org/10.1145/1071690.1064220)</sup> |
| 早期分类 | TCP 流的前 4–5 个包、UDP 流的前 1–2 个包即可满足需要<sup>[4](https://conferences.sigcomm.org/co-next/2010/CoNEXT_papers/09-Lim.pdf)</sup> |
| QUIC 基线 | 在 CESNET-QUIC22 上最高 88% 准确率（1.53 亿条流，102 个服务标签）<sup>[5](https://opendl.ifip-tc6.org/db/conf/tma/tma2023/tma2023-full-paper13.pdf)</sup> |
| 分布偏移 | 网络时延从 0 ms 增至 50 ms 时，准确率从 99% 降至 55%<sup>[6](https://www.usenix.org/system/files/usenixsecurity23-xie.pdf)</sup> |

## 工作原理

四类方法族的区别在于检视的对象不同。基于端口的分类将知名端口号映射到协议；它之所以失效，是因为应用开始使用不可预测的端口<sup>[7](https://www.sjalander.com/wolfgang/publications/PAM09-SWS-TC.pdf)</sup>，而随着使用动态端口号的协议——尤其是 eMule、[BitTorrent](https://www.edgepedia.org/zh/bittorrent) 等 P2P 应用——的增多，其准确率急剧下降。<sup>[8](http://tomasz.bujlow.com/publications/2013_techrep_comparison_of_dpi_tools.pdf)</sup> [深度包检测](https://www.edgepedia.org/zh/deep-packet-inspection)（DPI）匹配载荷中的字节签名；对已知的未加密协议准确率很高，但计算代价大，对加密数据包容易出错，在某些司法管辖区还受法律或隐私方面的限制。<sup>[8](http://tomasz.bujlow.com/publications/2013_techrep_comparison_of_dpi_tools.pdf)</sup> 统计与机器学习方法使用包头导出的特征，如包大小、到达间隔时间和流持续时间，完全避免检视载荷。<sup>[2](https://doi.org/10.1145/1071690.1064220)</sup> 深度学习方法基于原始字节、包长序列或握手字段进行运算，随着加密的普及在 2010 年代中期变得常见。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> 一个相关的族类是主机行为分析，它根据主机在社交、功能和应用层面的行为模式对流量分类，既不依赖载荷也不依赖端口；BLINC 在三条真实流量轨迹上分类了 80–90% 的流量，准确率超过 95%。<sup>[9](https://dl.acm.org/doi/10.1145/1090191.1080119)</sup>

## 实现方式

实践者的流水线分为四个阶段：抓包、精确打时间戳、可选的包选择，以及聚合为存放于流缓存中的流记录。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> 流量计采用非活动超时（无包到达后导出记录）、活动超时或最大持续时间超时，以及基于协议的过期机制（如 TCP 拆除）；例如 CICFlowMeter 在收到 FIN 包时终止 TCP 流，对 UDP 流则采用超时（例如 600 秒）。<sup>[10](https://github.com/ahlashkari/CICFlowMeter/blob/master/ReadMe.txt)</sup><sup> • </sup><sup>[11](https://flow-models.readthedocs.io/en/latest/workflow.html)</sup> 特征分为四组：包大小、时序、流量体积和协议上下文。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> 标准流量计（如 CICFlowMeter）输出包长和到达间隔时间的均值、标准差、最小值与最大值，TCP 标志计数，流持续时间，以及包计数和字节计数。<sup>[12](https://cacm.acm.org/research/traffic-classification-in-an-increasingly-encrypted-web/)</sup> 随后对流进行标注——通常借助 DPI 或 TLS 服务器名称指示（SNI）等元数据——训练模型，并在推理时应用。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> 需要注意的是，来自端口扫描或 DNS 查询的一两个包的流占全部流的一半以上，几乎不含可分类的结构。<sup>[11](https://flow-models.readthedocs.io/en/latest/workflow.html)</sup>

## 起源

统计方法源于早期使用统计应用签名进行 QoS 服务等级映射的工作，由马修·劳恩（Matthew Roughan）及其同事于 2004 年描述。<sup>[7](https://www.sjalander.com/wolfgang/publications/PAM09-SWS-TC.pdf)</sup> 随后 安德鲁·W·摩尔（Andrew W. Moore）和丹尼斯·祖耶夫（Denis Zuev） 于 2005 年在《ACM SIGMETRICS Performance Evaluation Review》上将监督式朴素贝叶斯估计器用于逐流分类，报告称最简单的估计器准确率约 65%，结合核估计与 FCBF 判别特征约简后超过 95%，较传统技术 50–70% 的水平大幅提升，且在测试集与训练集相隔 12 个月以上时仍然稳定。<sup>[2](https://doi.org/10.1145/1071690.1064220)</sup> 同年，帕特里克·哈夫纳（Patrick Haffner）及其同事基于流的前若干字节，用朴素贝叶斯、AdaBoost 和最大熵构建自动载荷签名，将字节位置和值编码为二值特征向量；他们指出签名对 ssh 和 https 仍然有效，因为两者都会以明文进行初始握手。<sup>[13](https://conferences.sigcomm.org/sigcomm/2005/paper-HafSen.pdf)</sup> 托马斯·卡拉扬尼斯（Thomas Karagiannis）、康斯坦丁娜·帕帕扬纳基（Konstantina Papagiannaki）和米哈利斯·法卢索斯（Michalis Faloutsos） 于 2005 年以 BLINC 引入了主机行为方法。<sup>[9](https://dl.acm.org/doi/10.1145/1090191.1080119)</sup> 后来的一篇综述将发展分为两波：第一波是使用人工设计特征的机器学习浪潮，由劳恩等人的工作点燃；第二波是由 CNN 在图像识别中的成功所点燃的深度学习浪潮。<sup>[14](https://nonsns.github.io/paper/rossi20ijcai-netaml.pdf)</sup>

## 变体

**早期流分类**根据流的前几个包进行分类。利姆（Lim）及其同事证明，端口加上前一个或两个包的大小足以分类单向 UDP 流，TCP 流则需要前四到五个包；使用端口和前五个包大小的 C4.5 决策树平均准确率达到 96.7%。<sup>[4](https://conferences.sigcomm.org/co-next/2010/CoNEXT_papers/09-Lim.pdf)</sup> **加密流量分类**不依赖端口、IP 地址或载荷检视，由里亚德·阿尔沙马里（Riyad Alshammari）和 A·努尔·津吉尔-海伍德（A. Nur Zincir-Heywood） 于 2010 年在《Computer Networks》上进行了探索。<sup>[15](https://doi.org/10.1016/j.comnet.2010.12.002)</sup> **深度学习变体**包括 Deep Packet<sup>[16](https://doi.org/10.1007/s00500-019-04030-2)</sup>；面向移动加密流量的多模态深度学习 MIMETIC<sup>[17](https://doi.org/10.1016/j.comnet.2019.106944)</sup>；将包大小直方图表示为类图像形式的 FlowPic<sup>[18](https://doi.org/10.1109/tnsm.2021.3071441)</sup>；以及用于在线分类的轻量级神经网络 MATEC<sup>[19](https://doi.org/10.1016/j.comnet.2021.108472)</sup>。**预训练 Transformer 模型**包括上下文化数据报表示 ET-BERT<sup>[20](https://doi.org/10.48550/arxiv.2202.06335)</sup>，以及预训练单向 [Mamba](https://www.edgepedia.org/zh/mamba-deep-learning-architecture) 模型的 NetMamba<sup>[21](https://doi.org/10.48550/arxiv.2405.11449)</sup>。**基于大语言模型的框架**包括双阶段微调框架 TrafficLLM<sup>[22](https://doi.org/10.48550/arxiv.2504.04222)</sup>，以及基于大语言模型的专家混合框架 TrafficMoE<sup>[23](https://doi.org/10.48550/arxiv.2603.29520)</sup>。**开集变体**增加了对未知类别的拒识；SepSpace 将[监督对比学习](https://www.edgepedia.org/zh/supervised-contrastive-learning)与基于包长和方向窗口的原型半径拒识相结合。<sup>[24](https://link.springer.com/article/10.1186/s42400-026-00635-x)</sup>

## 应用

分类推动了 QoS 映射、ISP 流量工程和安全监控。商用 DPI 中间盒（检视或过滤端点间流量的网络设备）可处理数百到数千个应用类别，而学术统计技术只考虑几十个类别，部署文献将这一差距视为主要的障碍。<sup>[14](https://nonsns.github.io/paper/rossi20ijcai-netaml.pdf)</sup> 不检视载荷的统计与机器学习工具据称可提供超过 95% 的准确率且资源需求低。<sup>[8](http://tomasz.bujlow.com/publications/2013_techrep_comparison_of_dpi_tools.pdf)</sup> 报告的准确率在很大程度上取决于流量条件和评估设计。在真实 ISP/移动数据集（Orange'20，19 个应用类别，12 万条标注流）上，一个结合流统计、流时间序列和 TLS 握手字节的三部分深度学习模型达到 95.56% 的准确率，而基于统计流特征的 C4.5 树仅达到 81.39%。<sup>[12](https://cacm.acm.org/research/traffic-classification-in-an-increasingly-encrypted-web/)</sup> 在 CESNET-QUIC22 数据集上，多模态 CNN、LightGBM 和基于 IP 的分类器在 102 个 Web 服务标签上最高达到 88% 的准确率。<sup>[5](https://opendl.ifip-tc6.org/db/conf/tma/tma2023/tma2023-full-paper13.pdf)</sup>

## 局限与替代方案

**加密与混淆。** [TLS 1.3](https://www.edgepedia.org/zh/tls-1-3)、QUIC、DoH/DoT 和 VPN 遮蔽了内容层，使 DPI 失效<sup>[25](https://doi.org/10.1109/access.2025.3592152)</sup>；TLS 1.3 加密了此前为明文的握手部分，因此分类不再能依赖这些字段，不过包时序、方向和包大小等可观测的流量模式以及未加密的元数据仍可作为特征使用。<sup>[26](https://arxiv.org/html/2503.20093v4)</sup> VPN 服务越来越多地使用流量整形、填充和随机化时序来模仿良性 HTTPS 流量，直接攻击分类器所依赖的统计特征。<sup>[25](https://doi.org/10.1109/access.2025.3592152)</sup> 超过 95% 的 Web 流量通过 HTTPS 提供，QUIC 支撑着超过 35% 的网站，而加密客户端问候（ECH）可能使 SNI 缺失或被加密，从而无法被一致地观测到。<sup>[27](https://avesis.hacettepe.edu.tr/yayin/f60b72f0-f011-425b-b3d0-d6691b095ecf/network-traffic-classification-from-handcrafted-features-to-foundation-models-a-comprehensive-survey)</sup><sup> • </sup><sup>[1](https://arxiv.org/pdf/2601.04089)</sup>

**数据集问题。** 旧数据集大多包含未加密流量：ISCXVPN2016 有 98.9% 未加密，USTC-TFC2016 为 94.7%，ISCXTor2016 为 89.3%，因此大多数已提出的加密流量分类器实际上是在未加密流量上误训的。<sup>[26](https://arxiv.org/html/2503.20093v4)</sup> ISCXVPN2016 被 70.6% 的受调查 VPN 论文使用，它在标注为 VPN 的流量中包含未加密载荷，部分 VPN 标注的抓包中包含多条并发连接，而且仅以 UDP 模式的 [OpenVPN](https://www.edgepedia.org/zh/openvpn) 抓取，使模型偏向 OpenVPN 特有的模式。<sup>[25](https://doi.org/10.1109/access.2025.3592152)</sup> 特征提取本身也有缺陷：CICFlowMeter 对 18 个特征计算错误，并产生 2 个冗余特征，它仅使用 L4 载荷长度来计算标注为包长的特征。<sup>[28](https://superviz.inria.fr/assets/pdf/anubis26/ESORICS_2026_paper_1397.pdf)</sup>

**泄漏与漂移。** 前 m 字节提取在 m 大于约 700 字节时通常会包含 TLS 客户端问候，从而包含 SNI；文献中 m 的取值从 764 到 3072 不等，引发了数据泄漏的担忧，许多最先进的分类器依赖来自 IP 地址、端口号、服务器标识符和明文的捷径信息，而非稳定的行为。<sup>[26](https://arxiv.org/html/2503.20093v4)</sup><sup> • </sup><sup>[24](https://link.springer.com/article/10.1186/s42400-026-00635-x)</sup> 概念漂移很严重：由于自然的流量漂移，一个模型的准确率在一周内下降了 10%。<sup>[1](https://arxiv.org/pdf/2601.04089)</sup> 鲁棒性是薄弱环节：六个基于包长序列分类 TLS 流量的深度学习模型在多种真实网络环境中测试时，准确率最多下降约 53%，且当时延从 0 ms 增至 50 ms 时准确率从 99% 降至 55%。<sup>[6](https://www.usenix.org/system/files/usenixsecurity23-xie.pdf)</sup> 一项对已发表深度学习分类器的独立再评估发现，所测试的每种架构的预期性能都低于 90%。<sup>[14](https://nonsns.github.io/paper/rossi20ijcai-netaml.pdf)</sup> 封闭世界与开放世界性能之间的差距仍是实际部署的最关键障碍。<sup>[27](https://avesis.hacettepe.edu.tr/yayin/f60b72f0-f011-425b-b3d0-d6691b095ecf/network-traffic-classification-from-handcrafted-features-to-foundation-models-a-comprehensive-survey)</sup> 据报道，基础模型比监督式深度学习高出 2–10 个百分点，同时所需的标注数据少得多。<sup>[27](https://avesis.hacettepe.edu.tr/yayin/f60b72f0-f011-425b-b3d0-d6691b095ecf/network-traffic-classification-from-handcrafted-features-to-foundation-models-a-comprehensive-survey)</sup>

## References

1. [Tutorial on Network Traffic Flow Classification Using Machine Learning](https://arxiv.org/pdf/2601.04089)
2. [Andrew W. Moore, Denis Zuev (2005). Internet traffic classification using bayesian analysis techniques. ACM SIGMETRICS Performance Evaluation Review.](https://doi.org/10.1145/1071690.1064220)
3. [Toward the Accurate Identification of Network Applications (Moore & Papagiannaki, PAM 2005)](https://www.cl.cam.ac.uk/research/srg/netos/papers/2005-moore2005toward.pdf)
4. [Internet Traffic Classification Demystified: On the Sources of the Discriminative Power (Lim et al., CoNEXT 2010)](https://conferences.sigcomm.org/co-next/2010/CoNEXT_papers/09-Lim.pdf)
5. [Encrypted Traffic Classification: the QUIC Case (TMA 2023)](https://opendl.ifip-tc6.org/db/conf/tma/tma2023/tma2023-full-paper13.pdf)
6. [Rosetta: Enabling Robust TLS Encrypted Traffic Classification in Diverse Network Environments with TCP-Aware Traffic Augmentation (USENIX Security 2023)](https://www.usenix.org/system/files/usenixsecurity23-xie.pdf)
7. [State of the Art in Traffic Classification: A Research Review (Sjalander et al., PAM 2009)](https://www.sjalander.com/wolfgang/publications/PAM09-SWS-TC.pdf)
8. [Comparison of Deep Packet Inspection (DPI) Tools for Traffic Classification (Bujlow et al.)](http://tomasz.bujlow.com/publications/2013_techrep_comparison_of_dpi_tools.pdf)
9. [BLINC: multilevel traffic classification in the dark (Karagiannis, Papagiannaki, Faloutsos, SIGCOMM 2005)](https://dl.acm.org/doi/10.1145/1090191.1080119)
10. [CICFlowMeter ReadMe (CICFlowmeter-V4.0, formerly ISCXFlowMeter)](https://github.com/ahlashkari/CICFlowMeter/blob/master/ReadMe.txt)
11. [Workflow, flow_models 2.2 documentation](https://flow-models.readthedocs.io/en/latest/workflow.html)
12. [Traffic Classification in an Increasingly Encrypted Web (Akbari et al., CACM Research Highlight)](https://cacm.acm.org/research/traffic-classification-in-an-increasingly-encrypted-web/)
13. [ACAS: Automated Construction of Application Signatures (Haffner, Sen, Spatscheck, Wang, SIGCOMM 2005 workshop)](https://conferences.sigcomm.org/sigcomm/2005/paper-HafSen.pdf)
14. [Deep Learning and Traffic Classification: A critical review with novel insights from real deployment (IJCAI NetAML workshop)](https://nonsns.github.io/paper/rossi20ijcai-netaml.pdf)
15. [Riyad Alshammari, A. Nur Zincir-Heywood (2010). Can encrypted traffic be identified without port numbers, IP addresses and payload inspection?. Computer Networks.](https://doi.org/10.1016/j.comnet.2010.12.002)
16. [Mohammad Lotfollahi and colleagues (2019). Deep packet: a novel approach for encrypted traffic classification using deep learning. Soft Computing.](https://doi.org/10.1007/s00500-019-04030-2)
17. [Giuseppe Aceto and colleagues (2019). MIMETIC: Mobile encrypted traffic classification using multimodal deep learning. Computer Networks.](https://doi.org/10.1016/j.comnet.2019.106944)
18. [Tal Shapira, Yuval Shavitt (2021). FlowPic: A Generic Representation for Encrypted Traffic Classification and Applications Identification. IEEE Transactions on Network and Service Management.](https://doi.org/10.1109/tnsm.2021.3071441)
19. [Jin Cheng and colleagues (2021). MATEC: A lightweight neural network for online encrypted traffic classification. Computer Networks.](https://doi.org/10.1016/j.comnet.2021.108472)
20. [Lin, Xinjie and colleagues (2022). ET-BERT: A Contextualized Datagram Representation with Pre-training Transformers for Encrypted Traffic Classification. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2202.06335)
21. [Wang, Tongze and colleagues (2024). NetMamba: Efficient Network Traffic Classification via Pre-training Unidirectional Mamba. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2405.11449)
22. [Cui, Tianyu and colleagues (2025). TrafficLLM: Enhancing Large Language Models for Network Traffic Analysis with Generic Traffic Representation. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2504.04222)
23. [He, Qing, Fu, Xiaowei, Zhang, Lei (2026). TrafficMoE: Heterogeneity-aware Mixture of Experts for Encrypted Traffic Classification. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2603.29520)
24. [SepSpace: payload-free open-set network traffic classification via supervised contrastive representation learning and prototype-radius rejection (Springer Cybersecurity)](https://link.springer.com/article/10.1186/s42400-026-00635-x)
25. [VPN Traffic Analysis: A Survey on Detection and Application Identification (IEEE Access, 2025)](https://doi.org/10.1109/access.2025.3592152)
26. [SoK: Decoding the Enigma of Encrypted Network Traffic Classifiers](https://arxiv.org/html/2503.20093v4)
27. [Network traffic classification from handcrafted features to foundation models: A comprehensive survey (Computer Networks, 2026)](https://avesis.hacettepe.edu.tr/yayin/f60b72f0-f011-425b-b3d0-d6691b095ecf/network-traffic-classification-from-handcrafted-features-to-foundation-models-a-comprehensive-survey)
28. [When Packet Length Is Not Packet Length: Correcting CICFlowMeter Features for Interpretable NIDS Evaluation (ESORICS 2026)](https://superviz.inria.fr/assets/pdf/anubis26/ESORICS_2026_paper_1397.pdf)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Networking fundamentals and architecture

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/traffic-classification-computer-networks

English original: https://www.edgepedia.org/traffic-classification-computer-networks
