TCP:在连接10.0.0.1:443 -> 192.168.1.50:54321上接收到乱序数据包,期望序列号12345,实际收到12390
TCP: Out-of-order packet received on connection 10.0.0.1:443 -> 192.168.1.50:54321, expected seq 12345, got 12390
ID: networking/tcp-out-of-order
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Linux kernel 6.5.0-14-generic | active | — | — | — |
| FreeBSD 13.2 | active | — | — | — |
| Windows 11 Pro 23H2 | active | — | — | — |
| nginx 1.24.0 | active | — | — | — |
根因分析
TCP数据包的序列号与预期的下一个序列号不匹配,表明网络中发生了数据包重排序,通常是由于多路径路由、负载均衡器或路由器缓冲区膨胀。
English
A TCP packet arrived with a sequence number that does not match the expected next sequence number, indicating packet reordering in the network, often due to multipath routing, load balancers, or router bufferbloat.
官方文档
https://datatracker.ietf.org/doc/html/rfc9293解决方案
-
Enable TCP reordering detection on the receiver: `sysctl -w net.ipv4.tcp_reordering=3` to allow up to 3 reordered packets before treating as loss
-
Use `tcpdump` to identify the path causing reordering and pin the connection to a single path via routing policy: `ip route add 192.168.1.50/32 via 10.0.0.1 dev eth0`
无效尝试
常见但无效的做法:
-
65% 失败
Large buffers can hide the symptom but exacerbate bufferbloat, leading to increased latency and packet drops.
-
75% 失败
SACK is designed to handle out-of-order packets efficiently; disabling it makes retransmission less efficient and can degrade performance.
-
80% 失败
The reordering is a network-level issue; restarting the app does not fix the underlying path and the problem will recur.