Animation: How to answer the interviewer's question about TCP congestion control?

Animation: How to answer the interviewer's question about TCP congestion control?

Previously, we shared the network layering protocol, TCP three-way handshake, and TCP four-way handshake. Today, we will continue to share in depth the congestion control in TCP.

There are many details involved in the design of TCP congestion control. Xiaolu hopes that this section can connect these contents together and help you remember them more deeply.

Mind Map

1. What is congestion control?

Congestion control is an algorithm used to adjust the number of packets sent at a time in a Transmission Control Protocol (TCP) connection. It gradually adjusts the number of packets sent at a time to approach the current network capacity by increasing or decreasing the amount of packets sent at a time.

To put it simply, the so-called congestion control, literally speaking, network communication is like water in a pipe. If the water is suddenly blocked by dirt in the pipe, then we should adopt certain strategies to deal with the blockage.

2. Why do we need congestion control?

If the sender wants to send data to the receiver, the receiver will return a response message to the sender only when it receives the data. If the receiver does not send a response message, the sender considers that the data has been lost and resends it.

In fact, we don't know whether the receiving end has received it. At which step did the data packet have a problem? There are two situations, as follows:

1. The data packet is really lost along the way

2. The network communication is in a congested state and the data packet has not yet reached the receiver.

Our congestion control is mainly aimed at the second situation. If the network channel is always congested, the sender will continue to send, which will become more congested and waste network resources.

3. Test network status

Before we perform congestion control, we must first determine whether the network channel is blocked. Only when we determine that the network is blocked can we perform congestion control. We usually test by continuously sending multiple data packets to the network. During the test, if the number of data packets sent reaches a certain level, the network communication will be blocked.

There are two ways to detect the network. The first is to gradually increase the number of data packets. Only one data packet is sent at a time, two at the second time, three at the third time, and so on. There will always be a point where the network is congested.

The second situation is exponential growth. As the name suggests, the number of data packets sent increases exponentially. The first time, one is sent, the second time, two are sent, the third time, four are sent... At some point, the network will be congested.

However, the first method has a problem that it grows too slowly. When congestion occurs, it takes a long time, and this detection method is too inefficient.

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

Since both methods have their own advantages, we will combine the two methods. First, we perform exponential growth. We set a certain threshold, and then after reaching the threshold, we continue to increase it step by step until network congestion occurs.

  • The exponential growth phase is called slow start
  • Congestion Avoidance

4. What is the congestion window?

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

We perform congestion control by controlling the size of the send window, that is, the number of data packets sent.

5. Blocking timeout

When the data packet grows to a certain size, a timeout event (blocking) will occur. When a timeout event occurs, it is considered that the network is congested and cannot continue to grow. At this time, it is marked as a maximum value M.

If we start congestion control after the timeout, what should we do? We reduce the growth threshold to half the size of M, that is, M/2. As shown in the figure below, the maximum value is 24, and congestion occurs at this time, so the threshold is reduced to 12.

Some friends said that your timeout does not necessarily mean blocking. You also mentioned above that data packets may be lost. How do you judge this situation?

6. Determine the sending timeout situation

As we said above, there are two situations of timeout. We use the method of continuously sending ACK to determine whether the network is blocked or the network data packet is lost.

As shown in the figure below, if a data packet is sent, the receiving end will return a response data packet after successfully receiving it, and then the sending end will send the next data packet again.

Once the sender loses a data packet while sending it, the receiver will return a confirmation response packet of the last received data packet. When the sender receives three identical response packets in a row, it means that the data packet is lost, and then the data packet is quickly retransmitted.

Then we set our threshold to half of the maximum congestion value M. At this time, the size of the congestion window is 1. When the size of the congestion window is equal to the threshold, it will increase linearly. We also call the above situation fast recovery.

summary

Today I mainly shared TCP congestion control. Why is there congestion control? How to perform congestion control and how to judge the situation in the network.

Through congestion control, we can better transmit data efficiently. In addition, our subsequent articles will also update TCP flow control in order to make full use of the traffic in the network.

<<:  In the 5G era, industry market users’ choice of public network or private network

>>:  MPLS Multi-Protocol Label Switching is a must-have network technology for carrier backbone networks. Learn more in one minute

Recommend

Detailed explanation of several wireless transmission modes!

1. Access Point (AP) In this mode, the wireless n...

What stage has IPv6 reached now? How to upgrade to IPv6?

Since Jon Postel defined IPv4 in RFC791 in 1981, ...

WiFi 7 is here. What are the improvements compared to WiFi 6?

WiFi 7 has become one of the hottest topics, espe...

We will bear the consequences of irresponsible criticism of operators.

There was a problem with the telecom broadband at...

What is the difference between a free SSL certificate and a paid one?

With the popularity of SSL certificates, CA agenc...

5G: A game changer on the factory floor

Driven by the Internet of Things, global manufact...

F5 security experts talk about DevSecOps: security by design

If someone asks, "What is changing the techn...