TCP's congestion control

1, congestion control

1.1, congestion

  At a certain time, if the demand for network resources over a portion of the available resources can provide, network performance will change, this is called blocking.

1.2 Congestion Control

  Injection to prevent excessive data among the network, this could make a link or a router in the network is not overloaded. In the sender maintains a virtual congestion window and use various algorithms to make it as close to the real point of congestion. (A mechanism by congestion window handle network congestion phenomenon)
  Premise network congestion control is able to withstand conventional current network load;
  Global congestion control is a process that involves all hosts, routers, and any reduction factors and related transmission performance;
  Difference congestion control and flow control: Flow control often refer to point traffic control, it is an end to end process; and congestion control to do is to control the transmission in the rate of transmission data, so that the receiving end too late received is a global of course;
  Congestion control requires access to information within the network traffic distribution. Before implementing congestion control, we need to exchange information and various commands between the node, and to select the control strategy implemented control. This results in additional overhead. Congestion control needs some resources allocated to each individual user, so that the network resources can be better shared.

1.3 congestion control mechanisms

 

1.4, congestion control method

  Slow start
  Congestion Avoidance
  Fast retransmit
  Fast Recovery

2, slow start

2.1, the algorithm principle

  When the host begins to transmit data, if a large amount of data bytes immediately injected into the network, then you may not know the current network load condition because of network congestion caused. Therefore, the best way is to look at the probe, i.e., gradually increasing from small to large transmission window, i.e., the congestion window is gradually increased from small to large values. Usually in the segment just sent, first the congestion window cwnd is set to a maximum value segment of the MSS packet. And after each receipt of a new acknowledgment message segment, the MSS increase up to a value of the congestion window. For example after receiving two packets sent a confirmation 2, the congestion window is increased 2 + 2 = 4, followed by a 4 + 4 + 8 = 16 = 8,8 ... ... This process is growing quickly but a very low base, the transmission speed is relatively slow, so called slow start (slow start) process. In this way gradually increase the congestion window cwnd sender, the packet can be injected into the network is more reasonable rate. (Slow Start among the "slow" does not refer cwnd increases slower, but at the start of the TCP segments sent to set cwnd = 1, so that just one sender transmits a segment at the beginning).
  When rwnd large enough, in order to prevent congestion window cwnd growth caused by network congestion, but also another variable ------ slow start threshold ssthresh.
  • When the cwnd <ssthresh when using the slow start algorithm;
  • When cwnd> ssthresh when, stop using the slow start algorithm, use congestion avoidance algorithm;

2.2, the limitations of slow start

  Need access to information within the network traffic distribution, waste available network capacity, the need for additional overhead;
  Not easy when estimating the fair value of ssthresh, it may take longer: 
    • Rwnd receiving side window, also known as the notification window (awnd), receiving end based on the latest value of the current window size of the reception buffer promised, a flow rate control from the receiving terminal.
    • Congestion window cwnd value of the transmission side is the window according to their estimated level of network congestion and set, the control flow is from the sender.
    • MSS is the maximum per data segment TCP packet can be transmitted, which does not include the TCP header. But only in the MSS among syn segment. In general the value of MSS in the case of non-segmented bigger the better (eg: an outgoing interface MTU MSS value is subtracted Minister of IP and TCP header)

3, Congestion Avoidance

3.1, the algorithm principle

  Let congestion window cwnd slow increase, per round-trip time RTT put through a congestion window cwnd plus 1 of the sender, instead of doubling, so the congestion window cwnd slow growth by linear law, growth slower start than the congestion window algorithm slow rate of more.
  Whether slow start algorithm or a congestion avoidance algorithm, as long as the determined network congestion, it should slow start half (> = 2) start threshold (ssthresh) configured to transmit window, CWnd is set to 1, then using the slow-start algorithm, this was done to quickly reduce the data transmission among the network, the router congestion occurs so that the completion queue can be accumulated in the packet processing. Congestion window is in accordance with the law of linear growth

3.2, the control process

  TCP connection initialization, the congestion window cwnd is set to one segment, i.e. cwnd = 1;
  Perform slow start algorithm, cwnd increase exponentially, until cwnd == ssthresh, begin congestion avoidance algorithm, cwnd begun to grow linearly in accordance with the law;
  When network congestion occurs, the updated value of ssthresh half cwnd value before congestion, cwnd is set to 1 again, and then begins a slow start algorithm;
  The picture shows the congestion control procedure is as follows:
  • When a TCP connection is initialized, cwnd = 1, ssthresh = 16;
  • When the slow start algorithm starts, CWnd initial value of 1, each time an ACK sender receives a congestion window is increased, when ssthresh == cwnd, starts congestion control algorithm, the congestion window to grow in a linear law;
  • When the cwnd = 24, the network timeout, the sender can not receive the ACK acknowledgment, this time provided ssthresh = 12, set cwnd = 1, then start the slow start algorithm, if cwnd = ssthresh = 12, congestion control becomes slow start algorithm algorithm, cwnd growth in a linear speed

3.3, AIMD (additive increase multiplicative decrease)

  Multiplicative decrease: in terms of the slow start phase or in congestion control phase, as long as the network timeout occurs, the cwnd is set to 1, ssthresh set to cwnd half, and then begin a slow start algorithm
  加法增大:当网络频繁出现超时情况时,ssthresh就下降的很快,为了减少注入到网络当中的分组数,而加法增大是执行拥塞避免算法后,是拥塞窗口缓慢的增大,以防止网络过早出现拥塞。
  这两个结合起来就是AIMD算法,是使用最广泛的算法。拥塞避免算法不能够完全避免网络拥塞,通过控制拥塞窗口的大小只能使网络不易出现拥塞。

4、快重传

4.1、算法原理

  一条TCP连接有时会因为等待重传计时的超时而空闲较长时间,慢开始和拥塞避免无法解决这类问题,因此提出了快重传和快恢复的拥塞控制方法。
  有时候网络拥塞很轻微,只有少量的包丢失。还有一些偶然因素,比如校验码不对,导致单个丢包。这两种丢包症状和严重拥塞时不一样,因为后续有包能正常到达。当后续的包到达接收方时,接收方会发现其Seq号比期望的大,所以它每收到一个包就Ack一次期望的Seq包,以此提醒发送方重传。当发送方收到3个或以上重复确认(Dup Ack)时,就意识到相应的包已经丢了,从而立即重传。这个过程称之为快重传。

4.2、算法过程

  快重传算法要求首先接收方收到一个失序的报文段后立刻发出重复确认,而不要等待自己发送数据时才进行捎带确认,如下图:
  在上图中,接收方成功的接受了发送方发来的M1,M2并且分别发送了ACK,现在接收方没有收到M3,而收到了M4,显然接收方不能确认M4,因为M4是失序的报文段。如果根据可靠性传输原理接收方什么都不做,但是按照快速重传算法,在收到M4,M5等报文段的时候,不断重复的向发送方发送M2的ACK,如果接收方一连收到三个重复的ACK,那么发送方不必等待重传计时器到期,由于发送方尽早重传未被确认的报文段。

5、快恢复

  采用快恢复算法时,慢开始只在TCP连接建立时和网络出现超时时才使用。
  当发送方连续收到三个重复确认时,执行“乘法减小”算法,慢启动门限减半,为了预防网络发生阻塞。
  由于发送方现在认为网络很可能没有发生阻塞,因此现在不执行慢启动算法,而是把cwnd值设置为慢启动门限减半后的值,然后开始执行拥塞避免算法,拥塞窗口cwnd值线性增大。
 
 

Guess you like

Origin www.cnblogs.com/Jummyer/p/11105981.html