TCP会重传多少次

发布于 2024-10-20 16:05:58 字数 171 浏览 1 评论 0原文

如果是半开连接,服务器崩溃(没有向客户端发送 FIN 或 RESET),并且客户端尝试在此断开的连接上发送一些数据,则每个 TCP 段都将变为未确认状态。 TCP 将在超时后尝试重新传输数据包。 TCP 在放弃之前会尝试重传多少次?在这种情况下会发生什么?它如何通知操作系统主机无法访问? TCP RFC 中在哪里指定了这一点?

In the case of a half open connection where the server crashes (no FIN or RESET sent to client), and the client attempts to send some data on this broken connection, each TCP segment will go un-ACKED. TCP will attempt to retransmit packets after some timeout. How many times will TCP attempt to retransmit before giving up and what happens in this case? How does it inform the operating system that the host is unreachable? Where is this specified in the TCP RFC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

杀手六號 2024-10-27 16:05:58

如果服务器程序崩溃,内核将适当地清理所有打开的套接字。 (嗯,从 TCP 的角度来看是适当的;它可能违反应用程序层协议,但应用程序应该为此事件做好准备。)

如果服务器内核崩溃并且没有恢复,则数量重试的时间取决于套接字是否已连接:(

   tcp_retries1 (integer; default: 3; since Linux 2.2)
          The number of times TCP will attempt to
          retransmit a packet on an established connection
          normally, without the extra effort of getting
          the network layers involved.  Once we exceed
          this number of retransmits, we first have the
          network layer update the route if possible
          before each new retransmit.  The default is the
          RFC specified minimum of 3.

   tcp_retries2 (integer; default: 15; since Linux 2.2)
          The maximum number of times a TCP packet is
          retransmitted in established state before giving
          up.  The default value is 15, which corresponds
          to a duration of approximately between 13 to 30
          minutes, depending on the retransmission
          timeout.  The RFC 1122 specified minimum limit
          of 100 seconds is typically deemed too short.

来自tcp(7)。)

如果服务器内核崩溃并且确实恢复,它就不会'不知道任何套接字,并且将 RST 这些后续数据包,从而更快地实现故障。

如果沿途任何单点故障路由器崩溃,如果它们足够快地恢复,连接可能会继续工作。这需要防火墙和路由器是无状态的,或者如果它们是有状态的,则具有允许预先存在的连接继续运行的规则集。 (可能不安全,不同的防火墙管理员对此有不同的策略。)

失败将返回给程序,并将 errno 设置为 ECONNRESET(至少对于 send(2 ))。

If the server program crashes, the kernel will clean up all open sockets appropriately. (Well, appropriate from a TCP point of view; it might violate the application layer protocol, but applications should be prepared for this event.)

If the server kernel crashes and does not come back up, the number and timing of retries depends if the socket were connected yet or not:

   tcp_retries1 (integer; default: 3; since Linux 2.2)
          The number of times TCP will attempt to
          retransmit a packet on an established connection
          normally, without the extra effort of getting
          the network layers involved.  Once we exceed
          this number of retransmits, we first have the
          network layer update the route if possible
          before each new retransmit.  The default is the
          RFC specified minimum of 3.

   tcp_retries2 (integer; default: 15; since Linux 2.2)
          The maximum number of times a TCP packet is
          retransmitted in established state before giving
          up.  The default value is 15, which corresponds
          to a duration of approximately between 13 to 30
          minutes, depending on the retransmission
          timeout.  The RFC 1122 specified minimum limit
          of 100 seconds is typically deemed too short.

(From tcp(7).)

If the server kernel crashes and does come back up, it won't know about any of the sockets, and will RST those follow-on packets, enabling failure much faster.

If any single-point-of-failure routers along the way crash, if they come back up quickly enough, the connection may continue working. This would require that firewalls and routers be stateless, or if they are stateful, have rulesets that allow preexisting connections to continue running. (Potentially unsafe, different firewall admins have different policies about this.)

The failures are returned to the program with errno set to ECONNRESET (at least for send(2)).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文