Networking
Difference Between TCP and UDP Protocol, CBSE Computer Networks
Complete comparison of TCP vs UDP protocol for CBSE Class 11 and 12. Comparison table, examples, diagrams, and board exam questions with answers.
TCP and UDP are two of the most important transport layer protocols in computer networks. Understanding the difference between them is essential for CBSE Class 11 and 12 Computer Science exams, where networking carries significant marks.
What is TCP?
TCP (Transmission Control Protocol) is a connection-oriented protocol. Before data is sent, a connection is established between the sender and receiver using a process called the three-way handshake.
TCP guarantees that:
- Data is delivered in the correct order, No data packets are lost, Errors are detected and corrupted packets are retransmitted
How the three-way handshake works:
- SYN, The client sends a synchronisation request to the server
- SYN-ACK, The server acknowledges and sends its own synchronisation request
- ACK, The client acknowledges, and the connection is established
Think of TCP like sending a registered letter through the post office, you get a confirmation that it was delivered.
What is UDP?
UDP (User Datagram Protocol) is a connectionless protocol. Data is sent without establishing a connection first. There is no guarantee of delivery, ordering, or error correction.
UDP is faster than TCP because it skips the handshake process and does not wait for acknowledgements.
Think of UDP like shouting a message across a room, you send it and hope the other person hears it, but you do not wait to confirm.
TCP vs UDP, Comparison Table
This table is frequently asked in CBSE board exams. Memorise it.
| Feature | TCP | UDP |
|---|---|---|
| Full Form | Transmission Control Protocol | User Datagram Protocol |
| Connection Type | Connection-oriented | Connectionless |
| Reliability | Reliable (guarantees delivery) | Unreliable (no guarantee) |
| Ordering | Data arrives in order | No ordering guarantee |
| Speed | Slower (due to overhead) | Faster (minimal overhead) |
| Error Checking | Yes, with retransmission | Basic checksum only |
| Flow Control | Yes | No |
| Header Size | 20 bytes (minimum) | 8 bytes (fixed) |
| Handshake | Three-way handshake | No handshake |
| Data Unit | Segment | Datagram |
| Overhead | High | Low |
| Broadcasting | Not supported | Supported |
When to Use TCP
TCP is used when data accuracy is more important than speed. If even one packet is lost or arrives out of order, the application breaks.
Real-world examples of TCP:
- Web browsing (HTTP/HTTPS), A web page must load completely and correctly. Missing data would mean broken pages.
- Email (SMTP, IMAP, POP3), Every word in an email must arrive exactly as sent.
- File transfer (FTP), A downloaded file must be identical to the original. A single corrupt byte can make the file unusable.
- Secure Shell (SSH), Remote login sessions require reliable, ordered data.
When to Use UDP
UDP is used when speed is more important than reliability. Losing a few packets is acceptable as long as the data keeps flowing.
Real-world examples of UDP:
- Video streaming (YouTube, Netflix), A few dropped frames are not noticeable. Waiting for retransmission would cause buffering.
- Online gaming, Real-time action games need instant data. A delayed packet is useless because the game has already moved on.
- Voice calls (VoIP), A tiny gap in audio is less annoying than a delay caused by retransmission.
- DNS lookups, A DNS query is a small, single request. If it fails, the application simply sends it again.
- Live broadcasts, Live TV or radio streaming needs continuous flow without pauses.
Understanding with an Analogy
| Scenario | Protocol | Why |
|---|---|---|
| Sending a legal document | TCP | Every page must arrive, in order, with no errors |
| Live cricket commentary on radio | UDP | A missed word is fine, delay is not acceptable |
| Downloading a software update | TCP | The file must be complete and uncorrupted |
| Video call with a friend | UDP | Slight quality drop is fine, lag is not acceptable |
TCP and UDP in the OSI Model
Both TCP and UDP work at Layer 4 (Transport Layer) of the OSI model and Layer 3 (Transport Layer) of the TCP/IP model.
- They sit above the Network Layer (IP) and below the Application Layer (HTTP, FTP, DNS), IP handles addressing and routing; TCP/UDP handle how data is delivered
Key point for exams: TCP and UDP both use port numbers to identify applications. For example:
- HTTP uses port 80
- HTTPS uses port 443
- DNS uses port 53
- FTP uses port 21
Diagrams for Board Exams
When answering in exams, draw this simple comparison:
TCP Communication:
Client Server
|--- SYN ------->|
|<-- SYN-ACK ----|
|--- ACK ------->|
|--- Data ------>|
|<-- ACK --------|
|--- FIN ------->|
|<-- ACK --------|
UDP Communication:
Client Server
|--- Data ------>|
|--- Data ------>|
|--- Data ------>|
(no acknowledgement)
Common Exam Questions with Answers
Q1: State two differences between TCP and UDP. (2 marks)
Answer:
| TCP | UDP |
|---|---|
| Connection-oriented protocol, establishes a connection before data transfer | Connectionless protocol, sends data without establishing a connection |
| Reliable, guarantees delivery of data in correct order | Unreliable, no guarantee of delivery or ordering |
Q2: Give one example each of an application that uses TCP and an application that uses UDP. Justify your answer. (3 marks)
Answer:
- TCP example: File Transfer Protocol (FTP). FTP is used to transfer files between computers. The file must arrive completely and without errors, so TCP's reliability is essential.
- UDP example: Video conferencing. In a video call, real-time delivery is more important than perfect accuracy. A few lost frames are acceptable, but delay caused by retransmission is not.
Q3: Why is UDP faster than TCP? (2 marks)
Answer: UDP is faster than TCP because it does not perform a three-way handshake before sending data, does not wait for acknowledgements from the receiver, and does not retransmit lost packets. This reduces overhead and allows data to be sent immediately.
Q4: What is a three-way handshake? (3 marks)
Answer: A three-way handshake is the process TCP uses to establish a connection before data transfer. It involves three steps:
- The client sends a SYN (synchronise) packet to the server
- The server replies with a SYN-ACK (synchronise-acknowledgement) packet
- The client sends an ACK (acknowledgement) packet
After these three steps, the connection is established and data transfer can begin.
Q5: Which protocol would you use for an online multiplayer game? Give a reason. (2 marks)
Answer: UDP would be used for an online multiplayer game. In real-time games, speed is more important than reliability. If a player's position data is delayed due to retransmission (as in TCP), the game would lag. UDP sends data immediately without waiting for acknowledgements, providing the low latency that games require.
Key Points to Remember
- TCP = Reliable but slower. Use when accuracy matters (file transfer, email, web).
- UDP = Fast but unreliable. Use when speed matters (streaming, gaming, voice calls).
- Both operate at the Transport Layer.
- TCP uses a three-way handshake; UDP does not.
- TCP header is 20 bytes minimum; UDP header is 8 bytes fixed.
- In exams, always support your answer with an example and justification.
Master this comparison and you will be prepared for any TCP/UDP question in your CBSE board exam.
Want to learn more?
Explore free chapter-wise notes with quizzes and code playground
Prefer watching over reading?
Subscribe for free.