TCP packet sticky problem

TCP stick package, mainly because of two packet sending end, TCP transmission is performed according stream, the buffer is full before the transmission.

  • If two packets are relatively small, the two will merge into packets transmitted together, resulting in the stream to the receiving end can not know that the packet is a packet or two
  • If sending two packets, the first packet large, TCP buffer pool does not fit, the first packet unpacking will then be sent with the second package, the stream received by the receiver can not know how the package assembly the

  • TCP (transport control protocol, the Transmission Control Protocol) is connection-oriented and stream-oriented, high reliability service. The receiver and transmitter (client and server) must have eleven pairs of socket, therefore, in order to transmit end a plurality of packets addressed to the receiving end, other more efficient to send, using the optimization method (the Nagle Algorithm), the times, at intervals smaller and smaller amount of data the data combined into a large block of data, then the packet. In this way, the receiving end, it is hard to tell the difference, and must provide scientific unpacking mechanism. I.e., non-oriented communication message stream is protected boundaries.

  • UDP (user datagram protocol, User Datagram Protocol) is a connectionless, message-oriented, providing efficient service. The combined use of the optimization algorithm does not support block ,, since UDP is a many mode, the receiving end of the skbuff (socket buffer) using the chain structure to record the arrival of each UDP packet in each UDP We have a package (information source address and port) message header, so that, for the receiving side, it is easy to distinguish the process. That message is a message-oriented communication protected boundaries.

Reference:
stick package question: https://www.cnblogs.com/nickchen121/p/11031027.html
interviewer asks: Are you concerned at Netty communication stick package, unpacking? : Https://mp.weixin.qq.com/s/A7CkBAN3fX6z2x60ZATgHA

Guess you like

Origin www.cnblogs.com/liyiran/p/12054186.html