# lwIP：TCP连接丢失，过多重复ACK导致套接字3重传超时

- **ID:** `embedded/lwip-tcp-dup-ack-retransmit`
- **领域:** embedded
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

由于网络拥塞或有故障的PHY导致持续丢包，使lwIP TCP进入重传超时并关闭连接。

## 版本兼容性

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

## 解决方案

1. ```
   Enable lwIP TCP keepalive to detect stale connections early and implement application-level retry logic.
   ```
2. ```
   Improve PHY stability by adding external pull-up resistors on TX and RX lines and verifying MDC/MDIO timing per datasheet.
   ```

## 无效尝试

- **Increase TCP retransmission timeout in lwIP config (TCP_RTO_MIN)** — Delays detection of genuine connection loss and may cause application-level timeouts; does not fix underlying packet loss. (65% 失败率)
- **Disable TCP Nagle algorithm to send smaller packets** — Reduces throughput and may increase ACK overhead; does not address duplicate ACK cause. (70% 失败率)
- **Replace PHY chip with a different model** — Expensive and time-consuming; the issue may be due to PCB layout or driver configuration, not the PHY itself. (50% 失败率)
