Established connection(3-way handshake)
Close connection (4-way handshake)
TCP connection is connected protocol. We will take a closer look at the states and how to handled basic TCP protocol.
To guaranteed the safe connection. We need to established the connection until close session. Detail:
To established TCP connection, it’s always initiated with 3-way handshake, which establishes and negotiates(đàm phán) the actual connection over sending data.
Before begin 3-way handshake. We have one listening connection on server. So, server need to register one static connection on one static port connection . This is passive connection and listen connection from client.
tcp 6 117 SYN_SENT src=192.168.1.5 dst=192.168.1.35 sport=1031 \
dport=23 [UNREPLIED] src=192.168.1.35 dst=192.168.1.5 sport=23 \
Way-1: Client send SYN packet to server . This is new connection and could be block if don’t register by firewall. The SYN_SENT is flag set.
tcp 6 57 SYN_RECV src=192.168.1.5 dst=192.168.1.35 sport=1031 \
dport=23 src=192.168.1.35 dst=192.168.1.5 sport=23 dport=1031 \
Way-2: After than, Server will feedback corresponding SYN_RECV packet. This is accepted from server to client . Client will receive and tell " ready send" to end of 3-way handshake.
tcp 6 431999 ESTABLISHED src=192.168.1.5 dst=192.168.1.35 \
sport=1031 dport=23 src=192.168.1.35 dst=192.168.1.5 \
sport=23 dport=1031 use=1
Way-3: Client will send established flag. After more packets, the connection will also become [ASSURED]
Ending of connection, stations always using the 4-way-handshake. One station will send FIN packet to done connection. Stepping follow picture. After that station stop send and wait other station ending session. In other station, it do that, too. After that, 2 station ending with together.
written by hotdream1990