【问题标题】:What is a separate flow in Linux fq_codel?Linux fq_codel 中的单独流程是什么?
【发布时间】:2026-02-01 05:20:03
【问题描述】:

我正在设置一个概念证明来限制终端(客户端)的入口流量:

eth0 -> ifb0 -> htb -> filter by ip -> htb rate -> fq_codel+ecn

我有 2 个源 ips 用于我想要限制的特定程序。有问题的程序打开了一堆 tcp 连接(下载,因此入口节流),我想限制它使用的总入口带宽(完成)并在连接到相同 IP 地址的连接之间进行公平调度(这个问题)。

最后有 1 个附加速率的存储桶和 1 个fq_codel 实例。

我有它的工作,但我有一些问题:

  • codel 肯定每个协议都有单独的队列(tcp 与 udp)吗?
  • codel 每个源 ip 有单独的队列吗?
  • codel 每个 tcp 连接是否有单独的队列?
  • 我必须手动分离/标记流吗?

每个互联网研究流 id 是“5 元组的哈希”,问题是,数据包的哪些元素是 5 元组的一部分?是否包括源端口和目标端口?

【问题讨论】:

  • P.S.我正在寻找比我自己更好/更权威的答案

标签: linux networking routing throttling bandwidth-throttling


【解决方案1】:

似乎包括源端口和目标端口,至少默认情况下:

http://lxr.free-electrons.com/source/net/core/flow_dissector.c#L655

655 /**
656  * __skb_get_hash: calculate a flow hash
657  * @skb: sk_buff to calculate flow hash from
658  *
659  * This function calculates a flow hash based on src/dst addresses
660  * and src/dst port numbers.  Sets hash in skb to non-zero hash value
661  * on success, zero indicates no valid hash.  Also, sets l4_hash in skb
662  * if hash is a canonical 4-tuple hash over transport ports.
663  */
664 void __skb_get_hash(struct sk_buff *skb)

【讨论】:

    【解决方案2】:

    根据http://mdh.diva-portal.org/smash/get/diva2:754020/FULLTEXT01.pdf(某人的博士论文):

    通过从数据包中散列一个 5 元组值来分离流 (默认是 src/dest 端口/ip 和协议)连同一个随机 编号

    除了默认位,一目了然。

    【讨论】:

      最近更新 更多