> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/4.3-bsd-unix-cao-zuo-xi-tong-she-ji-yu-shi-xian/di-si-bu-fen-jin-cheng-jian-tong-xin/11.6.-huan-chong-yu-yong-sai-kong-zhi.md).

# 11.6 缓冲与拥塞控制

影响协议性能的一大因素是缓冲策略。缺乏得当的缓冲策略会迫使分组被丢弃、让协议发出失真的窗口信息、割裂主机内存、损害主机整体性能。由于这些问题，多数系统给联网系统分配固定的内存池，并施加为 **正常** 网络运作优化的策略。

4.3BSD 联网系统在这方面并无戏剧性的不同。引导时联网系统分配少量固定内存；此后可按需请求更多系统内存，但内存从不归还系统。从网络回收内存本可做到，但要安全地做，更新数据结构期间得停用网络的一部分。在系统使用过的环境中，存储的使用从未成为问题，因此存储回收没有实现。

## 协议缓冲策略

协议在套接字创建时为发送和接收队列保留固定量的缓冲。这些量定义套接字例程决定何时阻塞、何时放行进程所用的高、低水位线。空间的保留目前并不引起内存管理例程的任何动作。

提供连接级流控的协议以关联套接字队列中的空间量为决策依据：发送窗口按套接字接收队列的空闲空间计算，接收窗口按发送队列中待发数据量调整。

## 队列限长

来自网络的入局分组只要内存分配不失败总是接收。但每个网络层协议的输入队列都有长度上限，超过上限的分组被丢弃。主机可能被过量的网络流量压垮（例如主机充当从高带宽网络到低带宽网络的网关时）。作为 **防御机制**，可以调整队列限制来扼制主机的网络流量负载。丢弃分组对这样的问题并不总是令人满意的解（单纯丢分组很可能增加网络负载）；队列长度主要作为保险机制纳入。另一方面，限制 **输出** 队列长度对把流量从高带宽网关到低带宽网络的主机很有价值。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://book.bsdcn.org/4.3-bsd-unix-cao-zuo-xi-tong-she-ji-yu-shi-xian/di-si-bu-fen-jin-cheng-jian-tong-xin/11.6.-huan-chong-yu-yong-sai-kong-zhi.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
