← 中文资源

简体中文版本

TCP 零窗口与流控

TCP 零窗口通告告知发送方接收缓冲区已满,暂停发送直到应用读取数据并重新打开窗口,是排查传输停滞的关键线索。

阅读英文原文

概念概述

TCP 零窗口与流控(TCP Zero Window and Flow Control)指的是:TCP 零窗口通告告知发送方接收缓冲区已满,暂停发送直到应用读取数据并重新打开窗口,是排查传输停滞的关键线索。

从更严格的定义看,The zero window condition occurs when a TCP receiver advertises a window size of zero, signalling that it has no buffer space left and that the sender must stop sending until a window update arrives. 该概念在工程实践中的价值,在于它能帮助团队用统一的语言描述一个具体的质量属性或设计约束,从而在评审与协作中减少歧义。

为什么需要它

It shows up in slow database responses, stalled uploads, and any pipeline where a slow consumer cannot keep up with a fast producer. 它与 MIME Type Sniffing and nosniff、Server Name Indication (SNI)、Application-Layer Protocol Negotiation (ALPN) 等概念经常一起出现,用于解决相近的工程问题。理解它的适用场景,有助于在多种备选方案之间做出有依据的取舍,而不是凭直觉选择技术方案。

常见误解

  • a zero window means the network path is broken
  • the sender resumes instantly once the application reads a byte

需要避免的反模式

  • tuning socket buffers before confirming the consumer is the bottleneck
  • ignoring window probes when diagnosing a stalled transfer

实践要点

  1. When the window closes, the sender periodically transmits window probes, and the receiver must answer them; a vanished peer that never probes leaves the connection hanging until a keepalive or timeout fires.
  2. Persistent zero windows usually mean the reading application is blocked, so the fix lies in consumer concurrency or processing speed rather than in network tuning.
  3. Capturing both sides reveals the pattern clearly: a zero-window advertisement followed by repeated probe and acknowledgement exchanges, with no application-level progress.

参考来源

https://datatracker.ietf.org/doc/html/rfc9293