Some knowledge of TCP

1. The three-way handshake, waving four

Detailed view: https://www.cnblogs.com/amiezhang/p/6703390.html

2. ARQ protocol

  ARQ retransmission timeout mechanism is divided into two kinds: Stop and Wait ARQ continuous ARQ

Stop and wait ARQ:

  A long period of sending messages to B, must stop transmitting and starts a timer and wait for the end of the response, received peer response to cancel the timer and sends the next packet within the period of time the timer.

  General timer set time will be greater than the average time of a RTT.

Continuous ARQ:

  If stop and wait ARQ, it is in a too inefficient. Each transmission request, a response will need to wait on.

  In continuous ARQ, the transmit end has a transmission window, the data can be continuously transmitted within the window in the case where no response is received, so compared to the stop and wait ARQ protocol can reduce waiting time and improve the efficiency.

  By cumulative confirmed that a reply can be unified response message, the flag can be used to tell the sender of the data before the numbers have all been received after receiving multiple messages.

  Cumulative confirmed also has a downside. In continuous receive messages, you may experience after receiving the packet sequence number 1, does not receive the packet number 2, number 3 but after the message has been received. When this happens, only respond to the ACK 2, this will result in the case of the transmitting side repeatedly transmits data.

3. Slide the window

  This window is a window continuous ARQ mentioned above, the window is not only the transmitting window, and receive window.

  The transmitting end is determined by the window size of the reception window remaining. Receiver will receive window size of the current remaining write response packet sender receives a response after transmitting window disposed according to the value and size of the current network congestion, the size of transmitting window is constantly changing.

Zero window

In the process of sending messages, you may encounter zero window that appears to end. In this case, the sender stops sending data and starts persistent timer. The timer periodically sends a request to the peer so that the peer inform the window size. After more than a certain number of retries, TCP may break the link.

There are four sliding window congestion handling algorithms, namely: slow start, congestion avoidance, fast retransmit and fast recovery.

Slow start algorithm

Slow start algorithm, by definition, will be sent when the transfer window slowly began to expand exponentially, thus avoiding the outset transmit large amounts of data lead to network congestion.

  1. Initial connection setting a congestion window (Congestion Window) is 1 MSS (maximum amount of data in one segment)
  2. Each had a window size multiplied by two RTT will
  3. Exponential growth is certainly not without limit, so there is a threshold limit, when the window size is greater than the threshold value will start congestion avoidance algorithm.

Congestion Avoidance Algorithm

Congestion avoidance algorithm compared to a simple point, with every passing RTT plus a window size only, so to avoid the exponential growth of network congestion, slowly adjust the size to an optimum value.

During transmission case might timer expires, the TCP would think that this time the network congestion, will immediately carry out the following steps:

  • The threshold is set to half of the current congestion window
  • The congestion window to 1 MSS
  • Start Congestion Avoidance Algorithm

Fast retransmit

Fast retransmission and fast recovery usually appear together. Once the situation appears out of sequence packets received by the receiving end, the receiver will only respond to a final order of the correct message number. If the sender receives three duplicate ACK, without waiting for the timer expires but directly start the fast retransmit algorithm.

Guess you like

Origin www.cnblogs.com/amiezhang/p/11521251.html