The reason sticky TCP packet UDP does not stick package

UDP packet loss due to lost packets and TCP stream is based on the transmission and there in the course of transmission loss retransmission mechanism is reliable TCP and UDP connection is unreliable to say that I do not

stick package on the TCP It is because TCP is a connection that is established can always stop sending no clear boundary definition streamed and when you send a UDP packet is in accordance with a data packet to be transmitted is a clear border

and TCP packet and no concept is completely stream, he will open up a buffer zone the sender to write data to each over a period of time and then sends out the data received by the receiver but not that I once sent data certainly will send out data buffer possible subsequent data transmitted and previously transmitted data exist buffer in a form which is then transmitted to the receiving end of the stick package is also the case with the stick package produced if the application does not timely processing of data in the buffer then the subsequent data arriving to the data buffer will continue to store the received twice i.e. When the next buffer will fetch buffer data extracted twice stick package which is in addition to many other forms such as a form of stick package buffer is filled half full buffer in the presence directly transmitted, but in fact, that bag is not completely filled this incomplete stick package will make up the remaining data when sending the next



on the solution if you are continuous throughout the data stream , such as sending a file that does not consider stick pack does not matter because you can build disconnect the connection after sending been sent throughout the data stream after the matter is that the entire data file from a cut does not matter where the entire mosaic is still a whole data file

If you are sending multiple data communications such as all the filenames in a directory are then sent in the past as a whole can not send them to the demarcation of the border must have a very simple approach is to use "data length + the actual data "this transmission data format" data length "is the format of a fixed width such as 4-byte 0 ~ 4GB may represent the width of a width sufficient to use this illustrates the subsequent actual data width so that you can put the stick package data taken out of the correct size

every four bytes are broken out of the correct size was then removed subsequent portions on OK

such as the constant data transmission if you are all fixed-width temperature data are each 1 then the width of each byte is known you remove a 1 byte is OK so do not transmit the data width of the

course, you can establish a connection according to the disconnect boundary to divide the transmission data are turned off each time a connection but for a small amount of data is frequently desirable approach as too costly to establish a connection and to close the connection also takes a network flow amount of

the total Where the words stick package can not be absolutely avoided because the network environment is very complex control dependence send and receive buffers are not guarantee 100% as long as the width of the data described in the data transmitted in the receiving section is then split according to this width open width all is OK even easier to fill in the open end of the transmission case of the known width of the uniform width data are omitted from the

Guess you like

Origin www.cnblogs.com/fan-1994716/p/11655977.html