TCP sliding window (send window and receive window)

Source: Internet
Author: User

TCP sliding window (send window and receive window)

TCP's sliding window mainly has two functions, one is to provide TCP reliability, and the other is to provide TCP flow control characteristics. at the same time, the sliding window mechanism also embodies the design idea of TCP for byte stream.

The TCP window is a 16bit bit field that represents the byte capacity of the window, that is, TCP's standard window is 2^16-1=65535 bytes maximum.

In addition, a TCP window enlargement factor is included in the TCP option field, Option-kind is 3,option-length 3 bytes, and the value range of Option-data is 0-14. The window enlargement factor is used to enlarge the TCP window, and the original 16bit window can be enlarged to 31bit.


Fundamentals of sliding windows

1) for the sender of a TCP session, any time in its sending cache data can be divided into 4 classes, "has been sent and received the ACK of the", "has been sent but not received the end of the Ack", "not sent but the end is allowed to send", "not sent and the peer is not allowed to send." the two parts of the data that have been sent but have not received an ACK and are not sent but are sent to the end are called the Send window (the middle two parts).

When a new ACK is received from the receiving party for subsequent bytes in the Send window, the window slides and the sliding principle is the same.

The window slides when ack=36 is received.

2) for TCP receiver, there are 3 kinds in its receive cache at a certain moment. "received", "not received ready to receive", "not received is not ready to receive" (due to ACK directly by the TCP stack reply, the default no application delay, there is no "received not reply Ack"). where "receive ready to receive" is called a receive window.


Send window relationship to receive window

TCP is a duplex protocol in which both sides of a session can receive and send data at the same time. Each side of the TCP session maintains a "Send Window" and a "receive window". The respective "Receive window" size depends on the application, system, and hardware limitations (TCP transfer rate cannot be greater than the data processing rate applied). The respective "Send window" requirements depend on the "receive window" advertised by the peer, which requires the same.


Sliding window for flow-oriented reliability

The most basic transmission reliability comes from the "confirm retransmission" mechanism.

The reliability of the TCP sliding window is also based on the "Confirm retransmission".

The Send window will move the left edge of the sending window only if it receives an ACK acknowledgment of the byte in the sending window for this paragraph.

The receive window moves the left edge only if all previous segments are confirmed. The window does not move and is not acknowledged for subsequent bytes when there is a previous byte that is not received but a subsequent byte is received. This ensures that the data is re-transmitted to the peer.


Flow control characteristics of sliding window

TCP sliding window is dynamic, we can imagine a common math problem in primary school, a pool, volume V, hourly intake of water V1, the amount of water V2. When the pool is full, it is not allowed to inject again, if there is a hydraulic system to control the size of the pool, then you can control the water injection rate and amount. Such a pool is similar to a TCP window. According to the change of its processing ability, the application of TCP receive window size control on the side to the terminal of the sending window traffic limit.

The application notifies the TCP protocol stack through the API to narrow the TCP receive window when it is needed, such as low memory. The TCP stack then includes a new window size notification to the peer when the next segment is sent, and a window to the notification to change the Send window to reduce the sending rate.

========================end========================

TCP sliding window (send window and receive window)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.