First handshake: Client sets Syn=1, randomly generates a serial number seq=x, sending the packet to the server. The client enters the Syn_send state,
Wait for the server to confirm.
Second handshake: The server looks at the packet syn=1 from the client and learns that it is a connection request from the client. Server Settings Syn=1 ack=1
Ack = x+1 seq = y, and the packet is sent to the client. The server enters the SYN_RCVD state.
Third handshake: Client is confirmed by the server to view Ack=1 ack=x+1. Then, give the server a confirmation, set ack=1 ack=y+1.
The server receives the client package to see if the ACK is 1,ack for y+1 if the connection is established correctly. Enter established at the same time.
First wave: A sets Fin=1 seq = x, sending the packet to B,a to enter the Fin_wait_1 state. Wait for the confirmation of B.
Second wave: B look at fin and know a is going to release the connection. b sets Ack=1 ack = x+1, which will confirm the return of a. B
Enter the close_wait. A receive the acknowledgement and enter the Fin_wait_2 state. Wait for the connection of B to release.
Third Wave: B sets Fin=1 seq = y, sends the packet to a A, and enters the Last_ack state. Wait for the confirmation of a.
Wave for the fourth time: a look at fin and know B is going to release the connection. A sets Ack=1 ack = y+1, which will confirm the return of B. A
Enter the time_wait. b receive the acknowledgement and enter the closed state.
Three-time handshake reason: Prevents messages that have failed to be sent to the server side.
Shake hands 3 times, wave to 4 times cause: When connected, the server has been in the listen state, and when the server receives the SYN message, the SYN and ACK are returned simultaneously.
When the connection is released, only one end is not sending the message, but it can still be received. The other end can be directly close. You can also wait for the send to complete before sending fin
Message, so is to be, fin and ACK hair developed to send.
Java Network programming three handshakes four times wave