TCP vs UDP at a Glance
Compare reliable connection-based TCP with fast, lightweight UDP.
TCP vs UDP at a Glance is a free Network+ Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Network+ Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Two Transport Protocols
At the transport layer, two protocols carry most internet traffic: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
Both move data between applications, but they make very different trade-offs between reliability and speed. Knowing when each is used is core Network+ knowledge.
TCP Is Connection-Oriented
TCP is connection-oriented: before sending data it establishes a connection, ensuring both sides are ready. It guarantees that data arrives complete and in order.
If a segment is lost, TCP detects the gap and retransmits it. This reliability makes TCP the choice for web pages, email, and file transfers where every byte matters.
The Three-Way Handshake
TCP starts a connection with a three-way handshake: SYN, SYN-ACK, ACK. The client sends SYN, the server replies SYN-ACK, and the client confirms with ACK.
Only after this exchange does data flow. The handshake synchronizes both sides and is a classic exam topic — remember the three steps in order.
Client -> SYN
Server -> SYN-ACK
Client -> ACKUDP Is Connectionless
UDP is connectionless: it sends data immediately with no handshake and no guarantee of delivery or order. It simply fires packets, called datagrams, toward the destination.
This makes UDP fast and lightweight, but the application must handle any lost or out-of-order data itself if it cares.
Reliability vs Speed
The core trade-off is clear: TCP adds reliability through acknowledgments and retransmission, which costs time and overhead. UDP skips all that for raw speed.
- TCP: reliable, ordered, slower.
- UDP: fast, lightweight, best-effort.
Choose based on whether accuracy or speed matters more.
When TCP Wins
Use TCP when every byte must arrive correctly. Web browsing (HTTP/HTTPS), email (SMTP), and file transfer (FTP) all rely on TCP.
A missing chunk of a web page or file would corrupt it, so the cost of TCP’s reliability is well worth it. Most internet traffic by volume is TCP.
When UDP Wins
Use UDP when speed and low latency beat perfect delivery. Live voice and video calls, online gaming, and streaming often use UDP.
In a video call, a slightly dropped frame is better than pausing to retransmit it. DNS lookups also use UDP for their quick, small queries.
Flow Control and Windows
TCP includes flow control to avoid overwhelming the receiver, using a sliding window that adjusts how much data is in flight before acknowledgment.
It also performs congestion control, slowing down when the network is busy. UDP has none of this, leaving rate control entirely to the application.
Headers and Overhead
TCP’s header is larger (20 bytes minimum) because it carries sequence numbers, acknowledgments, and flags. UDP’s header is only 8 bytes, holding just source/destination ports and length.
The smaller UDP header means less overhead per packet, contributing to its speed advantage for high-volume real-time traffic.
Choosing Between Them
To decide, ask: does the application need guaranteed, ordered delivery? If yes, TCP. If it values speed and can tolerate some loss, UDP.
Many protocols pick deliberately — DNS uses UDP for fast queries but switches to TCP for large transfers. Understanding the trade-off explains these design choices.
TCP and UDP Together
Both protocols use port numbers to direct traffic to the right application, the subject of the next lesson. They share the addressing scheme but differ in delivery guarantees.
Knowing TCP versus UDP is a foundation for understanding the specific protocols and ports that follow in this course.
Quick Check
Match the protocol to the need.
Recap
You compared TCP and UDP.
- TCP: connection-oriented, reliable, ordered; uses the SYN/SYN-ACK/ACK handshake.
- UDP: connectionless, fast, best-effort, no handshake.
- TCP suits web, email, and file transfer; UDP suits voice, video, gaming, and DNS queries.
- TCP adds flow and congestion control; UDP leaves that to the app.
- Both use port numbers to reach applications.
Frequently asked questions
Is the “TCP vs UDP at a Glance” lesson free?
Yes — the full text of “TCP vs UDP at a Glance” is free to read here on the web, and the Network+ Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Network+ Academy course, upgrade to CoddyKit PRO.
What will I learn in “TCP vs UDP at a Glance”?
Compare reliable connection-based TCP with fast, lightweight UDP. You practise Network+ Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Network+ Academy?
No prior experience is required. Network+ Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “TCP vs UDP at a Glance” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Network+ Academy lesson?
Yes. Every Network+ Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- TCP vs UDP at a Glance
- What Port Numbers Are For
- Web and File Transfer Protocols
- Remote Access and Mail Protocols