Tcpip explanation note (19) persist Timer

Source: Internet
Author: User

Persist Timer

1. Reasons for using the persist Timer

Ack transmission is not reliable. TCP does not confirm ACK packets. TCP only determines which ACK packets contain data.

In this way, if an ACK is lost, the connection will be terminated because both parties wait for each other: the receiver waits for receiving data (it has advertised a non-zero window ), the sender is waiting for a window update that allows it to continue with the data.

2. persist Timer: the sender uses a persist timer to regularly query the receiver for increasing the window size. These packets sent from the sender are called Window probes. Window probing contains one byte of data, that is, the serial number. These probes are sent every 60 s until the window is opened or the connection is terminated.

3. Confused window syndrome

The emergence of confused window syndrome

Consider the following two situations:

(1) The recipient's application reads data slowly, and reads only one byte at a time.

As you can imagine, soon the receiver's cache is filled up, so the [Window advtisement] In the return window was announced: It is full. Do not send it.
Next, the application slowly reads 1 byte, And the cache is free of one byte. The cheerful re-sending window announcement says: one byte is available. Come and fill me up.
The sender receives a notification to generate and transmit only one byte of data.
Then, repeat.

Obviously, this is not good and the efficiency is too low. generally, the header size of a TCP packet is at least 20 bytes. The result is only a little bit of data. The header is processed (checksum calculation, stream serial number reading, and data extraction ), encapsulation of IP data packets and corresponding unblocking should be followed by a line, which is actually very efficient.

(2) The sender's application program produces slow data. One byte and one byte at a time may also cause efficiency problems.

Prevention and treatment of confused window syndrome

(1) receiver
A. ack is returned for each incoming TCP packet, but I will not report the size of the window before the window size is increased to the specified size, so as not to send a 1 byte back, send a message if you want.
B. Alternatively, delayed ack transmission does not necessarily return ack to every TCP Message, but waits for a moment after each message arrives.

Adventage:
1. reduce transmission traffic. An ACK may reply to multiple messages without having to reply one by one.
2. Piggyback. When the receiver needs to send back data after receiving the data, it can include [piggyback] ack in the TCP Message of the data delivery, which also reduces network traffic.
3. window notice [Window advertizement] is issued only after the data is read in the buffer zone. This delay is due to the arrival time of the corresponding message, the delayed ack sending may wait for the window size to change, and the two may send back (piggyback?) together ?), It also reduces data traffic.

Disadventage:
1. the retransmission time is estimated based on the return time. the ack latency policy affects the determination of reasonable retransmission time. It would have arrived in one second. The delay setting time is too exaggerated. After ten seconds, the transmitter here will say that, it will take 15 seconds. If it is less than 15 seconds, even if your message is lost, the direct result will be slow response. If it is normal, it will take 5 seconds to determine the loss. It will take 15 seconds, it's hard to wait...
2. in addition, the delay time is too exaggerated. The most direct result is the sender and so on. If I don't wait, I simply re-transmit the message (in fact, the message arrived early, but I didn't send it back for confirmation ), this adds unnecessary retransmission and increases the network burden.

Solve:
The corresponding solution is very simple. Since the delay time is too exaggerated, I will set a maximum delay time. The recommended solution is 0.5 seconds.

(2) sender
Imagine that in order to avoid transmitting small data packets, TCP can wait for a while and send them together after the data is accumulated. Well, the idea is good, but how long does it take?
0.5 seconds? 50 seconds?
The key is that TCP responds to a variety of attacks, such as human beings, fast-typing people, and slow-typing People Who typed one word in half an hour, it is a File Transfer of 5 Mb/s .....
For a person, 0.5 seconds is too short, and the file transmission time is too long. Therefore, the selection of time is a problem.

Think of an adaptive strategy.

1. for those who are slow in typing, do not forcibly expect that each newspaper carries a large amount of data. Otherwise, the application may be too late. I may not have 20 bytes to write a line on QQ, as a result, you forced me to send bytes to you. I am not very depressed. therefore, in this case, it is ideal to send packets in a timely manner. The network Ack is fast compared to the person's speed, so whenever ack arrives, I will send the next datagram, ignore whether or not the packet data has reached a certain size (this does not improve the transmission efficiency, but the program, of course, the user experience is the first, a small sacrifice of efficiency is also worth dropping ).
2. What about large transmission users, such as file transfers?
It's too slow to send another packet, wait for ACK, and then send another packet. Hey, I am writing at a speed of 10 Mb/s, so I should despise ack, as long as the buffer zone data is written to the largest packet, it will be sent immediately without waiting (of course, you still have to follow the Sliding Window restrictions, guess, to be confirmed ).
The policy compatible with the above two situations is born:

1. For the first piece of data received from the application, the sender's TCP sends it directly, even if there is only one byte.
2. After that, the sending end accumulates data in the output cache and waits for a confirmation from the TCP sending at the receiving end, or the data has accumulated to a maximum packet segment. Both of them meet the requirements. The TCP at the sending end can send this packet segment.
3. Repeat Step 2 for the remaining transmission. This is: if you have received confirmation of the packet segment X, or the data has been accumulated to form the largest packet segment, then the next packet segment (x + 1) will be sent ).

Refer:
TCP/IP details
Http://mmliu.iteye.com/blog/686658

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.