Summary of TCP packet loss causes
I asked the boss at the company today that the bottom layer of the company's project is TCP. Because of its reliability and automatic reconnection, TCP is implemented at the bottom layer. But I remember that TCP may also cause packet loss problems, so this article came into being-about TCP packet loss, TCP implements reliable transmission based on unreliable networks, and packet loss will certainly exist.
If there is a lack of data or packet loss in the communication, the biggest possibility is that the process of sending or receiving the program has problems.
For example, if the server sends a large amount of data to the client and the sending frequency is very high, an error may occur during sending. (There may be many reasons, which may be the logic issue of program processing and multi-thread synchronization, buffer overflow, etc.). If the sending failure is not processed for re-sending data, the client will receive less data than the theoretical one, resulting in data loss and packet loss. In essence, this phenomenon is not packet loss or data loss. It is only because of errors in program processing that some data is not successfully sent out by the socket. Common solutions are as follows: Unpacking, adding a packet header, sending, and combining packages. If the client or server is offline, heartbeat testing is often used.