Tcp connection and disconnection diagram

Establishing a connection is very important, it is a prerequisite for the correct transfer of data; disconnection is also important, it allows the computer to release resources that are no longer used. If the connection cannot be disconnected normally, not only will the data transmission error be caused, but also the socket will not be closed, and the resources will continue to be occupied. If the concurrent amount is high, the server pressure is worrying.

It takes three handshakes to establish a connection, and four handshakes to disconnect. It can be compared to the following dialogue:

[Shake 1] Socket A: "The task is done, I want to disconnect."

[Shake 2] Socket B: "Oh, is it? Please wait, I am ready."

Waiting for a while...

[Shake 3] Socket B: "I am ready to disconnect."

[Shake 4] Socket A: "Okay, thank you for your cooperation."

The following figure illustrates the scenario where the client actively disconnects:

Tcp connection and disconnection diagram

After the connection is established, both the client and the server are in the ESTABLISED state. At this point, the client initiates a disconnect request:

1) After the client calls the close() function, it sends a FIN packet to the server and enters the FIN_WAIT_1 state. FIN is an abbreviation for Finish, which means that you need to disconnect when you complete the task.

2) After receiving the data packet, the server detects that the FIN flag is set, knows that it wants to disconnect, and then sends a “confirmation packet” to the client to enter the CLOSE_WAIT state.

Note: The server does not immediately disconnect after receiving the request. Instead, it sends a "confirmation package" to the client, telling it that I know it, I need to prepare to disconnect.

3) After receiving the “confirmation package”, the client enters the FIN_WAIT_2 state and waits for the server to prepare to send the packet again.

4) After waiting for a while, the server is ready to disconnect, so then send the FIN package to the client, telling it that I am ready, disconnect. Then enter the LAST_ACK state.

5) After the client receives the FIN packet from the server, it sends an ACK packet to the server, telling it that you are disconnected. Then enter the TIME_WAIT state.

6) After receiving the ACK packet from the client, the server disconnects, closes the socket, and enters the CLOSED state.

TCP establishment process (three-way handshake)

The so-called three-way handshake (Three-Way Handshake) means establishing a TCP connection, which means that when a TCP connection is established, the client and the server need to send a total of three packets to confirm the establishment of the connection.

Tcp connection and disconnection diagram

(1) First handshake: Client sets the flag SYN to 1, randomly generates a value seq=J, and sends the packet to the server. The client enters the SYN_SENT state and waits for the server to confirm.

(2) The second handshake: After the server receives the data packet, it is known by the flag bit SYN=1 that the client requests to establish a connection. The server sets the flag bits SYN and ACK to 1, ack=J+1, and randomly generates a value seq= K, and the packet is sent to the Client to confirm the connection request, and the Server enters the SYN_RCVD state.

(3) The third handshake: After the client receives the acknowledgment, it checks whether ack is J+1, whether the ACK is 1, and if it is correct, sets the flag ACK to 1, ack=K+1, and sends the packet. Give Server, Server check whether ack is K+1, and whether ACK is 1. If it is correct, the connection is established successfully. Client and Server enter ESTABLISHED state, complete three-way handshake, and then the client and server can start transmitting data.

Note: The serial number and acknowledgment number of the three-way handshake. If a handshake is indicated by (serial number, acknowledgment number), the sequence number and acknowledgment number of the three-way handshake are as follows:

1) Step 1: The client sends a synchronization data packet to the server to establish a connection. In the data packet, the initial sequence number (ISN) is a value randomly generated by the client, and the confirmation number is 0;

2) Step 2: After the server receives the synchronization request packet, it will perform a synchronization confirmation on the client. In this data packet, the serial number (ISN) is a value randomly generated by the server, and the confirmation number is the initial serial number of the client +1;

3) Step 3: After the client receives the synchronization confirmation packet, it will confirm the server. In the data packet, the serial number is the confirmation number value in the previous synchronization request packet, and the confirmation number is the initial sequence number of the server +1.

1, (X, 0)

2, (Y, X+1)

3, (X+1, Y+1)

Copper Cooling Tube

Copper Cooling Tube

[HIGH REFRIGERATION EFFICIENCY]Good heat dissipation and refrigeration capability,high strength at low temperature.Copper tubes are hollow,so has strong heat transfer capability.If you need refrigeration for refrigerators, freezers, air conditioners, this is a good choice

[COPPER MATERIAL]Copper refrigerator tube has the features of high temperature resistance, corrosion resistance, oxidation resistance, durability, long service life
[SOFT & SHAPE CHANGEABLE]Because refrigeration copper pipe can bend and deform, they can often be made into elbows and joints. Smooth bending allows copper tubes to bend at any angle
[WIDELY APPLICATION]Refrigerator Tubing is not only used for refrigerator, freezer and air conditioner as refrigeration tubing coil, but also used as a HVAC system pipe.

Condenser Copper Tube,Copper Cooling Tube,Copper Tube Air Cooling,Copper Cooling Fin Tube

FOSHAN SHUNDE JUNSHENG ELECTRICAL APPLIANCES CO.,LTD. , https://www.junshengcondenser.com