NetEase Mianjing: Do you understand the flow control and congestion control of the TCP protocol?

TCP (Transmission Control Protocol, Transmission Control Protocol) is a connection-oriented, reliable, byte stream-based transport layer communication protocol defined by RFC 793 of the IETF. TCP provides functions such as full-duplex communication, reliable data transmission, and congestion control, and is suitable for application scenarios such as the Internet. TCP is located in the network layer of the OSI seven-layer protocol model, and together with the User Datagram Protocol (UDP), it constitutes the transport layer protocol.

TCP controls network traffic through congestion control and flow control. Congestion control ensures that the network will not be congested due to excessive data transmission, while flow control ensures that the sender will not send too much data that the receiver cannot process.

  1. Congestion control:

The main goal of congestion control is to avoid network congestion caused by excessive data transmission. To this end, TCP uses an algorithm based on the congestion window (Congestion Window) to achieve congestion control.

When sending data, the congestion window is a value that limits the data sending rate, and it can be adjusted dynamically. On the sending side, TCP uses congestion windows to control the amount of data sent each time. If the network is congested, TCP will halve the congestion window and suspend sending data. When the network becomes smooth, TCP will gradually increase the congestion window until it reaches the original value.

  1. flow control:

The main goal of flow control is to ensure that the sender does not send too much data for the receiver to process. To this end, TCP uses a sliding window (Window) algorithm to achieve flow control.

When receiving data, the receiver sends a notification to the sender, telling the sender how much data it can send. This notification is called the "Receiver Window". The sender will control the rate of sending data according to the size of the receiving window to prevent the receiver from being unable to process it. If the amount of data sent by the sender exceeds the size of the receive window, the receiver discards some data and notifies the sender to reduce the sending rate.

The advantage of the TCP protocol lies in its reliability, stability and connection-oriented characteristics. TCP realizes the control of network flow through congestion control and flow control, avoiding problems such as network congestion and packet loss caused by excessive data transmission. In addition, TCP also provides a reliable data transmission mechanism, including confirmation mechanism, retransmission mechanism and congestion control mechanism, etc., to ensure the integrity of data. These advantages make TCP the preferred transmission protocol in application scenarios such as the Internet.

The disadvantage of the TCP protocol lies in its relatively slow transmission speed and the characteristics of occupying high system resources. Since TCP is a connection-oriented protocol, a connection needs to be established before data transmission, which consumes a certain amount of time and resources. In addition, in the process of congestion control and flow control, TCP needs to be constantly controlled and adjusted, which also consumes a lot of time and system resources. Therefore, in some application scenarios that require high transmission speed, TCP may not be the best choice.

Guess you like

Origin blog.csdn.net/u010986241/article/details/130916462