And four three-way handshake TCP waved issues you must know, the point I jump
1. Sliding Window
Data transfer process in case the recipient is receiving too late may occur, then you need to control the sender to avoid data loss. Can easily control the flow rate in the TCP sender is connected using a sliding window mechanism. TCP window in bytes, not the segment, the sender the transmission window can not exceed the value of the receiving window of the receiver are given.
Since TCP is set to zero even if the window must be received following segments:
Zero window probe segment
Carry emergency data segment
Missing Acknowledge and confirm late
There is a case where: the transmitting side after receiving a zero window packets send window is set to 0, stops sending data. However, when the recipient has enough cache, it sends a message of non-zero window size, but the way the message is lost, then the sender’s window has been sent to 0 lead to deadlock.
For this reason, TCP is a connection each has a duration timer (Persistence Timer): When the other party TCP connection to receive notice of zero window timer starts continued. If the duration time of the timer expires, sends a zero window probe segment (carrying a byte of data), then the one that receives the message segment in the acknowledgment segment is given when the probe is now reported window value. If the window is still zero, the party receiving this segment would continue to reset the timer; if the window is not zero, then the deadlock deadlock can be broken.
2. Delayed ACK
If TCP sends an acknowledgment ACK for each data packet, then only a single ACK packet to the cost of a high transmission, TCP will delay a period of time, if the peer has data to send this time, the transmitted piggyback ACK, ACK timer is triggered if the delay time, find ACK has not been sent, then immediately sent separately;
Delayed ACK benefits:
Avoid silly window syndrome.
When the transmission data transmitted piggyback ACK, without sending ACK alone. If there are multiple data segment arrives, the transmission protocol stack allows a plurality of segment acknowledgment ACK delay time. Reduces data usage.
Silly window syndrome: TCP receiver buffer is full, the interactive application process only once read 1 byte from the receive buffer (so that the space vacated only 1 byte receive buffer), and then send to the sender confirmed, and the window is set to 1 byte (but datagrams is 40 bytes words). When the sender has sent one byte of data (IP packet sender is 41 bytes), the receiver sends back an acknowledgment, the window remains set to 1 byte. Thus, the efficiency of the network is very low. To solve this problem, allowing the recipient to wait for some time, making or receiving buffer has enough space to accommodate one of the longest segment or wait until the recipient cache than half of the free space. As long as there both cases, the receiver will send back an acknowledgment message, and notifies the sender of the current window size. In addition, the sender can not send a small segment, but the data packet is accumulated sufficiently large segment, or up to half the size of the receiver buffer space.
Congestion difference between control and flow control:
Congestion control to prevent excessive injection of data into the network, routers in the network can be made or the links is not overloaded, it is a global process.
Flow control is the traffic control point, end to end is a problem mainly to suppress the transmission data rate of the transmitting end, the receiving end too late to the reception.
Congestion control action
Congestion control is to prevent excessive injection of data into the network, this could make the network router or link against overload.
Congestion control algorithm
We assume that:
Data transfer in one direction, the other direction only transmit a confirmation.
The recipient is always a large enough buffer space, because the size of the send window is determined by the degree of network congestion.
Upper limit value of the transmission window of the sender should be taken as a receiver window and the congestion window cwnd rwnd these two variables in a smaller, i.e., the upper limit value of the transmission window Min [rwnd, cwnd]
Congestion control process involving a total of four algorithms:
1. Slow Start
The sender maintains a congestion window cwnd state variables, the congestion window size depends on the congestion level of the network change dynamically. By gradually increasing the size of cwnd is to detect the available network capacity, preventing an inappropriate amount of transmission connection start time and network congestion.
When the host begins to transmit data, if the large transmission window by all data bytes are immediately injected into the network, since the network condition is not clear, it may cause network congestion. A better approach is tentative, cwnd value increases gradually from small to large end of the transmission of the congestion window.
For example: to set the sender starts cwnd = 1, transmits the first message segment M1, the recipient receives the M1, returns the ACK to the sender, the sender will cwnd increased to 2, then the sender transmits M2, received again ACK cwnd will increase to 4 … after a slow start algorithm for each round transmission congestion window cwnd will be doubled.
When rwnd large enough to prevent congestion window cwind growth caused by network congestion, but also another variable, the slow start threshold ssthresh
First slow start ssthresh value, you can see a variety of online discussion of the limited space, this article is not introduced ~
2. Congestion Avoidance
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, start congestion avoidance algorithm, cwnd increase linearly law
When blocking occurs in the network, the congestion ssthresh cwnd value is updated to the front half (12 = 24/2), cwnd is set to 1 again, and then performed in (2)
Let congestion window cwnd increases slowly, each through a round-trip time RTT put the sender’s congestion window cwnd + 1, instead of doubling. Such congestion window cwnd linearly slow growth, the growth rate is slower than the congestion window algorithm start slowly and more.
Whether slow start at the beginning or congestion avoidance phase, as long as the sender to determine the network congestion (not received ACK), put the slow start is half cwnd when the congestion threshold ssthresh set. Then the congestion window cwnd is reset to 1, execute slow start algorithm. The aim is to quickly reduce the transmission of data to the network host, so that the router of congestion can be accumulated in the packet queue is finished processing. Congestion window is in accordance with the laws of linear growth, much faster than the slow start algorithm congestion window growth.
Congestion avoidance is pulled down by the exponential growth to linear growth, may reduce congestion, not completely avoid network congestion
3. fast retransmit
Sometimes because of a TCP connection waits for the retry timer and idle a long time, the slow start and congestion avoidance can not be a good solution to this problem, and therefore proposed a congestion control method fast retransmission and fast recovery.
To make the sender as soon as possible to know the message did not reach the other side, the fast retransmit algorithm first asked each recipient receives a segment immediately after issuing a duplicate acknowledgment. Fast retransmission algorithm is not canceled retransmission mechanism, but in some cases earlier retransmission of lost segments. That is, when the TCP source receives three identical acknowledgment ACK, i.e. that a packet is lost, the source retransmits the lost data packet, without having to wait RTO (Retransmission Timeout) timeout. Because the sender as soon as possible retransmit unacknowledged segments. Therefore, the use of the fast retransmission of the entire network throughput can be increased by 20%
Fast retransmit algorithm requires first the receiver receives a disorder of the segment immediately after issuing duplicate acknowledgments, rather than waiting to send data only when piggybacking themselves. The recipient successfully received the M1 sender sent, M2 and respectively to send the ACK, now the recipient does not receive the M3, and received the M4, obviously the recipient can not confirm the M4, because the M4 is a disorder of the segment. If the recipient does not do anything based on the principle of transmission reliability, but in accordance with ACK fast retransmit algorithm, the receipt of M4, M5 and other segments of time, repeated sending M2 to the sender if the recipient received a row three duplicate ACK, then the sender without waiting for the retransmission timer expires, as soon as possible because the sender retransmit unacknowledged segments.
4. Fast Recovery
Fast recovery algorithm control process:
When the sender received three consecutive duplicate acknowledgment, the sender believes is the network congestion may not occur, and therefore do not perform slow start. But the cwnd value to a new threshold value, then the implementation of congestion avoidance algorithm, cwnd value increases linearly, avoiding the use of “slow start” algorithm when network congestion is not caused serious phenomenon too greatly reduce the send window size this is fast recovery.
Finally, my experience is limited to a limited level, readers are welcome valuable suggestions and comments on the text of the opinion. If you want to get more resources or want to learn more and exchange of technology enthusiasts together, I can focus on the public number “whole food engineer Xiaohui,” replies the background Keywords receive learning materials, into the front and back end technology exchange group and program members sideline group. Programmers also can join the group sideline Q group: 735 764 906 with the exchange.