Skip to Content
πŸŽ‰ Welcome to my notes πŸŽ‰
Networking15. TCP and UDP

🚚 TCP and UDP: The Backbone of the Internet

πŸ€” What are TCP and UDP?

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are core protocols of the Transport Layer (Layer 4). Their job is to move data between applications on different devices. They act like two different types of postal services for the internet, each with its own strengths.

🀝 TCP (Transmission Control Protocol)

TCP is a reliable, connection-oriented protocol. Think of it like sending a valuable package via a tracked courier service.

  • Main Characteristics:
    • Reliable: It guarantees that data will be delivered. If a packet is lost in transit, TCP detects this and re-transmits it.
    • Connection-Oriented: It establishes a formal connection using a three-way handshake (SYN, SYN-ACK, ACK) before sending any data. This ensures both devices are ready.
    • Ordered: It ensures that data packets are reassembled in the correct order at the destination.
  • Use Cases: Perfect for applications where accuracy is critical.
    • Web Browse (HTTP/HTTPS)
    • Email (SMTP)
    • File Transfer (FTP)

πŸš€ UDP (User Datagram Protocol)

UDP is a lightweight, connectionless protocol. Think of it like sending a simple postcard.

  • Main Characteristics:
    • Unreliable: It does not guarantee delivery. It’s a β€œfire-and-forget” protocol; if a packet is lost, it’s lost for good.
    • Connectionless: It sends data without establishing a formal connection, which reduces latency.
    • Fast: With very little overhead, UDP is much faster than TCP.
  • Use Cases: Perfect for real-time applications where speed is more important than perfect reliability.
    • Live video and audio streaming
    • Online gaming
    • DNS lookups

πŸ†š TCP vs. UDP: Key Differences

FeatureTCPUDP
ReliabilityHigh (Guaranteed delivery)Low (No guarantee)
ConnectionConnection-OrientedConnectionless
SpeedSlowerFaster
OrderingOrderedUnordered
Use CaseWeb, Email, File TransferStreaming, Gaming, DNS
Last updated on