How to understand that TCP at the transport layer is byte-oriented and UDP is message-oriented? The two are defined by whether they will be segmented (mss)?
Bob wrote a 14,600-byte love letter to Alice, and Bob used two chat software to send to Alice.
The first chat software is based on TCP, and the second chat software is based on UDP.
TCP chat software
Bob sent all 14,600 bytes in one go through the chat window. TCP is busy. TCP finds that the MSS of the TCP connection with Alice = 1460. It needs to cut the love letter into a standard transmission unit of 1460 bytes, a total of 10 transmission units. How did the number of transmission units come from?
Number of transmission units = total bytes transmitted / MSS = 14600/1460 = 10
These 10 transmission units can be thought of as 10 containers. It should be pointed out that these standard transmission units have a sequence. That is because the love letters cut into 10 pieces have a sequence.
This is hard to beat TCP, TCP is best at doing this! TCP transmits the first, second, and third in the order of time. . . 9,10 containers. among them,
o The first container transfers 1-1460 bytes
o The second container transmits 1461-2920 bytes
o. . .
o The tenth container transmits 13140-14600 bytes
Whether these 10 containers arrive in order, or arrive out of order, or there is a loss in the middle, and then retransmission arrives, Bob's TCP can queue the 10 containers again (1,2,3 ... 10) This is what TCP is good at.
TCP notified Bob's chat software to take away 14,600 bytes of data and eventually display it on the chat window. There is no one more byte or one less byte, which is exactly 14600 bytes. Love letters are not in reverse order, which is very important! In addition, Bob knew his love letter had arrived at Alice!
UDP chat software
The software sends 14600 to UDP at one time. UDP adds an 8-byte UDP protocol header to generate a UDP data message (14608 bytes), and calls the underlying IP interface to send the UDP message.
The underlying IP interface function, found that the love letter of 14608 bytes is much larger than the MTU (1500 bytes) of its own network interface. The love letter needs to be cut into 1480 bytes as a unit, and then each unit adds a 20-byte IP header Become a 1500-byte standard container and leave the host separately from the network interface.
Reaching the IP layer of Alice's host, the IP layer found these 10 container-like wholes. The IP layer opened a buffer to assemble them (Reassemble) into a whole, a total of 14608 bytes, and submitted them to UDP. UDP strips the 8-byte protocol header, transfers the 14,600-byte love letter to the chat software, and finally displays it on the chat window.
There is not one more byte, nor is there one less byte, which is also a love letter of 14600 bytes. However, does Bob know that Alice has received her love letter? This is even more critical! Because the UDP protocol itself does not provide a confirmation receipt mechanism, and the TCP protocol itself provides a confirmation receipt mechanism!
How can Bob know that Alice has received her love letter?
As long as Alice's chat software (application layer) sends a confirmation message, when the confirmation message reaches Bob's chat software, it will display as "love letter read", so Bob knows that his love letter has reached Alice. Although all of this is transmitted through the UDP protocol, a reliable transmission mechanism can be achieved. It's just that this reliable transmission mechanism is not implemented in UDP, but in a higher application layer!
Compared with TCP, UDP is a weak self-care ability! The reliable transmission mechanism is based on the application layer. When the message is very large, it often resorts to the underlying IP layer to cut the fragments, or hopes that the application layer will do the data fragmentation work! The only service that UDP can provide is to provide ports to serve different processes, as for the others, nothing! TCP is a generalist, all the above functions are plenary, and it also has the function of flow control!
The above is the news sharing from the PASSHOT. I hope it can be inspired you. If you think today' s content is not too bad, you are welcome to share it with other friends. There are more latest Linux dumps, CCNA 200-301 dumps and CCNP Written dumps waiting for you.
Comments