TCP keep-alive翻译

原文链接:

http://www.freesoft.org/CIE/RFC/1122/114.htm
http://www.freesoft.org/CIE/RFC/1122/index.htm

实现TCP的人或许会包含 "keep-alives" 在它们实现的TCP中,虽然keep-alive不是普遍被接受。如果keep-alive被包含,应用程序必须能够为每个连接打开或者关闭keep-alive,默认一定是关闭状态。
Keep-alive报文仅在一定时间间隔内没有收到数据或者确认报文时才被发送,时间间隔必须能够配置,默认的时间间隔必须不小于俩个小时。

记住TCP传播不包含数据的ack报文是不可靠的是十分重要的,因此,如果keep-alive机制被实现,
if a keep-alive mechanism is implemented it MUST NOT interpret failure to respond to any specific probe as a dead connection(没看懂).
然后,为了兼容错误的TCP实现,它可能被配置成发送一个包含垃圾八元组的keep-alive报文。

讨论

当连接空闲时,keep-alive机制定期的探测连接的另一方,即使它(发起探测的一方)没有数据要发送,TCP标准文档没有包含keep-alive机制,因为它会导致如下问题。
1:网络临时的错误的时候,导致一个良好的连接被断掉
2:浪费没有必要的带宽(如果没有人使用这个连接,谁会去管连接是否还是好的)
3:浪费钱

一些TCP实现包含keep-alive机制,为了确认一个空闲的连接依旧是活跃的(可用的),发送一个探测报文,为了引出对方的响应。
探测报文一般包含SEG.SEQ=SND.NXT-1(自己的TCP序号减一),探测报文可能还包含或不包含一个垃圾(无用的)八元组。
注意,在一条安静的连接中,SND.NXT(探测方下一个发送的字节序号)=RCV.NXT(被探测方希望收到的序号),所以当前的SEG.SEQ(探测报文中包含的TCP序号)将在窗口外。
因此,这个探测报文导致接收方返回一个ack(确认)报文来确认当前的连接还是存活的,
如果对等方已经放弃这个连接(由于网络改变,或者网络崩溃),
接收方将响应一个RST报文,而不是响应一个ack报文。

不幸运的是,一些不规范的实现不响应(SEG.SEQ=SND.NXT-1)的报文,除非这个报文包含数据。
Alternatively, an implementation could determine whether a peer responded correctly to keep-alive packets with no garbage data octet.(没看懂)

A TCP keep-alive mechanism should only be invoked in server applications that might otherwise hang indefinitely and consume resources unnecessarily if
a client crashes or aborts a connection during a network failure.
(好像是说服务器没必要为一个死了的客户端耗费资源)

原文

4.2.3.6 TCP Keep-Alives

Implementors MAY include "keep-alives" in their TCP implementations, although this practice is not universally accepted. If keep-alives are included, the application MUST be able to turn them on or off for each TCP connection, and they MUST default to off.

Keep-alive packets MUST only be sent when no data or acknowledgement packets have been received for the connection within an interval. This interval MUST be configurable and MUST default to no less than two hours.

It is extremely important to remember that ACK segments that contain no data are not reliably transmitted by TCP. Consequently, if a keep-alive mechanism is implemented it MUST NOT interpret failure to respond to any specific probe as a dead connection. An implementation SHOULD send a keep-alive segment with no data; however, it MAY be configurable to send a keep-alive segment containing one garbage octet, for compatibility with erroneous TCP implementations.

DISCUSSION:
A "keep-alive" mechanism periodically probes the other end of a connection when the connection is otherwise idle, even when there is no data to be sent. The TCP specification does not include a keep-alive mechanism because it could: (1) cause perfectly good connections to break during transient Internet failures; (2) consume unnecessary bandwidth ("if no one is using the connection, who cares if it is still good?"); and (3) cost money for an Internet path that charges for packets.

Some TCP implementations, however, have included a keep-alive mechanism. To confirm that an idle connection is still active, these implementations send a probe segment designed to elicit a response from the peer TCP. Such a segment generally contains SEG.SEQ = SND.NXT-1 and may or may not contain one garbage octet of data. Note that on a quiet connection SND.NXT = RCV.NXT, so that this SEG.SEQ will be outside the window. Therefore, the probe causes the receiver to return an acknowledgment segment, confirming that the connection is still live. If the peer has dropped the connection due to a network partition or a crash, it will respond with a RST instead of an acknowledgment segment.

Unfortunately, some misbehaved TCP implementations fail to respond to a segment with SEG.SEQ = SND.NXT-1 unless the segment contains data. Alternatively, an implementation could determine whether a peer responded correctly to keep-alive packets with no garbage data octet.

A TCP keep-alive mechanism should only be invoked in server applications that might otherwise hang indefinitely and consume resources unnecessarily if a client crashes or aborts a connection during a network failure.

  

时间: 2024-11-02 22:32:25

TCP keep-alive翻译的相关文章

TCP 连接与TCP keep alive 保活检测机制

生产环境中一台2核4G的linux服务器TCP连接数时常保持在5-7w间徘徊,查看日志每秒的请求数也就100-200,怎么会产生这么大的TCP连接数.检查了下客户端上行的HTTP协议,Connection 头字段是Keep-Alive,并且客户端在请求完之后没有立即关闭连接.而服务端的设计也是根据客户端来的,客户端上行如果Connection:Keep-Alive,服务端是不会主动关闭连接的.在客户端与服务端交互比较频繁的时候,这样的设计还是比较合理的,可以减少TCP的重复握手.显然如果只交互一

(转)RTSP - RTP over TCP

Normally, RTSP provide streaming over UDP. By nature, UDP is a better choice as it provides robust streaming capability for media. However, it is unlikely to use UDP for streaming over the Internet. 通常来说,RTSP提供UDP方式发送RTP流.当然,发送流媒体时,UDP往往是更好的选择.但是,在互联

RTSP - RTP over TCP

Normally, RTSP provide streaming over UDP. By nature, UDP is a better choice as it provides robust streaming capability for media. However, it is unlikely to use UDP for streaming over the Internet. 通常来说,RTSP提供UDP方式发送RTP流.当然,发送流媒体时,UDP往往是更好的选择.但是,在互联

c#网络通信框架networkcomms内核解析之十一 TCP连接与UDP连接

连接是通信的核心 客户端一般只会有一个连接 服务器端会维护成千上万的连接 在服务器端连接的维护工作是由NetworkComms静态类来完成的,当有新的客户端请求,服务器上会创建相应的连接,并把连接注册到NetworkComms静态类中.当连接断开后,NetworkComms通信框架会自动把相应连接的引用从NetworkComms静态类中删除. 连接的类图: 在V3以上版本中,数据监听部分已从Connnection类中提取出去成为一个单独的类: TCPConnectionListener   ,使

[转]HTTP的长连接和短连接

本文原链接:http://www.cnblogs.com/cswuyg/p/3653263.html   本文总结&分享网络编程中涉及的长连接.短连接概念.     关键字:Keep-Alive,并发连接数限制,TCP,HTTP 一.什么是长连接 HTTP1.1规定了默认保持长连接(HTTP persistent connection ,也有翻译为持久连接),数据传输完成了保持TCP连接不断开(不发RST包.不四次握手),等待在同域名下继续用这个通道传输数据:相反的就是短连接. HTTP首部的C

HTTP的长连接和短连接

 http://www.cnblogs.com/cswuyg/p/3653263.html 本文总结&分享网络编程中涉及的长连接.短连接概念.     关键字:Keep-Alive,并发连接数限制,TCP,HTTP 一.什么是长连接 HTTP1.1规定了默认保持长连接(HTTP persistent connection ,也有翻译为持久连接),数据传输完成了保持TCP连接不断开(不发RST包.不四次握手),等待在同域名下继续用这个通道传输数据:相反的就是短连接. HTTP首部的Connecti

长连接和短连接的区别(一)

一.什么是长连接 HTTP1.1规定了默认保持长连接(HTTP persistent connection ,也有翻译为持久连接),数据传输完成了保持TCP连接不断开(不发RST包.不四次握手),等待在同域名下继续用这个通道传输数据:相反的就是短连接. HTTP首部的Connection: Keep-alive是HTTP1.0浏览器和服务器的实验性扩展,当前的HTTP1.1 RFC2616文档没有对它做说明,因为它所需要的功能已经默认开启,无须带着它,但是实践中可以发现,浏览器的报文请求都会带上

【转】HTTP长连接与短连接(2)

一.什么是长连接 HTTP1.1规定了默认保持长连接(HTTP persistent connection ,也有翻译为持久连接),数据传输完成了保持TCP连接不断开(不发RST包.不四次握手),等待在同域名下继续用这个通道传输数据:相反的就是短连接. HTTP首部的Connection: Keep-alive是HTTP1.0浏览器和服务器的实验性扩展,当前的HTTP1.1 RFC2616文档没有对它做说明,因为它所需要的功能已经默认开启,无须带着它,但是实践中可以发现,浏览器的报文请求都会带上

HTTP的长、短连接介绍

一.长连接简介及使用 HTTP长连接:HTTP persistent connection ,也有翻译为持久连接,在HTTP1.1规定默认保持长连接,数据传输完成了保持TCP连接不断开(不会再发RST包.不会再进行四次握手),等待在同域名下继续用这个通道传输数据(与之相反的就是短连接). HTTP首部的Connection: Keep-alive是HTTP1.0浏览器和服务器的实验性扩展,当前的HTTP1.1 RFC2616文档没有对它做说明,因为它所需要的功能已经默认开启,无须带着它.但是实践

Wireshark抓包常见出现错误

转自这里 1.   tcp out-of-order(tcp有问题) 解答: 1).    应该有很多原因.但是多半是网络拥塞,导致顺序包抵达时间不同,延时太长,或者包丢失,需要重新组合数据单元 因为他们可能是通过不同的路径到达你电脑上面的. 2).    CRM IT 同仁上礼拜来跟我反应一个问题,由他们客服系统藉由邮件主机要寄送给客户的信件,常常会有寄送失败的问题,查看了一下 Log,发现正常的信件在主机接收 DATA 完成后会记录收到的邮件大小,然后开始进行后续寄送出去的处理,但这些有问题