Writing in the front

Previously we shared network layer protocol, TCP three-way handshake, and TCP four-way breakup. Today we’ll take a closer look at congestion control in TCP.

For TCP congestion control, there are a lot of details in the design, deer hope through this section can collate this part of the content, can let you more profound memory of this part of the content.

Mind mapping

What is congestion control?

Congestion control is an algorithm used to adjust the number of packets sent in a single transmission Control Protocol (TCP) connection. By increasing or decreasing the amount of a single transmission, it is gradually adjusted to approach the carrying capacity of the current network.

In simple terms, congestion control is, literally, like water in a pipe. If the water suddenly gets blocked by the loot of the pipe, then we should have a strategy for what to do with it when it gets blocked.

2. Why congestion control?

If the sender wants to send data to the receiver, a reply message is returned to the sender only when the receiver receives the data. If the receiving end does not send the reply message, the sending end considers that the data is lost and resends the data.

1. The packet is actually lost halfway.

2. The network communication is crowded, and the packet has not reached the receiver.

Our congestion control is mainly for the second case. If the network channel is always crowded, the sender will continue to send, becoming more congested and wasting network resources.

3. Test the network status

Before we carry out congestion control, we should first determine whether the network channel is blocked. Only when the network is blocked can we carry out congestion control. We usually test by sending multiple packets in succession to the network. During the test, if the packets are sent to a certain extent, the network communication will be blocked.

There are two ways to detect a network. The first way is to send packets incrementally, one at a time, two at a second time, three at a third time, and so on, always at a point where the network is congested.

The second case is exponential growth, as the name implies, is to send packets in the form of exponential growth, the first occurrence of one, the second send two, the third send four… There will also be times when the network will become congested.

However, one problem of the first method is that the growth rate is too slow. When congestion is reached, it takes a long time. This method of detection is inefficient.

When we use the second method, exponential growth tends to grow too fast and miss the point of growth.

Since both approaches have their strengths, let’s combine them. First we do exponential growth, we set a threshold, and then we hit a threshold, and then we increase and increase until we have network congestion.

The exponential growth phase is called slow start.

Successive increases are called congestion avoidance.

4. What is a congested window?

We call the window of how many packets can be sent at one time the congestion window.

We control congestion by controlling the size of the send window, that is, how many packets are sent.

5. Block timeout

When the number of packets increases to a certain extent, a timeout event (blocking) will occur. When a timeout event occurs, the network is considered congested and cannot continue to grow, which is marked as a maximum value M.

If we run out of time and start congestion control, what do we do? We lower the threshold for growth to half the size of M, which is M over 2. As shown in the figure below, the maximum value is 24 when congestion occurs, so the threshold is lowered to 12.

5. Determine the situation of sending timeout

As mentioned above, there are two cases of timeout. We use continuous ACK to determine whether the network is blocked or the network packet is lost.

As shown in the figure below, if a packet is sent, the receiver will return a response packet after successful reception, and then the sender will send the next packet again.

Once the sender loses the packet in the process of sending it, the receiver will return the acknowledgement response packet of the last received packet. When the sender receives three consecutive identical response packets, it indicates that the packet is lost and then quickly retransmits the packet.

Then we set our threshold value to half of the maximum congestion value M, and the size of the congestion window at this time is 1. When the size of the congestion window is equal to the threshold, the linear growth will be made. We also call this a quick recovery.

summary

TCP congestion control (TCP) How to do congestion control and how to determine the situation in the network.

Through congestion control, we can better carry out efficient transmission of data. In addition, we will update TCP traffic control in later articles, in order to make full use of traffic in the network.

❤️ Don’t forget to leave your learning footprints.

The article + animation wrote several hours, might as well like to support it. Hee hee, you don’t like that you are very selfish, you are afraid of so good articles let others see. Just a little joke.

You can pay attention to the deer public account: “Deer animation learning programming”, background reply: “resources”. Send you a deer before self-study information and pull you into the free study group oh!

The author Info:

【 author 】 : Deer

[original public account] : Deer animation programming.

[Introduction] : I learned programming from the ground up with Lu through animation, and presented the Web front-end field, data structure and algorithm, network principle and other easy-to-understand to my friends. First set a small goal, original 1000 animation technology articles, and your friends work together to learn together! Public reply “information” to send a from zero self-study information package!

[reproduced description] : reproduced please explain the source, thank you for your cooperation! ~