TCP Congestion Avoidance

TCP Congestion Avoidance

Congestion control is to prevent excessive injection data network, this could make a link or a router in the network is not overloaded. Congestion control is a different process global, and flow control, flow control refers to control point traffic.

Timeout retransmission mechanism

Timeout retransmission mechanism is to solve the packet loss during transmission problems.

Each TCP sends a segment, it will open a timer for this segment, still have not received a response packet receiving end if the timer expires, it is considered that TCP segment is lost during transmission, then resend this segment. This is the timeout retransmission mechanism

Example: The client sends a request "and hi" to start the timer segment, but did not receive a reply to end within the specified time, so re-send "and hi" segment, and restarts the timer (restarting timer will increase).

Congestion Control

Retransmission timeout to solve data loss problems, but the cause of data loss due to transmission path is a great program due to congestion.

In the normal transmission process, the data is skip to the next router from a router, each router has its own buffer, the new data will be stored in the buffer, while the router is continually buffer the data is sent to the next router. However, if the rate of the reception data rate of a router is greater than the transmission data, resulting buffer data is accumulated, eventually fill the buffer. At this time, if another data arrives, the buffer has been unable to accommodate them, they can only lose, loss of data, which is called the congestion, essentially nodes on the transmission path imbalance. To solve this problem, we need to immediately reduce the amount of data when the sender sends when congestion, provide time to empty the buffer for some of the nodes on the path, while avoiding unnecessary retransmissions.

But how can we know the sender congestion occurs on the network yet. Because since the data loss caused by a hardware error is very rare, so the sender assumes that, if the data loss, it can be identified congestion occurs.

Maintaining sender called congestion window cwnd (congestion window) state variable. Congestion window size depends on the degree of network congestion, and dynamically changing. So that the sender window is equal to its own transmission congestion window, while taking into account the reception capability of the recipient, the transmission window is smaller than the congestion window.

Slow Start

Slow start algorithm is thinking, do not start sending large amounts of data, to detect what level of network congestion, that is to say from small to big gradually increase the size of the congestion window.

Slow start algorithm exemplified herein, real-time congestion window size in bytes of the congestion window size with the number of packet segments.

As shown below:

Of course, a single acknowledgment is received but the acknowledgment packets when the plurality of data added to the corresponding value. So after one round of transmission congestion window is doubled. This is an increase of multiplication, addition and the subsequent growth of congestion avoidance algorithm comparison.

In order to prevent cwnd growth caused by excessive network congestion, the need to set a slow start threshold ssthresh state variables. ssthresh is used as follows:

当cwnd<ssthresh时,使用慢开始算法。

当cwnd>ssthresh时,改用拥塞避免算法。

当cwnd=ssthresh时,慢开始与拥塞避免算法任意。

Congestion Avoidance

Congestion avoidance algorithm allows the congestion window slow growth, that is, each through a round-trip time RTT put the congestion window cwnd sender plus one, instead of doubling. Such congestion window linearly laws slow growth.

Whether in the slow start phase or in the congestion avoidance phase , as long as the sender to determine the network congestion (which is based on acknowledgment is not received, although no acknowledgment packet may be lost for other reasons, but because it can not determine, as are so congested to deal with), put the slow start threshold is set to appear half the size of the send window when congestion. Then the congestion window is set to 1, the slow start algorithm execution.

As shown below:

Here again, for convenience only alert discussion of the congestion window size to the number of units of data packets, bytes actually should be.

Fast retransmit

Fast retransmission requirements issued by the recipient immediately repeated confirmation (in order to enable the sender to know as soon as possible segment does not reach the other side) and not wait until piggybacking send data himself after receipt of a disorder of the segment. Fast retransmission algorithm specifies, as long as the sender receive three consecutive duplicate acknowledgments should immediately retransmit the other segments have not yet received, rather than continue to wait to set the retransmission timer time expires.

As shown below:

Fast Recovery

快重传配合使用的还有快恢复算法,有以下两个要点:

  • 当发送方连续收到三个重复确认时,就执行“乘法减小”算法,把ssthresh门限减半。但是接下去并不执行慢开始算法。

  • 考虑到如果网络出现拥塞的话就不会收到好几个重复的确认,所以发送方现在认为网络可能没有出现拥塞。所以此时不执行慢开始算法,而是将cwnd设置为ssthresh的大小,然后执行拥塞避免算法。

如下图:

与流量控制区别

TCP有一个叫做流量控制的机制,它与拥塞控制非常相似,但是仍然有一些差异

  • 流量控制是端对端的控制机制,两端各自通知对方允许的窗口大小以防止对端发送过多数据导致自己来不及处理造成接收缓冲区被填满
  • 拥塞控制不是端对端的控制机制,它是为了缓解从一端到另一端这条路径上的拥堵问题

不过二者都是通过限制发送方发送的数据包个数来解决问题,所以上述算法无非就是降低发送端发送速率,缓解网络压力。

参考

TCP的拥塞控制

TCP/IP学习笔记(四)TCP超时重传及拥塞控制

浅谈 TCP 拥塞控制算法

TCP拥塞控制算法 优缺点 适用环境 性能分析

TCP拥塞控制ABC(Appropriate Byte Counting)的利弊说

Guess you like

Origin www.cnblogs.com/hongdada/p/11206679.html