Comparison & Protocols:
- Transport Layer: Both TCP and UDP operate at Layer 4 of the OSI model, multiplexing network communication using port numbers.
1. Transmission Control Protocol (TCP):
- Characteristics: Connection-oriented (established via 3-way handshake: SYN, SYN-ACK, ACK), reliable, ordered, and byte-stream oriented.
- Reliability: Implements sequence numbers, acknowledgments (ACKs), and automatic retransmissions for lost packets.
- Flow & Congestion Control: Uses sliding windows and congestion control algorithms (e.g., Cubic, BBR) to avoid overwhelming the network or receiver.
- Use Cases: Web traffic (HTTP/1.1, HTTP/2), file transfers (FTP), email (SMTP), financial transactions, database connections.
2. User Datagram Protocol (UDP):
- Characteristics: Connectionless, unreliable, unordered, and lightweight datagram-oriented.
- Efficiency: Zero handshake latency, minimal 8-byte header overhead (vs 20-60 bytes for TCP), no retransmission delays.
- Use Cases: Real-time gaming, live audio/video streaming (WebRTC), DNS queries, VoIP, and modern HTTP/3 (QUIC, which implements custom reliability on top of UDP).