Difference between TCP and UDP

Feature                        TCP                        UDP
Acronym forTransmission Control ProtocolUser Datagram Protocol.
Connection TypeTCP is a connection-oriented protocol, which means it requires the establishment of a connection to transfer data and the termination of that connection once the data has been transmitted.UDP is a connectionless protocol, which means it doesn’t require establishing, maintaining, or terminating a connection to send data.
SegmentationTCP allows segmentation, breaking the entire message into segments, assigning a sequence number to each segment, and then reassembling the segments into the original message based on the sequence numbers at the receiving end.UDP does not support segmentation. In UDP, there is no data sequencing. If sequencing is required, it has to be managed by the application layer.
Reliability TCP is reliable as it guarantees data delivery to the destination router.UDP is unreliable as it does not guarantee the delivery of data to the destination.
Error checkingTCP  provides error-checking mechanisms and also makes error recovery.UDP follows basic mechanisms of data checking like checksums.
RetransmissionIn TCP, if a data packet is lost, it is possible to retransmit the lost packet.It is not possible to retransmit a lost data packet in UDP.
SpeedTCP is slower than UDP.UDP is faster than TCP.
AcknowledgmentIn TCP, an acknowledgment segment is present.UDP has no acknowledgment segments.
Header LengthTCP uses a variable-length (20-60) bytes header.UDP has a fixed-length header of 8 bytes.
Flow ControlTCP uses a flow control technique to ensure that no more than a certain number of data packets are sent to the receiver at the same time.The UDP protocol has no such mechanism.
BroadcastingTCP does not support broadcasting.UDP supports broadcasting.
HandshakeSYN-ACK, SYN, and ACK protocols are used by TCP to establish connections.UDP does not need any handshake protocol because it is a connectionless protocol.
Optimal UseTCP is used by HTTPS, HTTP, SMTP, POP, FTP, etcThe UDP protocol is used by DNS, VoIP, media streaming, video conferencing systems, and other applications.