Free to talk about tcp

As tcp to four reliable transport protocol that provides a reliable byte stream to transport the upper layer protocol is made possible by reliable mainly because of the following:

1, stream segment: i.e. byte stream flow, typically in bytes, the computer processing program, if the upper layer protocol of the received byte stream is transmitted with the same time and order byte stream that will be very comfortable. But a large number of bytes are stuffed into a stream of packets transmitted will be some problems, to the network device has its own maximum transmission unit, if the message exceeds the transmission unit will be discarded, it will be transmitted to the tcp byte stream segment transmission.

2, the response: each piece will have a serial number, the receiving terminal will be received by the packet sequence number by 1 in accordance with the number (as will be appreciated that the next sequence number expected to be received) response.

3, and the sliding window flow control: IP packet transport layer is not order-preserving, which leads to a rear segment may tcp First, such as the sender sends 12,345 segments packets, the receiving end order may be received in 12543, and a method for preserving order at the receiving end, is a very easy in the order received, in the order of arrival is not directly discarded packets, relying on retransmission, such as the example described above, after receiving the received 12 packets, received a 5, was found not in order, directly discarded, and then received 4 also lost, and then receives three, like 4 to retransmit received, then five, so you can achieve protection Preface to the requirements, but a lot to lose packets, retransmission results in lower efficiency. At the other extreme the idea is to not follow the order to buffer the packets until all the packets are received and then sent to the upper layer protocol, but this is also a problem, just do not know how many on the device but did not order packets, so are cached locally, then do not know how much memory will be used. So there is a compromise --- sliding window, sliding window can be understood cache. Beyond the cache was lost, and so on receipt of a report on a shelf in the cache.

    In fact the sender and recipient are sliding window, sliding window of the sender can be understood as limiting the speed of sending packets, if only in the recipient cache, and the sender is not restricted, will result in a large number of packets in the buffer In addition, a waste of resources.

The sender sliding window:

 offered window to the overall size of the sliding window can be divided into the following two parts sent but not received and a response section for transmitting to the section.

Sliding Window recipient:

 

The receiving side of the sliding window with respect to the sender of a plurality of sliding window "Received; ACKed; Not Sent to Proc" section, the recipient receives the text stream read process must wait. If the process is busy doing something else, then the text flow even though they have the right to receive, or to temporarily occupy the receive buffer. But the other is already receiving portion and unused but not enough time to answer.

Now there is a problem, the sender of the sliding window should be set much? This is in fact the message interaction in the notification by the recipient, the recipient receives according to their ability to inform the sender own desired window size. Thus by adjusting the size of the window also functions as a natural flow control purposes.

4, the retransmission packet loss: each segment will be received after receiving the acknowledgment. It starts a timer after the sender sends the message, if the timer expires have not received this reply, the packet loss is considered, it will be retransmitted.

5, congestion control: that restrict their behavior in essence, found that reducing network congestion when his speed to send messages, find the network is not congested is more transmitters text. The sender has its own congestion window, the window will be adjusted in accordance with the stopper algorithm.

Guess you like

Origin www.cnblogs.com/bewolf/p/10960462.html