RFC9293 TCP 协议

RFC9293 TCP 协议中文翻译 #

这是 RFC 上最新(截止到 2023 年 3 月)完整描述了 TCP 协议标准的文档,它整合了 RFC793 提出的 TCP 规范以及后来提出的多项优化 ,如果对 RFC793 感兴趣可以参考 RFC793 TCP 协议中文翻译

原文: Transmission Control Protocol (TCP)

封面 #

Internet Engineering Task Force (IETF)
STD: 7
Request for Comments: 9293
Obsoletes: 793, 879, 2873, 6093, 6429, 6528, 6691
Updates: 1011, 1122, 5961
Category: Standards Track
ISSN: 2070-1721

W. Eddy, Ed.
MTI Systems
August 2022
Transmission Control Protocol (TCP)

摘要 #


This document specifies the Transmission Control Protocol (TCP).

TCP is an important transport-layer protocol in the Internet protocol stack, and it has continuously evolved over decades of use and growth of the Internet.
TCP 是 Internet 协议栈中重要的传输层协议,在互联网数十年的使用和发展过程中不断改进。

Over this time, a number of changes have been made to TCP as it was specified in RFC 793, though these have only been documented in a piecemeal fashion.
在这段时间里,已经对 RFC 793 中规定的 TCP 进行了一些修改,尽管这些修改只是以零散的方式被记录下来。

This document collects and brings those changes together with the protocol specification from RFC 793.
本文件收集了这些变化,并将其与 RFC 793 的协议规范结合在一起。

This document obsoletes RFC 793, as well as RFCs 879, 2873, 6093, 6429, 6528, and 6691 that updated parts of RFC 793.
本文档废弃了 RFC 793,以及更新了 RFC 793 部分内容的 RFC 879、2873、6093、6429、6528 和 6691。

It updates RFCs 1011 and 1122, and it should be considered as a replacement for the portions of those documents dealing with TCP requirements.
它更新了 RFC 1011 和 1122,它可以被视为那些文档中涉及 TCP 要求的部分的替代品。

It also updates RFC 5961 by adding a small clarification in reset handling while in the SYN-RECEIVED state.
它还更新了 RFC 5961,在 SYN-RECEIVED 状态下在重置处理中添加了一个小的说明。

The TCP header control bits from RFC 793 have also been updated based on RFC 3168.
RFC 793 中的 TCP 头控制位也根据 RFC 3168 进行了更新。

Status of This Memo

This is an Internet Standards Track document.

This document is a product of the Internet Engineering Task Force (IETF).
本文档是 Internet 工程任务组 (IETF) 的产品。

It represents the consensus of the IETF community.
它代表了 IETF 社区的共识。

It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG).
它已经接受了公众审阅,并已被互联网工程指导小组 (IESG) 批准发布。

Further information on Internet Standards is available in Section 2 of RFC 7841.
有关 Internet 标准的更多信息,请参阅 RFC 7841 的第 2 节。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at https://www.rfc-editor.org/info/rfc9293.
有关本文档的当前状态、任何勘误表以及如何提供反馈的信息,请访问 🔗

版权声明 #

Copyright Notice

Copyright (c) 2022 IETF Trust and the persons identified as the document authors.
Copyright (c) 2022 IETF Trust 和被认定为本文档作者的人员。

All rights reserved.

This document is subject to BCP 78 and the IETF Trust’s Legal Provisions Relating to IETF Documents ( https://trustee.ietf.org/license-info) in effect on the date of publication of this document.
本文档受 BCP 78 和 IETF 信托与 IETF 文档相关的法律规定 🔗 的约束,这些条款在本文档发布之日生效。

Please review these documents carefully, as they describe your rights and restrictions with respect to this document.

Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.
从本文件中提取的代码组件必须包括信托法律条款第 4.e 节中描述的修订版 BSD 许可文本,并且不提供修订版 BSD 许可中描述的保证。

This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008.
本文档可能包含 2008 年 11 月 10 日之前发布或公开提供的 IETF 文档或 IETF 文稿中的材料。

The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process.
控制本材料某些版权的人可能未授予 IETF 信托允许在 IETF 标准流程之外修改此类材料的权利。

Without obtaining an adequate license from the person(s) controlling the copyright in such materials, this document may not be modified outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process, except to format it for publication as an RFC or to translate it into languages other than English.
如果没有从控制此类材料的版权的人那里获得足够的许可,则不得在 IETF 标准流程之外修改本文档,并且不得在 IETF 标准流程之外创建其衍生作品,除非将其格式化为 RFC 出版或将其翻译成英语以外的其他语言。

目录 #

Table of Contents

1.Purpose and Scope 目的和范围
2.Introduction 介绍
 2.1. Requirements Language 需求语言
 2.2. Key TCP Concepts 关键的 TCP 概念
3.Functional Specification 功能规范
 3.1. Header Format 头部格式
 3.2. Specific Option Definitions 具体选项定义
  3.2.1. Other Common Options 其他常用选项
  3.2.2. Experimental TCP Options 实验性 TCP 选项
 3.3. TCP Terminology Overview TCP 术语概述
  3.3.1. Key Connection State Variables 关键连接状态变量
  3.3.2. State Machine Overview 状态机概述
 3.4. Sequence Numbers 序列号
  3.4.1. Initial Sequence Number Selection 初始序列号选择
  3.4.2. Knowing When to Keep Quiet 知道什么时候该保持静默
  3.4.3. The TCP Quiet Time Concept TCP 静默时间概念
 3.5. Establishing a Connection 建立连接
  3.5.1. Half-Open Connections and Other Anomalies 半开连接和其他异常
  3.5.2. Reset Generation 重置生成
  3.5.3. Reset Processing 重置处理
 3.6. Closing a Connection 关闭连接
  3.6.1. Half-Closed Connections 半关闭连接
 3.7. Segmentation 分段
  3.7.1. Maximum Segment Size Option 最大段长度选项
  3.7.2. Path MTU Discovery 路径 MTU 发现
  3.7.3. Interfaces with Variable MTU Values 可变 MTU 值的接口
  3.7.4. Nagle Algorithm Nagle 算法
  3.7.5. IPv6 Jumbograms IPv6 Jumbograms
 3.8. Data Communication 数据通信
  3.8.1. Retransmission Timeout 重传超时
  3.8.2. TCP Congestion Control TCP 拥塞控制
  3.8.3. TCP Connection Failures TCP 连接故障
  3.8.4. TCP Keep-Alives TCP 持久连接
  3.8.5. The Communication of Urgent Information 紧急信息的通信
  3.8.6. Managing the Window 管理窗口
 3.9. Interfaces 接口
  3.9.1. User/TCP Interface 用户/TCP 接口
  3.9.2. TCP/Lower-Level Interface TCP/下层协议接口
 3.10. Event Processing 事件处理
  3.10.1. OPEN Call OPEN 调用
  3.10.2. SEND Call SEND 调用
  3.10.3. RECEIVE Call RECEIVE 调用
  3.10.4. CLOSE Call CLOSE 调用
  3.10.5. ABORT Call ABORT 调用
  3.10.6. STATUS Call STATUS 调用
  3.10.7. SEGMENT ARRIVES 收到段
  3.10.8. Timeouts 超时
4.Glossary 词汇表
5.Changes from RFC 793 与 RFC 793 相比的改动
6.IANA Considerations IANA 的注意事项
7.Security and Privacy Considerations 安全和隐私注意事项
8.References 参考文献
 8.1. Normative References 规范性参考文献
 8.2. Informative References 非规范性参考文献
Appendix A. Other Implementation Notes 其他实现说明
 A.1. IP Security Compartment and Precedence IP 安全部分和优先级
  A.1.1. Precedence 优先级
  A.1.2. MLS Systems MLS 系统
 A.2. Sequence Number Validation 序列号验证
 A.3. Nagle Modification Nagle 修改
 A.4. Low Watermark Settings 低水印设置
Appendix B. TCP Requirement Summary TCP 要求概述
Acknowledgments 致谢
Author’s Address 作者的地址

目的和范围 #

1.Purpose and Scope

In 1981, RFC 793 [16] was released, documenting the Transmission Control Protocol (TCP) and replacing earlier published specifications for TCP.
1981 年,RFC 793 [16] 发布,记录了传输控制协议 (TCP) 并取代了早期发布的 TCP 规范。

Since then, TCP has been widely implemented, and it has been used as a transport protocol for numerous applications on the Internet.
从那时起,TCP 得到了广泛的应用,并被用作 Internet 上众多应用程序的传输协议。

For several decades, RFC 793 plus a number of other documents have combined to serve as the core specification for TCP [49].
几十年来,RFC 793 加上许多其他文档已合并为 TCP 的核心规范[49]。

Over time, a number of errata have been filed against RFC 793.
随着时间的流逝,已经针对 RFC 793 提出了许多勘误表。

There have also been deficiencies found and resolved in security, performance, and many other aspects.

The number of enhancements has grown over time across many separate documents.

These were never accumulated together into a comprehensive update to the base specification.

The purpose of this document is to bring together all of the IETF Standards Track changes and other clarifications that have been made to the base TCP functional specification (RFC 793) and to unify them into an updated version of the specification.
本文档的目的是将所有 IETF 标准轨道的修改和其他对基础 TCP 功能规范(RFC 793)的说明汇集在一起,并将它们统一到规范的更新版本中。

Some companion documents are referenced for important algorithms that are used by TCP (e.g., for congestion control) but have not been completely included in this document.
但是一些用于 TCP 使用的重要算法(例如,用于拥塞控制)的相关文档,还没有完全包括在本文档中。

This is a conscious choice, as this base specification can be used with multiple additional algorithms that are developed and incorporated separately.

This document focuses on the common basis that all TCP implementations must support in order to interoperate.
本文档重点关注所有 TCP 实现必须支持的共同基础,以实现互操作。

Since some additional TCP features have become quite complicated themselves (e.g., advanced loss recovery and congestion control), future companion documents may attempt to similarly bring these together.
因为一些额外的 TCP 功能本身已经变得相当复杂(例如,高级损失恢复和拥塞控制),未来的配套文档可能会试图类似地将这些功能集中起来。

In addition to the protocol specification that describes the TCP segment format, generation, and processing rules that are to be implemented in code, RFC 793 and other updates also contain informative and descriptive text for readers to understand aspects of the protocol design and operation.
除了描述要在代码中实现的 TCP 段格式、生成和处理规则的协议规范外,RFC 793 和其他更新还包含信息和描述性内容,以便读者了解协议设计和运行的各个方面。

This document does not attempt to alter or update this informative text and is focused only on updating the normative protocol specification.

This document preserves references to the documentation containing the important explanations and rationale, where appropriate.

This document is intended to be useful both in checking existing TCP implementations for conformance purposes, as well as in writing new implementations.
该文档旨在帮助检查现有的 TCP 实现以及编写新实现。

介绍 #


RFC 793 contains a discussion of the TCP design goals and provides examples of its operation, including examples of connection establishment, connection termination, and packet retransmission to repair losses.
RFC 793 包含了对 TCP 设计目标的讨论,并提供了其操作的示例,包括建立连接、关闭连接以及弥补丢失的数据包重传。

This document describes the basic functionality expected in modern TCP implementations and replaces the protocol specification in RFC 793.
本文档描述了现代 TCP 实现中预期的基本功能,并替换了 RFC 793 中的协议规范。

It does not replicate or attempt to update the introduction and philosophy content in Sections 1 and 2 of RFC 793.
它不会复制或尝试更新 RFC 793 第 1 和 2 节中的简介和理念内容。

Other documents are referenced to provide explanations of the theory of operation, rationale, and detailed discussion of design decisions.

This document only focuses on the normative behavior of the protocol.

The “TCP Roadmap” [49] provides a more extensive guide to the RFCs that define TCP and describe various important algorithms. “TCP 路线图” [49] 为定义 TCP 和描述各种重要算法的 RFC 提供了更广泛的指南。

The TCP Roadmap contains sections on strongly encouraged enhancements that improve performance and other aspects of TCP beyond the basic operation specified in this document.
TCP 路线图包含强烈推荐的增强功能,这些增强功能可以提高 TCP 的性能和其他超出本文档中规定的基本操作的方面。

As one example, implementing congestion control (e.g., [8]) is a TCP requirement, but it is a complex topic on its own and not described in detail in this document, as there are many options and possibilities that do not impact basic interoperability.
举个例子,实现拥塞控制(例如,[8])是一项 TCP 要求,但它本身就是一个复杂的主题,并且在本文档中没有详细描述,因为有许多不会影响基本的互操作性的选项和可能性 .

Similarly, most TCP implementations today include the high-performance extensions in [47], but these are not strictly required or discussed in this document.
类似地,今天的大多数 TCP 实现都包括 [47] 中的高性能扩展,但这些在本文档中并不是严格要求或讨论的。

Multipath considerations for TCP are also specified separately in [59].
TCP 的多路径注意事项也在 [59] 中单独指定。

A list of changes from RFC 793 is contained in Section 5.
与 RFC 793 相比的改动清单包含在第 5 节。

需求语言 #

2.1. Requirements Language

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in BCP 14 [3] [12] when, and only when, they appear in all capitals, as shown here.
本文中的关键词 “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, 和 “OPTIONAL”,当且仅当它们以大写字母出现时,应按照 BCP 14 [3] [12] 中的描述进行解释,如这里所示。

Each use of RFC 2119 keywords in the document is individually labeled and referenced in Appendix B, which summarizes implementation requirements.
文档中每次使用 RFC 2119 关键字都在附录 B 中单独标记和引用,附录 B 总结了实现要求。

Sentences using “MUST” are labeled as “MUST-X” with X being a numeric identifier enabling the requirement to be located easily when referenced from Appendix B.
使用 “MUST” 的句子被标记为 “MUST-X”,X 是一个数字标识符,可以很容易地从附录 B 找到引用的要求。

Similarly, sentences using “SHOULD” are labeled with “SHLD-X”, “MAY” with “MAY-X”, and “RECOMMENDED” with “REC-X”.
同样地,使用 “SHOULD” 的句子被标记为 “SHLD-X”,“MAY” 被标记为 “MAY-X”,“RECOMMENDED” 被标记为 “REC-X”。

For the purposes of this labeling, “SHOULD NOT” and “MUST NOT” are labeled the same as “SHOULD” and “MUST” instances.
出于此标签的目的,“SHOULD NOT” 和 “MUST NOT” 的标签与 “SHOULD” 和 “MUST” 实例的标签相同。

关键的 TCP 概念 #

2.2. Key TCP Concepts

TCP provides a reliable, in-order, byte-stream service to applications.
TCP 为应用程序提供可靠、有序的字节流服务。

The application byte-stream is conveyed over the network via TCP segments, with each TCP segment sent as an Internet Protocol (IP) datagram.
应用程序的字节流通过 TCP 段在网络上传输,每个 TCP 段作为互联网协议 (IP) 数据报发送。

TCP reliability consists of detecting packet losses (via sequence numbers) and errors (via per-segment checksums), as well as correction via retransmission.
TCP 可靠性包括检测数据包丢失(通过序列号)和错误(通过段校验和),以及通过重传进行纠正。

TCP supports unicast delivery of data.
TCP 支持单播传输数据。

There are anycast applications that can successfully use TCP without modifications, though there is some risk of instability due to changes of lower-layer forwarding behavior [46].
有一些任播应用程序可以在不修改的情况下成功地使用 TCP,尽管由于下层转发行为的变化存在一些不稳定的风险 [46]。

TCP is connection oriented, though it does not inherently include a liveness detection capability.
TCP 是面向连接的,尽管它本身并不包括活跃性检测功能。

Data flow is supported bidirectionally over TCP connections, though applications are free to send data only unidirectionally, if they so choose.
通过 TCP 连接双向支持数据流,但如果应用程序愿意,它们可以自由地仅单向发送数据。

TCP uses port numbers to identify application services and to multiplex distinct flows between hosts.
TCP 使用端口号来识别应用程序服务并在主机之间复用不同的流。

A more detailed description of TCP features compared to other transport protocols can be found in Section 3.1 of [52].
与其他传输协议相比,TCP 功能的更详细描述可以在 [52] 的第 3.1 节中找到。

Further description of the motivations for developing TCP and its role in the Internet protocol stack can be found in Section 2 of [16] and earlier versions of the TCP specification.
关于开发 TCP 的动机和它在互联网协议栈中的作用的更多描述,可以在[16]的第 2 节和早期版本的 TCP 规范中找到。

功能规范 #

3.Functional Specification

头部格式 #

3.1. Header Format

TCP segments are sent as internet datagrams.
TCP 段作为网络数据报发送。

The Internet Protocol (IP) header carries several information fields, including the source and destination host addresses [1] [13]. 网际互联协议 (IP) 报头携带多个信息字段,包括源和目标主机地址 [1] [13]。

A TCP header follows the IP headers, supplying information specific to TCP.
TCP 头部跟在 IP 头部之后,提供特定于 TCP 的信息。

This division allows for the existence of host-level protocols other than TCP.
这种划分允许存在除 TCP 之外的主机级协议。

In the early development of the Internet suite of protocols, the IP header fields had been a part of TCP.
在 Internet 协议套件的早期开发中,IP 报头字段一直是 TCP 的一部分。

This document describes TCP, which uses TCP headers.
本文档描述了使用 TCP 头部的 TCP。

A TCP header, followed by any user data in the segment, is formatted as follows, using the style from [66]:
在段中,TCP 头部后面是任意用户数据,格式如下,使用 [66] 中的样式:

 0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   |          Source Port          |       Destination Port        |
   |                        Sequence Number                        |
   |                    Acknowledgment Number                      |
   |  Data |       |C|E|U|A|P|R|S|F|                               |
   | Offset| Rsrvd |W|C|R|C|S|S|Y|I|            Window             |
   |       |       |R|E|G|K|H|T|N|N|                               |
   |           Checksum            |         Urgent Pointer        |
   |                           [Options]                           |
   |                                                               :
   :                             Data                              :
   :                                                               |

Note that one tick mark represents one bit position.

Figure 1: TCP Header Format
图 1:TCP 头部格式


Source Port: 16 bits

The source port number.

Destination Port: 16 bits

The destination port number.

Sequence Number: 32 bits

The sequence number of the first data octet in this segment (except when SYN is present).
该段数据中第一个字节的序列号(有 SYN 标志除外)。
If SYN is set, the sequence number is the initial sequence number (ISN) and the first data octet is ISN+1.
如果设置了 SYN,则序列号是初始序列号 (ISN),第一个字节数据是 ISN+1。

Acknowledgment Number: 32 bits

If the ACK control bit is set, this field contains the value of the next sequence number the sender of the segment is expecting to receive. Once a connection is established, this is always sent.
如果设置了 ACK 标志,这个字段表示发送者期望收到的下一个序列号的值。一旦建立了连接,一直会发送这个字段。

Data Offset (DOffset): 4 bits

The number of 32 bit words in the TCP Header. This indicates where the data begins. The TCP header (even one including options) is an integer multiple of 32 bits long.
这个数表示 TCP 头部的长度有多少个 32 bit,表示真正数据开始的位置。TCP 头部(即使包括选项部分)的长度是 32 bit 的整数倍。

Reserved (Rsrvd): 4 bits

A set of control bits reserved for future use. Must be zero in generated segments and must be ignored in received segments if the corresponding future features are not implemented by the sending or receiving host.

Control bits:

The control bits are also known as “flags”.
控制位也称为 “标志”。

Assignment is managed by IANA from the “TCP Header Flags” registry [62].
由 IANA 从 “TCP Header Flags” 注册表 [62] 中管理分配。

The currently assigned control bits are CWR, ECE, URG, ACK, PSH, RST, SYN, and FIN.

CWR: 1 bit

Congestion Window Reduced (see [6]).
减少拥塞窗口(参见 [6])。

ECE: 1 bit

ECN-Echo (see [6]).
显式拥塞通知回应(参见 [6]).

URG: 1 bit

Urgent pointer field is significant.

ACK: 1 bit

Acknowledgment field is significant.

PSH: 1 bit

Push function (see the Send Call description in Section 3.9.1).
推送功能(参见第 3.9.1 节中的 Send 调用说明)。

RST: 1 bit

Reset the connection.

SYN: 1 bit

Synchronize sequence numbers.

FIN: 1 bit

No more data from sender.

Window: 16 bits

The number of data octets beginning with the one indicated in the acknowledgment field which the sender of this segment is willing to accept.

The value is shifted when the window scaling extension is used [47].
当使用窗口缩放扩展时,该值会发生变化 [47]。

The window size MUST be treated as an unsigned number, or else large window sizes will appear like negative windows and TCP will not work (MUST-1).
窗口大小必须被视为无符号的数字,否则大的窗口大小将出现负窗口,TCP 将无法工作(MUST-1)。

It is RECOMMENDED that implementations will reserve 32-bit fields for the send and receive window sizes in the connection record and do all window computations with 32 bits (REC-1).
建议实现在连接记录中为发送和接收窗口大小保留 32 位字段,并以 32 位进行所有窗口计算(REC-1)。

Checksum: 16 bits

The checksum field is the 16 bit one’s complement of the one’s complement sum of all 16 bit words in the header and text.
检验和是头部和数据部分所有分割成 16 bit 数的经过二进制反码求和得到的数。

The checksum computation needs to ensure the 16-bit alignment of the data being summed.
校验和计算需要确保求和的数据 16 位对齐。

If a segment contains an odd number of header and text octets, alignment can be achieved by padding the last octet with zeros on its right to form a 16-bit word for checksum purposes.
如果段的头部和内容是奇数个字节,可以通过在最后一个字节的右侧填充零来对齐,以组成一个 16 位字来实现校验和。

The pad is not transmitted as part of the segment.
填充不会作为 TCP 段的一部分进行传输。

While computing the checksum, the checksum field itself is replaced with zeros.

The checksum also covers a pseudo-header (Figure 2) conceptually prefixed to the TCP header.
校验和还包括了一个伪头部(图 2),在概念上作为 TCP 头部的前缀。

The pseudo-header is 96 bits for IPv4 and 320 bits for IPv6.
伪头部在 IPv4 下是 96 位,在 IPv6 下是 320 位。

Including the pseudo-header in the checksum gives the TCP connection protection against misrouted segments.
在校验和中包含伪标头可以避免 TCP 连接错误路由的段。

This information is carried in IP headers and is transferred across the TCP/network interface in the arguments or results of calls by the TCP implementation on the IP layer.
这些信息包含在 IP 头部中,并在 TCP/网络 接口上通过 TCP 对 IP 层的调用的参数或结果进行传输。

|           Source Address          |
|         Destination Address       |
|  zero  |  PTCL  |    TCP Length   |

Figure 2: IPv4 Pseudo-header
图 2:IPv4 伪头部

Pseudo-header components for IPv4:
IPv4 的伪头组成:

Source Address: the IPv4 source address in network byte order
Source Address: 网络字节序的 IPv4 源地址

Destination Address: the IPv4 destination address in network byte order
Destination Address: 网络字节序的 IPv4 目的地址

zero: bits set to zero
zero: 全部设置为 0

PTCL: the protocol number from the IP header
PTCL: 来自 IP 头部的协议号

TCP Length: the TCP header length plus the data length in octets (this is not an explicitly transmitted quantity but is computed), and it does not count the 12 octets of the pseudo-header. TCP Length: TCP 报头加上数据部分的长度,单位是字节(这不是一个明确的传输量,而是计算出来的),并且不包括 12 字节的伪头部。

For IPv6, the pseudo-header is defined in Section 8.1 of RFC 8200 [13] and contains the IPv6 Source Address and Destination Address, an Upper-Layer Packet Length (a 32-bit value otherwise equivalent to TCP Length in the IPv4 pseudo-header), three bytes of zero padding, and a Next Header value, which differs from the IPv6 header value if there are extension headers present between IPv6 and TCP.
对于 IPv6,伪标头在 RFC 8200 [13] 的第 8.1 节中定义,包含 IPv6 源地址和目标地址、上层数据包长度(一个 32 位值,否则等同于 IPv4 伪标头中的 TCP 长度) header),三个字节的零填充和一个 Next Header 值,如果 IPv6 和 TCP 之间存在扩展头部,则该值与 IPv6 头部值不同。

The TCP checksum is never optional. The sender MUST generate it (MUST-2) and the receiver MUST check it (MUST-3).
TCP 校验和永远不是可选的,发送方必须生成它(MUST-2)并且接收方必须检查它(MUST-3)。

Urgent Pointer: 16 bits

This field communicates the current value of the urgent pointer as a positive offset from the sequence number in this segment.

The urgent pointer points to the sequence number of the octet following the urgent data.

This field should only be interpreted in segments with the URG control bit set.
这个字段只应在设置了 URG 标志的 TCP 段中使用。


[TCP Option]; size(Options) == (DOffset-5)*32; present only when DOffset > 5.
[TCP Option]; size(Options) == (DOffset-5)*32; 只有在 DOffset > 5 时存在.

Note that this size expression also includes any padding trailing the actual options present.

Options may occupy space at the end of the TCP header and are a multiple of 8 bits in length.
选项部分可能占用 TCP 头的末尾的空间,长度为 8bit 的倍数。

All options are included in the checksum.

An option may begin on any octet boundary.

There are two cases for the format of an option:

  • Case 1: A single octet of option-kind.
    情况 1: 一个字节的选项类型。
  • Case 2: An octet of option-kind (Kind), an octet of option-length, and the actual option-data octets.
    情况 2: 一个字节的选项类型(Kind)、一个字节的选项长度和真正选项数据。

The option-length counts the two octets of option-kind and option-length as well as the option-data octets.

Note that the list of options may be shorter than the Data Offset field might imply.

The content of the header beyond the End of Option List Option MUST be header padding of zeros (MUST-69).

The list of all currently defined options is managed by IANA [62], and each option is defined in other RFCs, as indicated there.
所有当前定义的选项列表由 IANA [62] 管理,每个选项都在其他 RFC 中定义,如此处所示。

That set includes experimental options that can be extended to support multiple concurrent usages [45].
该列表包括可以扩展以支持多个并发使用的实验选项 [45]。

A given TCP implementation can support any currently defined options, but the following options MUST be supported (MUST-4 – note Maximum Segment Size Option support is also part of MUST-14 in Section 3.7.1):
给定的 TCP 实现可以支持任何当前定义的选项,但必须支持以下选项(MUST-4 —— 注意最大段大小选项支持也是第 3.7.1 节中 MUST-14 的一部分):

| Kind | Length | Meaning                    |
| 0    | -      | End of Option List Option. |
| 1    | -      | No-Operation.              |
| 2    | 4      | Maximum Segment Size.      |

Table 1: Mandatory Option Set
表 1: 强制性选项列表

These options are specified in detail in Section 3.2.
这些选项在第 3.2 节中有详细说明。

A TCP implementation MUST be able to receive a TCP Option in any segment (MUST-5).
TCP 实现必须能够在任何段中接收 TCP 选项(MUST-5)。

A TCP implementation MUST (MUST-6) ignore without error any TCP Option it does not implement, assuming that the option has a length field.
TCP 实现必须(MUST-6)无误地忽略它没有实现的任何 TCP 选项,假设该选项有一个长度字段。

All TCP Options except End of Option List Option (EOL) and No-Operation (NOP) MUST have length fields, including all future options (MUST-68).
除了选项列表结束选项(EOL)和无操作(NOP)之外的所有 TCP 选项必须有长度字段,包括所有未来选项(MUST-68)。

TCP implementations MUST be prepared to handle an illegal option length (e.g., zero); a suggested procedure is to reset the connection and log the error cause (MUST-7).
TCP 实现必须准备好处理非法选项长度(例如,0),建议的处理是重置连接并记录错误原因 (MUST-7)。

Note: There is ongoing work to extend the space available for TCP Options, such as [65].
注意:目前正在进行扩展 TCP 选项可用空间的工作,例如 [65]。

Data: variable length

User data carried by the TCP segment.
TCP 段中携带的用户数据。

具体的选项定义 #

3.2. Specific Option Definitions

A TCP Option, in the mandatory option set, is one of an End of Option List Option, a No-Operation Option, or a Maximum Segment Size Option. TCP 选项,在强制性选项列表中,是选项列表结束选项、无操作选项或最大段大小选项中的一个。

An End of Option List Option is formatted as follows:

 0 1 2 3 4 5 6 7
|       0       |


Kind: 1 byte; Kind == 0.

This option code indicates the end of the option list.

This might not coincide with the end of the TCP header according to the Data Offset field.
根据数据偏移字段,这可能与 TCP 头部的结尾不一致。

This is used at the end of all options, not the end of each option, and need only be used if the end of the options would not otherwise coincide with the end of the TCP header.
这用于所有选项的末尾,而不是每个选项的末尾,并且仅在选项末尾与 TCP 标头末尾不一致时才需要使用。

A No-Operation Option is formatted as follows:

 0 1 2 3 4 5 6 7
|       1       |


Kind: 1 byte; Kind == 1.

This option code can be used between options, for example, to align the beginning of a subsequent option on a word boundary.

There is no guarantee that senders will use this option, so receivers MUST be prepared to process options even if they do not begin on a word boundary (MUST-64).

A Maximum Segment Size Option is formatted as follows:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|       2       |     Length    |   Maximum Segment Size (MSS)  |


Kind: 1 byte; Kind == 2.

If this option is present, then it communicates the maximum receive segment size at the TCP endpoint that sends this segment.
如果存在此选项,则它会在发送此段的 TCP 端传达最大接收段大小。

This value is limited by the IP reassembly limit.
该值受 IP 重组限制。

This field may be sent in the initial connection request (i.e., in segments with the SYN control bit set) and MUST NOT be sent in other segments (MUST-65).
该字段可以在初始连接请求中发送(即,在设置了 SYN 控制位的段中)并且不得在其他段中发送(MUST-65)。

If this option is not used, any segment size is allowed.

A more complete description of this option is provided in Section 3.7.1.
第 3.7.1 节提供了此选项的更完整描述。

Length: 1 byte; Length == 4.

Length of the option in bytes.

Maximum Segment Size (MSS): 2 bytes.

The maximum receive segment size at the TCP endpoint that sends this segment.
发送该段的 TCP 端的最大接收段大小。

其他常用选项 #

3.2.1. Other Common Options

Additional RFCs define some other commonly used options that are recommended to implement for high performance but are not necessary for basic TCP interoperability.
其他 RFC 定义了一些其他建议为实现高性能而实现的常用选项,但对于基本 TCP 互操作性而言不是必需的。

These are the TCP Selective Acknowledgment (SACK) Option [22] [26], TCP Timestamp (TS) Option [47], and TCP Window Scale (WS) Option [47].
这些是 TCP 选择性确认 (SACK) 选项 [22] [26]、TCP 时间戳 (TS) 选项 [47] 和 TCP 窗口比例 (WS) 选项 [47]。

实验性 TCP 选项 #

3.2.2. Experimental TCP Options

Experimental TCP Option values are defined in [30], and [45] describes the current recommended usage for these experimental values.
实验性 TCP 选项值在 [30] 中定义,[45] 描述了这些实验值的当前推荐用法。

术语概述 #

3.3. TCP Terminology Overview

This section includes an overview of key terms needed to understand the detailed protocol operation in the rest of the document.

There is a glossary of terms in Section 4.
第 4 节中有术语表。

关键连接状态变量 #

3.3.1. Key Connection State Variables

Before we can discuss the operation of the TCP implementation in detail, we need to introduce some detailed terminology.
在我们详细讨论 TCP 实现的操作之前,我们需要介绍一些详细的术语。

The maintenance of a TCP connection requires maintaining state for several variables.
TCP 连接的维护需要维护多个变量的状态。

We conceive of these variables being stored in a connection record called a Transmission Control Block or TCB.
我们设想将这些变量存储在称为传输控制块或 TCB 的连接记录中。

Among the variables stored in the TCB are the local and remote IP addresses and port numbers, the IP security level, and compartment of the connection (see Appendix A.1), pointers to the user’s send and receive buffers, pointers to the retransmit queue and to the current segment.
存储在 TCB 中的变量包括本地和远程 IP 地址和端口号、IP 安全级别和连接区段(参见附录 A.1)、指向用户发送和接收缓冲区的指针、指向重传队列的指针和当前段。

In addition, several variables relating to the send and receive sequence numbers are stored in the TCB.
此外,几个与发送和接收序列号相关的变量存储在 TCB 中。

| Variable | Description                                         |
| SND.UNA  | send unacknowledged                                 |
| SND.NXT  | send next                                           |
| SND.WND  | send window                                         |
| SND.UP   | send urgent pointer                                 |
| SND.WL1  | segment sequence number used for last window update |
| SND.WL2  | segment acknowledgment number used for last window  |
|          | update                                              |
| ISS      | initial send sequence number                        |

Table 2: Send Sequence Variables
表 2: 发送序列变量

| Variable | Description                     |
| RCV.NXT  | receive next                    |
| RCV.WND  | receive window                  |
| RCV.UP   | receive urgent pointer          |
| IRS      | initial receive sequence number |

Table 3: Receive Sequence Variables
表 3: 接收序列变量

The following diagrams may help to relate some of these variables to the sequence space.

    1         2          3          4

1 - old sequence numbers which have been acknowledged
2 - sequence numbers of unacknowledged data
3 - sequence numbers allowed for new data transmission
4 - future sequence numbers which are not yet allowed

Figure 3: Send Sequence Space
图 3:发送序列变量

The send window is the portion of the sequence space labeled 3 in figure 3.
发送窗口是图 3 中标记为 3 的序列空间的一部分。

  1          2          3

1 - old sequence numbers which have been acknowledged
2 - sequence numbers allowed for new reception
3 - future sequence numbers which are not yet allowed

Figure 4: Receive Sequence Space
图 4:接收序列变量

The receive window is the portion of the sequence space labeled 2 in figure 4.
接收窗口是图 4 中标记为 2 的序列空间的一部分。

There are also some variables used frequently in the discussion that take their values from the fields of the current segment.

| Variable | Description                   |
| SEG.SEQ  | segment sequence number       |
| SEG.ACK  | segment acknowledgment number |
| SEG.LEN  | segment length                |
| SEG.WND  | segment window                |
| SEG.UP   | segment urgent pointer        |

Table 4: Current Segment Variables
表 4:当前段变量

状态机概述 #

3.3.2. State Machine Overview

A connection progresses through a series of states during its lifetime.


CLOSED is fictional because it represents the state when there is no TCB, and therefore, no connection.
CLOSED 是虚构的,因为它代表了没有 TCB 的状态,也就是没有连接。

Briefly the meanings of the states are:

LISTEN - represents waiting for a connection request from any remote TCP peer and port.
LISTEN - 表示等待来自任何远程对等 TCP 和端口的连接请求。

SYN-SENT - represents waiting for a matching connection request after having sent a connection request.
SYN-SENT - 表示在发送了一个连接请求后等待一个匹配的连接请求。

SYN-RECEIVED - represents waiting for a confirming connection request acknowledgment after having both received and sent a connection request.
SYN-RECEIVED - 表示在收到和发送连接请求后,等待确认连接请求的确认。

ESTABLISHED - represents an open connection, data received can be delivered to the user. The normal state for the data transfer phase of the connection.
ESTABLISHED - 代表一个已建立的连接,收到的数据可以传递给用户,是连接数据传输阶段的正常状态。

FIN-WAIT-1 - represents waiting for a connection termination request from the remote TCP peer, or an acknowledgment of the connection termination request previously sent.
FIN-WAIT-1 - 表示等待来自远程对等 TCP 的连接终止请求,或等待之前发送的终止连接请求的确认。

FIN-WAIT-2 - represents waiting for a connection termination request from the remote TCP peer.
FIN-WAIT-2 - 表示等待来自远程对等 TCP 的连接终止请求。

CLOSE-WAIT - represents waiting for a connection termination request from the local user.
CLOSE-WAIT - 表示等待本端用户的连接终止请求。

CLOSING - represents waiting for a connection termination request acknowledgment from the remote TCP peer.
CLOSING - 表示等待来自远程对等 TCP 的连接终止请求确认。

LAST-ACK - represents waiting for an acknowledgment of the connection termination request previously sent to the remote TCP peer(this termination request sent to the remote TCP peer already included an acknowledgment of the termination request sent from the remote TCP peer). LAST-ACK - 表示等待对先前发送到远程对等 TCP 的连接终止请求的确认(发送给远程对等 TCP 的这个终止请求已经包括了远程对等 TCP 发送的终止请求的确认)。

TIME-WAIT - represents waiting for enough time to pass to be sure the remote TCP peer received the acknowledgment of its connection termination request and to avoid new connections being impacted by delayed segments from previous connections.
TIME-WAIT - 表示等待足够的时间通过以确保远程对等 TCP 收到其连接终止请求的确认,并避免新连接受到先前连接的延迟段的影响。

CLOSED - represents no connection state at all.
CLOSED - 表示没有连接的状态。

A TCP connection progresses from one state to another in response to events.
TCP 连接根据事件从一个状态转换到另一个状态。

The events are the user calls, OPEN, SEND, RECEIVE, CLOSE, ABORT, and STATUS; the incoming segments, particularly those containing the SYN and FIN flags; and timeouts.
这些事件是用户调用 OPEN、SEND、RECEIVE、CLOSE、ABORT 和 STATUS;收到 TCP 段,特别是包含 SYN 和 FIN 标志的段;以及超时。

The OPEN call specifies whether connection establishment is to be actively pursued, or to be passively waited for.
OPEN 调用指定是主动要求连接建立,还是被动等待。

A passive OPEN request means that the process wants to accept incoming connection requests, in contrast to an active OPEN attempting to initiate a connection.
被动 OPEN 请求意味着进程想要接受传入的连接请求,这与主动 OPEN 尝试启动连接相反。

The state diagram in Figure 5 illustrates only state changes, together with the causing events and resulting actions, but addresses neither error conditions nor actions that are not connected with state changes.
图 5 中的状态图只说明了状态的变化,以及引起的事件和触发的行为,但既没有涉及错误条件,也没有涉及与状态变化无关的行为。

In a later section, more detail is offered with respect to the reaction of the TCP implementation to events.
在后面的章节中,将提供关于 TCP 对事件响应的更多细节。

Some state names are abbreviated or hyphenated differently in the diagram from how they appear elsewhere in the document.

NOTA BENE: This diagram is only a summary and must not be taken as the total specification. Many details are not included.

                               +---------+ ---------\      active OPEN
                               |  CLOSED |            \    -----------
                               +---------+<---------\   \   create TCB
                                 |     ^              \   \  snd SYN
                    passive OPEN |     |   CLOSE        \   \
                    ------------ |     | ----------       \   \
                     create TCB  |     | delete TCB         \   \
                                 V     |                      \   \
             rcv RST (note 1)  +---------+            CLOSE    |    \
          -------------------->|  LISTEN |          ---------- |     |
         /                     +---------+          delete TCB |     |
        /           rcv SYN      |     |     SEND              |     |
       /           -----------   |     |    -------            |     V
   +--------+      snd SYN,ACK  /       \   snd SYN          +--------+
   |        |<-----------------           ------------------>|        |
   |  SYN   |                    rcv SYN                     |  SYN   |
   |  RCVD  |<-----------------------------------------------|  SENT  |
   |        |                  snd SYN,ACK                   |        |
   |        |------------------           -------------------|        |
   +--------+   rcv ACK of SYN  \       /  rcv SYN,ACK       +--------+
      |         --------------   |     |   -----------
      |                x         |     |     snd ACK
      |                          V     V
      |  CLOSE                 +---------+
      | -------                |  ESTAB  |
      | snd FIN                +---------+
      |                 CLOSE    |     |    rcv FIN
      V                -------   |     |    -------
   +---------+         snd FIN  /       \   snd ACK         +---------+
   |  FIN    |<----------------          ------------------>|  CLOSE  |
   | WAIT-1  |------------------                            |   WAIT  |
   +---------+          rcv FIN  \                          +---------+
     | rcv ACK of FIN   -------   |                          CLOSE  |
     | --------------   snd ACK   |                         ------- |
     V        x                   V                         snd FIN V
   +---------+               +---------+                    +---------+
   |FINWAIT-2|               | CLOSING |                    | LAST-ACK|
   +---------+               +---------+                    +---------+
     |              rcv ACK of FIN |                 rcv ACK of FIN |
     |  rcv FIN     -------------- |    Timeout=2MSL -------------- |
     |  -------            x       V    ------------        x       V
      \ snd ACK              +---------+delete TCB          +---------+
        -------------------->|TIME-WAIT|------------------->| CLOSED  |
                             +---------+                    +---------+
Figure 5: TCP Connection State Diagram
图 5:TCP 连接状态图

The following notes apply to Figure 5:
以下注释适用于图 5:

  • Note 1: The transition from SYN-RECEIVED to LISTEN on receiving a RST is conditional on having reached SYN-RECEIVED after a passive OPEN.
    在接收到 RST 时从 SYN-RECEIVED 到 LISTEN 的转换以在被动 OPEN 之后达到 SYN-RECEIVED 为条件。

  • Note 2: The figure omits a transition from FIN-WAIT-1 to TIME-WAIT if a FIN is received and the local FIN is also acknowledged.
    如果收到 FIN 并且本地 FIN 也得到确认,则图中省略了从 FIN-WAIT-1 到 TIME-WAIT 的转换。

  • Note 3: A RST can be sent from any state with a corresponding transition to TIME-WAIT (see [70] for rationale).
    RST 可以从任何状态发送,并相应地转换为 TIME-WAIT(基本原理参见 [70])。

    These transitions are not explicitly shown; otherwise, the diagram would become very difficult to read.

    Similarly, receipt of a RST from any state results in a transition to LISTEN or CLOSED, though this is also omitted from the diagram for legibility.
    类似地,从任何状态接收到 RST 都会导致转换为 LISTEN 或 CLOSED,尽管为了便于阅读,图中也省略了这一点。

序列号 #

3.4. Sequence Numbers

A fundamental notion in the design is that every octet of data sent over a TCP connection has a sequence number.
TCP 设计中的一个基本概念是,通过 TCP 连接发送的每个字节的数据都有一个序列号。

Since every octet is sequenced, each of them can be acknowledged.

The acknowledgment mechanism employed is cumulative so that an acknowledgment of sequence number X indicates that all octets up to but not including X have been received.
TCP 所采用的确认机制是累积性的,因此序列号为 X 的确认表示已经收到了之前但不包括 X 的所有字节。

This mechanism allows for straightforward duplicate detection in the presence of retransmission.

The numbering scheme of octets within a segment is as follows: the first data octet immediately following the header is the lowest numbered, and the following octets are numbered consecutively.

It is essential to remember that the actual sequence number space is finite, though large.

This space ranges from 0 to 2**32 - 1.
这个范围是从 0 到 2**32-1 。

Since the space is finite, all arithmetic dealing with sequence numbers must be performed modulo 2**32.
由于范围是有限的,所有处理序列号的运算都必须模 2**32。

This unsigned arithmetic preserves the relationship of sequence numbers as they cycle from 2**32 - 1 to 0 again.
这种无符号算术保留了序列号之间的关系,因为它们从 2**32-1 再重新到 0。

There are some subtleties to computer modulo arithmetic, so great care should be taken in programming the comparison of such values.

The symbol “=<” means “less than or equal” (modulo 2**32).
符号 “=<” 表示 “小于或等于” (模 2**32)。

The typical kinds of sequence number comparisons that the TCP implementation must perform include:
TCP 实现中需要操作的典型的序列号比较包括:

(a) Determining that an acknowledgment refers to some sequence number sent but not yet acknowledged.
(a) 确定一个确认是对应某个已发送但尚未确认的序列号。

(b) Determining that all sequence numbers occupied by a segment have been acknowledged (e.g., to remove the segment from a retransmission queue).
(b) 确定 TCP 段所占用的所有序列号都已被确认(例如,从重传队列中删除该 TCP 段)。

(c) Determining that an incoming segment contains sequence numbers which are expected (i.e., that the segment “overlaps” the receive window).
(c) 确定一个收到的 TCP 段包含预期的序列号(即该 TCP 段与接收窗口"重叠")。

In response to sending data, the TCP endpoint will receive acknowledgments.
TCP 将收到确认作为对发送数据的响应。

The following comparisons are needed to process the acknowledgments.

SND.UNA = oldest unacknowledged sequence number
SND.UNA = 最早的未确认的序列号

SND.NXT = next sequence number to be sent
SND.NXT = 下一个要发送的序列号

SEG.ACK = acknowledgment from the receiving TCP peer (next sequence number expected by the receiving TCP)
SEG.ACK = 来自接收 TCP 的确认(接收 TCP 所期望的下一个序列号)。

SEG.SEQ = first sequence number of a segment
SEG.SEQ = TCP 段的第一个序列号

SEG.LEN = the number of octets occupied by the data in the segment (counting SYN and FIN)
SEG.LEN = 段落中的数据所占的字节数 (包括 SYN 和 FIN)

SEG.SEQ+SEG.LEN-1 = last sequence number of a segment
SEG.SEQ+SEG.LEN-1 = TCP 段的最后一个序列号

A new acknowledgment (called an “acceptable ack”), is one for which the inequality below holds:
一个新的确认(即 “可接受的确认”),会满足以下不等式。

A segment on the retransmission queue is fully acknowledged if the sum of its sequence number and length is less than the acknowledgment value in the incoming segment.
如果重传队列中的一个 TCP 段的序列号和长度之和小于收到段的确认值,则该段被完全确认。

When data is received the following comparisons are needed:

RCV.NXT = next sequence number expected on an incoming segments, and is the left or lower edge of the receive window
RCV.NXT = 下一个预期收到 TCP 段的序列号,也是接收窗口的左边界或下限。

RCV.NXT+RCV.WND-1 = last sequence number expected on an incoming segment, and is the right or upper edge of the receive window
RCV.NXT+RCV.WND-1 = 最后一个预期收到 TCP 段的序列号,也是接收窗口的右边界或上限。

SEG.SEQ = first sequence number occupied by the incoming segment
SEG.SEQ = 收到 TCP 段的第一个序列号

SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming segment
SEG.SEQ+SEG.LEN-1 = 收到 TCP 段的最后一个序列号

A segment is judged to occupy a portion of valid receive sequence space if
在下列情况下,一个 TCP 段被判断为占据了有效接收序列范围的一部分




The first part of this test checks to see if the beginning of the segment falls in the window, the second part of the test checks to see if the end of the segment falls in the window; if the segment passes either part of the test it contains data in the window.

Actually, it is a little more complicated than this. Due to zero windows and zero-length segments, we have four cases for the acceptability of an incoming segment:
实际上,情况比这更复杂一些。由于零窗口和零长度的 TCP 段,我们有四种情况来判断一个收到的 TCP 段是否可接受:

| Segment | Receive | Test                                 |
| Length  | Window  |                                      |
| 0       | 0       | SEG.SEQ = RCV.NXT                    |
| 0       | >0      | RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND |
| >0      | 0       | not acceptable                       |
| >0      | >0      | RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND |
|         |         |                                      |
|         |         | or                                   |
|         |         |                                      |
|         |         | RCV.NXT =< SEG.SEQ+SEG.LEN-1 <       |
|         |         | RCV.NXT+RCV.WND                      |

Table 5: Segment Acceptability Tests
表 5:段可接受性测试

Note that when the receive window is zero no segments should be acceptable except ACK segments.
请注意,当接收窗口为零时,除了 ACK 段外,不应接受其他 TCP 段。

Thus, it is possible for a TCP implementation to maintain a zero receive window while transmitting data and receiving ACKs.
因此,TCP 实现应该有可能在传输数据和接收 ACK 的同时保持一个零接收窗口。

A TCP receiver MUST process the RST and URG fields of all incoming segments, even when the receive window is zero (MUST-66). 即使接收窗口为零,TCP 也必须处理所有接收段的 RST 和 URG 字段 (MUST-66)。

We have taken advantage of the numbering scheme to protect certain control information as well. 我们还利用了编号方案来保护某些控制信息。

This is achieved by implicitly including some control flags in the sequence space so they can be retransmitted and acknowledged without confusion (i.e., one and only one copy of the control will be acted upon).

Control information is not physically carried in the segment data space.
控制信息不实际在 TCP 段数据空间中携带。

Consequently, we must adopt rules for implicitly assigning sequence numbers to control. 因此,我们必须采用隐式分配序列号的规则来控制。

The SYN and FIN are the only controls requiring this protection, and these controls are used only at connection opening and closing.
SYN 和 FIN 是唯一需要这种保护的控制,而且这些控制只在连接打开和关闭时使用。

For sequence number purposes, the SYN is considered to occur before the first actual data octet of the segment in which it occurs, while the FIN is considered to occur after the last actual data octet in a segment in which it occurs.
就序列号而言,SYN 被认为发生在其所在 TCP 段的实际数据第一个字节之前,而 FIN 被认为发生在其所在段的实际数据的最后一个字节之后。

The segment length (SEG.LEN) includes both data and sequence space-occupying controls.
TCP 段的长度包括数据和占用序列空间的控制信息。

When a SYN is present then SEG.SEQ is the sequence number of the SYN.
当存在 SYN 时,SEG.SEQ 是 SYN 的序列号。

初始序列号的选择 #

3.4.1. Initial Sequence Number Selection

A connection is defined by a pair of sockets. Connections can be reused.

New instances of a connection will be referred to as incarnations of the connection.

The problem that arises from this is – “how does the TCP implementation identify duplicate segments from previous incarnations of the connection?”
由此产生的问题是 – “TCP 实现如何识别来自以前连接中的重复段?”

This problem becomes apparent if the connection is being opened and closed in quick succession, or if the connection breaks with loss of memory and is then reestablished.

To support this, the TIME-WAIT state limits the rate of connection reuse, while the initial sequence number selection described below further protects against ambiguity about which incarnation of a connection an incoming packet corresponds to.
为了支持这一点,TIME-WAIT 状态限制了连接重用的速度,而下面描述的初始序列号选择进一步防止关于接收数据包对应于哪个连接实例的歧义。

To avoid confusion, we must prevent segments from one incarnation of a connection from being used while the same sequence numbers may still be present in the network from an earlier incarnation.

We want to assure this even if a TCP endpoint crashes and loses all knowledge of the sequence numbers it has been using.
我们要保证这一点,即使 TCP 崩溃并失去了它使用的序列号的所有信息。

When new connections are created, an initial sequence number (ISN) generator is employed which selects a new 32 bit ISN.
当创建新连接时,使用初始序列号(ISN)生成器选择新的 32 位 ISN。

There are security issues that result if an off-path attacker is able to predict or guess ISN values [42].
如果 off-path attacker 能够预测或猜测 ISN 值,则会出现安全问题 [42]。

TCP initial sequence numbers are generated from a number sequence that monotonically increases until it wraps, known loosely as a “clock”.
TCP 初始序列号是由一个数字序列生成的,该数字序列单调递增,直到它回绕,广泛地称为 “时钟”。

This clock is a 32-bit counter that typically increments at least once every roughly 4 microseconds, although it is neither assumed to be realtime nor precise, and need not persist across reboots.
这个时钟是一个 32 位计数器,通常大约每 4 微秒至少递增一次,尽管它既不假定是实时的也不精确,并且不需要在重新启动后持续存在。

The clock component is intended to ensure that with a Maximum Segment Lifetime (MSL), generated ISNs will be unique since it cycles approximately every 4.55 hours, which is much longer than the MSL.
时钟组件旨在确保使用最大段寿命 (MSL) 生成的 ISN 将是唯一的,因为它大约每 4.55 小时循环一次,这比 MSL 长得多。

Please note that for modern networks that support high data rates where the connection might start and quickly advance sequence numbers to overlap within the MSL, it is recommended to implement the Timestamp Option as mentioned later in Section 3.4.3.
请注意,对于支持高数据率的现代网络,连接可能开始并快速推进序列号,在 MSL 内重叠,建议实现 3.4.3 节后面提到的时间戳选项。

A TCP implementation MUST use the above type of “clock” for clock-driven selection of initial sequence numbers (MUST-8), and SHOULD generate its initial sequence numbers with the expression:
对于初始序列号(MUST-8)的时钟驱动选择,TCP 实现必须使用上述类型的 “时钟”,并且应使用以下表达式生成其初始序列号:

ISN = M + F(localip, localport, remoteip, remoteport, secretkey)

where M is the 4 microsecond timer, and F() is a pseudorandom function (PRF) of the connection’s identifying parameters (“localip, localport, remoteip, remoteport”) and a secret key (“secretkey”) (SHLD-1).
其中,M 是 4 微秒计时器,F()是连接的标识参数(“localip, localport, remoteip, remoteport”)和密钥(“seckkey”)(SHLD-1)的伪随机函数(PRF)。

F() MUST NOT be computable from the outside (MUST-9), or an attacker could still guess at sequence numbers from the ISN used for some other connection.
F()不能从外部计算出来(MUST-9),否则攻击者仍然可以从用于其他连接的 ISN 中猜测序列号。

The PRF could be implemented as a cryptographic hash of the concatenation of the TCP connection parameters and some secret data.
PRF 可以被实现为 TCP 连接参数和一些秘密数据的级联的密码散列。

For discussion of the selection of a specific hash algorithm and management of the secret key data, please see Section 3 of [42].
关于特定散列算法的选择和密钥数据的管理的讨论,请参见[42]的第 3 节。

For each connection there is a send sequence number and a receive sequence number.

The initial send sequence number (ISS) is chosen by the data sending TCP peer, and the initial receive sequence number (IRS) is learned during the connection-establishing procedure.
初始发送序列号(ISS)由数据发送 TCP 选择,而初始接收序列号(IRS)在连接建立过程中得到。

For a connection to be established or initialized, the two TCP peers must synchronize on each other’s initial sequence numbers.
如果要建立或初始化的连接,两个 TCP 必须同步对方的初始序列号。

This is done in an exchange of connection-establishing segments carrying a control bit called “SYN” (for synchronize) and the initial sequence numbers.
这是通过交换建立连接的信息来完成的,这些信息带有一个称为 “SYN”(用于同步)的控制位和初始序列号。

As a shorthand, segments carrying the SYN bit are also called “SYNs”.
简而言之,携带 SYN 位的消息也称为 “SYNs”。

Hence, the solution requires a suitable mechanism for picking an initial sequence number and a slightly involved handshake to exchange the ISNs.
因此,该解决方案需要一个合适的机制来挑选初始序列号,并需要一个稍微复杂的握手来交换 ISN。

The synchronization requires each side to send its own initial sequence number and to receive a confirmation of it in acknowledgment from the remote TCP peer.
同步需要每一方发送自己的初始序列号,并从远端的 ACK 中得到确认。

Each side must also receive the remote peer’s initial sequence number and send a confirming acknowledgment.
每一方还必须收到远端的初始序列号,并发送确认的 ACK。

(1) A –> B SYN my sequence number is X
(1) A –> B 同步自己的序列号 X

(2) A <– B ACK your sequence number is X
(2) A <– B 确认你的序列号是 X

(3) A <– B SYN my sequence number is Y
(3) A <– B 同步自己的序列号 Y

(4) A –> B ACK your sequence number is Y
(4) A –> B 确认你的序列号是 Y

Because steps 2 and 3 can be combined in a single message this is called the three-way (or three message) handshake (3WHS).
由于第 2 和第 3 步可以结合在一个消息中,这被称为三次(或三次信息)握手(3WHS)。

A 3WHS is necessary because sequence numbers are not tied to a global clock in the network, and TCP implementations may have different mechanisms for picking the ISNs.
“三次握手” 是必要的,因为序列号没有绑定到网络中的全局时钟,并且 TCP 可能有不同的机制来挑选 ISN。

The receiver of the first SYN has no way of knowing whether the segment was an old one or not, unless it remembers the last sequence number used on the connection (which is not always possible), and so it must ask the sender to verify this SYN.
第一个 SYN 的接收者没有办法知道这个 TCP 段是否是一个旧的延迟段,除非它记得连接上使用的最后一个序列号(这并不总是可能的),所以它必须要求发送者验证这个 SYN。

The three-way handshake and the advantages of a clock-driven scheme for ISN selection are discussed in [69].
在[3]中讨论了 “三次握手” 和 ISN 选择 “时钟驱动” 方案的优势。

知道什么时候该保持静默 #

3.4.2. Knowing When to Keep Quiet

A theoretical problem exists where data could be corrupted due to confusion between old segments in the network and new ones after a host reboots if the same port numbers and sequence space are reused.

The “quiet time” concept discussed below addresses this, and the discussion of it is included for situations where it might be relevant, although it is not felt to be necessary in most current implementations.
下面讨论的 “静默时间” 概念解决了这一问题,并将它的讨论包括在可能与之相关的情况下,尽管它在大多数当前实现中并不是必要的。

The problem was more relevant earlier in the history of TCP.
在 TCP 历史的早期,这个问题更为相关。

In practical use on the Internet today, the error-prone conditions are sufficiently unlikely that it is safe to ignore.

Reasons why it is now negligible include: (a) ISS and ephemeral port randomization have reduced likelihood of reuse of port numbers and sequence numbers after reboots, (b) the effective MSL of the Internet has declined as links have become faster, and (c) reboots often taking longer than an MSL anyways.
(a) ISS 和临时端口随机化降低了重新启动后重用端口号和序列号的可能性。
(b) 随着链接变得更快,互联网的有效 MSL 已经下降。
(c) 无论如何,重新启动通常比 MSL 花费的时间更长。

To be sure that a TCP implementation does not create a segment carries a sequence number that may be duplicated by an old segment remaining in the network, the TCP endpoint must keep quiet for a MSL before assigning any sequence numbers upon starting up or recovering from a situation where memory of sequence numbers in use was lost.
为了确保 TCP 实现不会创建一个携带与网络中旧 TCP 段中序列号重复的 TCP 段,TCP 在启动时或从丢失当前使用序列号内存的崩溃中恢复时,在分配任何序列号之前保持最大段存活时间(MSL)的静默时间。

For this specification the MSL is taken to be 2 minutes.
在本规范中,MSL 是 2 分钟。

This is an engineering choice, and may be changed if experience indicates it is desirable to do so.

Note that if a TCP endpoint is reinitialized in some sense, yet retains its memory of sequence numbers in use, then it need not wait at all; it must only be sure to use sequence numbers larger than those recently used.
注意,如果一个 TCP 在某种情况被重新初始化,但保留了其正在使用的序列号的内存,那么它不需要等待;它只需要确保使用比最近使用的序列号大的序列号。

TCP 静默时间的概念 #

3.4.3. The TCP Quiet Time Concept

Hosts that for any reason lose knowledge of the last sequence numbers transmitted on each active (i.e., not closed) connection shall delay emitting any TCP segments for at least the agreed MSL in the internet system of which the host is a part.
如果主机因为任何原因没有保留在每个活动(即未关闭)连接上传输的最后一个序列号的任何信息,则应至少延迟商定的最大段生命周期(MSL)后,再发送任何 TCP 段到主机所处的 internet 系统中。

In the paragraphs below, an explanation for this specification is given.

TCP implementors may violate the “quiet time” restriction, but only at the risk of causing some old data to be accepted as new or new data rejected as old duplicated by some receivers in the internet system.
TCP 实现者可以会违反 “quiet time” 限制,但是可能存在导致某些旧数据被接受为新数据或新数据被 internet 系统中的某些接收方认为是旧的重复数据而拒收的风险。

TCP endpoints consume sequence number space each time a segment is formed and entered into the network output queue at a source host.
每次生成段并加入到源主机的网络输出队列时,TCP 都会消耗序列号空间。

The duplicate detection and sequencing algorithm in the TCP protocol relies on the unique binding of segment data to sequence space to the extent that sequence numbers will not cycle through all 2**32 values before the segment data bound to those sequence numbers has been delivered and acknowledged by the receiver and all duplicate copies of the segments have “drained” from the internet.
TCP 协议中的重复检测和排序算法依赖于段数据与序列空间的唯一绑定,因此与这些序列号绑定的段数据被送达并被接收方确认以及段的所有副本从互联网上 “耗尽” 之前,序列号不会在所有 2**32 值中循环。

Without such an assumption, two distinct TCP segments could conceivably be assigned the same or overlapping sequence numbers, causing confusion at the receiver as to which data is new and which is old.
如果没有这样的假设,两个不同的 TCP 段可能会被分配相同或重叠的序列号,从而导致接收方无法区分哪些数据是新数据,哪些是旧数据。

Remember that each segment is bound to as many consecutive sequence numbers as there are octets of data and SYN or FIN flags in the segment.
记住,每个段都绑定到与段中数据和 SYN 或 FIN 标志的字节一样多的连续序列号。

Under normal conditions, TCP implementations keep track of the next sequence number to emit and the oldest awaiting acknowledgment so as to avoid mistakenly reusing a sequence number over before its first use has been acknowledged.
在正常情况下,TCP 会跟踪下一个要发出的序列号和最旧的等待确认的序列号,以避免在第一次使用得到确认之前错误地重用该序列号。

This alone does not guarantee that old duplicate data is drained from the net, so the sequence space has been made very large to reduce the probability that a wandering duplicate will cause trouble upon arrival.

At 2 megabits/sec. it takes 4.5 hours to use up 2**32 octets of sequence space.
在 2 兆比特/秒的情况下,需要 4.5 小时才能用完 2**32 个字节的序列空间。

Since the maximum segment lifetime in the net is not likely to exceed a few tens of seconds, this is deemed ample protection for foreseeable nets, even if data rates escalate to 10’s of megabits/sec.
由于网络中的段的最大存活时间不太可能超过几十秒,这被认为是对可预见网络的充分保护,即使数据速率升级到 10 兆比特/秒。

At 100 megabits/sec, the cycle time is 5.4 minutes which may be a little short, but still within reason.
在 100 兆比特/秒时,循环时间为 5.4 分钟,这可能有点短,但仍在合理范围内。

Much higher data rates are possible today, with implications described in the final paragraph of this subsection.

The basic duplicate detection and sequencing algorithm in TCP can be defeated, however, if a source TCP endpoint does not have any memory of the sequence numbers it last used on a given connection.
然而,如果源 TCP 没有任何关于它在给定连接上最后使用的序列号的内存,则 TCP 中的基础重复检测和排序算法可能会失效。

For example, if the TCP implementation were to start all connections with sequence number 0, then upon the host rebooting, a TCP peer might re-form an earlier connection (possibly after half-open connection resolution) and emit packets with sequence numbers identical to or overlapping with packets still in the network which were emitted on an earlier incarnation of the same connection.
例如,如果 TCP 以序列号 0 开始所有连接,那么在重新启动时,TCP 可能会重新建立较早的连接(可能在半开连接解析之后)并发出序列号与网络中的数据包相同或重叠的数据包,这些数据包是在同一连接的早期实例下发出的。

In the absence of knowledge about the sequence numbers used on a particular connection, the TCP specification recommends that the source delay for MSL seconds before emitting segments on the connection, to allow time for segments from the earlier connection incarnation to drain from the system.
在不知道特定连接上使用的序列号的情况下,TCP 规范建议源 TCP 在连接上发送段之前延迟 MSL 秒,以便让来自早期连接实例的段有时间从系统中消失。

Even hosts which can remember the time of day and used it to select initial sequence number values are not immune from this problem (i.e., even if time of day is used to select an initial sequence number for each new connection incarnation).

Suppose, for example, that a connection is opened starting with sequence number S.
例如,假设一个连接以序列号 S 开始打开。

Suppose that this connection is not used much and that eventually the initial sequence number function (ISN(t)) takes on a value equal to the sequence number, say S1, of the last segment sent by this TCP on a particular connection.
假设这个连接使用不多,最终初始序列号函数(ISN(t))的值等于这个 TCP 在特定连接上发送的最后一个段的序列号,例如 S1。

Now suppose, at this instant, the host reboots and establishes a new incarnation of the connection.

The initial sequence number chosen is S1 = ISN(t) – last used sequence number on old incarnation of connection!
选择的初始序列号是 S1 = ISN(t) – 旧的连接的最后使用的序列号!

If the recovery occurs quickly enough, any old duplicates in the net bearing sequence numbers in the neighborhood of S1 may arrive and be treated as new packets by the receiver of the new incarnation of the connection.
如果恢复发生得足够快,网络中任何带有 S1 附近序列号的旧重复数据都可能到达,并被新的连接实例的接收者视为新的数据包。

The problem is that the recovering host may not know for how long it was down between rebooting nor does it know whether there are still old duplicates in the system from earlier connection incarnations.

One way to deal with this problem is to deliberately delay emitting segments for one MSL after recovery from a crash- this is the “quiet time” specification.
解决这个问题的一种方法是在从崩溃中恢复后故意延迟一个 MSL 再发送段,这是 “静默时间” 规范。

Hosts that prefer to avoid waiting are willing to risk possible confusion of old and new packets at a given destination may choose not to wait for the “quie t time”.
喜欢避免等待的主机,愿意冒着在目的地可能出现新旧数据包混淆的风险,可以选择不等待 “静默时间”。

Implementors may provide TCP users with the ability to select on a connection-by-connection basis whether to wait after a reboot, or may informally implement the “quiet time” for all connections.
实现者可以为 TCP 用户提供在连接基础上选择是否在崩溃后等待的能力,或者可以非正式地为所有连接实现 “静默时间”。

Obviously, even where a user selects to “wait”, this is not necessary after the host has been “up” for at least MSL seconds.
很明显,即使用户选择了 “等待”,在主机至少 “启动” 了 MSL 秒之后,也没有必要这样做。

To summarize: every segment emitted occupies one or more sequence numbers in the sequence space, the numbers occupied by a segment are “busy” or “in use” until MSL seconds have passed.
总结一下:每个发出的段在序列空间中占据一个或多个序列号,段所占据的序列号是 “忙” 或 “使用中”,直到 MSL 秒过去。

Upon rebooting, a block of space-time is occupied by the octets and SYN or FIN flags of any potentially still in-flight segments.
重启时,一个时空块被任何仍在网络中的段的数据和 SYN 或 FIN 标志占据。

If a new connection is started too soon and uses any of the sequence numbers in the space-time footprint of those potentially still in-flight segment of the previous connection incarnation, there is a potential sequence number overlap area which could cause confusion at the receiver.

High-performance cases will have shorter cycle times than those in the megabits per second that the base TCP design described above considers.
高性能情况下的周期时间将比上述基本 TCP 设计考虑的兆比特每秒的周期时间更短。

At 1 Gbps, the cycle time is 34 seconds, only 3 seconds at 10 Gbps, and around a third of a second at 100 Gbps.
在 1 Gbps 时,周期时间为 34 秒,在 10 Gbps 时仅为 3 秒,在 100 Gbps 时约为三分之一秒。

In these higher-performance cases, TCP Timestamp Options and Protection Against Wrapped Sequences (PAWS) [47] provide the needed capability to detect and discard old duplicates.
在这些更高性能的情况下,TCP 时间戳选项和针对包装序列的保护(PAWS)[47]提供了检测和丢弃旧副本所需的能力。

建立连接 #

3.5. Establishing a Connection

The “three-way handshake” is the procedure used to establish a connection.
“三次握手” 是用于建立连接的过程。

This procedure normally is initiated by one TCP peer and responded to by another TCP peer.
这个过程通常由一个 TCP 发起,由另一个 TCP 响应。

The procedure also works if two TCP peers simultaneously initiate the procedure.
如果两个 TCP 同时发起连接,该过程也应正常工作。

When simultaneous attempt occurs, each TCP peer receives a “SYN” segment which carries no acknowledgment after it has sent a “SYN”.
当同时尝试建立连接时,TCP 在发送 “SYN” 后,收到没有携带确认的 “SYN” 段。

Of course, the arrival of an old duplicate “SYN” segment can potentially make it appear, to the recipient, that a simultaneous connection initiation is in progress.
当然,当接收者收到一个旧的重复的 “SYN” 段时,有可能会认为是同时建立连接。

Proper use of “reset” segments can disambiguate these cases.
适当使用 “reset” 段可以消除这些情况。

Several examples of connection initiation follow.

Although these examples do not show connection synchronization using data-carrying segments, this is perfectly legitimate, so long as the receiving TCP endpoint doesn’t deliver the data to the user until it is clear the data is valid (i.e., the data must be buffered at the receiver until the connection reaches the ESTABLISHED state, given that the three-way handshake reduces the possibility of false connections).
虽然这些例子中连接同步没有显示携带数据,这是完全可以的,在接收 TCP 明确数据有效之前,它不向用户传递数据(即这些数据必须先放在接收者的缓存中,直到连接达到 ESTABLISHED 状态,因为三方握手减少了错误连接的可能性)。

It is the implementation of a trade-off between memory and messages to provide information for this checking.

The simplest 3WHS is shown in figure 6.
最简单的三次握手如图 6 所示。

The figures should be interpreted in the following way.

Each line is numbered for reference purposes.

Right arrows (–>) indicate departure of a TCP segment from TCP peer A to TCP peer B, or arrival of a segment at B from A.
右箭头 (–>) 表示从 TCP A 发送到 TCP B 的 TCP 段,或 B 接收到 A 的 TCP 段。

Left arrows (<–), indicate the reverse.
左箭头 (<–) 表示相反方向。

Ellipsis (…) indicates a segment which is still in the network (delayed).
省略号 (…) 表示仍在网络中的 TCP 段(延迟了)。

Comments appear in parentheses.

TCP connection states represent the state AFTER the departure or arrival of the segment (whose contents are shown in the center of each line).
TCP 状态表示数据段发送或到达后的状态(其内容显示在每行的中间)。

Segment contents are shown in abbreviated form, with sequence number, control flags, and ACK field.
TCP 段的内容以缩写的形式显示,包括序列号、控制标志和 ACK 字段。

Other fields such as window, addresses, lengths, and text have been left out in the interest of clarity.

      TCP Peer A                                            TCP Peer B
  1.  CLOSED                                                LISTEN
  2.  SYN-SENT    --> <SEQ=100><CTL=SYN>                --> SYN-RECEIVED
  4.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK>       --> ESTABLISHED
Figure 6: Basic Three-Way Handshake for Connection Synchronization
图 6:用于连接同步的基础三次握手

In line 2 of figure 6, TCP peer A begins by sending a SYN segment indicating that it will use sequence numbers starting with sequence number 100.
在图 9 的第 2 行,TCP A 开始发送一个 SYN 段,表明它将使用从序列号 100 开始的序列号。

In line 3, TCP peer B sends a SYN and acknowledges the SYN it received from TCP peer A.
在第 3 行,TCP B 发送了一个 SYN,并确认了它从 TCP A 收到的 SYN。

Note that the acknowledgment field indicates TCP peer B is now expecting to hear sequence 101, acknowledging the SYN which occupied sequence 100.
注意,确认字段表明 TCP B 现在期望收到到序列 101,确认收到序列 100 的 SYN。

At line 4, TCP peer A responds with an empty segment containing an ACK for TCP B’s SYN; and in line 5, TCP A sends some data.
在第 4 行,TCP A 发送一个包含 ACK 的空段回应 TCP B 的 SYN;在第 5 行,TCP A 发送了一些数据。

Note that the sequence number of the segment in line 5 is the same as in line 4 because the ACK does not occupy sequence number space (if it did, we would wind up ACKing ACK’s!).
注意,第 5 行的 TCP 段的序列号与第 4 行相同,因为 ACK 不占用序列号空间(如果它占用了,我们就会变成 ACK 的 ACK!)

Simultaneous initiation is only slightly more complex, as is shown in figure 7.
同时建立连接只是稍微复杂一些,如图 7 所示。

Each TCP peer’s connection state cycles from CLOSED to SYN-SENT to SYN-RECEIVED to ESTABLISHED.

      TCP Peer A                                       TCP Peer B
  1.  CLOSED                                           CLOSED
  2.  SYN-SENT     --> <SEQ=100><CTL=SYN>              ...
  3.  SYN-RECEIVED <-- <SEQ=300><CTL=SYN>              <-- SYN-SENT
  4.               ... <SEQ=100><CTL=SYN>              --> SYN-RECEIVED
  5.  SYN-RECEIVED --> <SEQ=100><ACK=301><CTL=SYN,ACK> ...
  7.               ... <SEQ=101><ACK=301><CTL=ACK>     --> ESTABLISHED
Figure 7: Simultaneous Connection Synchronization
图 7:同时连接同步

A TCP implementation MUST support simultaneous open attempts (MUST-10).
TCP 实现必须支持同时打开尝试(必须-10)。

Note that a TCP implementation MUST keep track of whether a connection has reached SYN-RECEIVED state as the result of a passive OPEN or an active OPEN (MUST-11).
注意,TCP 实现必须跟踪连接是由于被动打开还是主动打开(MUST-11)而达到 SYN-RECEIVED 状态。

The principle reason for the three-way handshake is to prevent old duplicate connection initiations from causing confusion.

To deal with this, a special control message, reset, is specified.

If the receiving TCP is in a non-synchronized state (i.e., SYN-SENT, SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset.
如果接收的 TCP 处于非同步状态(即 SYN-SENT,SYN-RECEIVED),它在收到有效的 reset 时返回到 LISTEN。

If the TCP is in one of the synchronized states (ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), it aborts the connection and informs its user.

We discuss this latter case under “half-open” connections below.
我们将在下面的 “half-open” 连接下讨论后面一种情况。

      TCP Peer A                                           TCP Peer B
  1.  CLOSED                                               LISTEN
  2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               ...
  3.  (duplicate) ... <SEQ=90><CTL=SYN>                --> SYN-RECEIVED
  4.  SYN-SENT    <-- <SEQ=300><ACK=91><CTL=SYN,ACK>   <-- SYN-RECEIVED
  5.  SYN-SENT    --> <SEQ=91><CTL=RST>                --> LISTEN
  6.              ... <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
  7.  SYN-SENT    <-- <SEQ=400><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
  8.  ESTABLISHED --> <SEQ=101><ACK=401><CTL=ACK>      --> ESTABLISHED
Figure 8: Recovery from Old Duplicate SYN
图 8: 从之前重复 SYN 中恢复

As a simple example of recovery from old duplicates, consider figure 8.
从之前重复 SYN 中恢复的简单示例,请参见图 8。

At line 3, an old duplicate SYN arrives at TCP Peer B.
在第 3 行,一个之前重复 SYN 到达了 TCP B。

TCP Peer B cannot tell that this is an old duplicate, so it responds normally (line 4).
TCP B 无法断定这是之前的 SYN,所以它正常响应(第 4 行)。

TCP A detects that the ACK field is incorrect and returns a RST (reset) with its SEQ field selected to make the segment believable.
TCP A 检测到 ACK 字段不正确,然后返回一个 RST(重置),同时选择 SEQ 字段以使该 TCP 段可信。

TCP B, on receiving the RST, returns to the LISTEN state.
TCP B 收到 RST 后,返回到 LISTEN 状态。

When the original SYN (pun intended) finally arrives at line 6, the synchronization proceeds normally.
在第 6 行,当真正的 SYN(双关语)最终到达时,同步正常进行。

If the SYN at line 6 had arrived before the RST, a more complex exchange might have occurred with RST’s sent in both directions.
如果第 6 行的 SYN 在 RST 之前到达,则可能会发生更复杂的交换,双方都会发送 RST。

半开放连接和其他异常情况 #

3.5.1. Half-Open Connections and Other Anomalies

An established connection is said to be “half-open” if one of the TCPs has closed or aborted the connection at its end without the knowledge of the other, or if the two ends of the connection have become desynchronized owing to a failure or reboot that resulted in loss of memory.
如果其中一个 TCP 在另一个不知道的情况下关闭或中止了连接,或者连接的两端由于错误或重启导致内存丢失而变得不同步,则已建立的连接被称为 “半开放”。

Such connections will automatically become reset if an attempt is made to send data in either direction.

However, half-open connections are expected to be unusual, and the recovery procedure is mildly involved.

If at site A the connection no longer exists, then an attempt by the user at site B to send any data on it will result in the site B TCP endpoint receiving a reset control message.
如果站点 A 的连接不再存在,那么站点 B 的用户试图在其上发送任何数据将导致站点 B 的 TCP 收到重置控制消息。

Such a message indicates to the site B TCP endpoint that something is wrong, and it is expected to abort the connection.
这种消息表明 B 的 TCP 有问题,并希望它能中止连接。

Assume that two user processes A and B are communicating with one another when a failure or reboot occurs causing loss of memory to A’s TCP implementation.
假设两个用户进程 A 和 B 正在相互通信,当发生错误或重启导致 A 的 TCP 实现丢失内存时。

Depending on the operating system supporting A’s TCP implementation, it is likely that some error recovery mechanism exists.
可能会存在一些错误恢复机制,这取决于 TCP A 实现所运行的操作系统。

When the TCP endpoint is up again, A is likely to start again from the beginning or from a recovery point.
当 TCP 再次启动时,A 可能会从头或从某个恢复点重新启动。

As a result, A will probably try to OPEN the connection again or try to SEND on the connection it believes open.
因此,A 可能会尝试再次打开连接或尝试在它认为已经打开的连接上发送。

In the latter case, it receives the error message “connection not open” from the local (A’s) TCP implementation.
在后面一种情况下,它会收到来自本地(A) TCP 实现的错误消息 “Connection Not Open”。

In an attempt to establish the connection, A’s TCP implementation will send a segment containing SYN.
在尝试建立连接时,A 的 TCP 实现将发送包含 SYN 的 TCP 段。

This scenario leads to the example shown in figure 9.
这种情况的示例如图 9 所示。

After TCP Peer A reboots, the user attempts to re-open the connection.
在 TCP A 崩溃后,用户试图重新打开连接。

TCP Peer B, in the meantime, thinks the connection is open.
在此期间,TCP B 认为连接是打开的。

      TCP Peer A                                       TCP Peer B
  1.  (REBOOT)                              (send 300,receive 100)
  2.  CLOSED                                           ESTABLISHED
  3.  SYN-SENT --> <SEQ=400><CTL=SYN>              --> (??)
  4.  (!!)     <-- <SEQ=300><ACK=100><CTL=ACK>     <-- ESTABLISHED
  5.  SYN-SENT --> <SEQ=100><CTL=RST>              --> (Abort!!)
  6.  SYN-SENT                                         CLOSED
  7.  SYN-SENT --> <SEQ=400><CTL=SYN>              -->
Figure 9: Half-Open Connection Discovery
图 9: 半开放连接发现

When the SYN arrives at line 3, TCP Peer B, being in a synchronized state, and the incoming segment outside the window, responds with an acknowledgment indicating what sequence it next expects to hear (ACK 100).
在第 3 行,当 SYN 到达时,TCP B 处于同步状态,而接收段在接收窗口之外,返回一个确认,ACK=100,表示它期望收到的下一个序列号。

TCP A Peer sees that this segment does not acknowledge anything it sent and, being unsynchronized, sends a reset (RST) because it has detected a half-open connection.
TCP A 看到这个 TCP 段没有确认它所发送的任何东西,并且由于不同步,发送了一个重置(RST),因为它检测到一个半开放的连接。

TCP B Peer aborts at line 5.
在第 5 行,TCP B 终止。

TCP Peer A will continue to try to establish the connection; the problem is now reduced to the basic 3-way handshake of figure 6.
TCP A 会继续尝试建立连接;问题现在简化为图 6 中基础的三次握手。

An interesting alternative case occurs when TCP A Peer reboots and TCP Peer B tries to send data on what it thinks is a synchronized connection.
另一种有趣的情况是,当 TCP A 崩溃,而 TCP B 尝试在它认为是同步的连接上发送数据时。

This is illustrated in figure 10.
图 10 说明了这种情况。

In this case, the data arriving at TCP Peer A from TCP Peer B (line 2) is unacceptable because no such connection exists, so TCP Peer A sends a RST.
在这种情况下,从 TCP B 到达 TCP A 的数据(第 2 行)是无效的,因为不存在这样的连接,所以 TCP A 发送了一个 RST。

The RST is acceptable so TCP Peer B processes it and aborts the connection.
RST 是有效的,所以 TCP B 处理它并终止连接。

      TCP Peer A                                           TCP Peer B
  1.  (REBOOT)                                  (send 300,receive 100)
  2.  (??)    <-- <SEQ=300><ACK=100><DATA=10><CTL=ACK> <-- ESTABLISHED
  3.          --> <SEQ=100><CTL=RST>                   --> (ABORT!!)
Figure 10: Active Side Causes Half-Open Connection Discovery
图 10:活跃端导致半开放连接的发现

In Figure 11, two TCP Peers A and B with passive connections waiting for SYN are depicted.
在图 11 中,描述了两个等待 SYN 的被动连接 TCP A 和 B。

An old duplicate arriving at TCP Peer B (line 2) stirs B into action.
一个以前重复的 SYN 到达 TCP B(第 2 行),导致 B 做出回应。

A SYN-ACK is returned (line 3) and causes TCP Peer A to generate a RST (the ACK in line 3 is not acceptable).
一个 SYN-ACK 被返回(第 3 行),并导致 TCP A 产生一个 RST(第 3 行的 ACK 是无效的)。

TCP Peer B accepts the reset and returns to its passive LISTEN state.
TCP B 接受重置,并返回到其被动的 LISTEN 状态。

      TCP Peer A                                    TCP Peer B
  1.  LISTEN                                        LISTEN
  2.       ... <SEQ=Z><CTL=SYN>                -->  SYN-RECEIVED
  3.  (??) <-- <SEQ=X><ACK=Z+1><CTL=SYN,ACK>   <--  SYN-RECEIVED
  4.       --> <SEQ=Z+1><CTL=RST>              -->  (return to LISTEN!)
  5.  LISTEN                                        LISTEN
Figure 11: Old Duplicate SYN Initiates a Reset on two Passive Sockets
图 11: 以前重复 SYN 在两个被动套接字上启动重置

A variety of other cases are possible, all of which are accounted for by the following rules for RST generation and processing.
可能存在多种其他情况,所有这些情况都可以通过以下 RST 生成和处理规则解释。

重置生成 #

3.5.2. Reset Generation

A TCP user or application can issue a reset on a connection at any time, though reset events are also generated by the protocol itself when various error conditions occur, as described below.
TCP 用户或应用程序可以随时对连接发出重置,但重置事件也会在发生各种错误情况时由协议本身生成,如下所述。

The side of a connection issuing a reset should enter the TIME-WAIT state, as this generally helps to reduce the load on busy servers for reasons described in [70].
发出重置的连接端应进入 TIME-WAIT 状态,因为这通常有助于减少繁忙服务器上的负载,原因如 [70] 所述。

As a general rule, reset (RST) is sent whenever a segment arrives that apparently is not intended for the current connection.
作为一般规则,当一个 TCP 段到达时,如果显然不是为当前连接准备的,就应该发送复位(RST)。

A reset must not be sent if it is not clear that this is the case.

There are three groups of states:

1.If the connection does not exist (CLOSED), then a reset is sent in response to any incoming segment except another reset.

A SYN segment that does not match an existing connection is rejected by this means.
通过此方法拒绝与现有连接不匹配的 SYN 段。

If the incoming segment has an ACK field, the reset takes its sequence number from the ACK field of the segment; otherwise the reset has sequence number zero and the ACK field is set to the sum of the sequence number and segment length of the incoming segment.
如果接收的段有 ACK 字段,重置从该段的 ACK 字段中获取其序列号,否则重置的序列号为 0,ACK 字段设置为接收段的序列号和段长之和。

The connection remains in the CLOSED state.

2.If the connection is in any non-synchronized state (LISTEN, SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges something not yet sent (the segment carries an unacceptable ACK), or if an incoming segment has a security level or compartment (Appendix A.1) that does not exactly match the level and compartment requested for the connection, a reset is sent.
2.如果连接处于任何非同步状态(LISTEN、SYN-SENT、SYN-RECEIVED),并且接收段确认没有发送的内容(该段携带无效的 ACK),或者如果接收段具有安全等级或区段(附录 A.1)与连接请求的层级和区段不完全匹配,则会发送重置。

If the incoming segment has an ACK field, the reset takes its sequence number from the ACK field of the segment, otherwise the reset has sequence number zero and the ACK field is set to the sum of the sequence number and segment length of the incoming segment.
如果接收的段有 ACK 字段,重置从该段的 ACK 字段中获取其序列号,否则重置的序列号为 0,ACK 字段设置为接收段的序列号和段长之和。

The connection remains in the same state.

3.If the connection is in a synchronized state (ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), any unacceptable segment (out of window sequence number or unacceptible acknowledgment number) must be responded to with an empty acknowledgment segment (without any user data) containing the current send sequence number and an acknowledgment indicating the next sequence number expected to be received, and the connection remains in the same state.

If an incoming segment has a security level or compartment that does not exactly match the level and compartment requested for the connection, a reset is sent and connection goes to the CLOSED state. The reset takes its sequence number from the ACK field of the incoming segment.
如果接收段的安全级别或区段与连接请求的级别和区段不完全匹配,则发送重置,连接进入 CLOSED 状态。 重置从接收段的 ACK 字段中获取其序列号。

重置处理 #

3.5.3. Reset Processing

In all states except SYN-SENT, all reset (RST) segments are validated by checking their SEQ-fields.
在除 SYN-SENT 之外的所有状态中,所有的重置(RST)段都通过检查其 SEQ 字段来验证。

A reset is valid if its sequence number is in the window.

In the SYN-SENT state (a RST received in response to an initial SYN), the RST is acceptable if the ACK field acknowledges the SYN.
在 SYN-SENT 状态(接收到响应初始 SYN 的 RST),如果 ACK 字段确认 SYN,则 RST 是有效的。

The receiver of a RST first validates it, then changes state.
RST 的接收者首先验证它,然后改变状态。

If the receiver was in the LISTEN state, it ignores it.
如果接收器处于 LISTEN 状态,就会忽略它。

If the receiver was in SYN-RECEIVED state and had previously been in the LISTEN state, then the receiver returns to the LISTEN state, otherwise the receiver aborts the connection and goes to the CLOSED state.
如果接收方处于 SYN-RECEIVED 状态,并且之前处于 LISTEN 状态,那么接收方返回到 LISTEN 状态,否则接收方中止连接,进入 CLOSED 状态。

If the receiver was in any other state, it aborts the connection and advises the user and goes to the CLOSED state.
如果接收方处于任何其它状态,它将中止连接并通知用户并进入 CLOSED 状态。

TCP implementations SHOULD allow a received RST segment to include data (SHLD-2).
TCP 实现应该允许接收到包含数据的 RST 段 (SHLD-2)。

It has been suggested that a RST segment could contain diagnostic data that explains the cause of the RST.
有人建议 RST 段可以包含解释 RST 原因的诊断数据。

No standard has yet been established for such data.

关闭连接 #

3.6. Closing a Connection

CLOSE is an operation meaning “I have no more data to send.”
CLOSE 是一个操作,意思是 “我没有更多的数据要发送”。

The notion of closing a full-duplex connection is subject to ambiguous interpretation, of course, since it may not be obvious how to treat the receiving side of the connection.

We have chosen to treat CLOSE in a simplex fashion.
我们选择以简单的方式来处理 CLOSE。

The user who CLOSEs may continue to RECEIVE until the TCP receiver is told that the remote peer has CLOSED also.

Thus, a program could initiate several SENDs followed by a CLOSE, and then continue to RECEIVE until signaled that a RECEIVE failed because the remote peer has CLOSED.

The TCP implementation will signal a user, even if no RECEIVEs are outstanding, that the remote peer has closed, so the user can terminate their side gracefully.
我们假设,即使没有未完成的接收,TCP 也会通知用户远端已经关闭,所以用户可以优雅地中止自己这端。

A TCP will reliably deliver all buffers SENT before the connection was CLOSED so a user who expects no data in return need only wait to hear the connection was CLOSED successfully to know that all his data was received at the destination TCP endpoint.
TCP 将在连接关闭前可靠地发送的所有缓冲区的数据,因此没有数据接收的用户只需等到连接被成功关闭,就能知道他的所有数据已经成功发送到目的地 TCP。

Users must keep reading connections they close for sending until the TCP implementation indicates there is no more data.
用户必须继续读取他们关闭发送的连接,直到 TCP 实现说没有更多数据为止。

There are essentially three cases:

 1) The user initiates by telling the TCP implementation to CLOSE the connection (TCP Peer A in Figure 12).
 1) 用户主动告诉 TCP 关闭连接(图 12 中的 TCP A)。

 2) The remote TCP initiates by sending a FIN control signal (TCP Peer B in Figure 12).
 2) 远程 TCP 通过发送 FIN 控制标志开始关闭(图 12 中的 TCP B)。

 3) Both users CLOSE simultaneously (Figure 13)
 3) 两个用户同时关闭(图 13)。

Case 1: Local user initiates the close
情况 1:本地用户发起关闭

In this case, a FIN segment can be constructed and placed on the outgoing segment queue.
在这种情况下,会生成一个 FIN 段,并将其加入到发送段队列中。

No further SENDs from the user will be accepted by the TCP, and it enters the FIN-WAIT-1 state.
TCP 将不再接受用户的发送,并进入 FIN-WAIT-1 状态。

RECEIVEs are allowed in this state.

All segments preceding and including FIN will be retransmitted until acknowledged.
在 FIN 之前和包括 FIN 在内的所有段超时将被重传,直到被确认。

When the other TCP peer has both acknowledged the FIN and sent a FIN of its own, the first TCP peer can ACK this FIN.
当另一个 TCP 既确认了 FIN 又发送了自己的 FIN 时,第一个 TCP 可以对这个 FIN 进行 ACK。

Note that a TCP endpoint receiving a FIN will ACK but not send its own FIN until its user has CLOSED the connection also.
注意,收到 FIN 的 TCP 会进行 ACK,但不会发送自己的 FIN,直到其用户也关闭了连接。

Case 2: TCP endpoint receives a FIN from the network
情况 2:TCP 收到来自网络的 FIN

If an unsolicited FIN arrives from the network, the receiving TCP endpoint can ACK it and tell the user that the connection is closing.
如果来自网络的未经请求的 FIN 到达,接收的 TCP 可以确认该 FIN 并告诉用户连接正在关闭。

The user will respond with a CLOSE, upon which the TCP endpoint can send a FIN to the other TCP peer after sending any remaining data.
在发送完剩余数据后,用户会用 CLOSE 来回应,在此基础上,TCP 可以向另一端 TCP 发送 FIN。

The TCP endpoint then waits until its own FIN is acknowledged whereupon it deletes the connection.
然后,TCP 等待,直到它自己的 FIN 被确认,然后它删除连接。

If an ACK is not forthcoming, after the user timeout the connection is aborted and the user is told.
如果没有收到 ACK,在超时后,连接将被终止,并告诉用户。

Case 3: Both users close simultaneously
情况 3:两个用户同时关闭

A simultaneous CLOSE by users at both ends of a connection causes FIN segments to be exchanged (Figure 13).
连接两端的用户同时关闭会交换 FIN 段 (图 13)。

When all segments preceding the FINs have been processed and acknowledged, each TCP can ACK the FIN it has received.
当 FIN 之前的所有段都被处理并确认后,每个 TCP 可以对它所收到的 FIN 进行 ACK。

Both will, upon receiving these ACKs, delete the connection.
两者都将在收到这些 ACK 后,删除连接。

      TCP Peer A                                           TCP Peer B
  1.  ESTABLISHED                                          ESTABLISHED
  2.  (Close)
      FIN-WAIT-1  --> <SEQ=100><ACK=300><CTL=FIN,ACK>  --> CLOSE-WAIT
  3.  FIN-WAIT-2  <-- <SEQ=300><ACK=101><CTL=ACK>      <-- CLOSE-WAIT
  4.                                                       (Close)
      TIME-WAIT   <-- <SEQ=300><ACK=101><CTL=FIN,ACK>  <-- LAST-ACK
  5.  TIME-WAIT   --> <SEQ=101><ACK=301><CTL=ACK>      --> CLOSED
  6.  (2 MSL)
Figure 12: Normal Close Sequence
图 12:正常关闭序列
      TCP Peer A                                           TCP Peer B
  1.  ESTABLISHED                                          ESTABLISHED
  2.  (Close)                                              (Close)
      FIN-WAIT-1  --> <SEQ=100><ACK=300><CTL=FIN,ACK>  ... FIN-WAIT-1
                  <-- <SEQ=300><ACK=100><CTL=FIN,ACK>  <--
                  ... <SEQ=100><ACK=300><CTL=FIN,ACK>  -->
  3.  CLOSING     --> <SEQ=101><ACK=301><CTL=ACK>      ... CLOSING
                  <-- <SEQ=301><ACK=101><CTL=ACK>      <--
                  ... <SEQ=101><ACK=301><CTL=ACK>      -->
  4.  TIME-WAIT                                            TIME-WAIT
      (2 MSL)                                              (2 MSL)
      CLOSED                                               CLOSED
Figure 13: Simultaneous Close Sequence
图 13:同时关闭序列

A TCP connection may terminate in two ways: (1) the normal TCP close sequence using a FIN handshake (Figure 12), and (2) an “abort” in which one or more RST segments are sent and the connection state is immediately discarded.
TCP 连接可能以两种方式终止:(1) 使用 FIN 握手的正常 TCP 关闭序列(图 12),以及 (2) 发送一个或多个 RST 段并立即丢弃连接状态的 “abort” .

If the local TCP connection is closed by the remote side due to a FIN or RST received from the remote side, then the local application MUST be informed whether it closed normally or was aborted (MUST-12).
如果本地 TCP 连接由于从远程端接收到 FIN 或 RST 而被远程端关闭,则必须通知本地应用程序它是正常关闭还是被中止(MUST-12)。

半关闭连接 #

3.6.1. Half-Closed Connections

The normal TCP close sequence delivers buffered data reliably in both directions.
正常的 TCP 关闭序列在两个方向上可靠地传送缓冲数据。

Since the two directions of a TCP connection are closed independently, it is possible for a connection to be “half closed”, i.e., closed in only one direction, and a host is permitted to continue sending data in the open direction on a half-closed connection.
由于 TCP 连接的两个方向是独立关闭的,因此连接有可能处于 “半关闭” 状态,即只在一个方向关闭,且允许主机在半关闭连接中打开的方向继续发送数据。

A host MAY implement a “half-duplex” TCP close sequence, so that an application that has called CLOSE cannot continue to read data from the connection (MAY-1).
主机可以实现 “半双工” TCP 关闭序列,这样调用 CLOSE 的应用程序就不能继续从连接中读取数据 (MAY-1)。

If such a host issues a CLOSE call while received data is still pending in the TCP connection, or if new data is received after CLOSE is called, its TCP implementation SHOULD send a RST to show that data was lost (SHLD-3). See [23], Section 2.17 for discussion.
如果这样的主机在收到的数据仍在 TCP 连接中等待时发出 CLOSE 调用,或者在调用 CLOSE 后收到新的数据,其 TCP 实现应发送一个 RST 以显示数据丢失(SHLD-3)。讨论见[23],第 2.17 节。

When a connection is closed actively, it MUST linger in the TIME-WAIT state for a time 2xMSL (Maximum Segment Lifetime) (MUST-13).
当一个连接被主动关闭时,它必须在 TIME-WAIT 状态下停留 2xMSL(最大段寿命)的时间(MUST-13)。

However, it MAY accept a new SYN from the remote TCP endpoint to reopen the connection directly from TIME-WAIT state (MAY-2), if it:
然而,它可能会接受来自远程 TCP 的新 SYN,直接从 TIME-WAIT 状态(MAY-2)重新打开连接,如果它:

(1) assigns its initial sequence number for the new connection to be larger than the largest sequence number it used on the previous connection incarnation, and
(1) 为新连接分配的初始序列号要大于它在上一个连接实例中使用的最大序列号,但是

(2) returns to TIME-WAIT state if the SYN turns out to be an old duplicate.
(2) 如果 SYN 是一个旧的重复段,则返回到 TIME-WAIT 状态。

When the TCP Timestamp Options are available, an improved algorithm is described in [40] in order to support higher connection establishment rates.
当 TCP 时间戳选项可用时,[40] 中提出了一种改进的算法,以支持更高的连接建立速率。

This algorithm for reducing TIME-WAIT is a Best Current Practice that SHOULD be implemented since Timestamp Options are commonly used, and using them to reduce TIME-WAIT provides benefits for busy Internet servers (SHLD-4).
这种减少 TIME-WAIT 的算法是当前应该实现的最佳做法,因为时间戳选项是常用的,使用它们来减少 TIME-WAIT 有利于繁忙的互联网服务器(SHLD-4)。

分段 #

3.7. Segmentation

The term “segmentation” refers to the activity TCP performs when ingesting a stream of bytes from a sending application and packetizing that stream of bytes into TCP segments.
术语 “分段” 是指 TCP 在从发送应用程序接收字节流并将该字节流打包为 TCP 段时执行的操作。

Individual TCP segments often do not correspond one-for-one to individual send (or socket write) calls from the application.
单独的 TCP 数据段通常不对应于来自应用程序的单独发送(或套接字写入)调用。

Applications may perform writes at the granularity of messages in the upper-layer protocol, but TCP guarantees no correlation between the boundaries of TCP segments sent and received and the boundaries of the read or write buffers of user application data.
应用程序可以在上层协议中以消息的粒度进行写入,但 TCP 不保证发送和接收的 TCP 段的边界与用户应用程序数据的读或写缓冲区的边界之间的相关性。

In some specific protocols, such as Remote Direct Memory Access (RDMA) using Direct Data Placement (DDP) and Marker PDU Aligned Framing (MPA) [34], there are performance optimizations possible when the relation between TCP segments and application data units can be controlled, and MPA includes a specific mechanism for detecting and verifying this relationship between TCP segments and application message data structures, but this is specific to applications like RDMA.
在一些特定的协议中,如使用 Direct Data Placement(DDP)和 Marker PDU Aligned Framing(MPA)的远程直接内存访问(RDMA)[34],当 TCP 段和应用数据单元之间的关系可以被控制时,有可能实现性能优化,MPA 包括一个特定的机制来检测和验证 TCP 段和应用消息数据结构之间的这种关系,但这是针对 RDMA 等应用的。

In general, multiple goals influence the sizing of TCP segments created by a TCP implementation.
一般来说,多个目的会影响 TCP 实现所创建的 TCP 段的大小。

Goals driving the sending of larger segments include:

  • Reducing the number of packets in flight within the network.

  • Increasing processing efficiency and potential performance by enabling a smaller number of interrupts and inter-layer interactions.

  • Limiting the overhead of TCP headers.
    限制 TCP 报头的开销。

Note that the performance benefits of sending larger segments may decrease as the size increases, and there may be boundaries where advantages are reversed.

For instance, on some implementation architectures, 1025 bytes within a segment could lead to worse performance than 1024 bytes, due purely to data alignment on copy operations.
例如,在一些实现架构上,段内的 1025 字节可能会导致比 1024 字节更差的性能,这纯粹是由于复制操作的数据对齐。

Goals driving the sending of smaller segments include:

  • Avoiding sending a TCP segment that would result in an IP datagram larger than the smallest MTU along an IP network path because this results in either packet loss or packet fragmentation.
    避免发送会导致 IP 数据报大于 IP 网络路径上最小 MTU 的 TCP 段,因为这将导致数据包丢失或数据包碎片化。

    Making matters worse, some firewalls or middleboxes may drop fragmented packets or ICMP messages related to fragmentation.
    更糟糕的是,一些防火墙或中间盒可能会放弃碎片数据包或与碎片有关的 ICMP 消息。

  • Preventing delays to the application data stream, especially when TCP is waiting on the application to generate more data, or when the application is waiting on an event or input from its peer in order to generate more data.
    防止应用数据流的延迟,特别是当 TCP 在等待应用产生更多的数据时,或者当应用在等待事件或来自对方的输入以产生更多的数据时。

  • Enabling “fate sharing” between TCP segments and lower-layer data units (e.g., below IP, for links with cell or frame sizes smaller than the IP MTU).
    在 TCP 段和下层数据单元之间启用"fate sharing"(例如,在 IP 之下,对于单元或帧大小小于 IP MTU 的链路)。

Towards meeting these competing sets of goals, TCP includes several mechanisms, including the Maximum Segment Size Option, Path MTU Discovery, the Nagle algorithm, and support for IPv6 Jumbograms, as discussed in the following subsections.
为了实现这些相互竞争的目标,TCP 有一些机制,包括最大段长度选项、路径 MTU 发现、Nagle 算法和对 IPv6 Jumbograms 的支持,在下面的小节中讨论。

最大段长度选项 #

3.7.1. Maximum Segment Size Option

TCP endpoints MUST implement both sending and receiving the MSS Option (MUST-14).
TCP 必须实现发送和接收 MSS 选项 (MUST-14)。

TCP implementations SHOULD send an MSS Option in every SYN segment when its receive MSS differs from the default 536 for IPv4 or 1220 for IPv6 (SHLD-5), and MAY send it always (MAY-3).
当 TCP 的接收 MSS 与默认值 536(对于 IPv4) 或 默认值 1220(对于 IPv6) 不同时,TCP 实现应在每个 SYN 段中发送一个 MSS 选项(SHLD-5),并且可能总是发送(MAY-3)。

If an MSS Option is not received at connection setup, TCP implementations MUST assume a default send MSS of 536 (576 - 40) for IPv4 or 1220 (1280 - 60) for IPv6 (MUST-15).
如果在连接建立时没有收到 MSS 选项,则 TCP 实现必须假定 IPv4 的默认发送 MSS 为 536(576-40),IPv6 为 1220(1280-60)(MUST-15)。

The maximum size of a segment that a TCP endpoint really sends, the “effective send MSS”, MUST be the smaller (MUST-16) of the send MSS (that reflects the available reassembly buffer size at the remote host, the EMTU_R [19]) and the largest transmission size permitted by the IP layer (EMTU_S [19]):
TCP 实际发送的数据段的最大长度,即 “有效发送 MSS”,必须是发送 MSS(反映远程主机上的可用重组缓冲区大小,EMTU_R[19])和 IP 层允许的最大传输大小(EMTU_S[19])之间的较小值(MUST-16):

Eff.snd.MSS = min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize


  • SendMSS is the MSS value received from the remote host, or the default 536 for IPv4 or 1220 for IPv6, if no MSS Option is received.
    SendMSS 是从远程主机接收的 MSS 值,如果没有收到 MSS 选项,则默认为 536(对于 IPv4)或 1220(对于 IPv6)。

  • MMS_S is the maximum size for a transport-layer message that TCP may send.
    MMS_S 是 TCP 可以发送的传输层消息的最大大小。

  • TCPhdrsize is the size of the fixed TCP header and any options.
    TCPhdrsize 是固定 TCP 头和所有选项的大小。

    This is 20 in the (rare) case that no options are present but may be larger if TCP Options are to be sent.
    在没有选项的(不常见)情况下,这是 20,但如果要发送 TCP 选项,则可能会更大。

    Note that some options might not be included on all segments, but that for each segment sent, the sender should adjust the data length accordingly, within the Eff.snd.MSS.
    注意,有些选项可能不包括在所有的段上,但对于每一个发送的段,发送方应在 Eff.snd.MSS 内相应地调整数据长度。

  • IPoptionsize is the size of any IPv4 options or IPv6 extension headers associated with a TCP connection.
    IPoptionsize 是与 TCP 连接相关的任何 IPv4 选项或 IPv6 扩展头的大小。

    Note that some options or extension headers might not be included on all packets, but that for each segment sent, the sender should adjust the data length accordingly, within the Eff.snd.MSS.
    注意,有些选项或扩展头可能不包括在所有的数据包上,但对于发送的每个段,发送方应在 Eff.snd.MSS 内相应调整数据长度。

The MSS value to be sent in an MSS Option should be equal to the effective MTU minus the fixed IP and TCP headers.
在 MSS 选项中发送的 MSS 值应该等于有效 MTU 减去固定的 IP 和 TCP 头。

By ignoring both IP and TCP Options when calculating the value for the MSS Option, if there are any IP or TCP Options to be sent in a packet, then the sender must decrease the size of the TCP data accordingly.
通过在计算 MSS 选项的值时忽略 IP 和 TCP 选项,如果有任何 IP 或 TCP 选项要在数据包中发送,那么发送方必须相应减少 TCP 数据的大小。

RFC 6691 [43] discusses this in greater detail.
RFC 6691 [43]对此进行了更详细的讨论。

The MSS value to be sent in an MSS Option must be less than or equal to:
在 MSS 选项中要发送的 MSS 值必须小于或等于:

 MMS_R - 20

where MMS_R is the maximum size for a transport-layer message that can be received (and reassembled at the IP layer) (MUST-67).
其中,MMS_R 是可以接收(并在 IP 层重组)的传输层消息的最大大小(MUST-67)。

TCP obtains MMS_R and MMS_S from the IP layer; see the generic call GET_MAXSIZES in Section 3.4 of RFC 1122.
TCP 从 IP 层获取 MMS_R 和 MMS_S;请参阅 RFC 1122 第 3.4 节中,通用调用 GET_MAXSIZES。

These are defined in terms of their IP MTU equivalents, EMTU_R and EMTU_S [19].
这些是根据其 IP MTU 等效项 EMTU_R 和 EMTU_S [19] 定义的。

When TCP is used in a situation where either the IP or TCP headers are not fixed, the sender must reduce the amount of TCP data in any given packet by the number of octets used by the IP and TCP options.
当在 IP 或 TCP 标头不固定的情况下使用 TCP 时,发送方必须将任何给定数据包中的 TCP 数据量减去 IP 和 TCP 选项使用的字节数。

This has been a point of confusion historically, as explained in RFC 6691, Section 3.1.
这在历史上一直是一个混淆的点,如 RFC 6691,第 3.1 节中所述。

路径 MTU 发现 #

3.7.2. Path MTU Discovery

A TCP implementation may be aware of the MTU on directly connected links, but will rarely have insight about MTUs across an entire network path.
TCP 实现可能知道直接连接的链路上的 MTU,但很少了解整个网络路径上的 MTU。

For IPv4, RFC 1122 recommends an IP-layer default effective MTU of less than or equal to 576 for destinations not directly connected, and for IPv6 this would be 1280.
对于 IPv4,RFC 1122 建议 IP 层默认有效 MTU 小于或等于 576(对于未直接连接的目的地),而对于 IPv6,则为 1280。

Using these fixed values limits TCP connection performance and efficiency.
使用这些固定值会限制 TCP 连接性能和效率。

Instead, implementation of Path MTU Discovery (PMTUD) and Packetization Layer Path MTU Discovery (PLPMTUD) is strongly recommended in order for TCP to improve segmentation decisions.
相反,强烈建议实现路径 MTU 发现 (PMTUD) 和分组层路径 MTU 发现 (PLPMTUD),以便 TCP 改进分段决策。

Both PMTUD and PLPMTUD help TCP choose segment sizes that avoid both on-path (for IPv4) and source fragmentation (IPv4 and IPv6).
PMTUD 和 PLPMTUD 都帮助 TCP 选择段大小,以避免路径上(对于 IPv4)和源分段(IPv4 和 IPv6)。

PMTUD for IPv4 [2] or IPv6 [14] is implemented in conjunction between TCP, IP, and ICMP.
用于 IPv4[2]或 IPv6[14]的 PMTUD 是在 TCP、IP 和 ICMP 之间联合实现的。

It relies both on avoiding source fragmentation and setting the IPv4 DF (don’t fragment) flag, the latter to inhibit on-path fragmentation.
它依赖于避免源分段和设置 IPv4 DF(不分段)标志,后者用于防止路径上分段。

It relies on ICMP errors from routers along the path whenever a segment is too large to traverse a link.
当一个网段太大,无法穿越一条链路时,它就依靠路径上的路由器的 ICMP 错误。

Several adjustments to a TCP implementation with PMTUD are described in RFC 2923 in order to deal with problems experienced in practice [27].
RFC 2923 中描述了对使用 PMTUD 的 TCP 实现的一些调整,以处理实践中遇到的问题 [27]。

PLPMTUD [31] is a Standards Track improvement to PMTUD that relaxes the requirement for ICMP support across a path, and improves performance in cases where ICMP is not consistently conveyed, but still tries to avoid source fragmentation.
PLPMTUD[31]是对 PMTUD 的标准追踪改进,它放宽了对跨路径 ICMP 支持的要求,并在 ICMP 不一致传输但仍试图避免源碎片的情况下提高了性能。

The mechanisms in all four of these RFCs are recommended to be included in TCP implementations.
所有这四个 RFC 中的机制都被建议包含在 TCP 实现中。

The TCP MSS Option specifies an upper bound for the size of packets that can be received (see [43]).
TCP MSS 选项指定了可以接收的数据包大小的上限(参见 [43])。

Hence, setting the value in the MSS Option too small can impact the ability for PMTUD or PLPMTUD to find a larger path MTU.
因此,将 MSS 选项的值设置得太小会影响 PMTUD 或 PLPMTUD 找到更大的路径 MTU 的能力。

RFC 1191 discusses this implication of many older TCP implementations setting the TCP MSS to 536 (corresponding to the IPv4 576 byte default MTU) for non-local destinations, rather than deriving it from the MTUs of connected interfaces as recommended.
RFC 1191 讨论了许多旧的 TCP 实现对非本地目的地将 TCP MSS 设置为 536(对应于 IPv4 的 576 字节默认 MTU),而不是像建议的那样从连接接口的 MTU 中推导出来的含义。

可变 MTU 值的接口 #

3.7.3. Interfaces with Variable MTU Values

The effective MTU can sometimes vary, as when used with variable compression, e.g., RObust Header Compression (ROHC) [37].
有效的 MTU 有时会变化,如在使用可变压缩时,如 RObust Header Compression(ROHC)[37]。

It is tempting for a TCP implementation to advertise the largest possible MSS, to support the most efficient use of compressed payloads.
对于 TCP 实现来说,公布尽可能大的 MSS 是很诱人的,以支持最有效地使用压缩载荷。

Unfortunately, some compression schemes occasionally need to transmit full headers (and thus smaller payloads) to resynchronize state at their endpoint compressors/decompressors.

If the largest MTU is used to calculate the value to advertise in the MSS Option, TCP retransmission may interfere with compressor resynchronization.
如果使用最大的 MTU 来计算要在 MSS 选项中公布的值,则 TCP 重传可能会干扰压缩器重新同步。

As a result, when the effective MTU of an interface varies packet-to-packet, TCP implementations SHOULD use the smallest effective MTU of the interface to calculate the value to advertise in the MSS Option (SHLD-6).
因此,当一个接口的有效 MTU 因数据包而异时,TCP 实现方案应该使用该接口的最小有效 MTU 来计算在 MSS 选项(SHLD-6)中公布的值。

Nagle 算法 #

3.7.4. Nagle Algorithm

The “Nagle algorithm” was described in RFC 896 [17] and was recommended in RFC 1122 [19] for mitigation of an early problem of too many small packets being generated.
RFC 896[17]中描述了 “Nagle 算法”,并在 RFC 1122[19]中被推荐用于缓解早期产生过多小数据包的问题。

It has been implemented in most current TCP code bases, sometimes with minor variations (see Appendix A.3).
它已经在当前大多数 TCP 代码库中实现,有时会有一些小的变化(见附录 A.3)。

If there is unacknowledged data (i.e., SND.NXT > SND.UNA), then the sending TCP endpoint buffers all user data (regardless of the PSH bit) until the outstanding data has been acknowledged or until the TCP endpoint can send a full-sized segment (Eff.snd.MSS bytes).
如果有未确认的数据(即 SND.NXT>SND.UNA),那么发送的 TCP 会缓冲所有的用户数据(不管 PSH 位),直到未确认的数据被确认,或者直到 TCP 可以发送一个完整大小的段(Eff.snd.MSS 字节)。

A TCP implementation SHOULD implement the Nagle algorithm to coalesce short segments (SHLD-7).
TCP 实现应该实现 Nagle 算法来合并短段 (SHLD-7)。

However, there MUST be a way for an application to disable the Nagle algorithm on an individual connection (MUST-17).
但是,必须有一种方法让应用程序在单个连接上禁用 Nagle 算法(MUST-17)。

In all cases, sending data is also subject to the limitation imposed by the slow start algorithm [8].

Since there can be problematic interactions between the Nagle algorithm and delayed acknowledgments, some implementations use minor variations of the Nagle algorithm, such as the one described in Appendix A.3.
由于 Nagle 算法和延迟确认之间可能存在问题,一些实现方案使用 Nagle 算法的微小改动版,例如附录 A.3 中描述的算法。

IPv6 Jumbograms #

3.7.5. IPv6 Jumbograms

In order to support TCP over IPv6 Jumbograms, implementations need to be able to send TCP segments larger than the 64-KB limit that the MSS Option can convey.
为了支持 TCP over IPv6 Jumbograms,实现需要能够发送大于 MSS 选项可以传送的 64-KB 限制的 TCP 段。

RFC 2675 [24] defines that an MSS value of 65,535 bytes is to be treated as infinity, and Path MTU Discovery [14] is used to determine the actual MSS.
RFC 2675 [24] 定义将 65,535 字节的 MSS 值视为无穷大,并使用 Path MTU Discovery [14] 来确定实际的 MSS。

The Jumbo Payload Option need not be implemented or understood by IPv6 nodes that do not support attachment to links with an MTU greater than 65,575 [24], and the present IPv6 Node Requirements does not include support for Jumbograms [55].
对于不支持连接到 MTU 大于 65,575 的链路的 IPv6 节点来说,不需要实现或理解 Jumbo Payload 选项[24],目前的 IPv6 节点要求并不包括对 Jumbograms 的支持[55]。

数据通信 #

3.8. Data Communication

Once the connection is established, data is communicated by the exchange of segments.
一旦建立了连接,就通过交换 TCP 段来传递数据。

Because segments may be lost due to errors (checksum test failure) or network congestion, TCP uses retransmission to ensure delivery of every segment.
由于错误(校验和测试失败)或网络拥塞可能导致段丢失,因此 TCP 使用重传来确保每个段的交付。

Duplicate segments may arrive due to network or TCP retransmission.
由于网络或 TCP 重传,可能会出现重复的 TCP 段。

As discussed in the section on sequence numbers (Section 3.4), the TCP implementation performs certain tests on the sequence and acknowledgment numbers in the segments to verify their acceptability.
正如在序列号一节(第 3.4 节)中所讨论的,TCP 实现对段中的序列号和确认号进行某些测试,以验证其可接受性。

The sender of data keeps track of the next sequence number to use in the variable SND.NXT.
数据发送方在变量 SND.NXT 中记录下一个要使用的序列号。

The receiver of data keeps track of the next sequence number to expect in the variable RCV.NXT.
数据接收方在变量 RCV.NXT 中保存下一个期望的序列号。

The sender of data keeps track of the oldest unacknowledged sequence number in the variable SND.UNA.
数据发送方在变量 SND.UNA 中跟踪最久的未确认的序列号。

If the data flow is momentarily idle and all data sent has been acknowledged then the three variables will be equal.

When the sender creates a segment and transmits it the sender advances SND.NXT.
当发送方创建一个 TCP 段并发送时,发送方会推进 SND.NXT。

When the receiver accepts a segment it advances RCV.NXT and sends an acknowledgment.
当接收方接收一个 TCP 段时,它推进 RCV.NXT 并发送一个确认。

When the data sender receives an acknowledgment it advances SND.UNA.
当数据发送方收到确认时,它会推进 SND.UNA。

The extent to which the values of these variables differ is a measure of the delay in the communication.

The amount by which the variables are advanced is the length of the data and SYN or FIN flags in the segment.
变量推进的数量是数据和段中的 SYN 或 FIN 标志的长度。

Note that, once in the ESTABLISHED state, all segments must carry current acknowledgment information.
注意,一旦处于 ESTABLISHED 状态,所有段都必须携带当前确认信息。

The CLOSE user call implies a push function (see Section 3.9.1), as does the FIN control flag in an incoming segment.
CLOSE 用户调用暗示推送功能(见第 3.9.1 节),接收段中的 FIN 控制标志也是如此。

重传超时 #

3.8.1. Retransmission Timeout

Because of the variability of the networks that compose an internetwork system and the wide range of uses of TCP connections, the retransmission timeout (RTO) must be dynamically determined.
由于构成互联网系统的网络的可变性和 TCP 连接的广泛用途,重传超时(RTO)必须动态地确定。

The RTO MUST be computed according to the algorithm in [10], including Karn’s algorithm for taking RTT samples (MUST-18).
RTO 必须根据 [10] 中的算法计算,包括 Karn 的 RTT 采样算法 (MUST-18)。

RFC 793 contains an early example procedure for computing the RTO, based on work mentioned in IEN 177 [71].
RFC 793 包含一个计算 RTO 的早期示例程序,基于 IEN 177 [71]中提到的工作。

This was then replaced by the algorithm described in RFC 1122, which was subsequently updated in RFC 2988 and then again in RFC 6298.
后来,这被 RFC 1122 中描述的算法所取代,该算法随后在 RFC 2988 中被更新,然后在 RFC 6298 中再次更新。

RFC 1122 allows that if a retransmitted packet is identical to the original packet (which implies not only that the data boundaries have not changed, but also that none of the headers have changed), then the same IPv4 Identification field MAY be used (see Section of RFC 1122) (MAY-4).
RFC 1122 允许,如果重传的数据包与原始数据包相同(这意味着不仅数据边界没有改变,而且头也没有改变),那么可以使用相同的 IPv4 标识字段(见 RFC 1122 的 节)(MAY-4)。

The same IP Identification field may be reused anyways since it is only meaningful when a datagram is fragmented[44].
相同的 IP 标识字段无论如何都可以重复使用,因为它只有在数据报被分段时才有意义[44]。

TCP implementations should not rely on or typically interact with this IPv4 header field in any way.
TCP 实现不应该以任何方式依赖或与这个 IPv4 头字段互动。

It is not a reasonable way to indicate duplicate sent segments nor to identify duplicate received segments.

TCP 拥塞控制 #

3.8.2. TCP Congestion Control

RFC 2914 [5] explains the importance of congestion control for the Internet.
RFC 2914[5] 解释了拥塞控制对互联网的重要性。

RFC 1122 required implementation of Van Jacobson’s congestion control algorithms slow start and congestion avoidance together with exponential backoff for successive RTO values for the same segment.
RFC 1122 要求实现 Van Jacobson 的拥塞控制算法慢速启动和拥塞避免,以及同一网段的连续 RTO 值的指数退避。

RFC 2581 provided IETF Standards Track description of slow start and congestion avoidance, along with fast retransmit and fast recovery.
RFC 2581 提供了 IETF 标准追踪对慢启动和拥塞避免以及快速重传和快速恢复的描述。

RFC 5681 is the current description of these algorithms and is the current Standards Track specification providing guidelines for TCP congestion control.
RFC 5681 是目前对这些算法的描述,也是目前提供 TCP 拥塞控制指南的标准追踪规范。

RFC 6298 describes exponential backoff of RTO values, including keeping the backed-off value until a subsequent segment with new data has been sent and acknowledged without retransmission.
RFC 6298 描述了 RTO 值的指数退避,包括保持退避值,直到具有新数据的后续段被发送和确认,而无需重新传输。

A TCP endpoint MUST implement the basic congestion control algorithms slow start, congestion avoidance, and exponential backoff of RTO to avoid creating congestion collapse conditions (MUST-19).
TCP 必须实现基本的拥塞控制算法慢速启动、拥塞避免和 RTO 的指数退避,以避免产生拥塞崩溃条件(MUST-19)。

RFC 5681 and RFC 6298 describe the basic algorithms on the IETF Standards Track that are broadly applicable.
RFC 5681 和 RFC 6298 描述了 IETF 标准追踪上广泛适用的基本算法。

Multiple other suitable algorithms exist and have been widely used.

Many TCP implementations support a set of alternative algorithms that can be configured for use on the endpoint.
很多 TCP 实现提供一组可供选择的算法,这些算法可以配置在终端上使用。

An endpoint MAY implement such alternative algorithms provided that the algorithms are conformant with the TCP specifications from the IETF Standards Track as described in RFC 2914, RFC 5033 [7], and RFC 8961 [15] (MAY-18).
终端可以实现此类替代算法,前提是算法符合 IETF 标准轨道的 TCP 规范,如 RFC 2914、RFC 5033 [7] 和 RFC 8961 [15](MAY-18)中所述。

Explicit Congestion Notification (ECN) was defined in RFC 3168 and is an IETF Standards Track enhancement that has many benefits [51].
显式拥塞通知(ECN)在 RFC 3168 中定义,是一项 IETF 标准追踪增强,具有许多优点[51]。

A TCP endpoint SHOULD implement ECN as described in RFC 3168 (SHLD-8).
TCP 终端应按照 RFC 3168(SHLD-8)中的描述实现 ECN。

连接故障 #

3.8.3. TCP Connection Failures

Excessive retransmission of the same segment by a TCP endpoint indicates some failure of the remote host or the internetwork path.
TCP 端点对同一段的过度重传表明远程主机或互联网络路径出现了一些故障。

This failure may be of short or long duration.

The following procedure MUST be used to handle excessive retransmissions of data segments (MUST-20):

(a) There are two thresholds R1 and R2 measuring the amount of retransmission that has occurred for the same segment.
(a) 有两个阈值 R1 和 R2 测量同一段触发的重传量。

R1 and R2 might be measured in time units or as a count of retransmissions (with the current RTO and corresponding backoffs as a conversion factor, if needed).
R1 和 R2 可以用时间单位或重传计数来衡量(如果需要,可以将当前 RTO 和相应的退避作为转换因子)。

(b) When the number of transmissions of the same segment reaches or exceeds threshold R1, pass negative advice (see Section of [19]) to the IP layer, to trigger dead-gateway diagnosis.
(b) 当同一段的传输次数达到或超过阈值 R1 时,向 IP 层传递 negative advice(见文献[19]的 节),触发 dead-gateway 诊断。

(c) When the number of transmissions of the same segment reaches a threshold R2 greater than R1, close the connection.
(c) 当同一段的传输次数达到阈值 R2(大于 R1 )时,关闭连接。

(d) An application MUST (MUST-21) be able to set the value for R2 for a particular connection.
(d) 应用程序必须(MUST-21)能够为一个特定的连接设置 R2 的值。

For example, an interactive application might set R2 to “infinity”, giving the user control over when to disconnect.
例如,交互式应用程序可能会将 R2 设置为"无穷大",让用户可以控制何时断开连接。

(e) TCP implementations SHOULD inform the application of the delivery problem (unless such information has been disabled by the application; see the “Asynchronous Reports” section (Section, when R1 is reached and before R2 (SHLD-9).
(e) 当达到 R1 且在 R2 之前,TCP 实现应将传递问题通知应用程序(除非应用程序已禁用此类信息,请参阅"异步报告"部分(第 节))(SHLD-9)。

This will allow a remote login application program to inform the user, for example.

The value of R1 SHOULD correspond to at least 3 retransmissions, at the current RTO (SHLD-10).
在当前 RTO (SHLD-10),R1 的值应该至少对应 3 次重传。

The value of R2 SHOULD correspond to at least 100 seconds (SHLD-11).
R2 的值应该对应于至少 100 秒 (SHLD-11)。

An attempt to open a TCP connection could fail with excessive retransmissions of the SYN segment or by receipt of a RST segment or an ICMP Port Unreachable.
尝试打开 TCP 连接可能会因 SYN 数据段重新传输过多或收到 RST 数据段或 ICMP 端口无法到达而失败。

SYN retransmissions MUST be handled in the general way just described for data retransmissions, including notification of the application layer.
必须按照刚才描述的数据重传的一般方式处理 SYN 重传,包括通知应用层。

However, the values of R1 and R2 may be different for SYN and data segments.
但是,对于 SYN 和数据段,R1 和 R2 的值可能不同。

In particular, R2 for a SYN segment MUST be set large enough to provide retransmission of the segment for at least 3 minutes (MUST-23). 特别是,SYN 段的 R2 必须设置得足够大,以提供至少 3 分钟的重传段(MUST-23)。

The application can close the connection (i.e., give up on the open attempt) sooner, of course.

持久连接 #

3.8.4. TCP Keep-Alives

A TCP connection is said to be “idle” if for some long amount of time there have been no incoming segments received and there is no new or unacknowledged data to be sent.
如果在很长一段时间内没有接收到传入的数据段并且没有新的或未确认的数据要发送,则 TCP 连接被称为"空闲"连接。

Implementers MAY include “keep-alives” in their TCP implementations (MAY-5), although this practice is not universally accepted.
实现者可以在他们的 TCP 实现中包含 “keep-alives”(MAY-5),尽管这种做法没有被普遍接受。

Some TCP implementations, however, have included a keep-alive mechanism.
然而,一些 TCP 的实现已经实现了一个 keep-alive 机制。

To confirm that an idle connection is still active, these implementations send a probe segment designed to elicit a response from the TCP peer.
为了确认空闲连接仍然处于活动状态,这些实现发送一个探测段,该探测段旨在从 TCP 对等端引发响应。

Such a segment generally contains SEG.SEQ = SND.NXT-1 and may or may not contain one garbage octet of data.
这样的段通常包含 SEG.SEQ = SND.NXT-1 并且可能包含也可能不包含一个字节没用的数据。

If keep-alives are included, the application MUST be able to turn them on or off for each TCP connection (MUST-24), and they MUST default to off (MUST-25).
如果包含 keep-alives,则应用程序必须能够为每个 TCP 连接打开或关闭它们(MUST-24),并且它们必须默认为关闭(MUST-25)。

Keep-alive packets MUST only be sent when no sent data is outstanding, and no data or acknowledgment packets have been received for the connection within an interval (MUST-26).
只有在没有未完成的发送数据,并且在一个时间间隔内(MUST-26)没有收到连接的数据或确认数据包时,才必须发送 keep-alives 数据包。

This interval MUST be configurable (MUST-27) and MUST default to no less than two hours (MUST-28).

It is extremely important to remember that ACK segments that contain no data are not reliably transmitted by TCP.
请记住,不包含数据的 ACK 段不能被 TCP 可靠地传输,这一点极其重要。

Consequently, if a keep-alive mechanism is implemented it MUST NOT interpret failure to respond to any specific probe as a dead connection (MUST-29).
因此,如果实现了 keep-alive 机制,那么它不能将无法响应任何特定探测的情况解释为死连接(MUST-29)。

An implementation SHOULD send a keep-alive segment with no data (SHLD-12); however, it MAY be configurable to send a keep-alive segment containing one garbage octet (MAY-6), for compatibility with erroneous TCP implementations.
TCP 实现应该发送一个没有数据的 keep-alive 段(SHLD-12);然而,为了与错误的 TCP 实现兼容,它可以被配置为发送一个包含一个字节无用数据的 keep-alive 段(MAY-6)。

紧急信息的通信 #

3.8.5. The Communication of Urgent Information

As a result of implementation differences and middlebox interactions, new applications SHOULD NOT employ the TCP urgent mechanism (SHLD-13).
由于实现方式的不同和中间件的相互作用,新的应用程序不应该使用 TCP 紧急机制(SHLD-13)。

However, TCP implementations MUST still include support for the urgent mechanism (MUST-30).
但是,TCP 实现仍必须包括对紧急机制的支持(必须-30)。

Information on how some TCP implementations interpret the urgent pointer can be found in RFC 6093[39].
有关一些 TCP 实现如何解释紧急指针的信息可以在 RFC 6093[39] 中找到。

The objective of the TCP urgent mechanism is to allow the sending user to stimulate the receiving user to accept some urgent data and to permit the receiving TCP endpoint to indicate to the receiving user when all the currently known urgent data has been received by the user. TCP 紧急机制的目的是允许发送用户促使接收用户接收一些紧急数据,并允许接收的 TCP 在用户收到当前所有已知的紧急数据时通知接收用户。

This mechanism permits a point in the data stream to be designated as the end of urgent information.

Whenever this point is in advance of the receive sequence number (RCV.NXT) at the receiving TCP endpoint, then the TCP implementation must tell the user to go into “urgent mode”; when the receive sequence number catches up to the urgent pointer, the TCP implementation must tell user to go into “normal mode”.
每当该点在接收 TCP 的接收序列号(RCV.NXT)之前时,则 TCP 实现必须告诉用户进入"紧急模式";当接收序列号赶上紧急指针时,TCP 实现必须告诉用户进入"正常模式"。

If the urgent pointer is updated while the user is in “urgent mode”, the update will be invisible to the user.

The method employs an urgent field that is carried in all segments transmitted.

The URG control flag indicates that the urgent field is meaningful and must be added to the segment sequence number to yield the urgent pointer.
URG 控制标志表示紧急字段是有意义的,必须加上段序号上以生成紧急指针。

The absence of this flag indicates that there is no urgent data outstanding.

To send an urgent indication, the user must also send at least one data octet.

If the sending user also indicates a push, timely delivery of the urgent information to the destination process is enhanced.

Note that because changes in the urgent pointer correspond to data being written by a sending application, the urgent pointer cannot “recede” in the sequence space, but a TCP receiver should be robust to invalid urgent pointer values.
注意,因为紧急指针的变化对应于发送应用程序正在写入的数据,所以紧急指针不能在序列空间中"后退",但是 TCP 接收者应该对无效的紧急指针值具有鲁棒性。

A TCP implementation MUST support a sequence of urgent data of any length (MUST-31) [19].
TCP 实现必须支持任意长度的紧急数据序列 (MUST-31) [19]。

The urgent pointer MUST point to the sequence number of the octet following the urgent data (MUST-62).

A TCP implementation MUST (MUST-32) inform the application layer asynchronously whenever it receives an urgent pointer and there was previously no pending urgent data, or whenever the urgent pointer advances in the data stream.
TCP 实现必须(MUST-32)在收到紧急指针且之前没有待处理的紧急数据时,或者在紧急指针在数据流中前进时,异步地通知应用层。

The TCP implementation MUST (MUST-33) provide a way for the application to learn how much urgent data remains to be read from the connection, or at least to determine whether more urgent data remains to be read [19].
TCP 实现必须(MUST-33)为应用程序提供一种方法,以了解还有多少紧急数据需要从连接中读取,或至少能够确定是否还有更多紧急数据需要读取[19]。

管理窗口 #

3.8.6. Managing the Window

The window sent in each segment indicates the range of sequence numbers the sender of the window (the data receiver) is currently prepared to accept.

There is an assumption that this is related to the data buffer space currently available for this connection.

The sending TCP endpoint packages the data to be transmitted into segments that fit the current window, and may repackage segments on the retransmission queue.
发送 TCP 将要传输的数据打包成适合当前窗口的段,并且可以在重传队列中重新打包段。

Such repackaging is not required but may be helpful.

In a connection with a one-way data flow, the window information will be carried in acknowledgment segments that all have the same sequence number, so there will be no way to reorder them if they arrive out of order.

This is not a serious problem, but it will allow the window information to be on occasion temporarily based on old reports from the data receiver.

A refinement to avoid this problem is to act on the window information from segments that carry the highest acknowledgment number (that is, segments with an acknowledgment number equal to or greater than the highest previously received).

Indicating a large window encourages transmissions.

If more data arrives than can be accepted, it will be discarded.

This will result in excessive retransmissions, adding unnecessarily to the load on the network and the TCP endpoints.
这将导致过多的重传,不必要地增加网络和 TCP 终端的负载。

Indicating a small window may restrict the transmission of data to the point of introducing a round-trip delay between each new segment transmitted.

The mechanisms provided allow a TCP endpoint to advertise a large window and to subsequently advertise a much smaller window without having accepted that much data.
提供的机制允许 TCP 告知一个大窗口,然后在不接受那么多数据的情况下告知一个小得多的窗口。

This so-called “shrinking the window” is strongly discouraged.
这种所谓的 “缩减窗口” 是被强烈反对的。

The robustness principle [19] dictates that TCP peers will not shrink the window themselves, but will be prepared for such behavior on the part of other TCP peers.
鲁棒性原则 [19] 规定 TCP 不会自己缩小窗口,但会为其他 TCP 的这种行为做好准备。

A TCP receiver SHOULD NOT shrink the window, i.e., move the right window edge to the left (SHLD-14).
TCP 接收方不应缩小窗口,即,将右窗口边缘向左移动 (SHLD-14)。

However, a sending TCP peer MUST be robust against window shrinking, which may cause the “usable window” (see Section to become negative (MUST-34).
但是,发送 TCP 必须对窗口收缩具有鲁棒性,这可能导致 “可用窗口”(参见第 节)变为负值(MUST-34)。

If this happens, the sender SHOULD NOT send new data (SHLD-15), but SHOULD retransmit normally the old unacknowledged data between SND.UNA and SND.UNA+SND.WND (SHLD-16).
如果发生这种情况,发送方不应发送新的数据(SHLD-15),但应正常重发 SND.UNA 和 SND.UNA+SND.WND 之间的未确认的旧数据(SHLD-16)。

The sender MAY also retransmit old data beyond SND.UNA+SND.WND (MAY-7), but SHOULD NOT time out the connection if data beyond the right window edge is not acknowledged (SHLD-17).
发送方也可以重传超出 SND.UNA+SND.WND 的旧数据(MAY-7),但如果超出右窗边的数据没有被确认,则不应使连接超时(SHLD-17)。

If the window shrinks to zero, the TCP implementation MUST probe it in the standard way (described below) (MUST-35).
如果窗口缩小到零,TCP 实现必须以标准方式(如下所述)探测它(MUST-35)。

零窗口探测 Zero-Window Probing

The sending TCP peer must regularly transmit at least one octet of new data (if available), or retransmit to the receiving TCP peer even if the send window is zero, in order to “probe” the window.
发送的 TCP 必须定期发送至少一个字节的新数据(如果有的话),或者即使发送窗口为零,也要向接收的 TCP 重新发送,以便 “探测” 窗口。

This retransmission is essential to guarantee that when either TCP peer has a zero window the reopening of the window will be reliably reported to the other.
这种重传对于保证当任何一个 TCP 的窗口为零时,窗口的重开将可靠地报告给另一方是至关重要的。

This is referred to as Zero-Window Probing (ZWP) in other documents.
这在其他文档中称为零窗口探测 (ZWP)。

Probing of zero (offered) windows MUST be supported (MUST-36).

A TCP implementation MAY keep its offered receive window closed indefinitely (MAY-8).
TCP 实现可以无限期地保持关闭其提供的接收窗口(MAY-8)。

As long as the receiving TCP peer continues to send acknowledgments in response to the probe segments, the sending TCP peer MUST allow the connection to stay open (MUST-37).
只要接收 TCP 继续发送确认以响应探测段,发送 TCP 就必须允许连接保持打开状态(MUST-37)。

This enables TCP to function in scenarios such as the “printer ran out of paper” situation described in Section of [19]. 这使得 TCP 能够在诸如[19]第 节中描述的 “printer ran out of paper” 的情况下发挥作用。

The behavior is subject to the implementation’s resource management concerns, as noted in [41].

When the receiving TCP peer has a zero window and a segment arrives, it must still send an acknowledgment showing its next expected sequence number and current window (zero).
当接收方的 TCP 是零窗口并且有一个段到达时,它仍然必须发送一个确认,显示它的下一个预期序列号和当前窗口(零)。

The transmitting host SHOULD send the first zero-window probe when a zero window has existed for the retransmission timeout period (SHLD- 29) (Section 3.8.1), and SHOULD increase exponentially the interval between successive probes (SHLD-30).
当零窗口存在于重传超时期(SHLD-29)(第 3.8.1 节)时,发送主机应发送第一个零窗口探测,并应以指数方式增加连续探测的间隔(SHLD-30)。

避免糊涂窗口综合症 Silly Window Syndrome Avoidance

The “Silly Window Syndrome” (SWS) is a stable pattern of small incremental window movements resulting in extremely poor TCP performance.
“糊涂窗口综合症”(SWS)是一种稳定的小型增量窗口移动模式,导致 TCP 性能极差。

Algorithms to avoid SWS are described below for both the sending side and the receiving side.
以下对发送方和接收方都描述了避免 SWS 的算法。

RFC 1122 contains more detailed discussion of the SWS problem.
RFC 1122 包含对 SWS 问题的更详细讨论。

Note that the Nagle algorithm and the sender SWS avoidance algorithm play complementary roles in improving performance.
注意,Nagle 算法和发送方 SWS 规避算法在提高性能方面起着互补的作用。

The Nagle algorithm discourages sending tiny segments when the data to be sent increases in small increments, while the SWS avoidance algorithm discourages small segments resulting from the right window edge advancing in small increments.
当要发送的数据以小幅度递增时,Nagle 算法不鼓励发送小的数据段,而 SWS 避免算法则不鼓励因右窗边小幅度递增而产生的小数据段。

发送方算法——何时发送数据 Sender’s Algorithm – When to Send Data

A TCP implementation MUST include a SWS avoidance algorithm in the sender (MUST-38).
TCP 实现必须在发送方包括 SWS 规避算法(MUST-38)。

The Nagle algorithm from Section 3.7.4 additionally describes how to coalesce short segments.
第 3.7.4 节中的 Nagle 算法还描述了如何合并短数据段。

The sender’s SWS avoidance algorithm is more difficult than the receiver’s because the sender does not know (directly) the receiver’s total buffer space (RCV.BUFF).
发送方的 SWS 规避算法比接收方的更难,因为发送方不(直接)知道接收方的总缓冲区空间(RCV.BUFF)。

An approach that has been found to work well is for the sender to calculate Max(SND.WND), which is the maximum send window it has seen so far on the connection, and to use this value as an estimate of RCV.BUFF.
已发现的一种行之有效的方法是,发送方计算 Max(SND.WND),这是迄今为止它在连接上看到的最大发送窗口,并使用这个值作为 RCV.BUFF 的估计值。

Unfortunately, this can only be an estimate; the receiver may at any time reduce the size of RCV.BUFF.
遗憾的是,这只是一个估计值;接收方可能随时减小 RCV.BUFF 的大小。

To avoid a resulting deadlock, it is necessary to have a timeout to force transmission of data, overriding the SWS avoidance algorithm.
为了避免由此产生的死锁,有必要设置一个超时来强制传输数据,从而覆盖 SWS 避免算法。

In practice, this timeout should seldom occur.

The “usable window” is:
“可用窗口” 是:


i.e., the offered window less the amount of data sent but not acknowledged.

If D is the amount of data queued in the sending TCP endpoint but not yet sent, then the following set of rules is recommended.
如果 D 是在发送 TCP 中排队但尚未发送的数据量,则建议使用以下规则集。

Send data:

(1) if a maximum-sized segment can be sent, i.e., if:
(1) 如果可以发送最大长度的数据段,即如果:

 min(D,U) >= Eff.snd.MSS;

(2) or if the data is pushed and all queued data can be sent now, i.e., if:
(2) 或者如果数据被推送,并且现在可以发送所有排队的数据,即如果:

 [SND.NXT = SND.UNA and] PUSHed and D <= U

 (the bracketed condition is imposed by the Nagle algorithm);
 (括号条件由 Nagle 算法强加);

(3) or if at least a fraction Fs of the maximum window can be sent, i.e., if:
(3) 或如果至少可以发送最大窗口的一部分 Fs,即如果:

 [SND.NXT = SND.UNA and]

 min(D,U) >= Fs * Max(SND.WND);

(4) or if the override timeout occurs.
(4) 或是否发生覆盖超时。

Here Fs is a fraction whose recommended value is 1/2.
这里的 Fs 是一个分数,其推荐值为 1/2。

The override timeout should be in the range 0.1 - 1.0 seconds.
覆盖超时应在 0.1 - 1.0 秒范围内。

It may be convenient to combine this timer with the timer used to probe zero windows (Section
将这个定时器与用于探测零窗口的定时器结合起来可能很方便( 节)。

接收方算法–何时发送窗口更新 Receiver’s Algorithm – When to Send a Window Update

A TCP implementation MUST include a SWS avoidance algorithm in the receiver (MUST-39).
TCP 实现必须在接收方中包含 SWS 规避算法 (MUST-39)。

The receiver’s SWS avoidance algorithm determines when the right window edge may be advanced; this is customarily known as “updating the window”.
接收方的 SWS 回避算法确定何时可以推进窗口右边缘;这通常被称为"更新窗口"。

This algorithm combines with the delayed ACK algorithm (Section to determine when an ACK segment containing the current window will really be sent to the receiver.
该算法结合延迟 ACK 算法(第 节)来确定何时真正将包含当前窗口的 ACK 段发送给接收方。

The solution to receiver SWS is to avoid advancing the right window edge RCV.NXT+RCV.WND in small increments, even if data is received from the network in small segments.
接收方 SWS 的解决方案是避免以小增量推进右窗口边缘 RCV.NXT+RCV.WND,即使数据是以小段的形式从网络接收的。

Suppose the total receive buffer space is RCV.BUFF.
假设总的接收缓冲区空间为 RCV.BUFF。

At any given moment, RCV.USER octets of this total may be tied up with data that has been received and acknowledged but that the user process has not yet consumed.
在任何时候,这个总数中的 RCV.USER 字节数都可能被已经接收和确认的数据所占用,但用户进程还没有消费。

When the connection is quiescent, RCV.WND = RCV.BUFF and RCV.USER = 0.
当连接处于静止状态时,RCV.WND = RCV.BUFF 和 RCV.USER = 0。

Keeping the right window edge fixed as data arrives and is acknowledged requires that the receiver offer less than its full buffer space, i.e., the receiver must specify a RCV.WND that keeps RCV.NXT+RCV.WND constant as RCV.NXT increases.
当数据到达并被确认时,保持右窗口边缘的固定需要接收方提供少于其全部的缓冲区空间,即接收方必须指定一个 RCV.WND,使 RCV.NXT+RCV.WND 随着 RCV.NXT 的增加而保持不变。

Thus, the total buffer space RCV.BUFF is generally divided into three parts:
因此,总的缓冲空间 RCV.BUFF 一般分为三部分:

                  |<------- RCV.BUFF ---------------->|
                       1             2            3
                         RCV.NXT               ^

              1 - RCV.USER =  data received but not yet consumed;
              2 - RCV.WND =   space advertised to sender;
              3 - Reduction = space available but not yet

The suggested SWS avoidance algorithm for the receiver is to keep RCV.NXT+RCV.WND fixed until the reduction satisfies:
建议接收方的 SWS 避免算法是保持 RCV.NXT+RCV.WND 的固定,直到减少满足:

RCV.BUFF - RCV.USER - RCV.WND  >=  min( Fr * RCV.BUFF, Eff.snd.MSS )

where Fr is a fraction whose recommended value is 1/2, and Eff.snd.MSS is the effective send MSS for the connection (see Section 3.7.1).
其中 Fr 是一个分数,推荐值为 1/2,Eff.snd.MSS 是连接的有效发送 MSS(见 3.7.1 节)。

When the inequality is satisfied, RCV.WND is set to RCV.BUFF-RCV.USER.

Note that the general effect of this algorithm is to advance RCV.WND in increments of Eff.snd.MSS (for realistic receive buffers: Eff.snd.MSS < RCV.BUFF/2).
请注意,此算法的一般效果是以 Eff.snd.MSS 为增量推进 RCV.WND(对于实际接收缓冲区:Eff.snd.MSS < RCV.BUFF/2)。

Note also that the receiver must use its own Eff.snd.MSS, making the assumption that it is the same as the sender’s.
还要注意的是,接收方必须使用自己的 Eff.snd.MSS,假设它与发送方的相同。

延迟确认——何时发送 ACK 段 Delayed Acknowledgments – When to Send an ACK Segment

A host that is receiving a stream of TCP data segments can increase efficiency in both the network and the hosts by sending fewer than one ACK (acknowledgment) segment per data segment received; this is known as a “delayed ACK”.
正在接收 TCP 数据段流的主机可以通过为每个接收到的数据段发送少于一个 ACK(确认)段来提高网络和主机的效率;这被称为 “延迟的 ACK”。

A TCP endpoint SHOULD implement a delayed ACK (SHLD-18), but an ACK should not be excessively delayed; in particular, the delay MUST be less than 0.5 seconds (MUST-40).
TCP 应该实现延迟的 ACK(SHLD-18),但 ACK 不应该过度延迟;特别是,延迟必须小于 0.5 秒(MUST-40)。

An ACK SHOULD be generated for at least every second full-sized segment or 2*RMSS bytes of new data (where RMSS is the MSS specified by the TCP endpoint receiving the segments to be acknowledged, or the default value if not specified) (SHLD-19).
至少每隔一个完整长度的段或 2*RMSS 字节的新数据(其中 RMSS 是接收要确认的段的 TCP 指定的 MSS,如果没有指定,则为默认值)就应该产生一个 ACK(SHLD-19)。

Excessive delays on ACKs can disturb the round-trip timing and packet “clocking” algorithms.
ACK 的过度延迟会干扰往返时间和数据包"计时"算法。

More complete discussion of delayed ACK behavior is in Section 4.2 of RFC 5681 [8], including recommendations to immediately acknowledge out-of-order segments, segments above a gap in sequence space, or segments that fill all or part of a gap, in order to accelerate loss recovery.
RFC 5681[8]第 4.2 节对延迟 ACK 行为进行了更完整的讨论,包括建议立即确认失序段、序列空间缺口以上的段,或填补全部或部分缺口的段,以加快损失恢复。

Note that there are several current practices that further lead to a reduced number of ACKs, including generic receive offload (GRO) [72], ACK compression, and ACK decimation [28].
注意,目前有几种做法可以进一步减少 ACK 的数量,包括通用接收卸载 (GRO) [72]、ACK 压缩和 ACK 抽取 [28]。

接口 #

3.9. Interfaces

There are of course two interfaces of concern: the user/TCP interface and the TCP/lower-level interface.
当然,有两个值得关注的接口:用户/TCP 接口和 TCP/底层接口。

We have a fairly elaborate model of the user/TCP interface, but the interface to the lower-level protocol module is left unspecified here since it will be specified in detail by the specification of the lower-level protocol.
我们有一个相当详细的用户/TCP 接口模型,但到底层协议模块的接口在这里没有指定,因为它将由下层协议的规范来详细指定。

For the case that the lower level is IP, we note some of the parameter values that TCP implementations might use.
对于下层是 IP 的情况,我们注意到 TCP 实现可能使用的一些参数值。

用户/TCP 接口 #

3.9.1. User/TCP Interface

The following functional description of user commands to the TCP implementation is, at best, fictional, since every operating system will have different facilities.
以下对 TCP 实现的用户命令的功能描述充其量是虚构的,因为每个操作系统都有不同的功能。

Consequently, we must warn readers that different TCP implementations may have different user interfaces.
因此,我们必须告知读者不同的 TCP 实现可能有不同的用户接口。

However, all TCP implementations must provide a certain minimum set of services to guarantee that all TCP implementations can support the same protocol hierarchy.
但是,所有 TCP 实现都必须提供特定的最小服务集,以保证所有 TCP 实现都可以支持相同的协议层次结构。

This section specifies the functional interfaces required of all TCP implementations.
本节详细说明了所有 TCP 实现所需的功能接口。

Section 3.1 of [53] also identifies primitives provided by TCP and could be used as an additional reference for implementers.
[53] 的第 3.1 节还确定了 TCP 提供的基元,可以用作实现者的附加参考。

The following sections functionally characterize a user/TCP interface.
以下部分从功能上描述了用户/TCP 接口。

The notation used is similar to most procedure or function calls in high-level languages, but this usage is not meant to rule out trap-type service calls.

The user commands described below specify the basic functions the TCP implementation must perform to support interprocess communication.
下面描述的用户命令指定了 TCP 实现必须执行以支持进程间通信的基本功能。

Individual implementations must define their own exact format and may provide combinations or subsets of the basic functions in single calls.

In particular, some implementations may wish to automatically OPEN a connection on the first SEND or RECEIVE issued by the user for a given connection.
特别是,某些实现可能希望在用户为给定连接发出的第一个 SEND 或 RECEIVE 时自动打开连接。

In providing interprocess communication facilities, the TCP implementation must not only accept commands, but must also return information to the processes it serves.
在提供进程间通信设施时,TCP 实现不仅需要接受命令,还需要将信息返回给它所服务的进程。

The latter consists of:

(a) general information about a connection (e.g., interrupts, remote close, binding of unspecified remote socket).
(a) 有关连接的基础信息(例如,中断、远程关闭、未指定的远程套接字的绑定)。

(b) replies to specific user commands indicating success or various types of failure.
(b) 对特定用户命令的回复,表明成功或各种类型的失败。

打开 Open

Format: OPEN (local port, remote socket, active/passive [, timeout] [, Diffserv field] [, security/compartment] [, local IP address] [, options]) -> local connection name

If the active/passive flag is set to passive, then this is a call to LISTEN for an incoming connection.
如果主动/被动标志被设置为被动,那么这就是一个调用 LISTEN 以获得一个外部的连接。

A passive OPEN may have either a fully specified remote socket to wait for a particular connection or an unspecified remote socket to wait for any call.
被动 OPEN 可以有一个完全指定的远程套接字来等待特定连接,也可以有一个未指定的远程套接字来等待任何调用。

A fully specified passive call can be made active by the subsequent execution of a SEND.
完全指定的被动调用可以通过随后执行 SEND 而变为主动调用。

A transmission control block (TCB) is created and partially filled in with data from the OPEN command parameters.
创建一个传输控制块 (TCB),并用来自 OPEN 命令参数的数据部分填充。

Every passive OPEN call either creates a new connection record in LISTEN state, or it returns an error; it MUST NOT affect any previously created connection record (MUST-41).
每个被动的 OPEN 调用要么在 LISTEN 状态下创建一个新的连接记录,要么返回一个错误;它必须不影响任何先前创建的连接记录(MUST-41)。

A TCP implementation that supports multiple concurrent connections MUST provide an OPEN call that will functionally allow an application to LISTEN on a port while a connection block with the same local port is in SYN-SENT or SYN-RECEIVED state (MUST-42).
支持多个并发连接的 TCP 实现必须提供一个 OPEN 调用,该调用在功能上允许应用程序在端口上侦听,而具有相同本地端口的连接块处于 SYN-SENT 或 SYN-RECEIVED 状态(MUST-42)。

On an active OPEN command, the TCP endpoint will begin the procedure to synchronize (i.e., establish) the connection at once.
在活跃的 OPEN 命令上,TCP 将立即开始同步(即建立)连接的过程。

The timeout, if present, permits the caller to set up a timeout for all data submitted to TCP.
超时参数(如果存在)允许调用者为所有提交给 TCP 的数据设置超时。

If data is not successfully delivered to the destination within the timeout period, the TCP endpoint will abort the connection. The present global default is five minutes.
如果数据在超时时间内没有成功传递到目的地,TCP 将终止连接。目前的全局默认值是 5 分钟。

The TCP implementation or some component of the operating system will verify the user’s authority to open a connection with the specified Diffserv field value or security/compartment.
TCP 实现或操作系统的某些组件将验证用户是否有权以指定的 Diffserv 字段值或安全/区段打开连接。

The absence of a Diffserv field value or security/compartment specification in the OPEN call indicates the default values must be used.
如果打开调用中没有 DiffServ 字段值或安全/区段规范,则表明必须使用默认值。

TCP will accept incoming requests as matching only if the security/ compartment information is exactly the same as that requested in the OPEN call.
只有当安全/隔间信息与 OPEN 调用中请求的信息完全相同时,TCP 才会接受传入的匹配请求。

The Diffserv field value indicated by the user only impacts outgoing packets, may be altered en route through the network, and has no direct bearing or relation to received packets.
用户指示的 Diffserv 字段值仅影响发出数据包,可能在通过网络的途中被更改,与接收数据包没有直接关系。

A local connection name will be returned to the user by the TCP implementation.
TCP 实现将向用户返回一个本地连接名称。

The local connection name can then be used as a shorthand term for the connection defined by the <local socket, remote socket> pair.
然后,本地连接名称可以用作 <local socket, remote socket> 对定义的连接的简写术语。

The optional “local IP address” parameter MUST be supported to allow the specification of the local IP address (MUST-43).
必须支持可选的 “本地 IP 地址” 参数,以允许指定本地 IP 地址(MUST-43)。

This enables applications that need to select the local IP address used when multihoming is present.
这使得在存在多宿主时,应用程序需要选择使用的本地 IP 地址成为可能。

A passive OPEN call with a specified “local IP address” parameter will await an incoming connection request to that address.
具有指定 “本地 IP 地址” 参数的被动 OPEN 调用将等待对该地址的传入连接请求。

If the parameter is unspecified, a passive OPEN will await an incoming connection request to any local IP address and then bind the local IP address of the connection to the particular address that is used.
如果未指定该参数,则被动 OPEN 将等待对任何本地 IP 地址的传入连接请求,然后将连接的本地 IP 地址绑定到所使用的特定地址。

For an active OPEN call, a specified “local IP address” parameter will be used for opening the connection.

对于主动 OPEN 调用,指定的 “本地 IP 地址” 参数将用于打开连接。

If the parameter is unspecified, the host will choose an appropriate local IP address (see RFC 1122, Section
如果该参数没有指定,主机将选择一个适当的本地 IP 地址(见 RFC 1122,第 节)。

If an application on a multihomed host does not specify the local IP address when actively opening a TCP connection, then the TCP implementation MUST ask the IP layer to select a local IP address before sending the (first) SYN (MUST-44).
如果多宿主主机上的应用程序在主动打开 TCP 连接时未指定本地 IP 地址,则 TCP 实现必须在发送(第 1 个)SYN(MUST-44)之前要求 IP 层选择本地 IP 地址。

See the function GET_SRCADDR() in Section 3.4 of RFC 1122.
请参阅 RFC 1122 第 3.4 节中的函数 GET_SRCADDR()。

At all other times, a previous segment has either been sent or received on this connection, and TCP implementations MUST use the same local address that was used in those previous segments (MUST-45).
在所有其他时间,先前的段已经在此连接上发送或接收,并且 TCP 实现必须使用与先前段中使用的相同的本地地址(MUST-45)。

A TCP implementation MUST reject as an error a local OPEN call for an invalid remote IP address (e.g., a broadcast or multicast address) (MUST-46).
TCP 实现必须拒绝对无效的远程 IP 地址(例如,广播或多播地址)的本地 OPEN 调用,并将其视为错误(MUST-46)。

发送 Send

Format: SEND (local connection name, buffer address, byte count, URGENT flag [, PUSH flag] [, timeout])
格式:SEND(本地连接名称,缓冲区地址,字节数,URGENT 标志[,PUSH 标志][,超时])。

This call causes the data contained in the indicated user buffer to be sent on the indicated connection.

If the connection has not been opened, the SEND is considered an error.
如果连接没有被打开,SEND 被视为是错误。

Some implementations may allow users to SEND first; in which case, an automatic OPEN would be done.
有些实现可能允许用户先发送,在这种情况下,会自动执行 OPEN。

For example, this might be one way for application data to be included in SYN segments.
例如,这可能是将应用程序数据包含在 SYN 段中的一种方式。

If the calling process is not authorized to use this connection, an error is returned.

A TCP endpoint MAY implement PUSH flags on SEND calls (MAY-15). TCP 可以在 SEND 调用中实现 PUSH 标志(MAY-15)。

If PUSH flags are not implemented, then the sending TCP peer: (1) MUST NOT buffer data indefinitely (MUST-60), and (2) MUST set the PSH bit in the last buffered segment (i.e., when there is no more queued data to be sent) (MUST-61).
如果没有实现 PUSH 标志,那么发送的 TCP:(1)不得无限期地缓冲数据(MUST-60),以及(2)必须在最后一个缓冲段中设置 PSH 位(即,当没有更多排队的数据要发送时)(MUST-61)。

The remaining description below assumes the PUSH flag is supported on SEND calls.
下面的其它描述假定 SEND 调用支持 PUSH 标志。

If the PUSH flag is set, the application intends the data to be transmitted promptly to the receiver, and the PSH bit will be set in the last TCP segment created from the buffer.
如果设置了 PUSH 标志,则应用程序希望将数据立即传输到接收方,并且 PSH 位将设置在从缓冲区创建的最后一个 TCP 段中。

The PSH bit is not a record marker and is independent of segment boundaries.
PSH 位不是一个记录标记,与段的边界无关。

The transmitter SHOULD collapse successive bits when it packetizes data, to send the largest possible segment (SHLD-27).

If the PUSH flag is not set, the data may be combined with data from subsequent SENDs for transmission efficiency.

When an application issues a series of SEND calls without setting the PUSH flag, the TCP implementation MAY aggregate the data internally without sending it (MAY-16).
当应用程序发出一系列的 SEND 调用而不设置 PUSH 标志时,TCP 实现可能会在内部聚集数据而不发送(MAY-16)。

Note that when the Nagle algorithm is in use, TCP implementations may buffer the data before sending, without regard to the PUSH flag (see Section 3.7.4).
注意,当使用 Nagle 算法时,TCP 实现可以在发送前缓冲数据,而不考虑 PUSH 标志(见 3.7.4 节)。

An application program is logically required to set the PUSH flag in a SEND call whenever it needs to force delivery of the data to avoid a communication deadlock.
从逻辑上讲,当一个应用程序需要强制交付数据以避免通信死锁时,它就需要在 SEND 调用中设置 PUSH 标志。

However, a TCP implementation SHOULD send a maximum-sized segment whenever possible (SHLD-28) to improve performance (see Section
然而,TCP 实现应该尽可能发送最大长度的段(SHLD-28)以提高性能(参见第 节)。

New applications SHOULD NOT set the URGENT flag [39] due to implementation differences and middlebox issues (SHLD-13).
由于实现差异和中间件问题 (SHLD-13),新应用程序不应设置紧急标志 [39]。

If the URGENT flag is set, segments sent to the destination TCP peer will have the urgent pointer set.
如果设置了紧急标志,发送到目标 TCP 的段将设置紧急指针。

The receiving TCP peer will signal the urgent condition to the receiving process if the urgent pointer indicates that data preceding the urgent pointer has not been consumed by the receiving process.
如果紧急指针表明紧急指针之前的数据没有被接收进程消耗,接收的 TCP 将向接收进程发出紧急条件信号。

The purpose of the URGENT flag is to stimulate the receiver to process the urgent data and to indicate to the receiver when all the currently known urgent data has been received.

The number of times the sending user’s TCP implementation signals urgent will not necessarily be equal to the number of times the receiving user will be notified of the presence of urgent data.
发送用户 TCP 实现发出紧急信号的次数不一定等于接收用户被通知存在紧急数据的次数。

If no remote socket was specified in the OPEN, but the connection is established (e.g., because a LISTENing connection has become specific due to a remote segment arriving for the local socket), then the designated buffer is sent to the implied remote socket.
如果在 OPEN 中没有指定远程套接字,但建立了连接(例如,由于远程段到达本地套接字而导致 LISTENing 连接变得特定),则指定的缓冲区被发送到隐含的远程套接字。

Users who make use of OPEN with an unspecified remote socket can make use of SEND without ever explicitly knowing the remote socket address.
使用 OPEN 和未指定的远程套接字的用户可以使用 SEND 而不必明确知道远程套接字的地址。

However, if a SEND is attempted before the remote socket becomes specified, an error will be returned.
但是,如果在指定远程套接字之前尝试发送 SEND,则会返回错误。

Users can use the STATUS call to determine the status of the connection.
用户可以使用 STATUS 调用来确定连接的状态。

Some TCP implementations may notify the user when an unspecified socket is bound.
一些 TCP 实现可能会在一个未指定的套接字被绑定时通知用户。

If a timeout is specified, the current user timeout for this connection is changed to the new one.

In the simplest implementation, SEND would not return control to the sending process until either the transmission was complete or the timeout had been exceeded.
在最简单的实现中,SEND 不会将控制权返回给发送进程,直到传输完成或超时了。

However, this simple method is both subject to deadlocks (for example, both sides of the connection might try to do SENDs before doing any RECEIVEs) and offers poor performance, so it is not recommended.

A more sophisticated implementation would return immediately to allow the process to run concurrently with network I/O, and, furthermore, to allow multiple SENDs to be in progress.
更复杂的实现将立即返回以允许进程与网络 I/O 并发运行,并且进一步允许多个 SEND 正在进行。

Multiple SENDs are served in first come, first served order, so the TCP endpoint will queue those it cannot service immediately.
多个 SEND 以先来后到的顺序提供服务,因此 TCP 将排队等待那些它不能立即提供服务的 SEND。

We have implicitly assumed an asynchronous user interface in which a SEND later elicits some kind of SIGNAL or pseudo-interrupt from the serving TCP endpoint. An alternative is to return a response immediately.
我们隐含地假设了一个异步用户接口,其中 SEND 稍后从服务的 TCP 引发某种信号或伪中断。另一种方法是立即返回响应。

For instance, SENDs might return immediate local acknowledgment, even if the segment sent had not been acknowledged by the distant TCP endpoint.
例如,SEND 可能会立即返回本地确认,即使发送的数据段尚未被远程 TCP 确认。

We could optimistically assume eventual success.

If we are wrong, the connection will close anyway due to the timeout.

In implementations of this kind (synchronous), there will still be some asynchronous signals, but these will deal with the connection itself, and not with specific segments or buffers.

In order for the process to distinguish among error or success indications for different SENDs, it might be appropriate for the buffer address to be returned along with the coded response to the SEND request.
为了让进程区分不同 SEND 的错误或成功指示,缓冲区地址与对 SEND 请求的编码响应一起返回可能是合适的。

TCP-to-user signals are discussed below, indicating the information that should be returned to the calling process.
下面讨论 TCP 到用户的信号,指出应该返回给调用进程的信息。

接收 Receive

Format: RECEIVE (local connection name, buffer address, byte count) -> byte count, URGENT flag [, PUSH flag]
格式:RECEIVE(本地连接名,缓冲区地址,字节数)->字节数,URGENT 标志[,PUSH 标志]

This command allocates a receiving buffer associated with the specified connection.

If no OPEN precedes this command or the calling process is not authorized to use this connection, an error is returned.
如果在此命令之前没有 OPEN,或者调用进程没有被授权使用此连接,则返回错误。

In the simplest implementation, control would not return to the calling program until either the buffer was filled or some error occurred, but this scheme is highly subject to deadlocks.

A more sophisticated implementation would permit several RECEIVEs to be outstanding at once.
更复杂的实现将允许多个 RECEIVEs 同时被处理。

These would be filled as segments arrive.

This strategy permits increased throughput at the cost of a more elaborate scheme (possibly asynchronous) to notify the calling program that a PUSH has been seen or a buffer filled.
这种策略允许增加吞吐量,但代价是需要一个更复杂的方案(可能是异步的)来通知调用程序已经看到一个 PUSH 或一个缓冲区被填满。

A TCP receiver MAY pass a received PSH bit to the application layer via the PUSH flag in the interface (MAY-17), but it is not required (this was clarified in RFC 1122, Section
TCP 接收方可以通过接口(MAY-17)中的 PUSH 标志将收到的 PSH 位传递给应用层,但这不是必须的(这在 RFC 1122 第 节中已阐明)。

The remainder of text describing the RECEIVE call below assumes that passing the PUSH indication is supported.
下面描述 RECEIVE 调用的其余部分假设支持传递 PUSH 指示。

If enough data arrive to fill the buffer before a PUSH is seen, the PUSH flag will not be set in the response to the RECEIVE.
如果在看到 PUSH 之前有足够的数据到达并填满缓冲区,那么 PUSH 标志将不会在 RECEIVE 的响应中被设置。

The buffer will be filled with as much data as it can hold.

If a PUSH is seen before the buffer is filled, the buffer will be returned partially filled and PUSH indicated.
如果在缓冲区被填满之前看到了 PUSH,缓冲区将被部分填满并返回 PUSH 指示。

If there is urgent data, the user will have been informed as soon as it arrived via a TCP-to-user signal.
如果有紧急数据,用户将在数据到达后立即通过 TCP 到用户的信号得到通知。

The receiving user should thus be in “urgent mode”.
接收用户因此处于 “紧急模式”。

If the URGENT flag is on, additional urgent data remains.
如果 URGENT 标志处于开启状态,则保留额外的紧急数据。

If the URGENT flag is off, this call to RECEIVE has returned all the urgent data, and the user may now leave “urgent mode”.
如果 URGENT 标志是关闭的,这个对 RECEIVE 的调用已经返回了所有的紧急数据,用户现在可以离开 “紧急模式”。

Note that data following the urgent pointer (non-urgent data) cannot be delivered to the user in the same buffer with preceding urgent data unless the boundary is clearly marked for the user.

To distinguish among several outstanding RECEIVEs and to take care of the case that a buffer is not completely filled, the return code is accompanied by both a buffer pointer and a byte count indicating the actual length of the data received.
为了区分几个未完成的 RECEIVE,并处理缓冲区没有完全填满的情况,返回代码同时带有缓冲区指针和指示接收到的数据的实际长度的字节计数。

Alternative implementations of RECEIVE might have the TCP endpoint allocate buffer storage, or the TCP endpoint might share a ring buffer with the user.
RECEIVE 的替代实现可能会让 TCP 分配缓冲区存储,或者 TCP 与用户共享一个环形缓冲区。

关闭 Close

Format: CLOSE (local connection name)

This command causes the connection specified to be closed.

If the connection is not open or the calling process is not authorized to use this connection, an error is returned.

Closing connections is intended to be a graceful operation in the sense that outstanding SENDs will be transmitted (and retransmitted), as flow control permits, until all have been serviced.
关闭连接旨在成为一种优雅的操作,因为在流量控制允许的情况下,将发送(和重新发送)未完成的 SEND,直到所有 SEND 都得到服务。

Thus, it should be acceptable to make several SEND calls, followed by a CLOSE, and expect all the data to be sent to the destination.
因此,进行几次 SEND 调用,然后是 CLOSE,并期望所有的数据被发送到目的地,这应该是可以接受的。

It should also be clear that users should continue to RECEIVE on CLOSING connections since the remote peer may be trying to transmit the last of its data.

Thus, CLOSE means “I have no more to send” but does not mean “I will not receive any more.”
因此,CLOSE 的意思是 “我没有更多的东西可以发送”,但并不意味着 “我不会再收到任何东西”。

It may happen (if the user-level protocol is not well thought out) that the closing side is unable to get rid of all its data before timing out.

In this event, CLOSE turns into ABORT, and the closing TCP peer gives up.
在这种情况下,CLOSE 变成了 ABORT,关闭的 TCP 放弃。

The user may CLOSE the connection at any time on their own initiative, or in response to various prompts from the TCP implementation (e.g., remote close executed, transmission timeout exceeded, destination inaccessible).
用户可以在任何时候主动关闭连接,或响应 TCP 实现的各种提示(例如,执行了远程关闭,传输超时,目的地无法访问)。

Because closing a connection requires communication with the remote TCP peer, connections may remain in the closing state for a short time.
因为关闭连接需要与远程 TCP 通信,所以连接可能会短时间内保持在关闭中状态。

Attempts to reopen the connection before the TCP peer replies to the CLOSE command will result in error responses.
在 TCP 回复 CLOSE 命令之前尝试重新打开连接将导致错误响应。

Close also implies push function.

状态 Status

Format: STATUS (local connection name) -> status data
格式:STATUS(本地连接名称) -> 状态数据

This is an implementation-dependent user command and could be excluded without adverse effect.

Information returned would typically come from the TCB associated with the connection.
返回的信息通常来自与该连接相关的 TCB。

This command returns a data block containing the following information:

 local socket,

 remote socket,

 local connection name,

 receive window,

 send window,

 connection state,

 number of buffers awaiting acknowledgment,

 number of buffers pending receipt,

 urgent state,

 Diffserv field value,
 Diffserv 字段值,

 security/compartment, and
 安全/区段, 和

 transmission timeout.

Depending on the state of the connection, or on the implementation itself, some of this information may not be available or meaningful.

If the calling process is not authorized to use this connection, an error is returned.

This prevents unauthorized processes from gaining information about a connection.

中止 Abort

Format: ABORT (local connection name)

This command causes all pending SENDs and RECEIVES to be aborted, the TCB to be removed, and a special RST message to be sent to the remote TCP peer of the connection.
这条命令导致所有待定的发送和接收被终止,TCB 被移除,并向连接的远程 TCP 发送一个特殊的 RST 消息。

Depending on the implementation, users may receive abort indications for each outstanding SEND or RECEIVE, or may simply receive an ABORT-acknowledgment.
根据实现方式的不同,用户可能会收到每个未完成的 SEND 或 RECEIVE 的中止指示,或者可能只是收到 ABORT 确认。

清空 Flush

Some TCP implementations have included a FLUSH call, which will empty the TCP send queue of any data that the user has issued SEND calls for but is still to the right of the current send window.
一些 TCP 实现包含一个 FLUSH 调用,它将清空 TCP 发送队列中用户已发出 SEND 调用但仍在当前发送窗口右侧的任何数据。

That is, it flushes as much queued send data as possible without losing sequence number synchronization.

The FLUSH call MAY be implemented (MAY-14).
可以实现 FLUSH 调用(5 月至 14 日)。

异步报告 Asynchronous Reports

There MUST be a mechanism for reporting soft TCP error conditions to the application (MUST-47).
必须有一种机制来向应用程序报告软 TCP 错误情况(MUST-47)。

Generically, we assume this takes the form of an application-supplied ERROR_REPORT routine that may be upcalled asynchronously from the transport layer:
通常,我们假设这采用应用程序提供的 Error_Report 例程的形式,该例程可以从传输层异步向上调用:

 ERROR_REPORT(local connection name, reason, subreason)

The precise encoding of the reason and subreason parameters is not specified here.

However, the conditions that are reported asynchronously to the application MUST include:

  • ICMP error message arrived (see Section for description of handling each ICMP message type since some message types need to be suppressed from generating reports to the application)
    ICMP 错误消息到达(有关处理每种 ICMP 消息类型的说明,请参见第 节,因为需要抑制某些消息类型向应用程序生成报告)

  • Excessive retransmissions (see Section 3.8.3)
    过度重传(见第 3.8.3 节)

  • Urgent pointer advance (see Section 3.8.5)
    紧急指针前进(见 3.8.5 节)。

However, an application program that does not want to receive such ERROR_REPORT calls SHOULD be able to effectively disable these calls (SHLD-20).
但是,不想接收此类 ERROR_REPORT 调用的应用程序应该能够有效地禁用这些调用(SHLD-20)。

设置差异化服务字段(IPv4 TOS 或 IPv6 流量类别) Set Differentiated Services Field (IPv4 TOS or IPv6 Traffic Class)

The application layer MUST be able to specify the Differentiated Services field for segments that are sent on a connection (MUST-48).
应用层必须能够为在连接上发送的段指定差异化服务字段 (MUST-48)。

The Differentiated Services field includes the 6-bit Differentiated Services Codepoint (DSCP) value.
Differentiated Services 字段包括 6 位差异化服务编码点(DSCP)值。

It is not required, but the application SHOULD be able to change the Differentiated Services field during the connection lifetime (SHLD-21).

TCP implementations SHOULD pass the current Differentiated Services field value without change to the IP layer, when it sends segments on the connection (SHLD-22).
当它在连接上发送段时(SHLD-22),TCP 实现应该在不更改 IP 层的情况下传递当前的差异化服务字段值。

The Differentiated Services field will be specified independently in each direction on the connection, so that the receiver application will specify the Differentiated Services field used for ACK segments.
差异化服务字段将在连接的每个方向上独立指定,以便接收方应用程序将指定用于 ACK 段的差异化服务字段。

TCP implementations MAY pass the most recently received Differentiated Services field up to the application (MAY-9).
TCP 实现可以将最近收到的差异化服务字段传递给应用程序(MAY-9)。

TCP/下层协议接口 #

3.9.2. TCP/Lower-Level Interface

The TCP endpoint calls on a lower-level protocol module to actually send and receive information over a network.
TCP 调用较低级别的协议模块以实际通过网络发送和接收信息。

The two current standard Internet Protocol (IP) versions layered below TCP are IPv4 [1] and IPv6 [13].
目前在 TCP 下面分层的两个标准互联网协议(IP)版本是 IPv4[1]和 IPv6[13]。

If the lower-level protocol is IPv4, it provides arguments for a type of service (used within the Differentiated Services field) and for a time to live.
如果下级协议是 IPv4,它提供服务类型(在差异化服务领域内使用)和生存时间的参数。

TCP uses the following settings for these parameters:
TCP 对这些参数使用以下设置:

Diffserv field: The IP header value for the Diffserv field is given by the user.
Diffserv 字段:Diffserv 字段的 IP 头值由用户给出。

This includes the bits of the Diffserv Codepoint (DSCP).
这包括 Diffserv Codepoint(DSCP)的比特位。

Time to Live (TTL): The TTL value used to send TCP segments MUST be configurable (MUST-49).
存活时间(TTL):用于发送 TCP 段的 TTL 值必须是可配置的(MUST-49)。

  • Note that RFC 793 specified one minute (60 seconds) as a constant for the TTL because the assumed maximum segment lifetime was two minutes.
    注意,RFC 793 将一分钟(60 秒)指定为 TTL 的常量,因为假定的最大段生命周期为两分钟。

    This was intended to explicitly ask that a segment be destroyed if it could not be delivered by the internet system within one minute.

    RFC 1122 updated RFC 793 to require that the TTL be configurable.
    RFC 1122 更新了 RFC 793,要求 TTL 是可配置的。

  • Note that the Diffserv field is permitted to change during a connection (Section of RFC 1122).
    请注意,Diffserv 字段允许在连接期间更改(RFC 1122 的第 节)。

    However, the application interface might not support this ability, and the application does not have knowledge about individual TCP segments, so this can only be done on a coarse granularity, at best.
    但是,应用程序接口可能不支持此功能,并且应用程序不了解单个 TCP 段,因此这最多只能在粗粒度上完成。

    This limitation is further discussed in RFC 7657 (Sections 5.1, 5.3, and 6) [50].
    RFC 7657(第 5.1、5.3 和 6 节)[50]进一步讨论了这一限制。

    Generally, an application SHOULD NOT change the Diffserv field value during the course of a connection (SHLD-23).
    通常,应用程序不应在连接过程中更改 Diffserv 字段值 (SHLD-23)。

Any lower-level protocol will have to provide the source address, destination address, and protocol fields, and some way to determine the “TCP length”, both to provide the functional equivalent service of IP and to be used in the TCP checksum.
任何较低级别的协议都必须提供源地址、目的地址和协议字段,并提供某种方法来确定 “TCP 长度”,以提供 IP 的功能相当的服务,并在 TCP 校验和中使用。

When received options are passed up to TCP from the IP layer, a TCP implementation MUST ignore options that it does not understand (MUST-50).
当收到从 IP 层向上传递到 TCP 的选项时,TCP 实现必须忽略它不理解的选项(MUST-50)。

A TCP implementation MAY support the Timestamp (MAY-10) and Record Route (MAY-11) Options.
TCP 实现可以支持 Timestamp(MAY-10)和 Record Route(MAY-11)选项。

源路由 Source Routing

If the lower level is IP (or other protocol that provides this feature) and source routing is used, the interface must allow the route information to be communicated.
如果下层是 IP(或提供此功能的其他协议)并使用源路由,则接口必须允许传递路由信息。

This is especially important so that the source and destination addresses used in the TCP checksum be the originating source and ultimate destination.
这一点特别重要,以便在 TCP 校验中使用的源地址和目的地址是发源地和最终目的地。

It is also important to preserve the return route to answer connection requests.

An application MUST be able to specify a source route when it actively opens a TCP connection (MUST-51), and this MUST take precedence over a source route received in a datagram (MUST-52).
应用程序必须能够在主动打开 TCP 连接时指定源路由(MUST-51),并且这必须优先于在数据报中收到的源路由(MUST-52)。

When a TCP connection is OPENed passively and a packet arrives with a completed IP Source Route Option (containing a return route), TCP implementations MUST save the return route and use it for all segments sent on this connection (MUST-53).
当一个 TCP 连接被被动打开并且一个带有完整的 IP 源路由选项(包含返回路由)的数据包到达时,TCP 实现必须保存返回路由并将其用于该连接上发送的所有段(MUST-53)。

If a different source route arrives in a later segment, the later definition SHOULD override the earlier one (SHLD-24).

ICMP 消息 ICMP Messages

TCP implementations MUST act on an ICMP error message passed up from the IP layer, directing it to the connection that created the error (MUST-54).
TCP 实现必须对从 IP 层向上传递的 ICMP 错误消息做出操作,将其定向到产生错误的连接 (MUST-54)。

The necessary demultiplexing information can be found in the IP header contained within the ICMP message.
可以在 ICMP 消息中包含的 IP 报头中找到必要的解复用信息。

This applies to ICMPv6 in addition to IPv4 ICMP.
除了 IPv4 ICMP 之外,这也适用于 ICMPv6。

[35] contains discussion of specific ICMP and ICMPv6 messages classified as either “soft” or “hard” errors that may bear different responses.
[35]包含了对具体的 ICMP 和 ICMPv6 消息的讨论,这些消息被分类为 “软” 或 “硬” 错误,可能会有不同的回应。

Treatment for classes of ICMP messages is described below:
对 ICMP 报文类别的处理方法描述如下:

Source Quench

TCP implementations MUST silently discard any received ICMP Source Quench messages (MUST-55). See [11] for discussion.
TCP 实现必须静默地丢弃任何接收到的 ICMP 源抑制消息(MUST-55)。有关讨论,请参见[11]。

Soft Errors
软错误 For IPv4 ICMP, these include: Destination Unreachable – codes 0, 1, 5; Time Exceeded – codes 0, 1; and Parameter Problem.
对于 IPv4 ICMP,这些包括:目的地不可达 – 代码 0、1、5;超时 – 代码 0、1;以及参数问题。

For ICMPv6, these include: Destination Unreachable – codes 0, 3; Time Exceeded – codes 0, 1; and Parameter Problem – codes 0, 1, 2.
对于 ICMPv6,这些包括:目的地不可达 – 代码 0,3;超时 – 代码 0,1;和参数问题 – 代码 0,1,2。

Since these Unreachable messages indicate soft error conditions, a TCP implementation MUST NOT abort the connection (MUST-56), and it SHOULD make the information available to the application (SHLD-25).
由于这些 “无法到达” 消息表示软错误条件,因此 TCP 实现不应终止连接(MUST-56),而且它应将信息提供给应用程序(SHLD-25)。

Hard Errors

For ICMP these include Destination Unreachable – codes 2-4.
对于 ICMP,这些包括目的地不可达 – 代码 2-4。

These are hard error conditions, so TCP implementations SHOULD abort the connection (SHLD-26).
这些是硬错误条件,所以 TCP 实现应中止连接(SHLD-26)。

[35] notes that some implementations do not abort connections when an ICMP hard error is received for a connection that is in any of the synchronized states.
[35] 指出,当收到处于任何同步状态的连接的 ICMP 硬错误时,某些实现不会中止连接。

Note that [35], Section 4 describes widespread implementation behavior that treats soft errors as hard errors during connection establishment.
注意,[35] 的第 4 节描述了在连接建立期间将软错误视为硬错误的广泛实现行为。

源地址验证 Source Address Validation

RFC 1122 requires addresses to be validated in incoming SYN packets: RFC 1122 要求验证传入 SYN 数据包中的地址:

An incoming SYN with an invalid source address MUST be ignored either by TCP or by the IP layer [(MUST-63)] (see Section
具有无效源地址的传入 SYN 必须被 TCP 或 IP 层[(必须-63)]忽略(参见第 节)。

A TCP implementation MUST silently discard an incoming SYN segment that is addressed to a broadcast or multicast address [(MUST-57)].
TCP 实现必须静默丢弃指向广播或多播地址的传入 SYN 段 [(MUST-57)]。

This prevents connection state and replies from being erroneously generated, and implementers should note that this guidance is applicable to all incoming segments, not just SYNs, as specifically indicated in RFC 1122.
这可以防止错误地生成连接状态和回复,实现者应该注意,该指南适用于所有传入段,而不仅仅是 SYN,正如 RFC 1122 中特别指出的那样。

事件处理 #

3.10. Event Processing

The processing depicted in this section is an example of one possible implementation.

Other implementations may have slightly different processing sequences, but they should differ from those in this section only in detail, not in substance.

The activity of the TCP endpoint can be characterized as responding to events.
TCP 的活动可以被描述为对事件的响应。

The events that occur can be cast into three categories: user calls, arriving segments, and timeouts.

This section describes the processing the TCP endpoint does in response to each of the events.
本节描述 TCP 为响应每个事件所做的处理。

In many cases, the processing required depends on the state of the connection.

Events that occur:

User Calls







Arriving Segments






The model of the TCP/user interface is that user commands receive an immediate return and possibly a delayed response via an event or pseudo-interrupt.

In the following descriptions, the term “signal” means cause a delayed response.
在以下描述中,术语 “signal” 是指引起延迟响应。

Error responses in this document are identified by character strings.

For example, user commands referencing connections that do not exist receive “error: connection not open”.
例如,引用不存在的连接的用户命令收到 “error: connection not open”。

Please note in the following that all arithmetic on sequence numbers, acknowledgment numbers, windows, et cetera, is modulo 2^32 (the size of the sequence number space).
请注意以下所有关于序列号、确认号、窗口等的算术都是模 2^32(序列号空间的大小)。

Also note that “=<” means less than or equal to (modulo 2^32).
还要注意,"=<" 意味着小于或等于(2^32 的模数)。

A natural way to think about processing incoming segments is to imagine that they are first tested for proper sequence number (i.e., that their contents lie in the range of the expected “receive window” in the sequence number space) and then that they are generally queued and processed in sequence number order.

When a segment overlaps other already received segments, we reconstruct the segment to contain just the new data and adjust the header fields to be consistent.
当一个 TCP 段与其他已经收到的 TCP 段重叠时,我们会重建段,使其只包含新的数据,并调整头部字段以保持一致。

Note that if no state change is mentioned, the TCP connection stays in the same state.
注意,如果未提及状态更改,则 TCP 连接将保持相同状态。

OPEN 调用 #

3.10.1. OPEN Call

CLOSED STATE (i.e., TCB does not exist)

  • Create a new transmission control block (TCB) to hold connection state information.

    Fill in local socket identifier, remote socket, Diffserv field, security/compartment, and user timeout information.
    填充本地套接字标识符、远程套接字、Diffserv 字段、安全/区段和用户超时信息。

    Note that some parts of the remote socket may be unspecified in a passive OPEN and are to be filled in by the parameters of the incoming SYN segment.
    注意,远程套接字的某些部分在被动的 OPEN 中可能没有被指定,要由传入的 SYN 段的参数来填写。

    Verify the security and Diffserv value requested are allowed for this user, if not, return “error: Diffserv value not allowed” or “error: security/compartment not allowed”.
    验证此用户允许请求的安全和 DiffServ 值,如果不允许,则返回 “Error:DiffServ Value Not Allowed” 或 “Error:Security/Compaign Not Allowed”。

    If passive, enter the LISTEN state and return.
    如果被动 OPEN 则进入 LISTEN 状态并返回。

    If active and the remote socket is unspecified, return “error: remote socket unspecified”; if active and the remote socket is specified, issue a SYN segment.
    如果是主动的,并且没有指定远程套接字,则返回 “error: remote socket unspecified”;如果是主动的,并且指定了远程套接字,则发出一个 SYN 段。

    An initial send sequence number (ISS) is selected.
    选择初始发送序列号 (ISS) 。

    A SYN segment of the form <SEQ=ISS><CTL=SYN> is sent.
    发送格式为 <SEQ=ISS><CTL=SYN> 的 SYN 段。

    Set SND.UNA to ISS, SND.NXT to ISS+1, enter SYN-SENT state, and return.
    设置 SND.UNA 为 ISS,SND.NXT 为 ISS+1,进入 SYN-SENT 状态,并返回。

  • If the caller does not have access to the local socket specified, return “error: connection illegal for this process”.
    如果调用者无权访问指定的本地套接字,返回 “error: connection illegal for this process”。

    If there is no room to create a new connection, return “error: insufficient resources”.
    如果没有空间创建新连接,则返回 “error: insufficient resources”。


  • If the OPEN call is active and the remote socket is specified, then change the connection from passive to active, select an ISS.
    如果 OPEN 调用是主动的并且指定了远程套接字,则将连接从被动更改为主动,选择一个 ISS。

    Send a SYN segment, set SND.UNA to ISS, SND.NXT to ISS+1.
    发送一个 SYN 段,设置 SND.UNA 为 ISS,SND.NXT 为 ISS+1。

    Enter SYN-SENT state.
    进入 SYN-SENT 状态。

    Data associated with SEND may be sent with SYN segment or queued for transmission after entering ESTABLISHED state.
    与 SEND 关联的数据可能与 SYN 段一起发送或排队等待在进入 ESTABLISHED 状态后再传输。

    The urgent bit if requested in the command must be sent with the data segments sent as a result of this command.

    If there is no room to queue the request, respond with “error: insufficient resources”.
    如果没有空间入队请求,请返回 “error: insufficient resources”。

    If the remote socket was not specified, then return “error: remote socket unspecified”.
    如果未指定远程套接字,则返回 “error: foreign socket unspecified”。


  • Return “error: connection already exists”.
    返回 “error: connection already exists”.

SEND 调用 #

3.10.2. SEND Call

CLOSED STATE (i.e., TCB does not exist)

  • If the user does not have access to such a connection, then return “error: connection illegal for this process”.
    如果调用者无权访问这个连接,则返回 “error: connection illegal for this process”。

  • Otherwise, return “error: connection does not exist”.
    否则,返回 “error: connection does not exist”。


  • If the remote socket is specified, then change the connection from passive to active, select an ISS.
    如果指定了远程套接字,则将连接从被动更改为主动,选择一个 ISS,然后选择接收缓冲区大小。

    Send a SYN segment, set SND.UNA to ISS, SND.NXT to ISS+1.
    发送一个 SYN 段,设置 SND.UNA 为 ISS,SND.NXT 为 ISS+1。

    Enter SYN-SENT state.
    进入 SYN-SENT 状态。

    Data associated with SEND may be sent with SYN segment or queued for transmission after entering ESTABLISHED state.
    与 SEND 关联的数据可能与 SYN 段一起发送或排队等待在进入 ESTABLISHED 状态后再传输。

    The urgent bit if requested in the command must be sent with the data segments sent as a result of this command.

    If there is no room to queue the request, respond with “error: insufficient resources”.
    如果没有空间入队请求,请返回 “error: insufficient resources”。

    If the remote socket was not specified, then return “error: remote socket unspecified”.
    如果未指定远程套接字,则返回 “error: remote socket unspecified”。


  • Queue the data for transmission after entering ESTABLISHED state.
    将数据入队,在进入 ESTABLISHED 状态后传输数据。

    If no space to queue, respond with “error: insufficient resources”.
    如果没有空间入队,则返回 “error: insufficient resources”。


  • Segmentize the buffer and send it with a piggybacked acknowledgment (acknowledgment value = RCV.NXT).

    If there is insufficient space to remember this buffer, simply return “error: insufficient resources”.
    如果没有足够的空间来保存这个缓冲区,就返回 “error: insufficient resources”。

  • If the URGENT flag is set, then SND.UP <- SND.NXT and set the urgent pointer in the outgoing segments.
    如果设置了紧急标志,则 SND.UP <- SND.NXT-1 并在传出段中设置紧急指针。


  • Return “error: connection closing” and do not service request.
    返回 “error: connection closing”, 并且不处理请求。


3.10.3. RECEIVE Call

CLOSED STATE (i.e., TCB does not exist)

  • If the user does not have access to such a connection, return “error: connection illegal for this process”.
    如果调用者无权访问这个连接,返回 “error: connection illegal for this process”。

  • Otherwise, return “error: connection does not exist”.
    否则返回 “error: connection does not exist”。


  • Queue for processing after entering ESTABLISHED state. 排队等待,在进入 ESTABLISHED 状态后处理。

    If there is no room to queue this request, respond with “error: insufficient resources”.
    如果没有空间入队这个请求,则返回 “error: insufficient resources”。


  • If insufficient incoming segments are queued to satisfy the request, queue the request.

    If there is no queue space to remember the RECEIVE, respond with “error: insufficient resources”.
    如果没有队列空间来保存 RECEIVE,则返回 “error: insufficient resources”。

  • Reassemble queued incoming segments into receive buffer and return to user.

    Mark “push seen” (PUSH) if this is the case.
    如果是这种情况,标记 “push seen” (PUSH)。

  • If RCV.UP is in advance of the data currently being passed to the user, notify the user of the presence of urgent data.
    如果 RCV.UP 在当前传递给用户的数据之前,则通知用户有紧急数据存在。

  • When the TCP endpoint takes responsibility for delivering data to the user, that fact must be communicated to the sender via an acknowledgment.
    当 TCP 向用户传递数据时,必须通过确认将这一情况传达给发送者。

    The formation of such an acknowledgment is described below in the discussion of processing an incoming segment.


  • Since the remote side has already sent FIN, RECEIVEs must be satisfied by data already on hand, but not yet delivered to the user.
    由于远程端已经发送了 FIN,RECEIVE 必须返回已经收到但尚未交付给用户的内容。

    If no text is awaiting delivery, the RECEIVE will get an “error: connection closing” response. 如果没有内容等待传递,RECEIVE 将收到 “error: connection closing” 响应。

    Otherwise, any remaining data can be used to satisfy the RECEIVE. 否则,可以使用任何剩余的内容来返回 RECEIVE 。


  • Return “error: connection closing”. 返回 “error: connection closing”。

CLOSE 调用 #

3.10.4. CLOSE Call

CLOSED STATE (i.e., TCB does not exist)

  • If the user does not have access to such a connection, return “error: connection illegal for this process”.
    如果调用者无权访问这个连接,返回 “error: connection illegal for this process”。

  • Otherwise, return “error: connection does not exist”.
    否则返回 “error: connection does not exist”。


  • Any outstanding RECEIVEs are returned with “error: closing” responses.
    任何未完成的 RECEIVE 都应返回 “error: closing”。

    Delete TCB, enter CLOSED state, and return.
    删除 TCB,进入 CLOSED 状态,然后返回。


  • Delete the TCB and return “error: closing” responses to any queued SENDs, or RECEIVEs.
    删除 TCB 并向所有队列中的 SEND 或 RECEIVE 返回 “error: closing” 响应。


  • If no SENDs have been issued and there is no pending data to send, then form a FIN segment and send it, and enter FIN-WAIT-1 state; otherwise, queue for processing after entering ESTABLISHED state.
    如果没有发出 SEND,也没有待发送的数据,则生成一个 FIN 段发送,进入 FIN-WAIT-1 状态; 否则进入 ESTABLISHED 状态后排队等待处理。


  • Queue this until all preceding SENDs have been segmentized, then form a FIN segment and send it.
    排队直到所有前面的 SEND 都被分段,然后形成一个 FIN 段并发送它。

    In any case, enter FIN-WAIT-1 state.
    无论什么情况下,进入 FIN-WAIT-1 状态。


  • Strictly speaking, this is an error and should receive an “error: connection closing” response.
    严格来说,这是一个错误,应该收到 “error: connection closing” 响应。

    An “ok” response would be acceptable, too, as long as a second FIN is not emitted (the first FIN may be retransmitted, though).
    只要不发出第二个 FIN(尽管可以重传第一个 FIN),返回 “ok” 也是可以接受的。


  • Queue this request until all preceding SENDs have been segmentized; then send a FIN segment, enter LAST-ACK state.
    排队直到所有前面的 SEND 都被分段,然后形成一个 FIN 段并发送它,进入 CLOSING 状态。


  • Respond with “error: connection closing”.
    返回 “error: connection closing”

ABORT 调用 #

3.10.5. ABORT Call

CLOSED STATE (i.e., TCB does not exist)

  • If the user should not have access to such a connection, return “error: connection illegal for this process”.
    如果调用者无权访问这个连接,返回 “error: connection illegal for this process”。

  • Otherwise, return “error: connection does not exist”.
    否则返回 “error: connection does not exist”。


  • Any outstanding RECEIVEs should be returned with “error: connection reset” responses.
    任何未完成的 RECEIVE 都应返回 “error: connection reset” 响应。

    Delete TCB, enter CLOSED state, and return.
    删除 TCB,进入 CLOSED 状态,然后返回。


  • All queued SENDs and RECEIVEs should be given “connection reset” notification.
    所有队列中的 SEND 和 RECEIVE 都应收到 “connection reset” 通知。

    Delete the TCB, enter CLOSED state, and return.
    删除 TCB,进入 CLOSED 状态,然后返回。


  • Send a reset segment:


  • All queued SENDs and RECEIVEs should be given “connection reset” notification; all segments queued for transmission (except for the RST formed above) or retransmission should be flushed.
    所有队列中的 SEND 和 RECEIVE 都应收到 “connection reset” 通知;所有队列中等待传输(除了上面生成的 RST)或重传的段都应该被清除。

    Delete the TCB, enter CLOSED state, and return.
    删除 TCB,进入 CLOSED 状态,然后返回。


  • Respond with “ok” and delete the TCB, enter CLOSED state, and return.
    回复 “ok” 并删除 TCB,进入 CLOSED 状态,然后返回。


3.10.6. STATUS Call

CLOSED STATE (i.e., TCB does not exist)

  • If the user should not have access to such a connection, return “error: connection illegal for this process”.
    如果调用者无权访问这个连接,返回 “error: connection illegal for this process”。

  • Otherwise, return “error: connection does not exist”.
    否则返回 “error: connection does not exist”。


  • Return “state = LISTEN” and the TCB pointer.
    返回 “state = LISTEN”,以及 TCB 指针。


  • Return “state = SYN-SENT” and the TCB pointer.
    返回 “state = SYN-SENT”,以及 TCB 指针。


  • Return “state = SYN-RECEIVED” and the TCB pointer.
    返回 “state = SYN-RECEIVED”,以及 TCB 指针。


  • Return “state = ESTABLISHED” and the TCB pointer.
    返回 “state = ESTABLISHED”,以及 TCB 指针。


  • Return “state = FIN-WAIT-1” and the TCB pointer.
    返回 “state = FIN-WAIT-1”,以及 TCB 指针。


  • Return “state = FIN-WAIT-2” and the TCB pointer.
    返回 “state = FIN-WAIT-2”,以及 TCB 指针。


  • Return “state = CLOSE-WAIT” and the TCB pointer.
    返回 “state = CLOSE-WAIT”,以及 TCB 指针。


  • Return “state = CLOSING” and the TCB pointer.
    返回 “state = CLOSING”,以及 TCB 指针。


  • Return “state = LAST-ACK” and the TCB pointer.
    返回 “state = LAST-ACK”,以及 TCB 指针。


  • Return “state = TIME-WAIT” and the TCB pointer.
    返回 “state = TIME-WAIT”,以及 TCB 指针。

段到达 #



If the state is CLOSED (i.e., TCB does not exist), then
如果状态为 CLOSED(即 TCB 不存在),则

all data in the incoming segment is discarded.

An incoming segment containing a RST is discarded.
丢弃包含 RST 的接收段。

An incoming segment not containing a RST causes a RST to be sent in response.
如果接收段不包含 RST,则回复一个 RST。

The acknowledgment and sequence field values are selected to make the reset sequence acceptable to the TCP endpoint that sent the offending segment.
选择确认和序列字段值是为了使发送无效段的 TCP 可以有效的接收重置序列。

If the ACK bit is off, sequence number zero is used,
如果没有 ACK 标志位,则使用序列号零,


If the ACK bit is on,
如果有 ACK 标志位,




If the state is LISTEN, then
如果状态是 LISTEN,则

First, check for a RST:
第一步,检查是否是 RST:

  • An incoming RST segment could not be valid since it could not have been sent in response to anything sent by this incarnation of the connection.
    接收的 RST 段不可能是有效的,因为它不可能是为了响应这个连接所发送的任何数据而发送的。

    An incoming RST should be ignored. Return.
    接收到 RST 则忽略,然后返回。

Second, check for an ACK:
第二步,检查是否是 ACK:

  • Any acknowledgment is bad if it arrives on a connection still in the LISTEN state.
    如果连接仍处于 LISTEN 状态的连接,则任何 ACK(确认)都是无效的。

    An acceptable reset segment should be formed for any arriving ACK-bearing segment. 对于任何到达的带有 ACK 段都应该生成一个有效的重置段。

    The RST should be formatted as follows:
    RST 的格式应如下所示:


  • Return.

Third, check for a SYN:
第三步,检查是否是 SYN:

  • If the SYN bit is set, check the security.
    如果设置了 SYN 标志位,则检查安全性。

    If the security/compartment on the incoming segment does not exactly match the security/compartment in the TCB, then send a reset and return.
    如果接收段上的安全/区段与 TCB 中的安全/区段不完全匹配,则发送重置段并返回。


  • Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ, and any other control or text should be queued for processing later.
    将 RCV.NXT 设置为 SEG.SEQ+1,IRS 设置为 SEG.SEQ,任何其他控制或内容都应排队等待稍后处理。

    ISS should be selected and a SYN segment sent of the form:
    应选择 ISS 并发送以下形式的 SYN 段:


  • SND.NXT is set to ISS+1 and SND.UNA to ISS.
    SND.NXT 设置为 ISS+1,SND.UNA 设置为 ISS。

    The connection state should be changed to SYN-RECEIVED.
    连接状态应更改为 SYN-RECEIVED。

    Note that any other incoming control or data (combined with SYN) will be processed in the SYN-RECEIVED state, but processing of SYN and ACK should not be repeated.
    注意,任何其它收到的控制或数据(与 SYN 关联)将在 SYN-RECEIVED 状态下处理,但 SYN 和 ACK 的处理不能重复。

    If the listen was not fully specified (i.e., the remote socket was not fully specified), then the unspecified fields should be filled in now.

Fourth, other data or control:

  • This should not be reached.

    Drop the segment and return.

    Any other control or data-bearing segment (not containing SYN) must have an ACK and thus would have been discarded by the ACK processing in the second step, unless it was first discarded by RST checking in the first step.
    任何其他控制或数据段(不包含 SYN)一定会有一个 ACK,因此会被第二步的 ACK 处理所丢弃,除非它首先被第一步的 RST 检查所丢弃。


If the state is SYN-SENT, then
如果状态是 SYN-SENT,则

First, check the ACK bit:
第一步,检查 ACK 标识位:

  • If the ACK bit is set,
    如果设置了 ACK 标识,

    • If SEG.ACK =< ISS or SEG.ACK > SND.NXT, send a reset (unless the RST bit is set, if so drop the segment and return)
      如果 SEG.ACK =< ISS,或 SEG.ACK > SND.NXT,发送一个重置(除非设置了 RST 位,如果设置了则丢弃该段并返回)


    • and discard the segment. Return.

    • If SND.UNA < SEG.ACK =< SND.NXT, then the ACK is acceptable.
      如果 SND.UNA =< SEG.ACK =< SND.NXT, 那么 ACK 是有效的。

      Some deployed TCP code has used the check SEG.ACK == SND.NXT (using “==” rather than “=<”), but this is not appropriate when the stack is capable of sending data on the SYN because the TCP peer may not accept and acknowledge all of the data on the SYN.
      某些已经部署的 TCP 代码使用 SEG.ACK==SND.NXT(使用 “==” 而不是 “=>")来检查,但是当堆栈能够在 SYN 上发送数据时,这是不合适的,因为 TCP 可能不会接受和确认 SYN 上的所有数据。

Second, check the RST bit:
第二步,检查 RST 标识位:

  • If the RST bit is set,
    如果设置了 RST 标识,

    • A potential blind reset attack is described in RFC 5961 [9].
      RFC 5961 [9] 中描述了一种潜在的 blind reset 攻击。

      The mitigation described in that document has specific applicability explained therein, and is not a substitute for cryptographic protection (e.g., IPsec or TCP-AO).
      该文档中描述的缓解措施在其中解释了特定的适用性,并且不能替代加密保护(例如 IPsec 或 TCP-AO)。

      A TCP implementation that supports the mitigation described in RFC 5961 SHOULD first check that the sequence number exactly matches RCV.NXT prior to executing the action in the next paragraph.
      TCP 实现在支持 RFC 5961 中描述的缓解措施时,应该在执行下一段中的操作之前首先检查序列号是否与 RCV.NXT 完全匹配。

    • If the ACK was acceptable, then signal to the user “error: connection reset”, drop the segment, enter CLOSED state, delete TCB, and return.
      如果 ACK 是可接受的,则向用户发出 “ERROR:Connection Reset” 的信号,丢弃该段,进入关闭状态,删除 TCB,然后返回。

      Otherwise (no ACK), drop the segment and return.
      否则(无 ACK)丢弃该段并返回。

Third, check the security:

  • If the security/compartment in the segment does not exactly match the security/compartment in the TCB, send a reset:
    如果段中的安全/区段与 TCB 中的安全/区段不完全匹配,则发送一个重置信号

    • If there is an ACK,
      如果有 ACK,


    • Otherwise,


  • If a reset was sent, discard the segment and return.

Fourth, check the SYN bit:
第四步,检查 SYN 标识位:

  • This step should be reached only if the ACK is ok, or there is no ACK, and the segment did not contain a RST.
    仅当 ACK 正常或没有 ACK 且该段不包含 RST 时才应执行此步骤。

  • If the SYN bit is on and the security/compartment is acceptable, then RCV.NXT is set to SEG.SEQ+1, IRS is set to SEG.SEQ.
    如果 SYN 位打开并且安全/区段和优先级是有效的,则 RCV.NXT 设置为 SEG.SEQ+1,IRS 设置为 SEG.SEQ。

    SND.UNA should be advanced to equal SEG.ACK (if there is an ACK), and any segments on the retransmission queue that are thereby acknowledged should be removed.
    SND.UNA 应增加到等于 SEG.ACK,重传队列中任何因此被确认的片段应被删除。

  • If SND.UNA > ISS (our SYN has been ACKed), change the connection state to ESTABLISHED, form an ACK segment
    如果 SND.UNA>ISS(我们的 SYN 已经被 ACK 了),将连接状态改为 ESTABLISHED,生成一个 ACK 段


  • and send it. Data or controls that were queued for transmission MAY be included.

    Some TCP implementations suppress sending this segment when the received segment contains data that will anyways generate an acknowledgment in the later processing steps, saving this extra acknowledgment of the SYN from being sent.
    当接收到的段包含数据时,无论如何都会在后面的处理步骤中生成确认时,某些 TCP 实现会阻止发送这种段,从而避免发送 SYN 的额外确认。

    If there are other controls or text in the segment, then continue processing at the sixth step under Section where the URG bit is checked; otherwise, return.
    如果段中还有其他操作或内容,则继续下面第 节中的第六步检查 URG 位的处理,否则返回。

  • Otherwise, enter SYN-RECEIVED, form a SYN,ACK segment
    否则进入 SYN-RECEIVED 状态,生成一个 SYN,ACK 段


  • and send it. Set the variables: 然后发送它。设置变量:


    SND.WL1 <- SEG.SEQ

    SND.WL2 <- SEG.ACK

    If there are other controls or text in the segment, queue them for processing after the ESTABLISHED state has been reached, return.
    如果段中有其他控制或内容,将其入队,在达到 ESTABLISHED 状态后处理,返回。

  • Note that it is legal to send and receive application data on SYN segments (this is the “text in the segment” mentioned above).
    注意,在 SYN 段上发送和接收应用数据是合法的(这就是上面提到的 “段中数据”)。

    There has been significant misinformation and misunderstanding of this topic historically.

    Some firewalls and security devices consider this suspicious.

    However, the capability was used in T/TCP [21] and is used in TCP Fast Open (TFO) [48], so is important for implementations and network devices to permit.
    然而,这种能力被用于 T/TCP[21],并被用于 TCP 快速开放(TFO)[48],所以允许这种能力,对于实现和网络设备来说很重要。

Fifth, if neither of the SYN or RST bits is set, then drop the segment and return.
第五步,如果 SYN 或 RST 标识位均未设置,则丢弃该段并返回。

其它状态 Other States


First, check sequence number:









    • Segments are processed in sequence.

      Initial tests on arrival are used to discard old duplicates, but further processing is done in SEG.SEQ order.
      到达时的初始检测用于丢弃旧的重复项,但进一步处理按 SEG.SEQ 顺序完成。

      If a segment’s contents straddle the boundary between old and new, only the new parts are processed. 如果一个段的内容即包括了新内容也包括了旧内容,那么应该只处理新的部分。

    • In general, the processing of received segments MUST be implemented to aggregate ACK segments whenever possible (MUST-58).
      通常,必须尽可能地对接收到的数据段进行处理以聚合 ACK 数据段(MUST-58)。

      For example, if the TCP endpoint is processing a series of queued segments, it MUST process them all before sending any ACK segments (MUST-59).
      例如,如果 TCP 正在处理一系列队列中的段,它必须处理所有这些段之后再发送 ACK 段(MUST-59)。

    • There are four cases for the acceptability test for an incoming segment:

      | Segment | Receive | Test                                 |
      | Length  | Window  |                                      |
      | 0       | 0       | SEG.SEQ = RCV.NXT                    |
      | 0       | >0      | RCV.NXT =< SEG.SEQ <                 |
      |         |         | RCV.NXT+RCV.WND                      |
      | >0      | 0       | not acceptable                       |
      | >0      | >0      | RCV.NXT =< SEG.SEQ <                 |
      |         |         | RCV.NXT+RCV.WND                      |
      |         |         |                                      |
      |         |         | or                                   |
      |         |         |                                      |
      |         |         | RCV.NXT =< SEG.SEQ+SEG.LEN-1         |
      |         |         | < RCV.NXT+RCV.WND                    |
                Table 6: Segment Acceptability Tests
    • In implementing sequence number validation as described here, please note Appendix A.2.
      在按照此处所述实现序列号验证时,请注意附录 A.2。

    • If the RCV.WND is zero, no segments will be acceptable, but special allowance should be made to accept valid ACKs, URGs, and RSTs.
      如果 RCV.WND 为 0,则不接收任何段,但有效的 ACK、URG 和 RST 还是需要处理。

    • If an incoming segment is not acceptable, an acknowledgment should be sent in reply (unless the RST bit is set, if so drop the segment and return):
      如果收到的段无效,则应发送确认段作为回复(除非 RST 位被设置,如果是那样,则放弃该段并返回):


    • After sending the acknowledgment, drop the unacceptable segment and return.

    • Note that for the TIME-WAIT state, there is an improved algorithm described in [40] for handling incoming SYN segments that utilizes timestamps rather than relying on the sequence number check described here.
      请注意,对于 TIME-WAIT 状态,在[40]中描述了一种改进的算法,用于处理传入的 SYN 段,该算法利用时间戳,而不是依赖于这里描述的序列号检查。

      When the improved algorithm is implemented, the logic above is not applicable for incoming SYN segments with Timestamp Options, received on a connection in the TIME-WAIT state.
      当实现改进的算法时,上述逻辑不适用于在 TIME-WAIT 状态的连接上收到的带有时间戳选项的 SYN 段。

    • In the following it is assumed that the segment is the idealized segment that begins at RCV.NXT and does not exceed the window.
      在下文中,假设该段是从 RCV.NXT 开始的理想化段,并且不超过窗口。

      One could tailor actual segments to fit this assumption by trimming off any portions that lie outside the window (including SYN and FIN) and only processing further if the segment then begins at RCV.NXT.
      我们可以通过修剪位于窗口之外的任何部分(包括 SYN 和 FIN),并只在段开始于 RCV.NXT 的情况下进一步处理,从而使实际段符合这一假设。

      Segments with higher beginning sequence numbers SHOULD be held for later processin(SHLD-31).

Second, check the RST bit:
第二步,检查 RST 标识位:

  • RFC 5961 [9], Section 3 describes a potential blind reset attack and optional mitigation approach.
    RFC 5961 [9] 第 3 节描述了一种潜在的 blind reset 攻击和可选的缓解方法。

    This does not provide a cryptographic protection (e.g., as in IPsec or TCP-AO) but can be applicable in situations described in RFC 5961.
    这不提供加密保护(例如,在 IPsec 或 TCP-AO 中),但可适用于 RFC 5961 中描述的情况。

    For stacks implementing the protection described in RFC 5961, the three checks below apply; otherwise, processing for these states is indicated further below.
    对于实现 RFC 5961 中描述的保护的堆栈,下面的三个检查适用;否则,对这些状态的处理在下面进一步说明。

    1. If the RST bit is set and the sequence number is outside the current receive window, silently drop the segment.
      如果设置了 RST 位并且序列号在当前接收窗口之外,则静默丢弃该段。

    2. If the RST bit is set and the sequence number exactly matches the next expected sequence number (RCV.NXT), then TCP endpoints MUST reset the connection in the manner prescribed below according to the connection state.
      如果设置了 RST 位并且序列号与下一个预期序列号(RCV.NXT)完全匹配,则 TCP 必须根据连接状态以下面规定的方式重置连接。

    3. If the RST bit is set and the sequence number does not exactly match the next expected sequence value, yet is within the current receive window, TCP endpoints MUST send an acknowledgment (challenge ACK):
      如果设置了 RST 位,并且序列号与下一个预期序列值不完全匹配,但仍在当前接收窗口内,则 TCP 必须发送确认(challenge ACK):


      After sending the challenge ACK, TCP endpoints MUST drop the unacceptable segment and stop processing the incoming packet further.
      在发送 challenge ACK 后,TCP 必须放弃不可接受的段,并停止进一步处理传入的数据包。

      Note that RFC 5961 and Errata ID 4772 [99] contain additional considerations for ACK throttling in an implementation.
      注意,RFC 5961 和 Errata ID 4772 [99] 包含有关实现中 ACK 限制的其他注意事项。


    • If the RST bit is set,
      如果设置了 RST 标识位,

      • If this connection was initiated with a passive OPEN (i.e., came from the LISTEN state), then return this connection to LISTEN state and return.
        如果这个连接是以被动的 OPEN 发起的(即来自 LISTEN 状态),那么将这个连接返回到 LISTEN 状态并返回。

      The user need not be informed.

      If this connection was initiated with an active OPEN (i.e., came from SYN-SENT state), then the connection was refused; signal the user “connection refused”.
      如果这个连接是以主动 OPEN 启动的(即来自 SYN-SENT 状态),然后这个连接被拒绝了,则向用户发出 “connection refused” 的信号。

      In either case, the retransmission queue should be flushed.

      And in the active OPEN case, enter the CLOSED state and delete the TCB, and return.
      如果是在主动 OPEN 情况下,进入 CLOSED 状态并删除 TCB,然后返回。





    • If the RST bit is set, then any outstanding RECEIVEs and SEND should receive “reset” responses.
      如果设置了 RST 标识位,那么所有未完成的 RECEIVE 和 SEND 都应该收到 “reset” 响应。

      All segment queues should be flushed. Users should also receive an unsolicited general “connection reset” signal.
      所有的段队列都应该被清除。用户还应收到未经请求通用的 “connection reset” 信号。

      Enter the CLOSED state, delete the TCB, and return.
      进入 CLOSED 状态,删除 TCB,并返回。




    • If the RST bit is set, then enter the CLOSED state, delete the TCB, and return.
      如果设置了 RST 标识位,进入 CLOSED 状态,删除 TCB,并返回。

Third, check security:


    • If the security/compartment in the segment does not exactly match the security/compartment in the TCB, then send a reset and return.
      如果段上的安全/区段与 TCB 中的安全/区段不完全匹配,则发送重置段并返回。







    • If the security/compartment in the segment does not exactly match the security/compartment in the TCB, then send a reset; any outstanding RECEIVEs and SEND should receive “reset” responses.
      如果段上的安全/区段与 TCB 中的安全/区段不完全匹配,则发送重置段,所有未完成的 RECEIVE 和 SEND 都应该收到 “reset” 响应。

    All segment queues should be flushed.

    Users should also receive an unsolicited general “connection reset” signal.
    用户还应收到未经请求通用的 “connection reset” 信号。

    Enter the CLOSED state, delete the TCB, and return.
    进入 CLOSED 状态,删除 TCB,并返回。

  • Note this check is placed following the sequence check to prevent a segment from an old connection between these port numbers with a different security from causing an abort of the current connection.

Fourth, check the SYN bit:
第四步,检查 SYN 标识位:


    • If the connection was initiated with a passive OPEN, then return this connection to the LISTEN state and return.
      如果连接是以被动的 OPEN 开始的,那么就把这个连接返回到 LISTEN 状态并返回。

      Otherwise, handle per the directions for synchronized states below.








    • If the SYN bit is set in these synchronized states, it may be either a legitimate new connection attempt (e.g., in the case of TIME-WAIT), an error where the connection should be reset, or the result of an attack attempt, as described in RFC 5961 [9].
      如果在这些同步状态中设置了 SYN 位,则它可能是合法的新连接尝试(例如,在 TIME-WAIT 的情况下),应该重置连接的错误,或者是攻击尝试的结果,如在 RFC 5961 [9] 中有描述。

      For the TIME-WAIT state, new connections can be accepted if the Timestamp Option is used and meets expectations (per [40]).
      对于 TIME-WAIT 状态,如果使用了时间戳选项并且符合预期(per [40]),则可以接受新连接。

      For all other cases, RFC 5961 provides a mitigation with applicability to some situations, though there are also alternatives that offer cryptographic protection (see Section 7).
      对于所有其他情况,RFC 5961 提供了一种适用于某些情况的缓解措施,但也有提供加密保护的替代方案(请参阅第 7 节)。

      RFC 5961 recommends that in these synchronized states, if the SYN bit is set, irrespective of the sequence number, TCP endpoints MUST send a “challenge ACK” to the remote peer:
      RFC 5961 建议在这些同步状态下,如果设置了 SYN 位,则无论序列号如何,TCP 端点都必须向远程发送 “challenge ACK”:


    • After sending the acknowledgment, TCP implementations MUST drop the unacceptable segment and stop processing further.
      发送确认后,TCP 实现必须丢弃不可接受的段并停止进一步处理。

      Note that RFC 5961 and Errata ID 4772 [99] contain additional ACK throttling notes for an implementation.
      注意,RFC 5961 和 Errata ID 4772 [99]包含了一个用于实现的额外 ACK 限制说明。

    • For implementations that do not follow RFC 5961, the original behavior described in RFC 793 follows in this paragraph.
      对于不遵循 RFC 5961 的实现,RFC 793 中描述的原始行为在本段下面。

      If the SYN is in the window it is an error: send a reset, any outstanding RECEIVEs and SEND should receive “reset” responses, all segment queues should be flushed, the user should also receive an unsolicited general “connection reset” signal, enter the CLOSED state, delete the TCB, and return.
      如果 SYN 在窗口中,则出现错误了,发送重置段,所有未完成的 RECEIVE 和 SEND 都应该收到 “reset” 响应,所有的段队列都应该被清除,用户还应收到未经请求通用的 “connection reset” 信号,进入 CLOSED 状态,删除 TCB,并返回。

    • If the SYN is not in the window, this step would not be reached and an ACK would have been sent in the first step (sequence number check).
      如果 SYN 不在窗口中,则不会到这里,并且会在第一步(序列号检查)中发送确认。

Fifth, check the ACK field:
第五步,检查 ACK 标识位:

  • if the ACK bit is off, drop the segment and return
    如果 ACK 标识位没有开启,则丢弃该段并返回

  • if the ACK bit is on,
    如果 ACK 标识位开启,

    • RFC 5961 [9], Section 5 describes a potential blind data injection attack, and mitigation that implementations MAY choose to include (MAY-12).
      RFC 5961 [9],第 5 节描述了潜在的 blind data 注入攻击,以及实现可能选择包含的缓解措施(MAY-12)。

      TCP stacks that implement RFC 5961 MUST add an input check that the ACK value is acceptable only if it is in the range of ((SND.UNA - MAX.SND.WND) =< SEG.ACK =< SND.NXT).
      实现 RFC 5961 的 TCP 堆栈必须添加一个输入检查,确保 ACK 值仅在 ((SND.UNA - MAX.SND.WND) =< SEG.ACK =< SND.NXT) 范围内时才可接受。

      All incoming segments whose ACK value doesn’t satisfy the above condition MUST be discarded and an ACK sent back.
      所有 ACK 值不满足上述条件的传入段都必须丢弃,并回复一个 ACK。

      The new state variable MAX.SND.WND is defined as the largest window that the local sender has ever received from its peer (subject to window scaling) or may be hard-coded to a maximum permissible window value.
      新状态变量 MAX.SND.WND 被定义为本地发送方曾经从其对等方接收到的最大窗口(受窗口缩放影响),或者可以硬编码为最大允许窗口值。

      When the ACK value is acceptable, the per-state processing below applies:
      当 ACK 值可以接受时,将应用以下按状态处理:


      • If SND.UNA < SEG.ACK =< SND.NXT, then enter ESTABLISHED state and continue processing with the variables below set to:
        如果 SND.UNA < SEG.ACK =< SND.NXT,则进入 ESTABLISHED 状态并继续处理,并将以下变量设置为:

        SND.WND <- SEG.WND

        SND.WL1 <- SEG.SEQ

        SND.WL2 <- SEG.ACK

      • If the segment acknowledgment is not acceptable, form a reset segment


      • and send it.


      • If SND.UNA < SEG.ACK =< SND.NXT, then set SND.UNA <- SEG.ACK.
        如果 SND.UNA < SEG.ACK =< SND.NXT,则设置 SND.UNA <- SEG.ACK。

        Any segments on the retransmission queue that are thereby entirely acknowledged are removed.

        Users should receive positive acknowledgments for buffers that have been SENT and fully acknowledged (i.e., SEND buffer should be returned with “ok” response).
        对于已经发送并完全确认的缓冲区,用户应该收到正向的确认(即,SEND 缓冲区应该返回 “ok” 响应)。

        If the ACK is a duplicate (SEG.ACK =< SND.UNA), it can be ignored.
        如果 ACK 是重复的 (SEG.ACK =< SND.UNA),则可以忽略它。

        If the ACK acks something not yet sent (SEG.ACK > SND.NXT), then send an ACK, drop the segment, and return.
        如果 ACK 确认尚未发送的内容(SEG.ACK > SND.NXT),则发送 ACK,丢弃该段,然后返回。

      • If SND.UNA =< SEG.ACK =< SND.NXT, the send window should be updated.
        如果 SND.UNA =< SEG.ACK =< SND.NXT,则应该更新发送窗口。

        If (SND.WL1 < SEG.SEQ or (SND.WL1 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set SND.WND <- SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- SEG.ACK.
        如果(SND.WL1 < SEG.SEQ 或 (SND.WL1 = SEG.SEQ 和 SND.WL2 =< SEG.ACK)),设置 SND.WND <- SEG.WND,设置 SND.WL1 <- SEG.SEQ,并设置 SND.WL2 <- SEG.ACK。

      • Note that SND.WND is an offset from SND.UNA, that SND.WL1 records the sequence number of the last segment used to update SND.WND, and that SND.WL2 records the acknowledgment number of the last segment used to update SND.WND.
        注意,SND.WND 是 SND.UNA 的偏移量,SND.WL1 记录用于更新 SND.WND 的最后一个段的序列号,SND.WL2 记录用于更新 SND.WND 的最后一个段的确认号。

        The check here prevents using old segments to update the window.


      • In addition to the processing for the ESTABLISHED state, if the FIN segment is now acknowledged, then enter FIN-WAIT-2 and continue processing in that state.
        除了 ESTABLISHED 状态的处理之外,如果我们的 FIN 现在被确认,则进入 FIN-WAIT-2 并继续在该状态下处理。

      • In addition to the processing for the ESTABLISHED state, if the retransmission queue is empty, the user’s CLOSE can be acknowledged (“ok”) but do not delete the TCB.
        除了对 ESTABLISHED 状态的处理,如果重传队列为空,可以用 “ok” 确认用户的 CLOSE, 但不删除 TCB。

      • Do the same processing as for the ESTABLISHED state.
        做与 ESTABLISHED 状态相同的处理。

      • In addition to the processing for the ESTABLISHED state, if the ACK acknowledges our FIN, then enter the TIME-WAIT state; otherwise, ignore the segment.
        除了 ESTABLISHED 状态的处理外,如果 ACK 确认了我们的 FIN,则进入 TIME-WAIT 状态,否则忽略该段。

      • The only thing that can arrive in this state is an acknowledgment of our FIN.
        唯一能到达这种状态的是对我们的 FIN 的确认。

        If our FIN is now acknowledged, delete the TCB, enter the CLOSED state, and return.
        如果现在确认了我们的 FIN,删除 TCB,进入 CLOSED 状态,然后返回。


      • The only thing that can arrive in this state is a retransmission of the remote FIN.
        唯一可以到达此状态的是远程 FIN 的重传。

        Acknowledge it, and restart the 2 MSL timeout.
        确认它,并重新启动 2 MSL 超时。

Sixth, check the URG bit:
第六步,检查 URG 标识位:




    • If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and signal the user that the remote side has urgent data if the urgent pointer (RCV.UP) is in advance of the data consumed.
      如果设置了 URG 标识位,RCV.UP <- max(RCV.UP,SEG.UP),如果紧急指针(RCV.UP)在所接收的数据之前,则向用户发出信号,表明远程端有紧急数据。

      If the user has already been signaled (or is still in the “urgent mode”) for this continuous sequence of urgent data, do not signal the user again.





    • This should not occur since a FIN has been received from the remote side. Ignore the URG.
      这不应该发生,因为已经收到了来自远程端的 FIN,忽略 URG。

Seventh, process the segment text:




    • Once in the ESTABLISHED state, it is possible to deliver segment data to user RECEIVE buffers.
      一旦进入 ESTABLISHED 状态,就有可能向用户的 RECEIVE 缓冲区传送段内容。

      Data from segments can be moved into buffers until either the buffer is full or the segment is empty.

      If the segment empties and carries a PUSH flag, then the user is informed, when the buffer is returned, that a PUSH has been received.
      如果该段为空并带有 PUSH 标志,则在返回缓冲区时通知用户已收到 PUSH。

    • When the TCP endpoint takes responsibility for delivering the data to the user, it must also acknowledge the receipt of the data.
      当 TCP 负责将数据传送给用户时,它也必须确认数据的接收。

    • Once the TCP endpoint takes responsibility for the data, it advances RCV.NXT over the data accepted, and adjusts RCV.WND as appropriate to the current buffer availability.
      一旦 TCP 对数据处理,它将 RCV.NXT 推进到所接受的数据上,并根据当前缓冲区的可用性调整 RCV.WND。

      The total of RCV.NXT and RCV.WND should not be reduced.
      RCV.NXT 和 RCV.WND 的总量不应减少。

    • A TCP implementation MAY send an ACK segment acknowledging RCV.NXT when a valid segment arrives that is in the window but not at the left window edge (MAY-13).
      当在窗口中但不在左窗口边缘的有效段到达时,TCP 实现可以发送确认 RCV.NXT 的 ACK 段(MAY-13)。

    • Please note the window management suggestions in Section 3.8.
      请注意 3.8 节中的窗口管理建议。

    • Send an acknowledgment of the form:


    • This acknowledgment should be piggybacked on a segment being transmitted if possible without incurring undue delay.





    • This should not occur since a FIN has been received from the remote side.
      这不应该发生,因为已经收到了来自远程端的 FIN。

      Ignore the segment text.

Eighth, check the FIN bit:
第八步,检查 FIN 标识位:

  • Do not process the FIN if the state is CLOSED, LISTEN, or SYN-SENT since the SEG.SEQ cannot be validated; drop the segment and return.
    如果状态为 CLOSED、LISTEN 或 SYN-SENT,则不要处理 FIN,因为无法验证 SEG.SEQ;丢弃段并返回。

  • If the FIN bit is set, signal the user “connection closing” and return any pending RECEIVEs with same message, advance RCV.NXT over the FIN, and send an acknowledgment for the FIN.
    如果设置了 FIN 标识位,向用户发出 “connection closing” 信号,并使用相同的消息返回任何待处理的 RECEIVE,推进 RCV.NXT 到 FIN,并发送 FIN 的确认。

    Note that FIN implies PUSH for any segment text not yet delivered to the user.
    注意,对于还没有传给用户的任何段内容,FIN 意味着 PUSH。



      • Enter the CLOSE-WAIT state.
        进入 CLOSE-WAIT 状态。

      • If our FIN has been ACKed (perhaps in this segment), then enter TIME-WAIT, start the time-wait timer, turn off the other timers; otherwise, enter the CLOSING state.
        如果我们的 FIN 已经被 ACK 了(可能在这个段),那么进入 TIME-WAIT,启动 time-wait 定时器,关闭其他定时器;否则进入 CLOSING 状态。

      • Enter the TIME-WAIT state. Start the time-wait timer, turn off the other timers.
        进入 TIME-WAIT 状态。 启动时间等待定时器,关闭其他定时器。

      • Remain in the CLOSE-WAIT state.
        保持在 CLOSE-WAIT 状态。

      • Remain in the CLOSING state.
        保持在 CLOSING 状态。

      • Remain in the LAST-ACK state.
        保持在 LAST-ACK 状态。

      • Remain in the TIME-WAIT state. Restart the 2 MSL time-wait timeout.
        保持在 TIME-WAIT 状态,重启 2MSL 超时定时器。

and return.

超时 #

3.10.8. Timeouts


  • For any state if the user timeout expires, flush all queues, signal the user “error: connection aborted due to user timeout” in general and for any outstanding calls, delete the TCB, enter the CLOSED state, and return.
    对于任何状态,如果用户超时到期,清空所有队列,对于任何未完成的调用,向用户发出信号 “error: connection aborted due to user timeout”,删除 TCB,进入到 CLOSE 状态并返回。


  • For any state if the retransmission timeout expires on a segment in the retransmission queue, send the segment at the front of the retransmission queue again, reinitialize the retransmission timer, and return.


  • If the time-wait timeout expires on a connection, delete the TCB, enter the CLOSED state, and return.
    如果连接中的 time-wait 超时,则删除 TCB,进入 CLOSED 状态并返回。

词汇表 #



A control bit (acknowledge) occupying no sequence space, which indicates that the acknowledgment field of this segment specifies the next sequence number the sender of this segment is expecting to receive, hence acknowledging receipt of all previous sequence numbers.


A logical communication path identified by a pair of sockets.


A message sent in a packet-switched computer communications network.

Destination Address

The network-layer address of the endpoint intended to receive a segment.


A control bit (finis) occupying one sequence number, which indicates that the sender will send no more data or control occupying sequence space.


To remove all of the contents (data or segments) from a store (buffer or queue).


A portion of a logical unit of data. In particular, an internet fragment is a portion of an internet datagram.


Control information at the beginning of a message, segment, fragment, packet, or block of data.


A computer. In particular, a source or destination of messages from the point of view of the communication network.


An Internet Protocol field. This identifying value assigned by the sender aids in assembling the fragments of a datagram.
IP 协议字段。发送方分配的这个标识值有助于组装数据报的片段。

internet address

A network-layer address.

internet datagram

A unit of data exchanged between internet hosts, together with the internet header that allows the datagram to be routed from source to destination.

internet fragment

A portion of the data of an internet datagram with an internet header.


Internet Protocol. See [1] and [13].
IP 协议。见[1]和[13]。


The Initial Receive Sequence number. The first sequence number used by the sender on a connection.


The Initial Sequence Number. The first sequence number used on a connection (either ISS or IRS).
初始序列号。连接上使用的第一个序列号(ISS 或 IRS)。

Selected in a way that is unique within a given period of time and is unpredictable to attackers.


The Initial Send Sequence number. The first sequence number used by the sender on a connection.

left sequence

This is the next sequence number to be acknowledged by the data-receiving TCP endpoint (or the lowest currently unacknowledged sequence number) and is sometimes referred to as the left edge of the send window.
这是接收数据的 TCP 要确认的下一个序列号(或当前未确认的最低序列号),有时称为发送窗口的左边缘。


An implementation, usually in software, of a protocol or other procedure.


Maximum Segment Lifetime, the time a TCP segment can exist in the internetwork system. Arbitrarily defined to be 2 minutes.
最大段存活时间,TCP 段可以存在于网络中的时间,定义为 2 分钟。


An eight-bit byte.


An Option field may contain several options, and each option may be several octets in length.


A package of data with a header that may or may not be logically complete.

More often a physical packaging than a logical packaging of data.


The portion of a connection identifier used for demultiplexing connections at an endpoint.


A program in execution. A source or destination of data from the point of view of the TCP endpoint or other host-to-host protocol.
正在执行的程序,从 TCP 或其他主机到主机协议的角度来看,数据的来源或目的地。


A control bit occupying no sequence space, indicating that this segment contains data that must be pushed through to the receiving user.


receive next sequence number


receive urgent pointer


receive window

receive next sequence number

This is the next sequence number the local TCP endpoint is expecting to receive.
这是本地 TCP 期望接收的下一个序列号。

receive window

This represents the sequence numbers the local (receiving) TCP endpoint is willing to receive.
这表示本地(接收)TCP 可接收的序列号。

Thus, the local TCP endpoint considers that segments overlapping the range RCV.NXT to RCV.NXT + RCV.WND - 1 carry acceptable data or control.
因此,本地 TCP 认为与范围 RCV.NXT 到 RCV.NXT + RCV.WND - 1 重叠的段携带有效的数据或控制。

Segments containing sequence numbers entirely outside this range are considered duplicates or injection attacks and discarded.


A control bit (reset), occupying no sequence space, indicating that the receiver should delete the connection without further interaction.

The receiver can determine, based on the sequence number and acknowledgment fields of the incoming segment, whether it should honor the reset command or ignore it.

In no case does receipt of a segment containing RST give rise to a RST in response.
在任何情况下,收到包含 RST 的段都不会产生 RST 作为响应。


segment acknowledgment


segment length


segment sequence


segment urgent pointer field


segment window field


A logical unit of data.

In particular, a TCP segment is the unit of data transferred between a pair of TCP modules.
特别的是, TCP 段是在一对 TCP 模块之间传输的数据单元。

segment acknowledgment

The sequence number in the acknowledgment field of the arriving segment.

segment length

The amount of sequence number space occupied by a segment, including any controls that occupy sequence space.

segment sequence

The number in the sequence field of the arriving segment.

send sequence

This is the next sequence number the local (sending) TCP endpoint will use on the connection.
这是本地(发送)TCP 将在连接上使用的下一个序列号。

It is initially selected from an initial sequence number curve (ISN) and is incremented for each octet of data or sequenced control transmitted.
它最初是从初始序列号曲线 (ISN) 中选择的,并因为传输的每个字节数据或序列控制递增。

send window

This represents the sequence numbers that the remote (receiving) TCP endpoint is willing to receive.
这表示远程(接收)TCP 期望接收的序列号。

It is the value of the window field specified in segments from the remote (data-receiving) TCP endpoint.
它是来自远程(数据接收)TCP 的段中指定的窗口字段的值。

The range of new sequence numbers that may be emitted by a TCP implementation lies between SND.NXT and SND.UNA + SND.WND - 1. (Retransmissions of sequence numbers between SND.UNA and SND.NXT are expected, of course.)
TCP 实现可能发出的序列号范围位于 SND.NXT 和 SND.UNA + SND.WND - 1 之间。(当然,重传序列号在 SND.UNA 和 SND.NXT 之间是意料之中的。)


send sequence


left sequence


send urgent pointer


segment sequence number at last window update 最后一次窗口更新时的序列号


segment acknowledgment number at last window update


send window

socket (or socket number, or socket address, or socket identifier)

An address that specifically includes a port identifier, that is, the concatenation of an Internet Address with a TCP port.
包括具体端口标识符的地址,即网络地址与 TCP 端口的组合

Source Address

The network-layer address of the sending endpoint.


A control bit in the incoming segment, occupying one sequence number, used at the initiation of a connection to indicate where the sequence numbering will start.


Transmission control block, the data structure that records the state of a connection.


Transmission Control Protocol: a host-to-host protocol for reliable communication in internetwork environments.


Type of Service, an obsoleted IPv4 field.
服务类型,废弃的 IPv4 字段。

The same header bits currently are used for the Differentiated Services field [4] containing the Differentiated Services Codepoint (DSCP) value and the 2-bit ECN codepoint [6].
当前,报头中相同的比特位用于包含 Differentiated Services Codepoint (DSCP) 值和 2 位 ECN codepoint [6] 的差分服务字段 [4]。

Type of Service

See “TOS”.
见 “TOS”。


A control bit (urgent), occupying no sequence space, used to indicate that the receiving user should be notified to do urgent processing as long as there is data to be consumed with sequence numbers less than the value indicated by the urgent pointer.
控制位(urgent),不占用序列空间,用于表示只要有序列号小于 urgent 指针指示值的数据需要消费,就通知接收用户做紧急处理。

urgent pointer

A control field meaningful only when the URG bit is on.
紧急指针,仅当 URG 标志位打开时才有意义的控制字段。

This field communicates the value of the urgent pointer that indicates the data octet associated with the sending user’s urgent call.

与 RFC 793 相比的改动 #

5.Changes from RFC 793

This document obsoletes RFC 793 as well as RFCs 6093 and 6528, which updated 793.
本文档废弃了 RFC 793 以及更新了 793 的 RFC 6093 和 6528。

In all cases, only the normative protocol specification and requirements have been incorporated into this document, and some informational text with background and rationale may not have been carried in.

The informational content of those documents is still valuable in learning about and understanding TCP, and they are valid Informational references, even though their normative content has been incorporated into this document.
这些文档的信息内容对于学习和理解 TCP 仍然很有价值,并且它们是有效的参考信息,即使它们的规范性内容已合并到本文档中。

The main body of this document was adapted from RFC 793’s Section 3, titled “FUNCTIONAL SPECIFICATION”, with an attempt to keep formatting and layout as close as possible.
本文件的主体部分改编自 RFC 793 的第 3 节,标题为 “功能规范”,并试图使格式和布局尽可能接近。

The collection of applicable RFC errata that have been reported and either accepted or held for an update to RFC 793 were incorporated (Errata IDs: 573 [73], 574 [74], 700 [75], 701 [76], 1283 [77], 1561[78], 1562 [79], 1564 [80], 1571 [81], 1572 [82], 2297 [83], 2298 [84], 2748 [85], 2749 [86], 2934 [87], 3213 [88], 3300 [89], 3301 [90], 6222 [91]).
合并了已报告并接受或保留以更新 RFC 793 的适用 RFC 勘误表的集合(勘误表 ID:573 [73]、574 [74]、700 [75]、701 [76]、1283 [77] ], 1561 [78], 1562 [79], 1564 [80], 1571 [81], 1572 [82], 2297 [83], 2298 [84], 2748 [85], 2749 [86], 2934 [87] ], 3213 [88], 3300 [89], 3301 [90], 6222 [91])。

Some errata were not applicable due to other changes (Errata IDs: 572 [92], 575 [93], 1565 [94], 1569 [95], 2296 [96], 3305 [97], 3602 [98]).
一些勘误表由于其他变化而不适用(勘误表编号:572 [92], 575 [93], 1565 [94], 1569 [95], 2296 [96], 3305 [97], 3602 [98]).

Changes to the specification of the urgent pointer described in RFCs 1011, 1122, and 6093 were incorporated.
合并了 RFC 1011、1122 和 6093 中描述的紧急指针规范的更改。

See RFC 6093 for detailed discussion of why these changes were necessary.
有关为什么需要进行这些更改的详细讨论,请参阅 RFC 6093。

The discussion of the RTO from RFC 793 was updated to refer to RFC 6298.
参考 RFC 6298 更新了 RFC 793 中关于 RTO 的讨论。

The text on the RTO in RFC 1122 originally replaced the text in RFC 793; however, RFC 2988 should have updated RFC 1122 and has subsequently been obsoleted by RFC 6298.
RFC 1122 中关于 RTO 的内容最初替换了 RFC 793 中的内容;但是,RFC 2988 应该已经更新了 RFC 1122,并且随后被 RFC 6298 所取代。

RFC 1011 [18] contains a number of comments about RFC 793, including some needed changes to the TCP specification.
RFC 1011[18]包含了许多关于 RFC 793 的注释,包括对 TCP 规范的一些必要更改。

These are expanded in RFC 1122, which contains a collection of other changes and clarifications to RFC 793.
这些内容在 RFC 1122 中进行了扩展,其中包含了对 RFC 793 的其他修改和说明的集合。

The normative items impacting the protocol have been incorporated here, though some historically useful implementation advice and informative discussion from RFC 1122 is not included here.
影响协议的规范性条目已纳入本文档,但是没有包含 RFC 1122 中的一些历史上有用的实现建议和信息讨论。

The present document, which is now the TCP specification rather than RFC 793, updates RFC 1011, and the comments noted in RFC 1011 have been incorporated.
本文件现在是 TCP 规范,而不是 RFC 793,它更新了 RFC 1011,并且纳入了 RFC 1011 中指出的注释。

RFC 1122 contains more than just TCP requirements, so this document can’t obsolete RFC 1122 entirely.
RFC 1122 不仅仅包含 TCP 要求,因此本文档不能完全废弃 RFC 1122。

It is only marked as “updating” RFC 1122; however, it should be understood to effectively obsolete all of the material on TCP found in RFC 1122.
它仅标记为 “正在更新” RFC 1122;然而,应该理解它实际上废弃了 RFC 1122 中发现的所有关于 TCP 的材料。

The more secure initial sequence number generation algorithm from RFC 6528 was incorporated.
RFC 6528 中更安全的初始序列号生成算法被纳入其中。

See RFC 6528 for discussion of the attacks that this mitigates, as well as advice on selecting PRF algorithms and managing secret key data.
请参阅 RFC 6528 以了解关于此缓解的攻击的讨论,以及有关选择 PRF 算法和管理密钥数据的建议。

A note based on RFC 6429 was added to explicitly clarify that system resource management concerns allow connection resources to be reclaimed.
增加了一个基于 RFC 6429 的说明,以明确说明系统资源管理问题允许连接资源被回收。

RFC 6429 is obsoleted in the sense that the clarification it describes has been reflected within this base TCP specification.
RFC 6429 在某种意义上已经过时,因为它所描述的澄清已经反映在这个基本的 TCP 规范中。

The description of congestion control implementation was added based on the set of documents that are IETF BCP or Standards Track on the topic and the current state of common implementations.
根据 IETF BCP 或标准跟踪上的主题和通用实现的当前状态的文档集添加了拥塞控制实现的描述。

IANA 的注意事项 #

6.IANA Considerations

In the “Transmission Control Protocol (TCP) Header Flags” registry, IANA has made several changes as described in this section.
在 “传输控制协议(TCP)头标志” 注册表中,IANA 做出了本节所述的几项修改。

RFC 3168 originally created this registry but only populated it with the new bits defined in RFC 3168, neglecting the other bits that had previously been described in RFC 793 and other documents.
RFC 3168 最初创建了此注册表,但只使用 RFC 3168 中定义的新位填充它,而忽略了先前在 RFC 793 和其他文档中描述的其他位。

Bit 7 has since also been updated by RFC 8311 [54].
后来,第 7 位也被 RFC 8311 [54] 更新。

The “Bit” column has been renamed below as the “Bit Offset” column because it references each header flag’s offset within the 16-bit aligned view of the TCP header in Figure 1.
“Bit” 列已在下面重命名为 “Bit Offset” 列,因为它引用了图 1 中 TCP 头部的 16 位对齐视图中每个头部标志的偏移量。

The bits in offsets 0 through 3 are the TCP segment Data Offset field, and not header flags.
偏移量中的 0 到 3 位是 TCP 段数据偏移量字段,而不是头部标志。

IANA has added a column for “Assignment Notes”.
IANA 增加了一个 “分配说明” 的栏目。

IANA has assigned values as indicated below.
IANA 已经分配了如下的值。

| Bit    | Name              | Reference | Assignment Notes   |
| Offset |                   |           |                    |
| 4      | Reserved for      | RFC 9293  |                    |
|        | future use        |           |                    |
| 5      | Reserved for      | RFC 9293  |                    |
|        | future use        |           |                    |
| 6      | Reserved for      | RFC 9293  |                    |
|        | future use        |           |                    |
| 7      | Reserved for      | RFC 8311  | Previously used by |
|        | future use        |           | Historic RFC 3540  |
|        |                   |           | as NS (Nonce Sum). |
| 8      | CWR (Congestion   | RFC 3168  |                    |
|        | Window Reduced)   |           |                    |
| 9      | ECE (ECN-Echo)    | RFC 3168  |                    |
| 10     | Urgent pointer    | RFC 9293  |                    |
|        | field is          |           |                    |
|        | significant (URG) |           |                    |
| 11     | Acknowledgment    | RFC 9293  |                    |
|        | field is          |           |                    |
|        | significant (ACK) |           |                    |
| 12     | Push function     | RFC 9293  |                    |
|        | (PSH)             |           |                    |
| 13     | Reset the         | RFC 9293  |                    |
|        | connection (RST)  |           |                    |
| 14     | Synchronize       | RFC 9293  |                    |
|        | sequence numbers  |           |                    |
|        | (SYN)             |           |                    |
| 15     | No more data from | RFC 9293  |                    |
|        | sender (FIN)      |           |                    |

Table 7: TCP Header Flags

The “TCP Header Flags” registry has also been moved to a subregistry under the global “Transmission Control Protocol (TCP) Parameters” registry <https://www.iana.org/assignments/tcp-parameters/>.
“TCP 标头标志” 注册表也已移至全局 “传输控制协议 (TCP) 参数” 注册表 <https://www.iana.org/assignments/tcp-parameters/> 下的子注册表。

The registry’s Registration Procedure remains Standards Action, but the Reference has been updated to this document, and the Note has been removed.

安全和隐私注意事项 #

7.Security and Privacy Considerations

The TCP design includes only rudimentary security features that improve the robustness and reliability of connections and application data transfer, but there are no built-in cryptographic capabilities to support any form of confidentiality, authentication, or other typical security functions.
TCP 的设计只包括基本的安全功能,以提高连接和应用数据传输的稳健性和可靠性,但没有内置的加密功能来支持任何形式的保密性、认证或其他典型的安全功能。

Non-cryptographic enhancements (e.g., [9]) have been developed to improve robustness of TCP connections to particular types of attacks, but the applicability and protections of non-cryptographic enhancements are limited (e.g., see Section 1.1 of [9]).
已经开发了非加密增强(例如,[9])以提高 TCP 连接对特定类型攻击的鲁棒性,但非加密增强的适用性和保护是有限的(例如,参见 [9] 的第 1.1 节)。

Applications typically utilize lower-layer (e.g., IPsec) and upper-layer (e.g., TLS) protocols to provide security and privacy for TCP connections and application data carried in TCP.
应用程序通常利用下层(如 IPsec)和上层(如 TLS)协议,为 TCP 连接和 TCP 中携带的应用数据提供安全和隐私。

Methods based on TCP Options have been developed as well, to support some security capabilities.
还开发了基于 TCP 选项的方法,以支持某些安全功能。

In order to fully provide confidentiality, integrity protection, and authentication for TCP connections (including their control flags), IPsec is the only current effective method.
为了充分为 TCP 连接(包括它们的控制标志)提供机密性、完整性保护和认证,IPsec 是目前唯一有效的方法。

For integrity protection and authentication, the TCP Authentication Option (TCP-AO) [38] is available, with a proposed extension to also provide confidentiality for the segment payload.
对于完整性保护和认证,可以使用 TCP 认证选项(TCP-AO)[38],并建议进行扩展,以便为数据段有效载荷提供保密性。

Other methods discussed in this section may provide confidentiality or integrity protection for the payload, but for the TCP header only cover either a subset of the fields (e.g., tcpcrypt [57]) or none at all (e.g., TLS).
本节中讨论的其他方法可以为有效载荷提供保密性或完整性保护,但是对于 TCP 报头只覆盖字段的子集(例如,tcpcrypt[57])或根本不覆盖(例如,TLS)。

Other security features that have been added to TCP (e.g., ISN generation, sequence number checks, and others) are only capable of partially hindering attacks.
已添加到 TCP 的其他安全功能(例如,ISN 生成、序列号检查等)只能部分阻止攻击。

Applications using long-lived TCP flows have been vulnerable to attacks that exploit the processing of control flags described in earlier TCP specifications [33].
使用长生命周期的 TCP 流的应用程序容易受到攻击,这些攻击利用了早期的 TCP 规范[33]中描述的控制标志的处理。

TCP-MD5 was a commonly implemented TCP Option to support authentication for some of these connections, but had flaws and is now deprecated.
TCP-MD5 是一种普遍实现的 TCP 选项,用于支持其中一些连接的身份验证,但存在缺陷,现已弃用。

TCP-AO provides a capability to protect long-lived TCP connections from attacks and has superior properties to TCP-MD5.
TCP-AO 提供保护长生命周期 TCP 连接免受攻击的能力,并且具有优于 TCP-MD5 的特性。

It does not provide any privacy for application data or for the TCP headers.
它不为应用程序数据或 TCP 头提供任何隐私。

The “tcpcrypt” [57] experimental extension to TCP provides the ability to cryptographically protect connection data.
TCP 的实验性扩展 “tcpcrypt” [57]提供了对连接数据进行加密保护的能力。

Metadata aspects of the TCP flow are still visible, but the application stream is well protected.
TCP 流的元数据方面仍然可见,但应用流得到了很好的保护。

Within the TCP header, only the urgent pointer and FIN flag are protected through tcpcrypt.
在 TCP 头中,只有紧急指针和 FIN 标志是通过 tcpcrypt 保护的。

The TCP Roadmap [49] includes notes about several RFCs related to TCP security.
TCP 路线图[49]包括关于几个与 TCP 安全有关的 RFC 的说明。

Many of the enhancements provided by these RFCs have been integrated into the present document, including ISN generation, mitigating blind in-window attacks, and improving handling of soft errors and ICMP packets.
这些 RFC 提供的许多增强功能已集成到本文档中,包括 ISN 生成、减轻 blind in-window 攻击以及改进对软错误和 ICMP 数据包的处理。

These are all discussed in greater detail in the referenced RFCs that originally described the changes needed to earlier TCP specifications.
这些都在参考的 RFC 中进行了更详细的讨论,这些 RFC 最初描述了对早期 TCP 规范所需的修改。

Additionally, see RFC 6093 [39] for discussion of security considerations related to the urgent pointer field, which also discourages new applications from using the urgent pointer.
此外,请参阅 RFC 6093 [39]关于与紧急指针字段有关的安全考虑的讨论,它也不鼓励新的应用程序使用紧急指针。

Since TCP is often used for bulk transfer flows, some attacks are possible that abuse the TCP congestion control logic.
由于 TCP 经常用于大容量传输流,因此可能会发生一些滥用 TCP 拥塞控制逻辑的攻击。

An example is “ACK-division” attacks.
“ACK-division” 攻击就是一个例子。

Updates that have been made to the TCP congestion control specifications include mechanisms like Appropriate Byte Counting (ABC) [29] that act as mitigations to these attacks.
对 TCP 拥塞控制规范所做的更新包括适当字节计数 (ABC) [29] 等机制,这些机制可以缓解这些攻击。

Other attacks are focused on exhausting the resources of a TCP server.
其他攻击的重点是耗尽 TCP 服务器的资源。

Examples include SYN flooding [32] or wasting resources on non-progressing connections [41].
这方面的例子包括 SYN flooding[32]或在非进行的连接上浪费资源[41]。

Operating systems commonly implement mitigations for these attacks.

Some common defenses also utilize proxies, stateful firewalls, and other technologies outside the end-host TCP implementation.
一些常见的防御还利用代理、状态防火墙和终端主机 TCP 实现之外的其他技术。

The concept of a protocol’s “wire image” is described in RFC 8546 [56], which describes how TCP’s cleartext headers expose more metadata to nodes on the path than is strictly required to route the packets to their destination.
RFC 8546 [56] 中描述了协议 “wire image” 的概念,它描述了 TCP 的明文标头如何向路径上的节点公开比将数据包路由到目的地所严格要求的更多的元数据。

On-path adversaries may be able to leverage this metadata. Lessons learned in this respect from TCP have been applied in the design of newer transports like QUIC [60].
路径上的对手可能能够利用这种元数据。在这方面从 TCP 学到的经验已经被应用于像 QUIC 这样的新的传输方式的设计中[60]。

Additionally, based partly on experiences with TCP and its extensions, there are considerations that might be applicable for future TCP extensions and other transports that the IETF has documented in RFC 9065 [61], along with IAB recommendations in RFC 8558 [58] and [67].
此外,部分基于 TCP 及其扩展的经验,有一些考虑可能适用于未来的 TCP 扩展和其他传输,IETF 在 RFC 9065 [61]中记录了这些考虑,以及 IAB 在 RFC 8558 [58]和[67]中的建议。

There are also methods of “fingerprinting” that can be used to infer the host TCP implementation (operating system) version or platform information.
还存在可用于推断主机 TCP 实现(操作系统)版本或平台信息的“指纹识别”方法。

These collect observations of several aspects, such as the options present in segments, the ordering of options, the specific behaviors in the case of various conditions, packet timing, packet sizing, and other aspects of the protocol that are left to be determined by an implementer, and can use those observations to identify information about the host and implementation.

Since ICMP message processing also can interact with TCP connections, there is potential for ICMP-based attacks against TCP connections.
由于 ICMP 消息处理也可以与 TCP 连接交互,因此存在基于 ICMP 针对 TCP 连接的攻击的可能性。

These are discussed in RFC 5927 [100], along with mitigations that have been implemented.
这些在 RFC 5927 [100] 中进行了讨论,以及已实现的缓解措施。

参考文献 #


规范性参考文献 #

8.1. Normative References

[1] Postel, J., “Internet Protocol”, STD 5, RFC 791, DOI 10.17487/RFC0791, September 1981, <https://www.rfc-editor.org/info/rfc791>.

[2] Mogul, J. and S. Deering, “Path MTU discovery”, RFC 1191, DOI 10.17487/RFC1191, November 1990, <https://www.rfc-editor.org/info/rfc1191>.

[3] Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels”, BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <https://www.rfc-editor.org/info/rfc2119>.

[4] Nichols, K., Blake, S., Baker, F., and D. Black, “Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers”, RFC 2474, DOI 10.17487/RFC2474, December 1998, <https://www.rfc-editor.org/info/rfc2474>.

[5] Floyd, S., “Congestion Control Principles”, BCP 41, RFC 2914, DOI 10.17487/RFC2914, September 2000, <https://www.rfc-editor.org/info/rfc2914>.

[6] Ramakrishnan, K., Floyd, S., and D. Black, “The Addition of Explicit Congestion Notification (ECN) to IP”, RFC 3168, DOI 10.17487/RFC3168, September 2001, <https://www.rfc-editor.org/info/rfc3168>.

[7] Floyd, S. and M. Allman, “Specifying New Congestion Control Algorithms”, BCP 133, RFC 5033, DOI 10.17487/RFC5033, August 2007, <https://www.rfc-editor.org/info/rfc5033>.

[8] Allman, M., Paxson, V., and E. Blanton, “TCP Congestion Control”, RFC 5681, DOI 10.17487/RFC5681, September 2009, <https://www.rfc-editor.org/info/rfc5681>.

[9] Ramaiah, A., Stewart, R., and M. Dalal, “Improving TCP’s Robustness to Blind In-Window Attacks”, RFC 5961, DOI 10.17487/RFC5961, August 2010, <https://www.rfc-editor.org/info/rfc5961>.

[10] Paxson, V., Allman, M., Chu, J., and M. Sargent, “Computing TCP’s Retransmission Timer”, RFC 6298, DOI 10.17487/RFC6298, June 2011, <https://www.rfc-editor.org/info/rfc6298>.

[11] Gont, F., “Deprecation of ICMP Source Quench Messages”, RFC 6633, DOI 10.17487/RFC6633, May 2012, <https://www.rfc-editor.org/info/rfc6633>.

[12] Leiba, B., “Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words”, BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, https://www.rfc-editor.org/info/rfc8174\.

[13] Deering, S. and R. Hinden, “Internet Protocol, Version 6 (IPv6) Specification”, STD 86, RFC 8200, DOI 10.17487/RFC8200, July 2017, <https://www.rfc-editor.org/info/rfc8200>.

[14] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., “Path MTU Discovery for IP version 6”, STD 87, RFC 8201, DOI 10.17487/RFC8201, July 2017, <https://www.rfc-editor.org/info/rfc8201>.

[15] Allman, M., “Requirements for Time-Based Loss Detection”, BCP 233, RFC 8961, DOI 10.17487/RFC8961, November 2020, <https://www.rfc-editor.org/info/rfc8961>.

非规范性参考文献 #

8.2. Informative References

[16] Postel, J., “Transmission Control Protocol”, STD 7, RFC 793, DOI 10.17487/RFC0793, September 1981, <https://www.rfc-editor.org/info/rfc793>.

[17] Nagle, J., “Congestion Control in IP/TCP Internetworks”, RFC 896, DOI 10.17487/RFC0896, January 1984, <https://www.rfc-editor.org/info/rfc896>.

[18] Reynolds, J. and J. Postel, “Official Internet protocols”, RFC 1011, DOI 10.17487/RFC1011, May 1987, <https://www.rfc-editor.org/info/rfc1011>.

[19] Braden, R., Ed., “Requirements for Internet Hosts - Communication Layers”, STD 3, RFC 1122, DOI 10.17487/RFC1122, October 1989, <https://www.rfc-editor.org/info/rfc1122>.

[20] Almquist, P., “Type of Service in the Internet Protocol Suite”, RFC 1349, DOI 10.17487/RFC1349, July 1992, <https://www.rfc-editor.org/info/rfc1349>.

[21] Braden, R., “T/TCP – TCP Extensions for Transactions Functional Specification”, RFC 1644, DOI 10.17487/RFC1644, July 1994, https://www.rfc-editor.org/info/rfc1644\.

[22] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, “TCP Selective Acknowledgment Options”, RFC 2018, DOI 10.17487/RFC2018, October 1996, <https://www.rfc-editor.org/info/rfc2018>.

[23] Paxson, V., Allman, M., Dawson, S., Fenner, W., Griner, J., Heavens, I., Lahey, K., Semke, J., and B. Volz, “Known TCP Implementation Problems”, RFC 2525, DOI 10.17487/RFC2525, March 1999, <https://www.rfc-editor.org/info/rfc2525>.

[24] Borman, D., Deering, S., and R. Hinden, “IPv6 Jumbograms”, RFC 2675, DOI 10.17487/RFC2675, August 1999, <https://www.rfc-editor.org/info/rfc2675>.

[25] Xiao, X., Hannan, A., Paxson, V., and E. Crabbe, “TCP Processing of the IPv4 Precedence Field”, RFC 2873, DOI 10.17487/RFC2873, June 2000, <https://www.rfc-editor.org/info/rfc2873>.

[26] Floyd, S., Mahdavi, J., Mathis, M., and M. Podolsky, “An Extension to the Selective Acknowledgement (SACK) Option for TCP”, RFC 2883, DOI 10.17487/RFC2883, July 2000, <https://www.rfc-editor.org/info/rfc2883>.

[27] Lahey, K., “TCP Problems with Path MTU Discovery”, RFC 2923, DOI 10.17487/RFC2923, September 2000, <https://www.rfc-editor.org/info/rfc2923>.

[28] Balakrishnan, H., Padmanabhan, V., Fairhurst, G., and M.Sooriyabandara, “TCP Performance Implications of Network Path Asymmetry”, BCP 69, RFC 3449, DOI 10.17487/RFC3449, December 2002, https://www.rfc-editor.org/info/rfc3449\.

[29] Allman, M., “TCP Congestion Control with Appropriate Byte Counting (ABC)”, RFC 3465, DOI 10.17487/RFC3465, February 2003, https://www.rfc-editor.org/info/rfc3465\.

[30] Fenner, B., “Experimental Values In IPv4, IPv6, ICMPv4, ICMPv6, UDP, and TCP Headers”, RFC 4727, DOI 10.17487/RFC4727, November 2006, <https://www.rfc-editor.org/info/rfc4727>.

[31] Mathis, M. and J. Heffner, “Packetization Layer Path MTU Discovery”, RFC 4821, DOI 10.17487/RFC4821, March 2007, <https://www.rfc-editor.org/info/rfc4821>.

[32] Eddy, W., “TCP SYN Flooding Attacks and Common Mitigations”, RFC 4987, DOI 10.17487/RFC4987, August 2007, <https://www.rfc-editor.org/info/rfc4987>.

[33] Touch, J., “Defending TCP Against Spoofing Attacks”, RFC 4953, DOI 10.17487/RFC4953, July 2007, <https://www.rfc-editor.org/info/rfc4953>.

[34] Culley, P., Elzur, U., Recio, R., Bailey, S., and J.Carrier, “Marker PDU Aligned Framing for TCP Specification”, RFC 5044, DOI 10.17487/RFC5044, October 2007, https://www.rfc-editor.org/info/rfc5044\.

[35] Gont, F., “TCP’s Reaction to Soft Errors”, RFC 5461, DOI 10.17487/RFC5461, February 2009, <https://www.rfc-editor.org/info/rfc5461>.

[36] StJohns, M., Atkinson, R., and G. Thomas, “Common Architecture Label IPv6 Security Option (CALIPSO)”, RFC 5570, DOI 10.17487/RFC5570, July 2009, <https://www.rfc-editor.org/info/rfc5570>.

[37] Sandlund, K., Pelletier, G., and L-E. Jonsson, “The RObust Header Compression (ROHC) Framework”, RFC 5795, DOI 10.17487/RFC5795, March 2010, <https://www.rfc-editor.org/info/rfc5795>.

[38] Touch, J., Mankin, A., and R. Bonica, “The TCP Authentication Option”, RFC 5925, DOI 10.17487/RFC5925, June 2010, https://www.rfc-editor.org/info/rfc5925\.

[39] Gont, F. and A. Yourtchenko, “On the Implementation of the TCP Urgent Mechanism”, RFC 6093, DOI 10.17487/RFC6093, January 2011, https://www.rfc-editor.org/info/rfc6093\.

[40] Gont, F., “Reducing the TIME-WAIT State Using TCP Timestamps”, BCP 159, RFC 6191, DOI 10.17487/RFC6191, April 2011, https://www.rfc-editor.org/info/rfc6191\.

[41] Bashyam, M., Jethanandani, M., and A. Ramaiah, “TCP Sender Clarification for Persist Condition”, RFC 6429, DOI 10.17487/RFC6429, December 2011, <https://www.rfc-editor.org/info/rfc6429>.

[42] Gont, F. and S. Bellovin, “Defending against Sequence Number Attacks”, RFC 6528, DOI 10.17487/RFC6528, February 2012, https://www.rfc-editor.org/info/rfc6528\.

[43] Borman, D., “TCP Options and Maximum Segment Size (MSS)”, RFC 6691, DOI 10.17487/RFC6691, July 2012, <https://www.rfc-editor.org/info/rfc6691>.

[44] Touch, J., “Updated Specification of the IPv4 ID Field”, RFC 6864, DOI 10.17487/RFC6864, February 2013, <https://www.rfc-editor.org/info/rfc6864>.

[45] Touch, J., “Shared Use of Experimental TCP Options”, RFC 6994, DOI 10.17487/RFC6994, August 2013, <https://www.rfc-editor.org/info/rfc6994>.

[46] McPherson, D., Oran, D., Thaler, D., and E. Osterweil, “Architectural Considerations of IP Anycast”, RFC 7094, DOI 10.17487/RFC7094, January 2014, <https://www.rfc-editor.org/info/rfc7094>.

[47] Borman, D., Braden, B., Jacobson, V., and R.Scheffenegger, Ed., “TCP Extensions for High Performance”, RFC 7323, DOI 10.17487/RFC7323, September 2014, <https://www.rfc-editor.org/info/rfc7323>.

[48] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, “TCP Fast Open”, RFC 7413, DOI 10.17487/RFC7413, December 2014, <https://www.rfc-editor.org/info/rfc7413>.

[49] Duke, M., Braden, R., Eddy, W., Blanton, E., and A. Zimmermann, “A Roadmap for Transmission Control Protocol (TCP) Specification Documents”, RFC 7414, DOI 10.17487/RFC7414, February 2015, <https://www.rfc-editor.org/info/rfc7414>.

[50] Black, D., Ed. and P. Jones, “Differentiated Services (Diffserv) and Real-Time Communication”, RFC 7657, DOI 10.17487/RFC7657, November 2015, <https://www.rfc-editor.org/info/rfc7657>.

[51] Fairhurst, G. and M. Welzl, “The Benefits of Using Explicit Congestion Notification (ECN)”, RFC 8087, DOI 10.17487/RFC8087, March 2017, <https://www.rfc-editor.org/info/rfc8087>.

[52] Fairhurst, G., Ed., Trammell, B., Ed., and M. Kuehlewind, Ed., “Services Provided by IETF Transport Protocols and Congestion Control Mechanisms”, RFC 8095, DOI 10.17487/RFC8095, March 2017, <https://www.rfc-editor.org/info/rfc8095>.

[53] Welzl, M., Tuexen, M., and N. Khademi, “On the Usage of Transport Features Provided by IETF Transport Protocols”, RFC 8303, DOI 10.17487/RFC8303, February 2018, <https://www.rfc-editor.org/info/rfc8303>.

[54] Black, D., “Relaxing Restrictions on Explicit Congestion Notification (ECN) Experimentation”, RFC 8311, DOI 10.17487/RFC8311, January 2018, <https://www.rfc-editor.org/info/rfc8311>.

[55] Chown, T., Loughney, J., and T. Winters, “IPv6 Node Requirements”, BCP 220, RFC 8504, DOI 10.17487/RFC8504, January 2019, https://www.rfc-editor.org/info/rfc8504\.

[56] Trammell, B. and M. Kuehlewind, “The Wire Image of a Network Protocol”, RFC 8546, DOI 10.17487/RFC8546, April 2019, https://www.rfc-editor.org/info/rfc8546\.

[57] Bittau, A., Giffin, D., Handley, M., Mazieres, D., Slack, Q., and E. Smith, “Cryptographic Protection of TCP Streams (tcpcrypt)”, RFC 8548, DOI 10.17487/RFC8548, May 2019, <https://www.rfc-editor.org/info/rfc8548>.

[58] Hardie, T., Ed., “Transport Protocol Path Signals”, RFC 8558, DOI 10.17487/RFC8558, April 2019, <https://www.rfc-editor.org/info/rfc8558>.

[59] Ford, A., Raiciu, C., Handley, M., Bonaventure, O., and C.Paasch, “TCP Extensions for Multipath Operation with Multiple Addresses”, RFC 8684, DOI 10.17487/RFC8684, March 2020, https://www.rfc-editor.org/info/rfc8684\.

[60] Iyengar, J., Ed. and M. Thomson, Ed., “QUIC: A UDP-Based Multiplexed and Secure Transport”, RFC 9000, DOI 10.17487/RFC9000, May 2021, <https://www.rfc-editor.org/info/rfc9000>.

[61] Fairhurst, G. and C. Perkins, “Considerations around Transport Header Confidentiality, Network Operations, and the Evolution of Internet Transport Protocols”, RFC 9065, DOI 10.17487/RFC9065, July 2021, <https://www.rfc-editor.org/info/rfc9065>.

[62] IANA, “Transmission Control Protocol (TCP) Parameters”, <https://www.iana.org/assignments/tcp-parameters/>.

[63] Gont, F., “Processing of IP Security/Compartment and Precedence Information by TCP”, Work in Progress, Internet-Draft, draft-gont-tcpm-tcp-seccomp-prec-00, 29 March 2012, https://datatracker.ietf.org/doc/html/draft-gont-tcpm-tcp-seccomp-prec-00\.

[64] Gont, F. and D. Borman, “On the Validation of TCP Sequence Numbers”, Work in Progress, Internet-Draft, draft-gont-tcpm-tcp-seq-validation-04, 11 March 2019 <https://datatracker.ietf.org/doc/html/draft-gont-tcpm-tcp-seq-validation-04>.

[65] Touch, J. and W. M. Eddy, “TCP Extended Data Offset Option”, Work in Progress, Internet-Draft, draft-ietf-tcpm-tcp-edo-12, 15 April 2022, <https://datatracker.ietf.org/doc/html/draft-ietf-tcpm-tcp-edo-12>.

[66] McQuistin, S., Band, V., Jacob, D., and C. Perkins, “Describing Protocol Data Units with Augmented Packet Header Diagrams”, Work in Progress, Internet-Draft, draft- mcquistin-augmented-ascii-diagrams-10, 7 March 2022, <https://datatracker.ietf.org/doc/html/draft-mcquistin-augmented-ascii-diagrams-10>.

[67] Thomson, M. and T. Pauly, “Long-Term Viability of Protocol Extension Mechanisms”, RFC 9170, DOI 10.17487/RFC9170, December 2021, https://www.rfc-editor.org/info/rfc9170\.

[68] Minshall, G., “A Suggested Modification to Nagle’s Algorithm”, Work in Progress, Internet-Draft, draft- minshall-nagle-01, 18 June 1999, <https://datatracker.ietf.org/doc/html/draft-minshall-nagle-01>.

[69] Dalal, Y. and C. Sunshine, “Connection Management in Transport Protocols”, Computer Networks, Vol. 2, No. 6, pp. 454-473, DOI 10.1016/0376-5075(78)90053-3, December 1978, https://doi.org/10.1016/0376-5075(78)90053-3\.

[70] Faber, T., Touch, J., and W. Yui, “The TIME-WAIT state in TCP and Its Effect on Busy Servers”, Proceedings of IEEE INFOCOM, pp. 1573-1583, DOI 10.1109/INFCOM.1999.752180, March 1999, https://doi.org/10.1109/INFCOM.1999.752180\.

[71] Postel, J., “Comments on Action Items from the January Meeting”, IEN 177, March 1981, <https://www.rfc-editor.org/ien/ien177.txt>.

[72] “Segmentation Offloads”, The Linux Kernel Documentation, <https://www.kernel.org/doc/html/latest/networking/segmentation-offloads.html>.

[73] RFC Errata, Erratum ID 573, RFC 793, <https://www.rfc-editor.org/errata/eid573>.

[74] RFC Errata, Erratum ID 574, RFC 793, <https://www.rfc-editor.org/errata/eid574>.

[75] RFC Errata, Erratum ID 700, RFC 793, <https://www.rfc-editor.org/errata/eid700>.

[76] RFC Errata, Erratum ID 701, RFC 793, <https://www.rfc-editor.org/errata/eid701>.

[77] RFC Errata, Erratum ID 1283, RFC 793, <https://www.rfc-editor.org/errata/eid1283>.

[78] RFC Errata, Erratum ID 1561, RFC 793, <https://www.rfc-editor.org/errata/eid1561>.

[79] RFC Errata, Erratum ID 1562, RFC 793, <https://www.rfc-editor.org/errata/eid1562>.

[80] RFC Errata, Erratum ID 1564, RFC 793, <https://www.rfc-editor.org/errata/eid1564>.

[81] RFC Errata, Erratum ID 1571, RFC 793, <https://www.rfc-editor.org/errata/eid1571>.

[82] RFC Errata, Erratum ID 1572, RFC 793, <https://www.rfc-editor.org/errata/eid1572>.

[83] RFC Errata, Erratum ID 2297, RFC 793, <https://www.rfc-editor.org/errata/eid2297>.

[84] RFC Errata, Erratum ID 2298, RFC 793, <https://www.rfc-editor.org/errata/eid2298>.

[85] RFC Errata, Erratum ID 2748, RFC 793, <https://www.rfc-editor.org/errata/eid2748>.

[86] RFC Errata, Erratum ID 2749, RFC 793, <https://www.rfc-editor.org/errata/eid2749>.

[87] RFC Errata, Erratum ID 2934, RFC 793, <https://www.rfc-editor.org/errata/eid2934>.

[88] RFC Errata, Erratum ID 3213, RFC 793, <https://www.rfc-editor.org/errata/eid3213>.

[89] RFC Errata, Erratum ID 3300, RFC 793, <https://www.rfc-editor.org/errata/eid3300>.

[90] RFC Errata, Erratum ID 3301, RFC 793, <https://www.rfc-editor.org/errata/eid3301>.

[91] RFC Errata, Erratum ID 6222, RFC 793, <https://www.rfc-editor.org/errata/eid6222>.

[92] RFC Errata, Erratum ID 572, RFC 793, <https://www.rfc-editor.org/errata/eid572>.

[93] RFC Errata, Erratum ID 575, RFC 793, <https://www.rfc-editor.org/errata/eid575>.

[94] RFC Errata, Erratum ID 1565, RFC 793, <https://www.rfc-editor.org/errata/eid1565>.

[95] RFC Errata, Erratum ID 1569, RFC 793, <https://www.rfc-editor.org/errata/eid1569>.

[96] RFC Errata, Erratum ID 2296, RFC 793, <https://www.rfc-editor.org/errata/eid2296>.

[97] RFC Errata, Erratum ID 3305, RFC 793, <https://www.rfc-editor.org/errata/eid3305>.

[98] RFC Errata, Erratum ID 3602, RFC 793, <https://www.rfc-editor.org/errata/eid3602>.

[99] RFC Errata, Erratum ID 4772, RFC 5961, <https://www.rfc-editor.org/errata/eid4772>.

[100] Gont, F., “ICMP Attacks against TCP”, RFC 5927, DOI 10.17487/RFC5927, July 2010, <https://www.rfc-editor.org/info/rfc5927>.

附录 A. 其他实现说明 #

Appendix A. Other Implementation Notes

This section includes additional notes and references on TCP implementation decisions that are currently not a part of the RFC series or included within the TCP standard.
本节包括关于 TCP 实现决定的额外说明和参考,这些决定目前不是 RFC 系列的一部分,也没有包含在 TCP 标准中。

These items can be considered by implementers, but there was not yet a consensus to include them in the standard.

IP 安全部分和优先级 #

A.1. IP Security Compartment and Precedence

The IPv4 specification [1] includes a precedence value in the (now obsoleted) Type of Service (TOS) field.
IPv4 规范 [1] 在(现已废弃的)服务类型 (TOS) 字段中包含一个优先级值。

It was modified in [20] and then obsoleted by the definition of Differentiated Services (Diffserv) [4].

Setting and conveying TOS between the network layer, TCP implementation, and applications is obsolete and is replaced by Diffserv in the current TCP specification.
在网络层、TCP 实现和应用之间设置和传递 TOS 已经过时,在当前的 TCP 规范中被 Diffserv 所取代。

RFC 793 required checking the IP security compartment and precedence on incoming TCP segments for consistency within a connection and with application requests.
RFC 793 要求检查传入 TCP 段上 IP 安全分区和优先级,以保证连接内和应用请求的一致性。

Each of these aspects of IP have become outdated, without specific updates to RFC 793.
IP 协议的这几个方面都已过时,没有对 RFC 793 进行特定更新。

The issues with precedence were fixed by [25], which is Standards Track, and so this present TCP specification includes those changes.
优先级问题由 [25] 修复,这是标准跟踪,因此当前的 TCP 规范包括这些更改。

However, the state of IP security options that may be used by Multi-Level Secure (MLS) systems is not as apparent in the IETF currently.
但是,多级安全(MLS)系统可能使用的 IP 安全选项的状况,目前在 IETF 中并不明显。

Resetting connections when incoming packets do not meet expected security compartment or precedence expectations has been recognized as a possible attack vector [63], and there has been discussion about amending the TCP specification to prevent connections from being aborted due to nonmatching IP security compartment and Diffserv codepoint values.
当传入的数据包不满足预期的安全区段或优先级时重置连接会被认为可能是攻击向量[63],并且已经讨论过修改 TCP 规范以防止由于不匹配的 IP 安全区段和 Diffserv 代码值而中止连接。

优先级 #

A.1.1. Precedence

In Diffserv, the former precedence values are treated as Class Selector codepoints, and methods for compatible treatment are described in the Diffserv architecture.
在 Diffserv 中,以前的优先级值被视为类选择器代码点,并且在 Diffserv 体系结构中描述了兼容处理的方法。

The RFC TCP specification defined by RFCs 793 and 1122 included logic intending to have connections use the highest precedence requested by either endpoint application, and to keep the precedence consistent throughout a connection.
RFC 793 和 1122 定义的 RFC TCP 规范包括这样的逻辑:让连接使用任一端应用程序所请求的最高优先级,并使优先级在整个连接中保持一致。

This logic from the obsolete TOS is not applicable to Diffserv and should not be included in TCP implementations, though changes to Diffserv values within a connection are discouraged.
这种来自过时的 TOS 的逻辑不适用于 Diffserv,不应包括在 TCP 实现中,尽管不鼓励在一个连接中改变 Diffserv 值。

For discussion of this, see RFC 7657 (Sections 5.1, 5.3, and 6) [50].
有关这方面的讨论,请参阅 RFC 7657(第 5.1、5.3 和 6 节)[50]。

The obsoleted TOS processing rules in TCP assumed bidirectional (or symmetric) precedence values used on a connection, but the Diffserv architecture is asymmetric.
TCP 中已过时的 TOS 处理规则假定在连接上使用双向(或对称)优先级值,但 Diffserv 体系结构是不对称的。

Problems with the old TCP logic in this regard were described in [25], and the solution described is to ignore IP precedence in TCP.
[25]中描述了旧的 TCP 逻辑在这方面的问题,描述的解决方案是在 TCP 中忽略 IP 优先权。

Since RFC 2873 is a Standards Track document (although not marked as updating RFC 793), current implementations are expected to be robust in these conditions.
由于 RFC 2873 是一个标准跟踪文档(尽管没有标记为更新 RFC 793),因此当前的实现预计在这些条件下是稳健的。

Note that the Diffserv field value used in each direction is a part of the interface between TCP and the network layer, and values in use can be indicated both ways between TCP and the application.
注意,在每个方向上使用的 Diffserv 字段值是 TCP 和网络层之间接口的一部分,使用中的值可以在 TCP 和应用程序之间双向指示。

MLS 系统 #

A.1.2. MLS Systems

The IP Security Option (IPSO) and compartment defined in [1] was refined in RFC 1038, which was later obsoleted by RFC 1108.
在[1]中定义的 IP 安全选项(IPSO)和分区在 RFC 1038 中进行了改进,后来被 RFC 1108 所取代。

The Commercial IP Security Option (CIPSO) is defined in FIPS-188 (withdrawn by NIST in 2015) and is supported by some vendors and operating systems.
商业 IP 安全选项 (CIPSO) 在 FIPS-188 中定义(2015 年被 NIST 撤销),并得到一些供应商和操作系统的支持。

RFC 1108 is now Historic, though RFC 791 itself has not been updated to remove the IP Security Option.
RFC 1108 现在是历史性的,尽管 RFC 791 本身并没有被更新以移除 IP 安全选项。

For IPv6, a similar option (Common Architecture Label IPv6 Security Option (CALIPSO)) has been defined [36].
对于 IPv6,已经定义了一个类似的选项(通用架构标签 IPv6 安全选项 (CALIPSO))[36]。

RFC 793 includes logic that includes the IP security/compartment information in treatment of TCP segments.
RFC 793 包括在处理 TCP 段时包括 IP 安全/区段信息的逻辑。

References to the IP “security/compartment” in this document may be relevant for Multi-Level Secure (MLS) system implementers but can be ignored for non-MLS implementations, consistent with running code on the Internet.
本文件中提到的 IP “安全/分区” 可能与多级安全(MLS)系统实现者有关,但对于非 MLS 实现者可以忽略,这与在互联网上的运行代码是一致的。

See Appendix A.1 for further discussion.
进一步讨论见附录 A.1。

Note that RFC 5570 describes some MLS networking scenarios where IPSO, CIPSO, or CALIPSO may be used.
注意,RFC 5570 描述了一些 MLS 网络情况,其中可以使用 IPSO、CIPSO 或 CALIPSO。

In these special cases, TCP implementers should see Section 7.3.1 of RFC 5570 and follow the guidance in that document.
在这些特殊情况下,TCP 实现者应参阅 RFC 5570 的第 7.3.1 节并遵循该文档中的指导。

序列号验证 #

A.2. Sequence Number Validation

There are cases where the TCP sequence number validation rules can prevent ACK fields from being processed.
在某些情况下,TCP 序列号验证规则可能会阻止处理 ACK 字段。

This can result in connection issues, as described in [64], which includes descriptions of potential problems in conditions of simultaneous open, self-connects, simultaneous close, and simultaneous window probes.
这可能会导致连接问题,如 [64] 中所述,其中包括对同时打开、自连接、同时关闭和同时窗口探测条件下的潜在问题的描述。

The document also describes potential changes to the TCP specification to mitigate the issue by expanding the acceptable sequence numbers.
该文件还描述了对 TCP 规范的潜在修改,以通过扩大可接受的序列号来缓解这一问题。

In Internet usage of TCP, these conditions rarely occur.
在互联网上使用 TCP 时,这些情况很少发生。

Common operating systems include different alternative mitigations, and the standard has not been updated yet to codify one of them, but implementers should consider the problems described in [64].
常见的操作系统包括不同的替代缓解措施,并且标准尚未更新以编纂其中之一,但实现者应该考虑 [64] 中描述的问题。

Nagle 修改 #

A.3. Nagle Modification

In common operating systems, both the Nagle algorithm and delayed acknowledgments are implemented and enabled by default.
在常见的操作系统中,Nagle 算法和延迟确认都已实现,并默认启用。

TCP is used by many applications that have a request-response style of communication, where the combination of the Nagle algorithm and delayed acknowledgments can result in poor application performance.
许多具有请求-响应通信方式的应用程序都使用 TCP,其中 Nagle 算法和延迟确认的组合会导致应用程序性能不佳。

A modification to the Nagle algorithm is described in [68] that improves the situation for these applications.
[68] 中描述了对 Nagle 算法的修改,它改善了这些应用程序的情况。

This modification is implemented in some common operating systems and does not impact TCP interoperability.
此修改在一些常见的操作系统中实现,不会影响 TCP 互操作性。

Additionally, many applications simply disable Nagle since this is generally supported by a socket option.
此外,许多应用程序只是简单地禁用 Nagle,因为这通常由套接字选项支持。

The TCP standard has not been updated to include this Nagle modification, but implementers may find it beneficial to consider.
TCP 标准尚未更新以包括此 Nagle 修改,但实现者可能会发现考虑它是有益的。

低水印设置 #

A.4. Low Watermark Settings

Some operating system kernel TCP implementations include socket options that allow specifying the number of bytes in the buffer until the socket layer will pass sent data to TCP (SO_SNDLOWAT) or to the application on receiving (SO_RCVLOWAT).
某些操作系统内核的 TCP 实现包括套接字选项,允许指定在套接字层将发送的数据传递给 TCP(SO_SNDLOWAT)或接收时传递给应用程序(SO_RCVLOWAT)之前缓冲区中的字节数。

In addition, another socket option (TCP_NOTSENT_LOWAT) can be used to control the amount of unsent bytes in the write queue.

This can help a sending TCP application to avoid creating large amounts of buffered data (and corresponding latency).
这可以帮助发送 TCP 应用程序避免产生大量的缓冲数据(和相应的延迟)。

As an example, this may be useful for applications that are multiplexing data from multiple upper-level streams onto a connection, especially when streams may be a mix of interactive/real-time and bulk data transfer.

附录 B. TCP 要求概述 #

Appendix B. TCP Requirement Summary

This section is adapted from RFC 1122.
本节改编自 RFC 1122。

Note that there is no requirement related to PLPMTUD in this list, but that PLPMTUD is recommended.
请注意,此列表中没有与 PLPMTUD 相关的要求,但建议使用 PLPMTUD。

|     Feature     |  ReqID  | MUST | SHOULD | MAY | SHOULD | MUST |
|                 |         |      |        |     |  NOT   | NOT  |
| PUSH flag                                                       |
| Aggregate or    | MAY-16  |      |        |  X  |        |      |
| queue un-pushed |         |      |        |     |        |      |
| data            |         |      |        |     |        |      |
| Sender collapse | SHLD-27 |      |   X    |     |        |      |
| successive PSH  |         |      |        |     |        |      |
| bits            |         |      |        |     |        |      |
| SEND call can   | MAY-15  |      |        |  X  |        |      |
| specify PUSH    |         |      |        |     |        |      |
| *  If cannot:   | MUST-60 |      |        |     |        |  X   |
|    sender       |         |      |        |     |        |      |
|    buffer       |         |      |        |     |        |      |
|    indefinitely |         |      |        |     |        |      |
| *  If cannot:   | MUST-61 |  X   |        |     |        |      |
|    PSH last     |         |      |        |     |        |      |
|    segment      |         |      |        |     |        |      |
| Notify          | MAY-17  |      |        |  X  |        |      |
| receiving ALP^1 |         |      |        |     |        |      |
| of PSH          |         |      |        |     |        |      |
| Send max size   | SHLD-28 |      |   X    |     |        |      |
| segment when    |         |      |        |     |        |      |
| possible        |         |      |        |     |        |      |
| Window                                                          |
| Treat as        | MUST-1  |  X   |        |     |        |      |
| unsigned number |         |      |        |     |        |      |
| Handle as       | REC-1   |      |   X    |     |        |      |
| 32-bit number   |         |      |        |     |        |      |
| Shrink window   | SHLD-14 |      |        |     |   X    |      |
| from right      |         |      |        |     |        |      |
| *  Send new     | SHLD-15 |      |        |     |   X    |      |
|    data when    |         |      |        |     |        |      |
|    window       |         |      |        |     |        |      |
|    shrinks      |         |      |        |     |        |      |
| *  Retransmit   | SHLD-16 |      |   X    |     |        |      |
|    old unacked  |         |      |        |     |        |      |
|    data within  |         |      |        |     |        |      |
|    window       |         |      |        |     |        |      |
| *  Time out     | SHLD-17 |      |        |     |   X    |      |
|    conn for     |         |      |        |     |        |      |
|    data past    |         |      |        |     |        |      |
|    right edge   |         |      |        |     |        |      |
| Robust against  | MUST-34 |  X   |        |     |        |      |
| shrinking       |         |      |        |     |        |      |
| window          |         |      |        |     |        |      |
| Receiver's      | MAY-8   |      |        |  X  |        |      |
| window closed   |         |      |        |     |        |      |
| indefinitely    |         |      |        |     |        |      |
| Use standard    | MUST-35 |  X   |        |     |        |      |
| probing logic   |         |      |        |     |        |      |
| Sender probe    | MUST-36 |  X   |        |     |        |      |
| zero window     |         |      |        |     |        |      |
| *  First probe  | SHLD-29 |      |   X    |     |        |      |
|    after RTO    |         |      |        |     |        |      |
| *  Exponential  | SHLD-30 |      |   X    |     |        |      |
|    backoff      |         |      |        |     |        |      |
| Allow window    | MUST-37 |  X   |        |     |        |      |
| stay zero       |         |      |        |     |        |      |
| indefinitely    |         |      |        |     |        |      |
| Retransmit old  | MAY-7   |      |        |  X  |        |      |
| data beyond     |         |      |        |     |        |      |
| SND.UNA+SND.WND |         |      |        |     |        |      |
| Process RST and | MUST-66 |  X   |        |     |        |      |
| URG even with   |         |      |        |     |        |      |
| zero window     |         |      |        |     |        |      |
| Urgent Data                                                     |
| Include support | MUST-30 |  X   |        |     |        |      |
| for urgent      |         |      |        |     |        |      |
| pointer         |         |      |        |     |        |      |
| Pointer         | MUST-62 |  X   |        |     |        |      |
| indicates first |         |      |        |     |        |      |
| non-urgent      |         |      |        |     |        |      |
| octet           |         |      |        |     |        |      |
| Arbitrary       | MUST-31 |  X   |        |     |        |      |
| length urgent   |         |      |        |     |        |      |
| data sequence   |         |      |        |     |        |      |
| Inform ALP^1    | MUST-32 |  X   |        |     |        |      |
| asynchronously  |         |      |        |     |        |      |
| of urgent data  |         |      |        |     |        |      |
| ALP^1 can learn | MUST-33 |  X   |        |     |        |      |
| if/how much     |         |      |        |     |        |      |
| urgent data Q'd |         |      |        |     |        |      |
| ALP employ the  | SHLD-13 |      |        |     |   X    |      |
| urgent          |         |      |        |     |        |      |
| mechanism       |         |      |        |     |        |      |
| TCP Options                                                     |
| Support the     | MUST-4  |  X   |        |     |        |      |
| mandatory       |         |      |        |     |        |      |
| option set      |         |      |        |     |        |      |
| Receive TCP     | MUST-5  |  X   |        |     |        |      |
| Option in any   |         |      |        |     |        |      |
| segment         |         |      |        |     |        |      |
| Ignore          | MUST-6  |  X   |        |     |        |      |
| unsupported     |         |      |        |     |        |      |
| options         |         |      |        |     |        |      |
| Include length  | MUST-68 |  X   |        |     |        |      |
| for all options |         |      |        |     |        |      |
| except EOL+NOP  |         |      |        |     |        |      |
| Cope with       | MUST-7  |  X   |        |     |        |      |
| illegal option  |         |      |        |     |        |      |
| length          |         |      |        |     |        |      |
| Process options | MUST-64 |  X   |        |     |        |      |
| regardless of   |         |      |        |     |        |      |
| word alignment  |         |      |        |     |        |      |
| Implement       | MUST-14 |  X   |        |     |        |      |
| sending &       |         |      |        |     |        |      |
| receiving MSS   |         |      |        |     |        |      |
| Option          |         |      |        |     |        |      |
| IPv4 Send MSS   | SHLD-5  |      |   X    |     |        |      |
| Option unless   |         |      |        |     |        |      |
| 536             |         |      |        |     |        |      |
| IPv6 Send MSS   | SHLD-5  |      |   X    |     |        |      |
| Option unless   |         |      |        |     |        |      |
| 1220            |         |      |        |     |        |      |
| Send MSS Option | MAY-3   |      |        |  X  |        |      |
| always          |         |      |        |     |        |      |
| IPv4 Send-MSS   | MUST-15 |  X   |        |     |        |      |
| default is 536  |         |      |        |     |        |      |
| IPv6 Send-MSS   | MUST-15 |  X   |        |     |        |      |
| default is 1220 |         |      |        |     |        |      |
| Calculate       | MUST-16 |  X   |        |     |        |      |
| effective send  |         |      |        |     |        |      |
| seg size        |         |      |        |     |        |      |
| MSS accounts    | SHLD-6  |      |   X    |     |        |      |
| for varying MTU |         |      |        |     |        |      |
| MSS not sent on | MUST-65 |      |        |     |        |  X   |
| non-SYN         |         |      |        |     |        |      |
| segments        |         |      |        |     |        |      |
| MSS value based | MUST-67 |  X   |        |     |        |      |
| on MMS_R        |         |      |        |     |        |      |
| Pad with zero   | MUST-69 |  X   |        |     |        |      |
| TCP Checksums                                                   |
| Sender compute  | MUST-2  |  X   |        |     |        |      |
| checksum        |         |      |        |     |        |      |
| Receiver check  | MUST-3  |  X   |        |     |        |      |
| checksum        |         |      |        |     |        |      |
| ISN Selection                                                   |
| Include a       | MUST-8  |  X   |        |     |        |      |
| clock-driven    |         |      |        |     |        |      |
| ISN generator   |         |      |        |     |        |      |
| component       |         |      |        |     |        |      |
| Secure ISN      | SHLD-1  |      |   X    |     |        |      |
| generator with  |         |      |        |     |        |      |
| a PRF component |         |      |        |     |        |      |
| PRF computable  | MUST-9  |      |        |     |        |  X   |
| from outside    |         |      |        |     |        |      |
| the host        |         |      |        |     |        |      |
| Opening Connections                                             |
| Support         | MUST-10 |  X   |        |     |        |      |
| simultaneous    |         |      |        |     |        |      |
| open attempts   |         |      |        |     |        |      |
| SYN-RECEIVED    | MUST-11 |  X   |        |     |        |      |
| remembers last  |         |      |        |     |        |      |
| state           |         |      |        |     |        |      |
| Passive OPEN    | MUST-41 |      |        |     |        |  X   |
| call interfere  |         |      |        |     |        |      |
| with others     |         |      |        |     |        |      |
| Function:       | MUST-42 |  X   |        |     |        |      |
| simultaneously  |         |      |        |     |        |      |
| LISTENs for     |         |      |        |     |        |      |
| same port       |         |      |        |     |        |      |
| Ask IP for src  | MUST-44 |  X   |        |     |        |      |
| address for SYN |         |      |        |     |        |      |
| if necessary    |         |      |        |     |        |      |
| *  Otherwise,   | MUST-45 |  X   |        |     |        |      |
|    use local    |         |      |        |     |        |      |
|    addr of      |         |      |        |     |        |      |
|    connection   |         |      |        |     |        |      |
| OPEN to         | MUST-46 |      |        |     |        |  X   |
| broadcast/      |         |      |        |     |        |      |
| multicast IP    |         |      |        |     |        |      |
| address         |         |      |        |     |        |      |
| Silently        | MUST-57 |  X   |        |     |        |      |
| discard seg to  |         |      |        |     |        |      |
| bcast/mcast     |         |      |        |     |        |      |
| addr            |         |      |        |     |        |      |
| Closing Connections                                             |
| RST can contain | SHLD-2  |      |   X    |     |        |      |
| data            |         |      |        |     |        |      |
| Inform          | MUST-12 |  X   |        |     |        |      |
| application of  |         |      |        |     |        |      |
| aborted conn    |         |      |        |     |        |      |
| Half-duplex     | MAY-1   |      |        |  X  |        |      |
| close           |         |      |        |     |        |      |
| connections     |         |      |        |     |        |      |
| *  Send RST to  | SHLD-3  |      |   X    |     |        |      |
|    indicate     |         |      |        |     |        |      |
|    data lost    |         |      |        |     |        |      |
| In TIME-WAIT    | MUST-13 |  X   |        |     |        |      |
| state for 2MSL  |         |      |        |     |        |      |
| seconds         |         |      |        |     |        |      |
| *  Accept SYN   | MAY-2   |      |        |  X  |        |      |
|    from TIME-   |         |      |        |     |        |      |
|    WAIT state   |         |      |        |     |        |      |
| *  Use          | SHLD-4  |      |   X    |     |        |      |
|    Timestamps   |         |      |        |     |        |      |
|    to reduce    |         |      |        |     |        |      |
|    TIME-WAIT    |         |      |        |     |        |      |
| Retransmissions                                                 |
| Implement       | MUST-19 |  X   |        |     |        |      |
| exponential     |         |      |        |     |        |      |
| backoff, slow   |         |      |        |     |        |      |
| start, and      |         |      |        |     |        |      |
| congestion      |         |      |        |     |        |      |
| avoidance       |         |      |        |     |        |      |
| Retransmit with | MAY-4   |      |        |  X  |        |      |
| same IP         |         |      |        |     |        |      |
| identity        |         |      |        |     |        |      |
| Karn's          | MUST-18 |  X   |        |     |        |      |
| algorithm       |         |      |        |     |        |      |
| Generating ACKs                                                 |
| Aggregate       | MUST-58 |  X   |        |     |        |      |
| whenever        |         |      |        |     |        |      |
| possible        |         |      |        |     |        |      |
| Queue out-of-   | SHLD-31 |      |   X    |     |        |      |
| order segments  |         |      |        |     |        |      |
| Process all Q'd | MUST-59 |  X   |        |     |        |      |
| before send ACK |         |      |        |     |        |      |
| Send ACK for    | MAY-13  |      |        |  X  |        |      |
| out-of-order    |         |      |        |     |        |      |
| segment         |         |      |        |     |        |      |
| Delayed ACKs    | SHLD-18 |      |   X    |     |        |      |
| *  Delay < 0.5  | MUST-40 |  X   |        |     |        |      |
|    seconds      |         |      |        |     |        |      |
| *  Every 2nd    | SHLD-19 |      |   X    |     |        |      |
|    full-sized   |         |      |        |     |        |      |
|    segment or   |         |      |        |     |        |      |
|    2*RMSS ACK'd |         |      |        |     |        |      |
| Receiver SWS-   | MUST-39 |  X   |        |     |        |      |
| Avoidance       |         |      |        |     |        |      |
| Algorithm       |         |      |        |     |        |      |
| Sending Data                                                    |
| Configurable    | MUST-49 |  X   |        |     |        |      |
| TTL             |         |      |        |     |        |      |
| Sender SWS-     | MUST-38 |  X   |        |     |        |      |
| Avoidance       |         |      |        |     |        |      |
| Algorithm       |         |      |        |     |        |      |
| Nagle algorithm | SHLD-7  |      |   X    |     |        |      |
| *  Application  | MUST-17 |  X   |        |     |        |      |
|    can disable  |         |      |        |     |        |      |
|    Nagle        |         |      |        |     |        |      |
|    algorithm    |         |      |        |     |        |      |
| Connection Failures                                             |
| Negative advice | MUST-20 |  X   |        |     |        |      |
| to IP on R1     |         |      |        |     |        |      |
| retransmissions |         |      |        |     |        |      |
| Close           | MUST-20 |  X   |        |     |        |      |
| connection on   |         |      |        |     |        |      |
| R2              |         |      |        |     |        |      |
| retransmissions |         |      |        |     |        |      |
| ALP^1 can set   | MUST-21 |  X   |        |     |        |      |
| R2              |         |      |        |     |        |      |
| Inform ALP of   | SHLD-9  |      |   X    |     |        |      |
| R1<=retxs<R2    |         |      |        |     |        |      |
| Recommended     | SHLD-10 |      |   X    |     |        |      |
| value for R1    |         |      |        |     |        |      |
| Recommended     | SHLD-11 |      |   X    |     |        |      |
| value for R2    |         |      |        |     |        |      |
| Same mechanism  | MUST-22 |  X   |        |     |        |      |
| for SYNs        |         |      |        |     |        |      |
| *  R2 at least  | MUST-23 |  X   |        |     |        |      |
|    3 minutes    |         |      |        |     |        |      |
|    for SYN      |         |      |        |     |        |      |
| Send Keep-alive Packets                                         |
| Send Keep-alive | MAY-5   |      |   X    |     |        |      |
| Packets:        |         |      |        |     |        |      |
| *  Application  | MUST-24 |  X   |        |     |        |      |
|    can request  |         |      |        |     |        |      |
| *  Default is   | MUST-25 |  X   |        |     |        |      |
|    "off"        |         |      |        |     |        |      |
| *  Only send if | MUST-26 |  X   |        |     |        |      |
|    idle for     |         |      |        |     |        |      |
|    interval     |         |      |        |     |        |      |
| *  Interval     | MUST-27 |  X   |        |     |        |      |
|    configurable |         |      |        |     |        |      |
| *  Default at   | MUST-28 |  X   |        |     |        |      |
|    least 2 hrs. |         |      |        |     |        |      |
| *  Tolerant of  | MUST-29 |  X   |        |     |        |      |
|    lost ACKs    |         |      |        |     |        |      |
| *  Send with no | SHLD-12 |      |   X    |     |        |      |
|    data         |         |      |        |     |        |      |
| *  Configurable | MAY-6   |      |        |  X  |        |      |
|    to send      |         |      |        |     |        |      |
|    garbage      |         |      |        |     |        |      |
|    octet        |         |      |        |     |        |      |
| IP Options                                                      |
| Ignore options  | MUST-50 |  X   |        |     |        |      |
| TCP doesn't     |         |      |        |     |        |      |
| understand      |         |      |        |     |        |      |
| Timestamp       | MAY-10  |      |   X    |     |        |      |
| support         |         |      |        |     |        |      |
| Record Route    | MAY-11  |      |   X    |     |        |      |
| support         |         |      |        |     |        |      |
| Source Route:   |         |      |        |     |        |      |
| *  ALP^1 can    | MUST-51 |  X   |        |     |        |      |
|    specify      |         |      |        |     |        |      |
| *     Overrides | MUST-52 |  X   |        |     |        |      |
|       src route |         |      |        |     |        |      |
|       in        |         |      |        |     |        |      |
|       datagram  |         |      |        |     |        |      |
| *  Build return | MUST-53 |  X   |        |     |        |      |
|    route from   |         |      |        |     |        |      |
|    src route    |         |      |        |     |        |      |
| *  Later src    | SHLD-24 |      |   X    |     |        |      |
|    route        |         |      |        |     |        |      |
|    overrides    |         |      |        |     |        |      |
| Receiving ICMP Messages from IP                                 |
| Receiving ICMP  | MUST-54 |  X   |        |     |        |      |
| messages from   |         |      |        |     |        |      |
| IP              |         |      |        |     |        |      |
| *  Dest Unreach | SHLD-25 |  X   |        |     |        |      |
|    (0,1,5) =>   |         |      |        |     |        |      |
|    inform ALP   |         |      |        |     |        |      |
| *  Abort on     | MUST-56 |      |        |     |        |  X   |
|    Dest Unreach |         |      |        |     |        |      |
|    (0,1,5)      |         |      |        |     |        |      |
| *  Dest Unreach | SHLD-26 |      |   X    |     |        |      |
|    (2-4) =>     |         |      |        |     |        |      |
|    abort conn   |         |      |        |     |        |      |
| *  Source       | MUST-55 |  X   |        |     |        |      |
|    Quench =>    |         |      |        |     |        |      |
|    silent       |         |      |        |     |        |      |
|    discard      |         |      |        |     |        |      |
| *  Abort on     | MUST-56 |      |        |     |        |  X   |
|    Time         |         |      |        |     |        |      |
|    Exceeded     |         |      |        |     |        |      |
| *  Abort on     | MUST-56 |      |        |     |        |  X   |
|    Param        |         |      |        |     |        |      |
|    Problem      |         |      |        |     |        |      |
| Address Validation                                              |
| Reject OPEN     | MUST-46 |  X   |        |     |        |      |
| call to invalid |         |      |        |     |        |      |
| IP address      |         |      |        |     |        |      |
| Reject SYN from | MUST-63 |  X   |        |     |        |      |
| invalid IP      |         |      |        |     |        |      |
| address         |         |      |        |     |        |      |
| Silently        | MUST-57 |  X   |        |     |        |      |
| discard SYN to  |         |      |        |     |        |      |
| bcast/mcast     |         |      |        |     |        |      |
| addr            |         |      |        |     |        |      |
| TCP/ALP Interface Services                                      |
| Error Report    | MUST-47 |  X   |        |     |        |      |
| mechanism       |         |      |        |     |        |      |
| ALP can disable | SHLD-20 |      |   X    |     |        |      |
| Error Report    |         |      |        |     |        |      |
| Routine         |         |      |        |     |        |      |
| ALP can specify | MUST-48 |  X   |        |     |        |      |
| Diffserv field  |         |      |        |     |        |      |
| for sending     |         |      |        |     |        |      |
| *  Passed       | SHLD-22 |      |   X    |     |        |      |
|    unchanged to |         |      |        |     |        |      |
|    IP           |         |      |        |     |        |      |
| ALP can change  | SHLD-21 |      |   X    |     |        |      |
| Diffserv field  |         |      |        |     |        |      |
| during          |         |      |        |     |        |      |
| connection      |         |      |        |     |        |      |
| ALP generally   | SHLD-23 |      |        |     |   X    |      |
| changing        |         |      |        |     |        |      |
| Diffserv during |         |      |        |     |        |      |
| conn.           |         |      |        |     |        |      |
| Pass received   | MAY-9   |      |        |  X  |        |      |
| Diffserv field  |         |      |        |     |        |      |
| up to ALP       |         |      |        |     |        |      |
| FLUSH call      | MAY-14  |      |        |  X  |        |      |
| Optional local  | MUST-43 |  X   |        |     |        |      |
| IP addr param   |         |      |        |     |        |      |
| in OPEN         |         |      |        |     |        |      |
| RFC 5961 Support                                                |
| Implement data  | MAY-12  |      |        |  X  |        |      |
| injection       |         |      |        |     |        |      |
| protection      |         |      |        |     |        |      |
| Explicit Congestion Notification                                |
| Support ECN     | SHLD-8  |      |   X    |     |        |      |
| Alternative Congestion Control                                  |
| Implement       | MAY-18  |      |        |  X  |        |      |
| alternative     |         |      |        |     |        |      |
| conformant      |         |      |        |     |        |      |
| algorithm(s)    |         |      |        |     |        |      |

Table 8: TCP Requirements Summary

FOOTNOTES: (1) “ALP” means Application-Layer Program.
脚注: (1) “ALP” 是指应用层程序。

致谢 #


This document is largely a revision of RFC 793, of which Jon Postel was the editor.
本文档主要是 Jon Postel 编辑的 RFC 793 的修订版。

Due to his excellent work, it was able to last for three decades before we felt the need to revise it.
由于他的出色工作,它能够持续 30 年,然后我们才觉得有必要对其进行修改。

Andre Oppermann was a contributor and helped to edit the first revision of this document.
Andre Oppermann 是本文的撰稿人之一,他帮助编辑了本文件的第一版。

We are thankful for the assistance of the IETF TCPM working group chairs over the course of work on this document:
我们感谢 IETF TCPM 工作组主席在本文档的工作过程中提供的协助:

Michael Scharf

Yoshifumi Nishida

Pasi Sarolahti

Michael Tüxen

During the discussions of this work on the TCPM mailing list, in working group meetings, and via area reviews, helpful comments, critiques, and reviews were received from (listed alphabetically by last name): Praveen Balasubramanian, David Borman, Mohamed Boucadair, Bob Briscoe, Neal Cardwell, Yuchung Cheng, Martin Duke, Francis Dupont, Ted Faber, Gorry Fairhurst, Fernando Gont, Rodney Grimes, Yi Huang, Rahul Jadhav, Markku Kojo, Mike Kosek, Juhamatti Kuusisaari, Kevin Lahey, Kevin Mason, Matt Mathis, Stephen McQuistin, Jonathan Morton, Matt Olson, Tommy Pauly, Tom Petch, Hagen Paul Pfeifer, Kyle Rose, Anthony Sabatini, Michael Scharf, Greg Skinner, Joe Touch, Michael Tüxen, Reji Varghese, Bernie Volz, Tim Wicinski, Lloyd Wood, and Alex Zimmermann.
在 TCPM 邮件列表上、工作组会议上和通过区域审查讨论这项工作期间,收到了以下方面的有用意见、批评和评论(按姓氏字母顺序排列): Praveen Balasubramanian, David Borman, Mohamed Boucadair, Bob Briscoe, Neal Cardwell, Yuchung Cheng, Martin Duke, Francis Dupont, Ted Faber, Gorry Fairhurst, Fernando Gont, Rodney Grimes, Yi Huang, Rahul Jadhav, Markku Kojo, Mike Kosek, Juhamatti Kuusisaari, Kevin Lahey, Kevin Mason, Matt Mathis, Stephen McQuistin, Jonathan Morton, Matt Olson, Tommy Pauly, Tom Petch, Hagen Paul Pfeifer, Kyle Rose, Anthony Sabatini, Michael Scharf, Greg Skinner, Joe Touch, Michael Tüxen, Reji Varghese, Bernie Volz, Tim Wicinski, Lloyd Wood, and Alex Zimmermann。

Joe Touch provided additional help in clarifying the description of segment size parameters and PMTUD/PLPMTUD recommendations.
Joe Touch 在阐明分段大小参数和 PMTUD/PLPMTUD 建议的描述方面提供了额外的帮助。

Markku Kojo helped put together the text in the section on TCP Congestion Control.
Markku Kojo 帮助整理了 TCP 拥塞控制部分的内容。

This document includes content from errata that were reported by (listed chronologically): Yin Shuming, Bob Braden, Morris M. Keesan, Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta Yevstifeyev, EungJun Yi, Botong Huang, Charles Deng, Merlin Buge.
本文档包含由以下人员报告的勘误表中的内容(按时间顺序列出):Yin Shuming, Bob Braden, Morris M. Keesan, Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta Yevstifeyev, EungJun Yi, Botong Huang, Charles Deng, Merlin Buge。

Author’s Address

Wesley M. Eddy (editor)
MTI Systems
United States of America
Email: [email protected]