cool hit counter Three handshakes and four handshakes of the TCP protocol_Intefrankly

Three handshakes and four handshakes of the TCP protocol


I. The concept of TCP/IP

TCP/IP is not a protocol, but a collective term for a cluster of protocols, and the diagram below has some of the protocols and the corresponding layers

II. tcp protocol

TCP is a connection-oriented, reliable, byte-stream-based transport layer communication protocol that belongs to the transport layer. To ensure that information arrives accurately, TCP uses the famous three or four handshakes and four hands-offs.

III. Three handshakes (ACK and ack are two different concepts)

1. The client sets the flag bit SYN to 1, generates a random seq=x, sends the packet to the server, and the client enters the SYN-SENT state, waiting for a response

2, the server receives the data bit packet by the flag bit SYN=1 to know that the client is requesting a connection, then SYN=1 and ACK=1, ack=x+1, and seq to generate a random number seq=y, then the packet is sent to the client to confirm the connection request, and the server enters the SYN-RCVD state

3, the client receives the confirmation, check whether the ack is x+1, ACK is 1, if correct, the flag bit ACK=1, seq=x+1, ack=y+1, the packet is sent to the server, the server confirms ack=y+1 and ACK+1, both the client and the server enter ESTAB-LISHED state to complete the three handshakes, and then the data transmission

IV. Four waves of the hand

After the data transfer is complete, perform four waves to release the connection

1. The client sends a FIN to close the data transfer to the server, sends the seq to generate a random number u to the server, and the client enters the FIN-WAIT-1 state

2, the server receives the FIN, sends an ACk, seq is a random number, ack=u+1, three sent to the client to confirm, the server enters the CLOSE-WAIT state

3, the server then sends FIN=1, ACK=1, seq is a random number w, ack=u+1 is used to close the data transmission and the server enters the LAST-ACK state

4. After receiving FIN, the client enters the TIME-WAIT state, then sends ACK=1, seq=u+1, ack=w+1, and the server enters the CLOSED state, completing four waves

V. Learning extensions

1、SYN attack

In the middle of three handshakes, the server is in the SYN_RCVD state at this time, and when an ACK is received, the Server moves to the ESTABLISHED state. SYN attack is that Client forges a large number of non-existent IP addresses in a short period of time and keeps sending SYN packets to Server, Server replies with acknowledgement packets and waits for Client's confirmation, since the source address is non-existent, Server needs to keep retransmitting until timeout, these forged SYN packets will occupy the unconnected queue for a long time, causing normal SYN requests to be discarded because the queue is full, thus causing network blockage or even system paralysis.

2. Why is it necessary to shake hands three times and wave four times?

This is because the server receives a SYN message with a connection establishment request in the LISTEN state and sends the ACK and SYN in a single message to the client. When the connection is closed, when the FIN message is received from the other party, it only means that the other party is no longer sending data but can still receive data, and the party may not send all data to the other party, so the party can close immediately, or send some data to the other party, and then send a FIN message to the other party to agree to close the connection now.


Recommended>>
1、A day to lead the way in smart travel
2、What will Industry 40 bring to the machinery processing industry
3、Cow tycoon cheat cow tycoon auxiliary hangers download
4、Riskier trademarks that are abandoned Or apply
5、Five trivia facts about blockchain that you know well

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号