cla*_*ion 14 linux tcp linux-kernel
3s 的初始 TCP RTO 值对于大多数基于 LAN 的应用程序来说太长了。我怎样才能调低?有sysctl吗?
Mar*_*rri 12
不,你不能;它被硬编码在内核中。于是换内核重新编译。
#define TCP_TIMEOUT_INIT ((unsigned)(3*HZ)) /* RFC 1122 initial RTO value */
Run Code Online (Sandbox Code Playgroud)
这是你应该在你的 include/net/tcp.h 中得到的。
但是我可以看到有人提供了补丁,即使我自己从未尝试过
初始设置不会对您的整体性能产生太大影响,因为 RTO 会根据网络条件进行自我调整。如果您确实更改 RTO,则可以将其设置为 1 秒(但不能更低)。
RFC 1122中有对此的讨论:
Run Code Online (Sandbox Code Playgroud)The following values SHOULD be used to initialize the estimation parameters for a new connection:
(a) RTT = 0 seconds.
(b) RTO = 3 seconds. (The smoothed variance is to be
initialized to the value that will result in this RTO).
The recommended upper and lower bounds on the RTO are known
to be inadequate on large internets. The lower bound SHOULD
be measured in fractions of a second (to accommodate high
speed LANs) and the upper bound should be 2*MSL, i.e., 240
seconds.
DISCUSSION:
Experience has shown that these initialization values
are reasonable, and that in any case the Karn and
Jacobson algorithms make TCP behavior reasonably
insensitive to the initial parameter choices.
Run Code Online (Sandbox Code Playgroud)
RFC 6298是一项拟议的更新(2011 年 6 月发布),其中规定RTO可以初始化为较低的值(但不低于 1 秒),并且包含一个附录,其中包含证明 1 秒作为合理初始值的数据。
请参阅这篇博客文章,了解如何制作一个覆盖超时的 eBPF 程序。
简而言之,您需要加载这个sockops程序:
#include<linux/bpf.h>
#define SEC(NAME) __attribute__((section(NAME), used))
// TODO: assumes little-endian (x86, amd64)
#define bpf_ntohl(x) __builtin_bswap32(x)
SEC("sockops")
int bpf_sockmap(struct bpf_sock_ops *skops)
{
const int op = (int) skops->op;
if (op == BPF_SOCK_OPS_TIMEOUT_INIT) {
// TODO: this is in jiffies, and despite `getconf CLK_TCK` return 100, HZ is clearly 250 on my kernel.
// 5000 / 250 = 20 seconds
skops->reply = 5000;
return 1;
}
return 0;
}
char _license[] __attribute((section("license"),used)) = "GPL";
int _version SEC("version") = 1;
Run Code Online (Sandbox Code Playgroud)
您可以使用以下命令编译并加载它:
clang $CFLAGS -target bpf -Wall -g -O2 -c set_rto.c -o set_rto.o
sudo bpftool prog load set_rto.o /sys/fs/bpf/bpf_sockop
sudo bpftool cgroup attach /sys/fs/cgroup/unified/ sock_ops pinned /sys/fs/bpf/set_rto
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22063 次 |
| 最近记录: |