Topic 6

Transport Layer Protocols: TCP vs. UDP

2 min read1 question to test yourself

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

ServerClientServerClientTCP connection established · data transfer beginsSYN · Seq = XSYN-ACK · Seq = Y, Ack = X + 1ACK · Ack = Y + 1UDP datagram 1 (separate connectionless example)UDP datagram 2 (no handshake or acknowledgement)

5Working / How It Works

  • TCP Connection Lifecycle:
    1. Three-Way Handshake: Client sends SYN →\rightarrow Server replies SYN-ACK →\rightarrow Client sends ACK.
    2. Reliable Data Transfer: Receiver sends ACK for incoming segments. If timer expires without ACK, sender retransmits missing segments.
    3. Connection Teardown: Four-way handshake (FIN →\rightarrow ACK →\rightarrow FIN →\rightarrow 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 X=5000X = 5000. What are the sequence and acknowledgment numbers in the server's SYN-ACK response?

Solution:

  1. Client sends SYNSYN with Seq=5000Seq = 5000.
  2. SYN flag consumes 1 sequence number.
  3. Server receives SYNSYN, sets Ack=Seq+1=5000+1=5001Ack = Seq + 1 = 5000 + 1 = 5001.
  4. Server generates its own initial sequence number Y=8000Y = 8000.
  5. Server sends SYN−ACKSYN-ACK with Seq=8000Seq = 8000 and Ack=5001Ack = 5001.

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

  1. 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.
  2. Explain: Walk through the 3 steps of the TCP Three-Way Handshake.

Finished this topic?

0 of 10 topics read in Computer Networks & Security

Handwritten notes for the exam

Unit-wise SPPU notes and PYQs for this subject.

Helpful? Share it with your class

Free for everyone, no login needed.

Share topic