Difference between TCP and UDP
In the TCP/IP protocol system, there are two transport layer protocols: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
TCP is a connection-oriented protocol that prioritizes reliability and performs advanced control, while UDP is a connectionless protocol that prioritizes processing speed and performs control.
Features of TCP
TCP provides a reliable service for serving processes.
① Reliably deliver data
We take care of it as much as possible to ensure that the data is delivered to the other party. If something goes wrong, notify the process side.
② Deal with errors
If the data does not reach the other party or is corrupted on the way, it has a mechanism to detect it and resend the data.
(3) Control the order of data
In IP communication, there is no guarantee that the data sent will arrive in order due to network conditions. TCP has a mechanism to reassemble it in the original order.
④ Eliminate duplication
It guarantees that the data is one. If for some reason data is delivered multiple times, TCP has a mechanism to remove it.
⑤ Perform flow control and congestion control
It controls the flow rate according to the processing speed of each host, and controls the transfer speed according to the network congestion state.
Features of UDP
As explained above, TCP has complex control procedures, while UDP, which provides connectionless service, has very simple controls.
There is no mechanism to check whether the data was properly delivered to the other party. All UDP does is check to see if the data has been corrupted. Check the checksum to see if the data is corrupted.
There are no complex controls, so there is no overhead.