Transmission Control Protocol (TCP) and User Datagram Protocol (UDP)

TCP

TCP is connection-oriented, meaning once a connection has been established, data can be transmitted in two directions. TCP has built-in systems to check for errors and to guarantee data will be delivered in the order it was sent.

It uses a 3-way handshake to establish a reliable connection. The connection is full duplex, and both sides synchronize (SYD) and acknowledge (ACK) each other. The exchange of these four flas is performed in 3 steps -- SYN, SYN-ACK, and ACK.

sequenceDiagram participant Client participant Server Client->>Server: SYN Server->>Client: SYN/ACK Client->>Server: ACK

UDP

UDP is a simpler, connectionless internet protocol wherein error checking and recovery services are not required. There is no overhead for opening, maintaining and terminating a connection. Data is continuously sent to the recipent, whether or not they receive it.

Comparisons

Feature TCP UDP
Data sequencing X
Guaranteed delivery X
Retransmission of data X
Error checking Extensive Basic like checksums
Speed Slower than UDP Faster than TCP
Broadcasting X
Optimal use HTTPS, HTTP, SMTP, POP, FTP Video conferencing, streaming, DNS, VoIP

References


  1. ScienceDirect -- Three-Way Handshake
  2. Understanding The TCP/IP Transport Layer
  3. TCP vs. UDP: What’s the Difference?