Briefly describe the difference between TCP and UDP

  TCP is a connection-oriented protocol, that is to say, before sending and receiving data, a reliable connection must be established with the other party. A TCP connection must go through three "conversations" to establish. Use the TCP protocol to transmit data. TCP provides functions such as timeout retransmission, discarding duplicate data, checking data, and flow control to ensure that data can be transmitted from one end to the other. When the data is transmitted from the A side to the B side, the B side will send an acknowledgment packet (ACK packet) to the A side to inform the A side that I have received the data!

  The UDP protocol does not have such a confirmation mechanism, which is why the TCP protocol is reliable and the UDP protocol is unreliable. Providing such a reliable service will increase the network bandwidth overhead, because the "virtual channel" persists, and the network also There will be a lot of ACK and FIN packets. The TCP protocol provides reliable data transmission, but the network overhead of its congestion control, data verification, and retransmission mechanisms is very large, and it is not suitable for real-time communication. Therefore, the UDP protocol with low overhead is selected to transmit data. The UDP protocol is a connectionless data transmission protocol and has no retransmission mechanism, so there will be packet loss, duplicate packets received, out of order, etc.

  1. Connection-based vs. connectionless.

  2. UDP does not provide reliability and cannot guarantee that the data will reach the destination.

  3. Requirements for system resources (more TCP, less UDP).

  4.UDP structure is relatively simple.

  5. TCP is oriented to byte stream mode. TCP will ensure that the server receives all byte streams in order. UDP is oriented to datagram mode and does not guarantee sequence.

  Obviously, the TCP protocol is chosen when the performance of data transfer must give way to the integrity, controllability and reliability of data transfer. UDP is the best choice when the emphasis is on transport performance rather than transport integrity, such as in audio and multimedia applications. UDP is also a good choice when the data transfer time is so short that the previous connection process becomes the main body of the entire traffic, such as DNS exchange. The lower overhead of UDP gives it a better chance of delivering management data. The rich functionality of TCP can sometimes lead to unpredictable performance degradation.

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325387173&siteId=291194637