📘 CCNA 200-301 v1.1
1.5 Compare TCP to UDP
1️⃣ What are TCP and UDP?
Both TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are transport layer protocols in the TCP/IP model.
Their main job is to control how data is sent between devices over a network.
They operate at Layer 4 (Transport Layer) of the OSI model.
When one computer sends data to another (for example, from a client to a server), the data passes through several layers — and the transport layer decides how that data is delivered:
- Should it ensure every packet arrives correctly (reliable)?
- Or just send packets fast without checking for errors (unreliable but quick)?
That’s where TCP and UDP differ.
2️⃣ TCP (Transmission Control Protocol)
🔹 Overview
TCP is a connection-oriented protocol.
This means before sending data, it creates a reliable connection between the sender and the receiver.
It guarantees that:
- All data is received.
- Data is received in the correct order.
- Corrupted or lost data is retransmitted.
🔹 Key Features of TCP
| Feature | Explanation |
|---|---|
| Connection-Oriented | TCP first establishes a connection before sending data. This is done through a three-way handshake. |
| Reliable Delivery | TCP ensures all data reaches the destination correctly. If packets are lost or damaged, TCP resends them. |
| Ordered Delivery | Packets arrive in the same order they were sent. TCP uses sequence numbers to keep order. |
| Flow Control | TCP uses a window size mechanism to control how much data can be sent before receiving an acknowledgment. This prevents overwhelming the receiver. |
| Error Detection and Recovery | TCP uses checksums to detect errors and requests retransmission if errors are found. |
| Acknowledgments (ACKs) | The receiver sends an acknowledgment after receiving packets. If no ACK is received, TCP assumes packets are lost and resends them. |
| Congestion Control | TCP monitors network congestion and slows down data transmission when the network is busy. |
🔹 TCP Header Fields (Basic)
TCP has a larger header (minimum 20 bytes) because it includes more control information.
Important fields:
- Source Port / Destination Port: Identify which applications are communicating.
- Sequence Number: Used to keep track of data order.
- Acknowledgment Number: Confirms receipt of data.
- Flags: Control bits such as SYN, ACK, FIN for connection setup and teardown.
- Window Size: Used for flow control.
- Checksum: For error detection.
🔹 TCP Three-Way Handshake
Before data transfer begins, TCP uses a three-step process to establish the connection:
- SYN – Sender sends a synchronization request.
- SYN-ACK – Receiver acknowledges the request and also sends its own synchronization signal.
- ACK – Sender acknowledges the receiver’s response.
After this, data can flow both ways.
When communication is finished, TCP uses a four-step termination (FIN/ACK) process to close the connection.
🔹 TCP Use Cases (Common in IT)
TCP is used where reliability and data accuracy are critical:
- Web browsing (HTTP/HTTPS)
- Email (SMTP, POP3, IMAP)
- File transfer (FTP)
- Remote access (SSH, Telnet)
3️⃣ UDP (User Datagram Protocol)
🔹 Overview
UDP is a connectionless protocol.
This means it does not establish a connection before sending data and does not guarantee delivery.
UDP simply sends packets (called datagrams) without checking if they arrive, arrive in order, or are damaged.
This makes it faster, but less reliable than TCP.
🔹 Key Features of UDP
| Feature | Explanation |
|---|---|
| Connectionless | No handshake or connection setup — packets are sent directly. |
| Unreliable | No acknowledgment, retransmission, or error correction. |
| No Ordering | Packets may arrive out of order or be lost. |
| Low Overhead | Smaller header (8 bytes only). Faster and uses less bandwidth. |
| No Flow or Congestion Control | UDP doesn’t manage how much data is sent; it sends as fast as the application allows. |
🔹 UDP Header Fields (Basic)
UDP header is only 8 bytes, containing:
- Source Port / Destination Port
- Length
- Checksum
This simplicity makes UDP very fast.
🔹 UDP Use Cases (Common in IT)
UDP is used where speed and low delay are more important than reliability:
- DNS (Domain Name System) – quick request and reply.
- DHCP (Dynamic Host Configuration Protocol) – for assigning IP addresses.
- VoIP (Voice over IP) – voice packets; delay is worse than lost packets.
- Video streaming / online gaming – where real-time delivery is critical.
4️⃣ Comparison Table: TCP vs UDP
| Feature | TCP | UDP |
|---|---|---|
| Type | Connection-oriented | Connectionless |
| Reliability | Reliable (error recovery, retransmission) | Unreliable (no recovery) |
| Ordering | Maintains order using sequence numbers | No order guarantee |
| Error Checking | Yes, with retransmission | Yes, but no retransmission |
| Flow Control | Yes | No |
| Congestion Control | Yes | No |
| Acknowledgment | Yes | No |
| Speed | Slower due to overhead | Faster due to simplicity |
| Header Size | 20 bytes | 8 bytes |
| Use Cases | Web, Email, File Transfer, SSH | DNS, DHCP, VoIP, Streaming, Gaming |
5️⃣ How TCP and UDP Work in the Network
When a device sends data:
- The application layer decides if it needs reliability or speed.
- Based on that, it uses either TCP or UDP at the transport layer.
- The IP layer below handles addressing and routing to deliver the packets.
Example (IT context):
- When you open a web page: The browser uses HTTP over TCP — reliable connection.
- When you stream a live video: The app uses RTP over UDP — fast, real-time data with no retransmission.
6️⃣ Key CCNA Exam Points to Remember
✅ TCP is reliable, connection-oriented, uses three-way handshake, acknowledgments, and sequence numbers.
✅ UDP is unreliable, connectionless, faster, and has low overhead.
✅ TCP header = 20 bytes, UDP header = 8 bytes.
✅ TCP provides flow control, congestion control, and error recovery.
✅ UDP is used for real-time, time-sensitive traffic.
✅ Both TCP and UDP use port numbers to identify applications.
✅ Examples of well-known ports:
- TCP 80/443 = HTTP/HTTPS
- TCP 22 = SSH
- UDP 53 = DNS
- UDP 67/68 = DHCP
✅ Summary
| Concept | TCP | UDP |
|---|---|---|
| Reliability | High | Low |
| Connection | Required | Not required |
| Header | 20 bytes | 8 bytes |
| Speed | Slower | Faster |
| Used For | Reliable data transfer | Real-time or lightweight communication |
