TCP transport protocol in how to solve the problem of packet loss

TCP transport protocol in how to solve the problem of packet loss

TCP reliable transmission over an unreliable network, there must be a loss. TCP is a "flow" agreement, a detailed TCP packet will be split into several packages upload, will also upload the small package into large, which means that TCP stick package and unpacking problems.

But many people have different interpretations. TCP protocol itself to ensure the integrity of data transmission is not lost. If it is found during transmission of data loss or packet loss, is most likely a problem in the process of transmitting or receiving the program.

TCP transport protocol in how to solve the problem of packet loss

For example, the server sends large amounts of data to the client, and the transmission frequency is very high, so the transmission link is error may occur (1, program processing logic error; 2, multi-thread synchronization issues; 3, buffer overflow) if the transmission fails not addressed, then the client receives the data obtained will be less than the theoretical data, which will result in data loss and packet loss. This phenomenon, in fact, is not the essence of packet loss, data is not lost, just because a program error handling, resulting in some data was not successfully sent socket.

Send questions about the function of:

Send function must first be clear what has been done. He is passing the data to the local TCP layer, or to pass data to the application layer, and then confirm the receiving TCP layer to return. In the latter case, you're right, it is not. That is because nagle algorithm can not be used, i.e. the algorithm will send data aggregation function receives little larger than the packet transmission.

You can even send data transmission function, the other party will not necessarily be accepted. TCP protocol at the transport layer just to fulfill the obligation, send function only acts as an application layer to the TCP layer transfer of data, in addition to any relationship with the TCP layer.

Common solutions include unpacking, adding header and sends the combined package. If the server or the client disconnects, usually using heartbeat test.

Heartbeat Test: time to time send packets to the server. To save resources, typically sends empty packets. If the transmission fails indicates that the socket is interrupted, and the need to free up resources based on specific criteria and reconnect.

TCP transport protocol in how to solve the problem of packet loss

TCP transport can ensure the reliability of data exchange, which means that a host will correctly transmit data to the target computer, the protocol stack of the target computer has certain restrictions, if not timely processing of the received data on the target computer, the stack would overflow.

This overflow not by the TCP protocol itself is the cause, but by the IP protocol stack buffer overflow caused by the system!

Guess you like

Origin blog.51cto.com/13609234/2421398