Computer Networks · Module 6 — Transport Layer
TCP vs UDP
Not every application wants the same thing. Two very different needs exist.
Sign in to track your score
When a web page loses a piece, you want it sent again. When a video call loses a piece, sending it again is pointless — that moment has already passed.
Why & what
Why there are two protocols. Not every application wants the same thing. Two very different needs exist.
- Some data must be complete. A missing line of code in a downloaded file makes it useless.
- Some data must be current. A video frame that arrives two seconds late is worse than no frame at all.
You cannot serve both with one protocol, so the transport layer offers two.
What TCP is. TCP (Transmission Control Protocol) is connection-oriented and reliable.
- It agrees a connection first, with a handshake.
- It numbers every byte, so pieces can be reassembled in order.
- It waits for acknowledgements and resends anything that goes missing.
- Its header is 20 bytes.
What UDP is. UDP (User Datagram Protocol) is connectionless and unreliable.
- No handshake. It just sends.
- No numbering, no reordering, no acknowledgements, no resending.
- Its header is 8 bytes — source port, destination port, length, checksum. That is all.
"Unreliable" is a technical word here, not an insult. It means makes no promises, not works badly.
The comparison, in the order interviewers ask for it:
| TCP | UDP | |
|---|---|---|
| Connection | handshake first | just send |
| Lost data | detected and resent | gone forever |
| Order | reassembled in order | arrives however |
| Speed | slower, more checking | faster, no checking |
| Header | 20 bytes | 8 bytes |
| Used by | HTTP, HTTPS, FTP, SMTP | DNS, video calls, games, DHCP |
How it works
How an application chooses.
- Ask: is late data still useful? If yes, TCP. If no, UDP.
- Aisha loading college.edu — every byte matters, and a page half a second late is fine. TCP.
- Aisha on a video call with Rahul — a frame from two seconds ago is useless. Skipping it is better than stalling. UDP.
- A DNS lookup one tiny question, one tiny answer. Setting up a whole TCP connection would cost more than just asking again if it fails. UDP.
- The choice is made by the application when it opens the socket. The network does not decide.

Common confusion
Students think UDP is just a worse, broken version of TCP. Actually, UDP is deliberately minimal, and for live traffic that is the better design.
Imagine a video call using TCP. One frame goes missing, so TCP stops and waits for the resend before delivering anything after it. Your call freezes for half a second, then jumps. Everything that arrived on time was held back for something that no longer mattered. UDP just skips the missing frame. You see one tiny glitch and the call keeps flowing.
TCP's reliability is a cost, paid willingly when it is worth it.
Interview angle
Asked as: "Difference between TCP and UDP?" probably the single most asked networking question in placements. Give the table, then give a reason for each side.
Model answer:
TCP is connection-oriented and reliable. It sets up a connection with a three-way handshake, numbers the data, acknowledges what arrives, retransmits what is lost, and delivers everything in order. Its header is 20 bytes. UDP is connectionless. It sends datagrams with no handshake, no acknowledgements, no ordering and no retransmission, with an 8-byte header. The choice depends on whether late data is still useful. Web pages, file transfers and email use TCP because completeness matters. Video calls, gaming and DNS use UDP because speed matters more than perfection — retransmitting an old video frame would stall the stream for data that is already useless.
- 1.
How large is the UDP header?
- 2.
Which protocol does a live video call normally use?
- 3.
"UDP is unreliable" means
- 4.
Which of these is a TCP feature that UDP does not have?