简体   繁体   中英

TCP TIME_WAIT problem

I have read a TCP and socket programming book. I have a question,

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?

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.

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM