In this section, we introduce the basic situation of TCP reliable transmission, but we ignore the fact that transmission to the application layer also takes time. This section describes what this processing time brings and TCP’s solution
What is Flow control?
The application layer extracts data from the socket at the transport layer. However, the data will not be retrieved so fast. If the sender keeps sending data, it will overflow the RcvBuffer at the receiving end and the data will be invalidated.
PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC/PC
Need to pay attention to
Flow control has nothing to do with the congestion of the entire network, nor can it directly affect the congestion of the network
Two concepts related to the size of transmitted data
MSS: Max segment size: indicates the maximum length of data (excluding the header) that can be carried by each packet segment during TCP connection establishment. The MTU is the maximum amount of data that can be transmitted at the network layer. If the MTU is too large, the router will reject the packet forwarding because it cannot process too large packets.
Other problems encountered with flow control
Nagle’s algorithm
The speed at which humans send data is too slow compared to the speed of the network, so it is common to enter a packet and send it immediately
Nagle’s algorithm is an algorithm that solves this situation
- When you receive the first message, send it directly
- The remaining packets are sent when the size of the sender reaches MSS and the receiver sends an ACK saying it received the previous packet (there is at most one unacknowledged packet on the TCP connection)
As shown in the figure, HELLO is divided into two parts, where H is sent immediately and ELLO is sent in a packet, which is not continuous
You can find this algorithm in many applications, such as XShell
Idiot window syndrome
Silly Window Syndrome is another symptom.
- The app collects too slowly, the cache on the receiving end fills up quickly, and the application layer continues to collect one or two bytes at a time
- The commands that the receiver sends to the sender can only be told to send one or two at a time
- The problem with Nagle’s algorithm is that it transmits packets with little information, which makes the channel inefficient
The solution is usually very simple: wait for RWND to be larger and then notify sender!