TCP sliding window with congestion window and a summary of various buffers

Source: Internet
Author: User
Tags ack socket

One: The sliding window is to accept the data side of the window size used to inform the sending side of the cache size, so as to control the sending side of the size of the sending data, so as to achieve the purpose of traffic control , corresponding ==>rwnd: Receiver window (receiver windows)

For flow control, it is an end-to-end concept. The Rwnd control returned by the receiving end.

Second: Then for the data is the sending end of the congestion window, congestion window does not represent the cache, congestion window refers to a source end of the data stream in a RTT can send the maximum number of packets, CWnd: Send side window (congestion windows).

Congestion control: Active control of the sending side of CWnd, with slow start (starting from CWnd initial 1 start, exponential start), congestion avoidance (reaching Ssthresh

, in order to prevent congestion from beginning to attempt linear growth), fast retransmission (receiver each received a message segment to reply to a current maximum continuous position confirmation,

As long as the sender receives three duplicate confirmations, it knows that the receiver drops the packet, quickly retransmissions the packet loss, and TCP immediately reduces the congestion window CWnd to

1), fast recovery (linear growth directly from Ssthresh).


Three: The sender window is mutually affected, as follows:

Upper value of Sender window = Min [Rwnd, CWnd]

When Rwnd < CWnd, it is the receiver's ability to limit the maximum value of the sender window.

When CWnd < Rwnd, the network congestion limit is the maximum value of the sender window.


The size of the TCP sliding window is actually the number of bytes of the socket's receive buffer size, which can be set with the upper setopt.


Five, for the server side of the socket must set the buffer size between listen, because, accept the newly generated socket will inherit the listener socket

The buffer size. For the client socket, be sure to set the buffer size before connet, as the connet requires a three-time handshake process,

will notify each other of their own window size. There is no point in setting the buffer after connet.


VI: Re-understanding of ACK, ACK is usually understood as a confirmation given after receiving the data ack,ack contains two very important information:


One is expected to receive the next byte ordinal n, which means that the receiver has received the first n-1 bytes of data, at this time, if the receiver receives the N+1 byte data instead of the nth byte data, the receiver will not send an ACK ordinal of n+2. For example, if the receiver receives 1-1024 bytes, it sends an ACK with a confirmation number of 1025, but then receives 2049-3072, which does not send an ACK with a confirmation number of 3072 and still sends a 1025 ACK.

The second is the current window size m, so the sender can calculate how many bytes of data can be sent after receiving the ACK, and assuming that the current sender has been sent to Byte X, the number of bytes that can be sent is y=m-(x-n). This is the basic principle of sliding window control flow

Focus: The sender receives an ACK from the expected number of the next byte ordinal N and Window m, as well as the currently sent byte ordinal x, to calculate the number of bytes that can also be sent.

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.