Joke Collection Website - Public benefit messages - What are the differences and similarities between the UDP protocol and the TCP protocol?

What are the differences and similarities between the UDP protocol and the TCP protocol?

Connection-oriented TCP:

"Connection-oriented" means that a connection must be established with the other party before formal communication. For example, when you call someone, you have to wait until the line is connected and the other party picks up the phone before you can talk to each other.

TCP (Transmission Control Protocol) is a connection-based protocol, which means that a reliable connection must be established with the other party before data can be officially sent and received. A TCP connection must go through three "conversations" before it can be established. The process is very complicated. We only give a simple and vivid introduction here. You only need to be able to understand the process.

TCP protocol can provide reliable communication connections for applications, so that the byte stream sent by one computer can be sent to other computers on the network without errors. Data communication systems with high reliability requirements often use it. TCP protocol transmits data.

Connectionless UDP protocol.

"Non-connection oriented" means that there is no need to establish a connection with the other party before formal communication, and it is sent directly regardless of the other party's status. This is very similar to the popular mobile phone text messages now: when you send a text message, you only need to enter the other party’s mobile phone number.

UDP (User Data Protocol, User Datagram Protocol) is a protocol corresponding to TCP. It is a non-connection-oriented protocol. It does not establish a connection with the other party, but directly sends the data packet there!

UDP is suitable for application environments that only transmit a small amount of data at a time and do not require high reliability. . For example, we often use the "ping" command to test whether the TCP/IP communication between two hosts is normal. In fact, the principle of the "ping" command is to send a UDP data packet to the other host, and then the other host confirms receipt of the data packet. If the data If the message of whether the packet arrives is fed back in time, the network will be open.

TCP protocol and UDP protocol each have their own strengths and weaknesses, and are suitable for communication environments with different requirements.