TCP TIME_WAIT问题 [英] TCP TIME_WAIT problem
问题描述
我已经阅读了TCP和套接字编程书。我有一个问题,
I have read a TCP and socket programming book. I have a question,
本书说,TCP的TIME_WAIT状态应保持2MSL时间段为
。但是如何像应用程序
这样的互联网探索没有这个问题?
The TIME_WAIT state of the TCP should remain 2MSL time period as the book said. But how then a internet explore like application does not have this problem?
根据文档,它是4分钟,但在Internet探索
我不需要等待10秒才能刷新网页?
According to the documentation, it's 4 minutes , but in Internet explore I don't have to wait even 10 seconds to refresh a web page?
这是如何运作的?我很困惑请解释。
How this works? I'm confused please explain.
推荐答案
有几种可能性,其中一些我在下面列出。
There are a few possibilities, some of which I've listed below.
首先,并非所有会话都通过 TIME_WAIT
状态。如果另一方关闭连接,则本地转换为 ESTABLISHED
, CLOSE_WAIT
, LAST_ACK
和 CLOSED
,因此没有涉及 TIME_WAIT
。
The first is that not all sessions move through the TIME_WAIT
state at all. If the other side closes the connection, the local transitions are ESTABLISHED
, CLOSE_WAIT
, LAST_ACK
and CLOSED
, so there's no TIME_WAIT
involved.
其次, TIME_WAIT
状态适用于会话,这是一个5元组 {协议,source-ip,source-port,dest-ip,dest-port}
。
Secondly, the TIME_WAIT
state applies to a session, which is a 5-tuple {protocol,source-ip,source-port,dest-ip,dest-port}
.
如果任何这些值会在下一个会话(通常是源端口)中发生变化,不受前一个会话的影响。
If any of those values change for the next session (usually source-port), that's unaffected by the previous session.
最后,浏览器没有在每个请求后关闭会话。为了重新使用它们,更有可能(为了提高效率)维护一个开放会话池,例如当你想要下载一个包含50个图像(一个会话而不是五十个)的页面时。
Lastly, the browser doesn't have to shut down the session after each request. It's more likely (for efficiency) to maintain a pool of open sessions in order to re-use them, such as when you want to download a page with fifty images (one session rather than fifty one).
它甚至可以在页面完全加载后打开这些会话,因为你有可能访问该服务器上的其他内容。
It can even leave such sessions open after a page is fully loaded, on the off-chance you'll access something else on that server.
这篇关于TCP TIME_WAIT问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!