TCP / UDP common problem face by

# TCP connection establishment process

1. The three-way handshake

Why should three-way handshake.

Shaking hands is to make both sides understand the sequence number of the data starts, but three times is to allow the two sides reached consensus on the minimum number of

Three-way handshake process:

1. The client sends (SYN = 1, ISN = A); // SYN_SEND

2. The server sends (ACK = 1, SYN = 1), (ack = A + 1, ISN = B); // this time, the server knows the client's sequence number, and notifies the client of this fact.

3. The client sends (ack = B + 1, seq = A + 1); // SYN-SEND-> ESTABLISHED, notification server, the client has to know the sequence number of the server.

After the three-way handshake, the client and server are guaranteed both sides know their serial numbers to each other, which is the beginning of the data transmission.

If two-way handshake:

1. The client (connected to the active side) is transmitted (SYN = 1, ACK = 0, seq = A);

2. The back end services (SYN = 1, ACK = 1, ack = A + 1, seq = B)

At this end, only the client is notified of their information has been known to the server, but the server can not know whether the serial number is known to the client.

If the four-way handshake

1. Client: (SYN = 1, ISN = A)

Server 2: (ACK = 1, ack = A + 1)

3. server: (SYN = 1, ISN = B)

4. The client (ACK = 1, ack = B + 1)

2 and 3 may significantly overlap.

 

Semijoin : The server receives no response from the client, not from SYN-RECEIVE-> ESTABLISH

1. The end of the service may be SYN-ACK lost.

2. The client might be missing ACK.

In this case, the server maintains a queue connection half, waiting for timeout retransmission.

 

2. Four waving

Assumption is that clients give up connection

1. Client: send FIN // FIN_WAIT

2. server: send ACK // CLOSE_WAIT, then, to understand the client service side has closed the connection

3. server: send FIN // LAST_ACK

4. The client: sending ACK // TIME_WAIT -> (After 2MSL) CLOSE

 

Half open and half closed:

Half-open: one end connected to the sudden closure of

Half-off:

Send the FIN A, B receives the ACK transmission, but does not continue to send the FIN B, A leads to not fully close the connection.

 

Why wait 2MSL

1. Prevention Service receives no ACK

2. Wait for duplicate data network disappears (MSL: MAX SEGMENT LIFETIME)

 

# TCP的Congestion Control

TCP to determine the transmission environment, Duplicate ACK Time Out, and two ways. Duplicate ACK occurs when the described transfer process, the individual packets do not reach the destination, need to resend. If the Time Out occurs, indicating that the network environment is very poor.

There are two important parameters in the TCP control congestion window of time, ssthresh (threshold), cwnd (window size).

When TCP Slow Start in stages:

Each receives an ACK, cwnd increases exponentially, that is, cwnd = (1,2,4,8 .....).

When cwnd> ssthresh, cwnd become a linear increase, that is, into Congestion Control stage.

Timeout occurs, or when DuplicateACK,

1. If the Tahoe: cwnd = 1, ssthresh = cwnd / 2.

2. If you are using Reno and is DuplicateACK, cwnd = cwnd / 2, that is, without the slow start phase, directly over to the Congestion Control.

 

Sliding window

To control the transmission rate of the TCP connection by controlling the size of the sliding window. According to network conditions, the size of the sliding window will change.

 

Guess you like

Origin www.cnblogs.com/AcodingDg/p/12447781.html