User Tools

Site Tools


networking:protocols:tcp-udp

TCP vs UDP

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two of the most widely used transport layer protocols on the Internet.

Both are used to transfer data between applications, but they have different characteristics and are designed for different purposes.

::contentReference[oaicite:0]{index=0}


At a Glance

Feature TCP UDP
Connection Connection-oriented Connectionless
Reliability Reliable Best effort
Packet Order Guaranteed Not guaranteed
Error Recovery Yes No
Speed Slower Faster
Overhead Higher Lower
Typical Uses Web, Email, File Transfer DNS, VoIP, Streaming, Gaming

What Is TCP?

TCP establishes a connection before transmitting data.

It ensures that:

  • Data arrives successfully.
  • Packets are delivered in order.
  • Lost packets are retransmitted.
  • Duplicate packets are discarded.

This reliability makes TCP suitable for applications where accuracy is more important than speed.

Examples:

  • HTTP / HTTPS
  • FTP
  • SSH
  • SMTP
  • IMAP
  • POP3

What Is UDP?

UDP sends packets without establishing a connection.

It does not guarantee:

  • Delivery
  • Ordering
  • Retransmission

Instead, it focuses on speed and low latency.

This makes UDP ideal for applications where occasional packet loss is acceptable.

Examples:

  • DNS
  • DHCP
  • VoIP
  • Video conferencing
  • Online gaming
  • Live streaming
  • NTP

TCP Connection

Before exchanging data, TCP performs a connection setup called the Three-Way Handshake.

Client          Server

SYN      ─────►

        ◄───── SYN-ACK

ACK      ─────►

Connection Established

Only after this process begins does application data flow.


UDP Communication

UDP has no connection setup.

The sender immediately transmits packets.

Client

Packet 1 ─────►

Packet 2 ─────►

Packet 3 ─────►

Server

This reduces delay but provides no guarantee that packets arrive.


Reliability

TCP detects missing packets and retransmits them.

If packet number 3 is lost:

1 ✓
2 ✓
3 ✗
4 ✓

↓

TCP retransmits packet 3.

UDP simply continues sending.

The application must decide how to handle missing data.


Performance

Because TCP performs acknowledgements, retransmissions, and congestion control, it generally has more overhead.

UDP is usually:

  • Faster
  • Lower latency
  • Simpler

This is why many real-time applications prefer UDP.


Common Protocols

TCP

  • HTTP
  • HTTPS
  • SSH
  • FTP
  • SMTP
  • POP3
  • IMAP

UDP

  • DNS
  • DHCP
  • NTP
  • TFTP
  • SNMP
  • RTP
  • VoIP

TCP and UDP Port Numbers

Many services use different port numbers.

Examples:

Service Protocol Default Port
HTTP TCP 80
HTTPS TCP 443
SSH TCP 22
SMTP TCP 25
DNS UDP (usually) 53
DNS Zone Transfer TCP 53
DHCP UDP 67 / 68
NTP UDP 123

Which One Should Be Used?

Use TCP when:

  • Data must not be lost.
  • Correct packet order is important.
  • Reliability is more important than speed.

Use UDP when:

  • Low latency is critical.
  • Small packet loss is acceptable.
  • Real-time communication is required.

TCP vs UDP in Telenegar

Several Telenegar tools distinguish between TCP and UDP.

Port Check

A port may accept:

  • TCP
  • UDP
  • Both
  • Neither

For example:

53

TCP ✓
UDP ✓

443

TCP ✓
UDP ✗

Knowing which protocol a service uses is essential when troubleshooting connectivity.


Common Misconceptions

  • UDP is better than TCP.
    • False. Each protocol is designed for different applications.
  • TCP is always slower.
    • Not necessarily. For many applications, reliability outweighs the additional overhead.
  • DNS always uses UDP.
    • False. DNS usually uses UDP, but TCP is used for large responses and zone transfers.


tcp udp transport-layer networking ports protocols

networking/protocols/tcp-udp.txt · Last modified: by 127.0.0.1