TCP-Connection

Establish a connection (three-way handshake)

The process of establishing the connection

  1. Requester (also commonly referred to as Client client) transmits with a SYN identifier ISN +. 1 TCP segment to the other end of the serial number (also commonly referred Server server) a request to establish a TCP connection .
  2. If the Server to establish a TCP connection, with a send back the ACK identifier while confirming the number of Client 1 + SEQ ID NO acknowledgment of the segment to the Client.
  3. Client transmission with a new ACK identifier while confirming the number of Server sequence number + 1 segment of the Server to confirm (in many cases, Client has started in the data block of the segment to be transmitted to the stuffing Server data).
    So far, the three-way handshake is completed, TCP connection is established.

Connection establishment timeout

Obviously, there are many exceptions may cause the TCP connection can not be established. For example, Server not in normal condition; Or load TCP segment of the IP datagram is lost in the process forwarded.
TCP protocol handling this situation is set to establish a TCP connection timeout , it will be transmitted before the timeout plurality of incoming SYN packet to establish a TCP connection request to establish the peer. After the timeout time comes, if the connection is not established, then gave up a connection.

End connection (handshake)

Establish a TCP connection requires three-way handshake, and completely terminate the TCP connection it takes four times. Since a TCP connection is full-duplex, a FIN segment can only close the data transfer in one direction. Therefore, I want to completely close a TCP connection, you need two pairs of FIN - ACK FIN the segment pairing job. This case is also called semi-closed TCP connection .

FIN close the TCP connection transmits a result of the application layer is normally closed!

If the device at the time of application of the active capture closing the connection, can clearly see the side of the active hair Close Great column  TCP-Connection sent with a FIN segment to the other identifier.

TCP half-closed connection

Although FIG passive close side (first recipient FIN) appears after receiving the FIN sends an ACK to its peer FIN immediately. But in fact, in many cases between these two segments is the time interval, but also in the time interval transmitting a lot of data segments for transmission of data not yet sent. This phenomenon is the TCP half-closed.
The TCP protocol allows such a "window period" characteristics, often also be used to advantage. (For example Client has sent over their own data to be transmitted, but still want to receive data transmitted Server)

While at the same time open & closed

Because TCP is full duplex, so the two sides at the same time a request to establish a connection or end at the same time close the connection is possible. However, because the probability is very small, but very few application scenarios, there is not much introduced.

RST

Request to establish a connection port does not exist

Which is often the case, the request to establish the connection SYN segment has been sent to the Server, but Server checks to the corresponding destination port was not listening (the port binding application process does not start). Server at this time ACK packet is sent back to the Client's will would RST identifier is set to inform the Client connection can not be established.

Aborted connection

By sending a RST rather than sending a FIN segment to end the way TCP connection is also known as abnormal release . Sending back a normal one at the receiving end the peer to abnormal packet RST to the abnormal termination of terminal connection. Speaking of abnormal may not segment the content in question, but can not handle this segment. (In the application TCP keep-alive timer, receives a TCP connection to the old terminal of the probe sent from the server segment, it will send back a RST packet for the server to terminate the connection after the restart Client.)
Such abnormal termination connection there are two advantages:

  • No need to perform four-way handshake, RST the receiving end after receipt of the segment will be directly closed. (RST of the sender 're sending RST packets is most likely because he did not perform a normal four-way handshake to close a TCP connection)
  • RST is the receiving end know abnormalities that end, to enter the appropriate exception handling process .

Guess you like

Origin www.cnblogs.com/liuzhongrong/p/12000040.html