# lwIP: 到192.168.1.100:80的TCP连接在3次重传后超时

- **ID:** `embedded/lwip-tcp-retransmit-timeout`
- **领域:** embedded
- **类别:** network_error
- **错误码:** `ERR_TIMEOUT`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

由于网络拥塞、防火墙阻止或设备电源状态，TCP远程主机不可达或未响应。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| lwIP v2.1.3 | active | — | — |
| lwIP v2.2.0 | active | — | — |
| FreeRTOS+TCP v3.0.0 | active | — | — |

## 解决方案

1. ```
   Implement a TCP keepalive mechanism using tcp_keepalive() to detect connection failure earlier and reduce retransmission count.
   ```
2. ```
   Add a fallback DNS resolution check before connecting: if host resolution fails, abort and retry with exponential backoff.
   ```

## 无效尝试

- **Increase the TCP retransmission timeout in lwIP configuration (e.g., TCP_RTO_MIN)** — Longer timeouts only mask the problem; if the remote host is unreachable, the connection will still fail eventually. (80% 失败率)
- **Disable TCP checksum offloading on the network interface** — Checksum offloading is unrelated to retransmission timeouts; the issue is network reachability, not data corruption. (95% 失败率)
