Analysis of TCP interactive data streams and block data streams

Source: Internet
Author: User

Analysis of TCP interactive data streams and block data streams there are many network protocols currently established on the TCP protocol, including telnet, ssh, ftp, and http. These protocols can be roughly divided into two categories based on data throughput: (1) interactive data types, such as telnet and ssh. In most cases, these protocols only exchange small traffic data, for example, press the keyboard to display some text. (2) Data is block type, such as ftp. This type of Protocol requires that TCP can carry data as much as possible, maximize the data throughput, and improve the efficiency as much as possible. For these two cases, TCP provides two different policies for data transmission. 1. TCP interactive data streams have high requirements on interaction. TCP provides two policies to improve transmission efficiency and reduce network burden: (1) routing with ACK. (2) Nagle algorithm (send as much data as possible at a time ). Generally, when the network speed is very fast, for example, using the lo interface for telnet communication, when the primary key is pressed and the ECHO is required, the client and server will go through the process of sending key data-> ack for sending key data on the server-> ACK for sending echo data on the server-> ack for sending echo data on the client, among them, the data traffic will be 40bit + 41bit + 41bit + 40bit = 162bit. If it is in the WAN, the TCP traffic of such small groups will cause a great network burden. 1. 1. when the host receives the TCP datagram from the remote host, it usually does not send the ACK datagram immediately, but waits for a short time, if there is a TCP datagram sent from the host to the remote host during this time, the ACK datagram "rst" will be sent out, and the original two TCP datagram will be integrated into one. Generally, this time is 200 ms. We can see that this policy can significantly improve the utilization of TCP datagram. 1.2.if the Nagle algorithm is used by bbs users, they may feel that they post messages when the network is slow. Sometimes, after a string is entered, after a period of time, the client suddenly shows a lot of content, as if the data was suddenly passed over, which is the role of the Nagle algorithm. The Nagle algorithm indicates that when host A sends a tcp datagram to host B and enters the status of ACK datagram waiting for host B, only one TCP datagram is allowed in the TCP output buffer, in addition, this datagram constantly collects subsequent data and integrates it into a large data packet. When the ACK packet of host B arrives, the data will be sent "in a brain. Although such a description is inaccurate, it is still an image and easy to understand. We can also appreciate the benefits of this policy to reduce the network burden. When writing a plug-in program, you can disable this algorithm through TCP_NODELAY. In addition, this algorithm is used to check the situation. For example, if the X Window Protocol Based on TCP still uses this algorithm when processing mouse events, the "latency" may be very high. 2. The block data stream of TCP has high requirements on the data throughput of FTP, so it will always hope to send as much data as possible to the other host each time, even if it is a little "delay. TCP also provides a set of policies to support such requirements. In TCP, 16 bits indicate the size of the window, which is the core of these policies. 2. 1. before interpreting the sliding window, you need to check the ACK response policy. Generally, if the sender sends a TCP datagram, the receiver should send an ACK datagram. But in fact, this is not the case. The sender will continuously send data to fill the receiver's buffer zone as much as possible, and the receiver only needs to send an ACK message to respond to the data, this is the cumulative feature of ACK, which greatly reduces the burden on the sender and receiver. 2. Sliding Window the sliding window essentially describes the data of the receiver's TCP datagram buffer size. Based on this data, the sender calculates the maximum amount of data that can be sent by himself. If the sender receives a TCP datagram whose window size is 0, the sender stops sending data and waits until the sender sends a datagram whose window size is not 0. P211 and P212 explain this point well. For the sliding window protocol, the book also introduces three terms: Window aggregation: when the window is close from the left to the right, this occurs when the data is sent and confirmed. Window Opening: when the right side of the window moves to the right, this phenomenon occurs after the receiver processes the data. Window contraction: this phenomenon does not often occur when the right side of the window moves to the left. TCP uses this window to slowly move from the left of the data to the right, and send the data in the window range (but do not send all, only data in the window can be sent .). This is the meaning of the window. Figure 20-6 illustrates this. The window size can be determined through socket. 4096 is not the ideal window size, while 16384 can greatly increase the throughput. 2. 3. the above policies of Data congestion can be used for LAN transmission, but problems may occur when used in wide area networks, the biggest problem is that a large amount of data congestion (congestion) occurs when the transmission encounters a bottleneck (for example, it must go through a slip low-speed link). To solve this problem, the TCP sender needs to confirm the maximum data throughput of the lines connecting both parties. This is the so-called congestion window. The principle of the congestion window is very simple. The TCP sender first sends a datagram and then waits for the response from the other party. After receiving a response, the sender doubles the size of the window and then sends two consecutive datagram packets, wait until the other party responds, and then double the window (first the exponential double of 2, to a certain extent, it will become the current growth, this is the so-called slow start), send more data packets, after a timeout error occurs, the sender learns the line bearing capacity of both parties, determines the size of the congestion window, and the sender sends data using the size of the congestion window. It is very easy to observe this phenomenon. Generally, when downloading data, the speed is slowly "Rushed". The above is the general process of TCP data transmission, although not meticulous, however, it is sufficient to describe the working principle of TCP, focusing on TCP traffic control principle, sliding window, congestion window, ACK cumulative confirmation and other knowledge points.

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.