TCP three-way handshake to establish a connection
Server side simulation
Client simulation
# 创建TCP套接字
tcp_client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# 客户端连接服务端
tcp_client_socket.connect(("192.168.241.1", 8080))
Wireshark filters tcp ports
tcp.port == 8080
First handshake
The client sends a SYN signal to the server
Second handshake
The server sends a (SYN, ACK) signal from the client
Third handshake
The client sends an ACK signal to the server
TCP waved four times to close the connection
The picture is forwarded from TCP's three-way handshake and four waved hands. Understanding and interview questions (very comprehensive) by青柚_
The client actively closes the connection
tcp_client_socket.close()