15.12.6 What Is the Difference Between TCP and UDP?
- Why Does the Internet Need Transport Protocols?
- Why Are There Two Different Protocols?
- What Is TCP?
- Why Is Reliability Important?
- Does Reliability Have a Cost?
- What Is UDP?
- Why Would Anyone Accept Lost Packets?
- Which Applications Use UDP?
- Which Protocol Is Faster?
- How Do Applications Choose Between TCP and UDP?
- Do Users Need to Choose the Protocol?
- Can TCP and UDP Be Used Together?
- Will TCP and UDP Continue to Be Used?
- What Should You Remember?
Short Answer
The Internet uses two principal transport protocols: the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). Both deliver information between applications running on different computers, but they have been designed for different purposes. TCP provides reliable, connection-oriented communication, ensuring that information arrives correctly and in the proper order. UDP provides lightweight, connectionless communication with minimal delay, making it ideal for real-time applications where speed is often more important than perfect reliability.
Why Does the Internet Need Transport Protocols?
The Internet Protocol (IP) delivers packets from one computer to another.
However, a modern computer often runs many network applications simultaneously. For example, you might be:
- browsing the web;
- receiving email;
- streaming music;
- participating in a video conference; and
- downloading software updates.
The Transport Layer ensures that incoming information is delivered to the correct application.
It also determines how that information is managed during transmission.
Why Are There Two Different Protocols?
Different applications have different communication requirements.
Some applications cannot tolerate lost information. Others cannot tolerate long delays. No single transport protocol can optimize both reliability and speed simultaneously. The Internet therefore provides two complementary transport protocols:
- TCP, which emphasizes reliability; and
- UDP, which emphasizes simplicity and low latency.
Applications choose whichever protocol best matches their needs.
What Is TCP?
Transmission Control Protocol (TCP) is designed for reliable communication.
Before data is exchanged, TCP establishes a logical connection between the two communicating devices. During transmission it continually monitors the communication to ensure that information arrives correctly. If packets are lost or corrupted, TCP automatically retransmits them. It also ensures that information is delivered to the receiving application in exactly the same order in which it was sent.
To the application, the communication appears as one continuous and reliable stream of information.
Why Is Reliability Important?
Many Internet applications depend upon complete accuracy.
Examples include:
- web browsing;
- electronic mail;
- file transfers;
- cloud storage;
- online banking; and
- software downloads.
Imagine downloading a computer program if one packet were missing. The program might not install correctly. Similarly, an incorrect bank transaction or incomplete email could have serious consequences.
TCP prevents these problems by ensuring that every piece of information is delivered successfully.
Does Reliability Have a Cost?
Yes.
Providing reliable communication requires additional processing and extra information within the transmitted packets. TCP performs tasks such as:
- establishing a connection;
- confirming successful reception;
- detecting missing information;
- retransmitting lost packets; and
- delivering information in the correct order.
These features improve reliability but introduce additional communication overhead and may slightly increase delay.
For many applications, this trade-off is entirely worthwhile.
What Is UDP?
User Datagram Protocol (UDP) takes a much simpler approach.
Rather than establishing a connection before transmission, UDP simply sends each packet independently. The protocol does not attempt to determine whether packets arrive successfully. If a packet is lost, UDP normally does not retransmit it.
This simplicity reduces processing overhead and minimizes transmission delay.
Why Would Anyone Accept Lost Packets?
Surprisingly, many applications function perfectly well despite occasional packet loss.
Consider a live video conversation. If one video frame is lost, the conversation continues.
Most users never notice. However, if the system paused for several seconds while waiting for the missing packet to be retransmitted, the interruption would be obvious and distracting.
For real-time communication, receiving information quickly is often more important than receiving every packet.
Which Applications Use UDP?
UDP is commonly used for applications requiring low delay, including:
- Voice over IP (VoIP);
- video conferencing;
- live video streaming;
- online gaming;
- Domain Name System (DNS) queries; and
- many Internet of Things (IoT) applications.
These applications can usually tolerate occasional packet loss far better than excessive delay.
Which Protocol Is Faster?
UDP generally introduces less delay because it performs fewer processing steps.
However, this does not necessarily mean that applications using UDP always operate faster. TCP can often achieve extremely high data rates while still providing reliable delivery. The more important difference is that TCP invests additional effort in ensuring correctness, whereas UDP minimizes overhead to reduce latency.
Each protocol is optimized for different communication requirements.
How Do Applications Choose Between TCP and UDP?
The choice depends upon what the application considers most important.
Applications typically choose TCP when they require:
- complete reliability;
- accurate data delivery;
- correct packet ordering; and
- guaranteed communication.
Applications generally choose UDP when they require:
- minimal delay;
- continuous real-time communication;
- rapid response; or
- simple request-and-response transactions.
Neither protocol is universally superior.
Each solves a different engineering problem.
Do Users Need to Choose the Protocol?
Usually not.
The application selects the appropriate transport protocol automatically. For example:
- a web browser normally uses TCP;
- an email program uses TCP;
- a video conference often uses UDP;
- an online game may use UDP;
- a DNS lookup typically uses UDP.
The user simply launches the application, while the underlying networking software selects the appropriate communication method.
Can TCP and UDP Be Used Together?
Yes.
Many Internet applications use both protocols. For example, a video conferencing system might use:
- TCP for user authentication and session setup;
- UDP for transmitting live audio and video; and
- TCP again for transferring documents shared during the meeting.
Similarly, many online games use TCP for account management while relying on UDP for real-time player movements.
The two protocols therefore complement one another rather than compete.
Will TCP and UDP Continue to Be Used?
Almost certainly.
Although new transport technologies continue to be developed, TCP and UDP remain the foundation of modern Internet communication. Newer protocols often build upon UDP while adding features that improve security or reduce latency. Nevertheless, the underlying design philosophy remains unchanged:
- reliable communication when accuracy is essential; and
- lightweight communication when responsiveness is more important.
This simple division has served the Internet successfully for many decades.
What Should You Remember?
TCP and UDP perform the same basic function—they deliver information between applications running on different computers—but they do so in different ways.
TCP provides reliable, ordered, connection-oriented communication and is used whenever accurate data delivery is essential.
UDP provides lightweight, connectionless communication with minimal delay and is preferred for many real-time applications.
Together, these two transport protocols allow the Internet to support an extraordinary variety of communication services, from web browsing and email to video conferencing, streaming media, and online gaming.
Back to reading