Three handshakes
First handshake
The client first sends a SYN message.
Second handshake
The server acknowledges the SYN + ACK response to indicate that it received the message.
Third handshake
The client then confirms the response with an ACK.
The SYN is a packet sent during the first handshake of a TCP connection. It can be used as a means of hacker attacks. SYN attacks are DDoS attacks, which take advantage of TCP defects and send a large number of connection requests, consuming CPU and memory resources.
An ACK is an acknowledgement character sent by a receiving station to a transmitting station, indicating that it has received the ACK.
The process of transmitting data
TCP transmission is transmitted through byte stream. Before transmission, the data stream is divided into multiple segments and sent to the receiving end. To ensure the reliability of transmission, TCP has several transmission mechanisms:
Timeout retransmission
After sending data, if no ACK response is received within a certain period of time, the data is resend until the data is successfully sent.
The fast retransmission
If the sender receives more than three duplicate ACK replies, it knows that the data may have been lost and immediately retransmits it.
Four waves too long
First wave
The active closing end sends a FIN first, indicating that data is sent.
Second wave
Passive close After receiving a FIN, the peer sends an ACK to confirm the passive close.
Third wave
After a period of time, the passive closing end sends a FIN to tell the active end that data transmission has been closed.
Fourth wave
The active shutdown terminal confirms the FIN after receiving the packet.