# TCP：在连接10.0.0.1:443 -> 192.168.1.50:54321上接收到乱序数据包，期望序列号12345，实际收到12390

- **ID:** `networking/tcp-out-of-order`
- **领域:** networking
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 72%

## 根因

TCP数据包的序列号与预期的下一个序列号不匹配，表明网络中发生了数据包重排序，通常是由于多路径路由、负载均衡器或路由器缓冲区膨胀。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Linux kernel 6.5.0-14-generic | active | — | — |
| FreeBSD 13.2 | active | — | — |
| Windows 11 Pro 23H2 | active | — | — |
| nginx 1.24.0 | active | — | — |

## 解决方案

1. ```
   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
   ```
2. ```
   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`
   ```

## 无效尝试

- **** — Large buffers can hide the symptom but exacerbate bufferbloat, leading to increased latency and packet drops. (65% 失败率)
- **** — SACK is designed to handle out-of-order packets efficiently; disabling it makes retransmission less efficient and can degrade performance. (75% 失败率)
- **** — The reordering is a network-level issue; restarting the app does not fix the underlying path and the problem will recur. (80% 失败率)
