如果其中一台机器死亡,TCP 连接如何终止? [英] How does TCP connection terminate if one of the machine dies?

查看:59
本文介绍了如果其中一台机器死亡,TCP 连接如何终止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在两台主机(A 和 B)之间建立了 TCP 连接,假设主机 A 向主机 B 发送了 5 个八位字节,然后主机 B 崩溃(由于未知原因).主机 A 将等待确认,但在未收到确认时,将重新发送八位字节并减小发送方窗口大小.这将重复几次,直到窗口大小因数据包丢失而缩小为零.我的问题是,接下来会发生什么?

If a TCP connection is established between two hosts (A & B), and lets say host A has sent 5 octets to host B, and then the host B crashes (due to unknown reason). The host A will wait for acknowledgments, but on not getting them, will resend octets and also reduce the sender window size. This will repeat couple times till the window size shrinks to zero because of packet loss. My question is, what will happen next?

推荐答案

在这种情况下,TCP 最终会超时等待 ack 并向应用程序返回错误.应用程序必须从 TCP 套接字读取/接收以了解该错误,随后的写入/发送调用也会失败.直到 TCP 确定连接消失为止,写入/发送调用不会失败,它们会从应用程序中看到成功或如果套接字缓冲区已满则阻塞.

In this case, TCP eventually times out waiting for the ack's and return an error to the application. The application have to read/recv from the TCP socket to learn about that error, a subsequent write/send call will fail as well. Up till the point that TCP determined that the connection is gone, write/send calls will not fail, they'll succeed as seen from the application or block if the socket buffer is full.

如果您的主机 B 在发送 ACK 后消失,主机 A 将不会知道这一点,直到它向 B 发送一些东西,这最终也会超时,或导致 ICMP 错误.(通常,第一次写/发送调用不会失败,因为 TCP 不会立即使连接失败,请记住,写/发送调用不会等待 ACK 直到它们完成).

In the case your host B vanishes after it has sent its ACKs, host A will not learn about that until it sends something to B, which will eventually also time out, or result in an ICMP error. (Typically the first write/send call will not fail as TCP will not fail the connection immediately, and keep in mind that write/send calls does not wait for ACKs until they complete).

还要注意重传不会减小窗口大小.

Note also that retransmission does not reduce the window size.

这篇关于如果其中一台机器死亡,TCP 连接如何终止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆