logo

TCP vs UDP

TL;DR

  • UDP: fire and forget.
  • TCP: guaranteed delivery and the correct order of the packets.

TCP vs UDP

TCP (Transmission Control Protocol)

  • A connection-based protocol that provides a reliable flow of data between two computers.
  • Example: HTTP, FTP, Telnet
  • Use socket
  • Use the packet's 5-tuple (source IP address, destination IP address, source port, destination port, and protocol number) to uniquely identifies which connection it belongs to.

UDP (User Datagram Protocol)

  • A protocol that sends independent packets of data, called datagrams, from one computer to another with no guarantees about arrival. UDP is not connection-based like TCP.
  • Example: time request, ping
  • Use datagram