1Definition
TCP (Transmission Control Protocol) is a connection-oriented, reliable Transport Layer protocol that guarantees ordered delivery and error recovery using acknowledgments and flow control. UDP (User Datagram Protocol) is a connectionless, lightweight Transport Layer protocol optimized for high-speed transmission without delivery guarantees.
2Simple Explanation
- TCP is like a registered mail service with return receipts: you dial the recipient, confirm they are ready, send packets, get signed receipts for every page, and resend anything lost in transit.
- UDP is like sending a postcard or broadcasting a live radio signal: you throw data out as fast as possible without checking if the receiver was listening or if pages got dropped.
3Real-Life Example / Analogy
- TCP: File downloads (FTP), online banking, sending emails—where a single missing byte corrupts the file.
- UDP: Live video streaming (Zoom, YouTube Live), voice over IP (VoIP), online multiplayer gaming—where speed matters more than retransmitting a single lost frame.
4Diagram / Visual Representation
5Working / How It Works
- TCP Connection Lifecycle:
- Three-Way Handshake: Client sends SYN Server replies SYN-ACK Client sends ACK.
- Reliable Data Transfer: Receiver sends ACK for incoming segments. If timer expires without ACK, sender retransmits missing segments.
- Connection Teardown: Four-way handshake (FIN ACK FIN ACK).
- UDP Transmission: Sender attaches UDP header (containing source/destination ports, length, and checksum) and transmits immediately without establishing a stateful connection.
6Types / Components / Characteristics
- Comparison Matrix:
- Connection State: TCP is Connection-Oriented; UDP is Connectionless.
- Speed: TCP is slower due to handshaking & overhead; UDP is much faster and simpler.
- Reliability & Error Control: TCP provides extensive error checking, flow control, and packet retransmission; UDP has only basic error checking via optional checksums.
- Header Size: TCP header is larger (20–60 bytes); UDP header is minimal (8 bytes).
7Solved Examples / Problems
Problem: A client initiates a TCP connection to a web server. Sequence number for SYN is . What are the sequence and acknowledgment numbers in the server's SYN-ACK response?
Solution:
- Client sends with .
- SYN flag consumes 1 sequence number.
- Server receives , sets .
- Server generates its own initial sequence number .
- Server sends with and .
8Advantages, Disadvantages & Applications
- TCP: Guaranteed delivery, ordered packets; higher latency and CPU overhead. (Apps: HTTP/HTTPS, FTP, SMTP, SSH).
- UDP: Low latency, overhead-free; no retransmission or delivery guarantees. (Apps: DNS queries, DHCP, VoIP, Streaming).
9Important Points to Remember
- TCP = Connection-Oriented, Reliable, Slower, Flow & Congestion Control.
- UDP = Connectionless, Unreliable, Faster, Lightweight.
- Retransmission of lost data packets is only possible with TCP.
10Test Your Understanding
- Multiple Choice: Which protocol uses checksums for minimal error detection but does NOT support retransmission of lost data?
- a) TCP
- b) UDP
- c) IP
- d) HTTP
Show answer
b) UDP. - Explain: Walk through the 3 steps of the TCP Three-Way Handshake.
