Sobes.tech
Junior

What is the difference between TCP and UDP protocols?

sobes.tech AI

Answer from AI

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are transport protocols of the TCP/IP stack.

Feature TCP UDP
Connection Type Connection-oriented Connectionless
Reliability High (guaranteed delivery, packet order) Low (no guarantees)
Packet Order Guaranteed Not guaranteed
Error Control Present (loss correction, duplicates) Present (detection only, no correction)
Flow Control Present Absent
Speed Lower (due to overhead) Higher
Header Size 20-60 bytes 8 bytes
Use Cases HTTP, HTTPS, FTP, SSH, SMTP DNS, DHCP, SNMP, VoIP, streaming video

Key Differences:

  • TCP establishes a three-way handshake to create a reliable connection, guarantees packet delivery in the correct order, and retransmits lost packets. This makes it ideal for applications where data accuracy is important (e.g., web pages, file transfer).
  • UDP sends packets without establishing a connection beforehand and without delivery or order guarantees. This makes it faster and more efficient for applications where small data losses are acceptable or low latency is crucial (e.g., online gaming, streaming media).