TCP- three-way handshake and a brief overview of four wave

Three-way handshake (three-way handshaking)

1. Background: TCP transport layer is located, is to provide a reliable byte stream service, in order to accurately reach the destination data, TCP three-way handshake protocol adoption strategies.

 

2. Principle:

1) with a transmitting side first sends a SYN (synchronize) flag to a data packet to the receiving side.

2) after the recipient receives back data packet with a SYN / ACK flag delivery confirmation information indicating I received.

3) Finally, return to sender transmit a packet with the ACK flag, representing I know, means 'handshake' end.

 

Popular view

1) Client: Hey, John Doe, it's me, hear me?

2) Server: I hear, can you hear me?

3) Client: Yes, we can hear each other's words, our communication can begin.

 

 

 

Four waving (Four-Way-Wavehand)

1. Significance: When received the passive side active side of FIN message notification, it merely represents the active side there is no data before sending it to the passive side. But not necessarily the passive side all the data is sent intact to the active side, so the passive side does not close SOCKET immediately, it may also need to send some data to the active side, and then send a FIN packet to the active side, agreed to tell initiative close the connection, so that in most cases ACK and FIN packets where packets are transmitted separately.

 

2. Principle:

 1) First Wave: Client sends a FIN, for closing the data transfer Client Server tenderer, Client enters FIN_WAIT_1 state.

 2) The second wave: Server receives the FIN, ACK to send a Client, the acknowledgment number for the receipt number +1 (the same SYN, FIN a occupy a sequence number), Server enters CLOSE_WAIT state.

 3) The third wave: Server sends a FIN, for closing the Client Server data transfer, LAST_ACK Server enters state.

 4) The fourth wave: the Client receives the FIN, Client enters TIME_WAIT state, and then sends an ACK to the Server, for the receipt of the acknowledgment number number + 1, Server enters the CLOSED state, four complete wave

 

Popular view

1) Client: All the things I said and done

2) Server: All I've heard, but wait for me, I have not finished

3) Server: Well, I've finished

4) Client: Well, that's the end of our communication

 

Guess you like

Origin www.cnblogs.com/chen-xia/p/11672328.html