Networking

TCP vs UDP: Differences, Ports and Exam Tips

TCP vs UDP explained: handshake, reliability, speed, which protocols use each, and how Network+ and A+ test the difference.

By CompCertQuiz Editorial · Published · Last reviewed · 7 min read

Part of the Network+ N10-009 study hub: CompTIA Network+ Study Guide (N10-009): 5 Domains

TCP and UDP are the two main transport protocols on the internet. TCP is connection-oriented and reliable: it sets up a session, numbers and acknowledges data, and retransmits anything lost. UDP is connectionless and best-effort: it sends datagrams with no handshake, no acknowledgment and no retransmission. TCP is used when every byte must arrive in order; UDP is used when speed and low overhead matter more than completeness.

This is core exam material for CompTIA Network+ N10-009 (objective 1.4 on ports and protocols) and A+ Core 1 (objective 2.1). Protocol behavior is defined in RFC 9293 (TCP) and RFC 768 (UDP).

TCP vs UDP at a glance

FeatureTCPUDP
ConnectionConnection-oriented (three-way handshake)Connectionless
ReliabilityAcknowledgments and retransmissionNone; best effort
OrderingSegments are sequenced and reorderedNo ordering guarantee
Flow and congestion controlYesNo
Header size20 bytes minimum8 bytes
Speed and overheadSlower, more overheadFaster, less overhead
Data unitSegmentDatagram
OSI layerLayer 4 (transport)Layer 4 (transport)
Typical usesWeb, email, file transfer, SSHDNS lookups, DHCP, NTP, voice, video, streaming

How TCP works

TCP opens a connection with a three-way handshake: the client sends SYN, the server replies SYN-ACK, and the client answers ACK. From then on every segment carries a sequence number and the receiver acknowledges what it has received. If an acknowledgment does not arrive in time, the sender retransmits. Window sizes control how much data can be in flight, which is TCP's flow control. The connection ends with FIN and ACK exchanges, or abruptly with RST.

This reliability costs time. A handshake adds a round trip before any data moves, and retransmission can delay everything behind a lost segment. For a web page or a file, that is a good trade.

How UDP works

UDP adds only port numbers and a checksum on top of IP. There is no session to set up and nothing to tear down, so a sender can transmit immediately. If a datagram is lost, UDP does nothing; the application decides whether to ask again. That makes UDP a good fit for a DNS query, where a lost request is simply asked again, and for live voice or video, where a late packet is worse than a missing one.

When to use TCP and when to use UDP

  • Use TCP when data must be complete and ordered: HTTP and HTTPS, SSH, SMTP, FTP, SMB.
  • Use UDP when delay hurts more than loss: DHCP, NTP, SNMP, TFTP, VoIP, online games and video calls.
  • Some protocols use both. DNS uses UDP 53 for normal queries and TCP 53 for zone transfers and responses too large for one datagram. LDAP is listed on both.

Modern QUIC, which carries HTTP/3, runs over UDP and adds its own reliability, which shows that "UDP" does not always mean "unreliable application".

Common ports by transport

ProtocolPortTransport
FTP20/21TCP
SSH and SFTP22TCP
Telnet23TCP
SMTP25TCP
DNS53UDP and TCP
DHCP67/68UDP
TFTP69UDP
HTTP80TCP
NTP123UDP
SNMP161/162UDP
LDAP389TCP and UDP
HTTPS443TCP
SMB445TCP
RDP3389TCP

The full list with purposes and secure alternatives is in the Network+ ports and protocols cheat sheet.

How the exam asks about it

  • Match the protocol to the transport. If a question names DHCP, NTP or TFTP, the answer is UDP; if it names HTTPS, SSH or SMTP, the answer is TCP.
  • Spot the requirement."Guaranteed delivery" or "ordered" points to TCP; "low latency" or "real-time" points to UDP.
  • Know the handshake order. SYN, SYN-ACK, ACK. A flood of SYN packets with no final ACK is the signature of a SYN flood.
  • Layer 4. Both are transport layer protocols, so a question about segmenting data or port numbers is a Layer 4 question.

Frequently asked questions

What is the main difference between TCP and UDP?

TCP is connection-oriented and reliable, with a handshake, acknowledgments and retransmission. UDP is connectionless and sends datagrams with no guarantee of delivery or order, which makes it faster with less overhead.

Is UDP faster than TCP?

Usually yes, because it has no handshake, no acknowledgments and a smaller header. That speed comes from giving up reliability, so the application has to tolerate or handle loss.

Does DNS use TCP or UDP?

Both. DNS uses UDP port 53 for normal queries and TCP port 53 for zone transfers and responses that are too large for a single UDP datagram.

What is the TCP three-way handshake?

The client sends SYN, the server answers SYN-ACK, and the client sends ACK. After that the connection is established and data can flow.

Which protocols use UDP?

Common examples are DHCP, NTP, SNMP, TFTP and most voice and video streaming. DNS uses UDP for ordinary queries.

Related reading

CompCertQuiz is an independent practice-exam site and is not affiliated with, endorsed by, or sponsored by CompTIA. Our practice questions are original material written for exam preparation. CompTIA and its certification names are trademarks of CompTIA, Inc. Always confirm exam details on comptia.org.

More from the blog