You are on page 1of 12

4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

Aptitude Engineering Mathematics Discrete Mathematics Operating System DBMS Computer Networks

Differences between TCP and UDP


Last Updated : 06 May, 2023
Prerequisite – Transport Layer responsibilities

Transmission Control Protocol (TCP) and User Datagram Protocol (UDP)


both are protocols of the Transport Layer. TCP is a connection-oriented
protocol where as UDP is a part of the Internet Protocol suite, referred to as
the UDP/IP suite. Unlike TCP, it is an unreliable and connectionless protocol.

Transmission Control Protocol (TCP)


TCP (Transmission Control Protocol) is one of the main protocols of the
Internet protocol suite. It lies between the Application and Network Layers
which are used in providing reliable delivery services. It is a connection-
oriented protocol for communications that helps in the exchange of
messages between different devices over a network. The Internet Protocol
(IP), which establishes the technique for sending data packets between
computers, works with TCP.

Transmission Control Protocol

We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Got It !
Features of TCP Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 1/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

TCP keeps track of the segments being transmitted or received by


assigning numbers to every single one of them.
Flow control limits the rate at which a sender transfers data. This is done
to ensure reliable delivery.
TCP implements an error control mechanism for reliable data transfer.
TCP takes into account the level of congestion in the network.

Advantages of TCP

It is reliable for maintaining a connection between Sender and Receiver.


It is responsible for sending data in a particular sequence.
Its operations are not dependent on OS.
It allows and supports many routing protocols.
It can reduce the speed of data based on the speed of the receiver.

Disadvantages of TCP

It is slower than UDP and it takes more bandwidth.


Slower upon starting of transfer of a file.
Not suitable for LAN and PAN Networks.
It does not have a multicast or broadcast category.
It does not load the whole page if a single data of the page is missing.

User Datagram Protocol (UDP)


User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part
of the Internet Protocol suite, referred to as the UDP/IP suite. Unlike TCP, it is
an unreliable and connectionless protocol. So, there is no need to establish a
connection before data transfer. The UDP helps to establish low-latency and
loss-tolerating connections establish over the network. The UDP enables
process-to-process communication.

We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 2/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

User Datagram Protocol

Features of UDP

Used for simple request-response communication when the size of data is


less and hence there is lesser concern about flow and error control.
It is a suitable protocol for multicasting as UDP supports packet
switching.
UDPto ensure
We use cookies is used
you havefor some
the best routing
browsing experienceupdate protocols
on our website. By using like RIP(Routing
our site, you acknowledge that
Information you have read and understood our Cookie Policy & Privacy
Protocol).
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 3/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

Normally used for real-time applications which can not tolerate uneven
delays between sections of a received message.

Advantages of UDP

It does not require any connection for sending or receiving data.


Broadcast and Multicast are available in UDP.
UDP can operate on a large range of networks.
UDP has live and real-time data.
UDP can deliver data if all the components of the data are not complete.

Disadvantages of UDP

We can not have any way to acknowledge the successful transfer of data.
UDP cannot have the mechanism to track the sequence of data.
UDP is connectionless, and due to this, it is unreliable to transfer data.
In case of a Collision, UDP packets are dropped by Routers in comparison
to TCP.
UDP can drop packets in case of detection of errors.

Which Protocol is Better: TCP or UDP?


The answer to this question is difficult because it totally depends on what
work we are doing and what type of data is being delivered. UDP is better in
the case of online gaming as it allows us to work lag-free. TCP is better if
we are transferring data like photos, videos, etc. because it ensures that data
must be correct has to be sent.

In general, both TCP and UDP are useful in the context of the work assigned
by us. Both have advantages upon the works we are performing, that’s why
it is difficult to say, which one is better.

We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 4/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

Difference Between TCP and UDP

Where TCP is Used?


Sending Emails
Transferring Files
Web Browsing

Where UDP is Used?


Gaming
Video Streaming
Online Video Chats

Differences between TCP and UDP


The main differences between TCP (Transmission Control Protocol) and UDP
(User Datagram Protocol) are:

Basis Transmission Control User Datagram


Protocol (TCP) Protocol (UDP)

Type of Service TCP is a connection- UDP is the Datagram-


oriented protocol. oriented protocol. This is
Connection because

orientation means that the there is no overhead for


communicating devices opening a connection,
should establish a maintaining a connection,
connection before or terminating a
We use cookies to ensure you have the besttransmitting data on
browsing experience and connection.
our website. By using UDP is efficient
our site, you acknowledge that you have readshould
and understood
close our
theCookie Policy
for&broadcast
Privacy and multicast
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 5/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

Basis Transmission Control User Datagram


Protocol (TCP) Protocol (UDP)

connection after types of network


transmitting the data. transmission.

TCP is reliable as it
The delivery of data to the
guarantees the delivery of
Reliability destination cannot be
data to the destination
guaranteed in UDP.
router.

TCP provides extensive


error-checking
Error checking mechanisms. UDP has only the basic
mechanism error-checking mechanism
It is because it provides
using checksums.
flow control and
acknowledgment of data.

An acknowledgment No acknowledgment
Acknowledgment
segment is present. segment.

Sequencing of data is a
feature of Transmission There is no sequencing of
Control data in UDP. If the order is
Sequence required, it has to be
Protocol (TCP). this means
managed by the
that packets arrive in order
application layer.
at the receiver.

TCP is comparatively UDP is faster, simpler, and


Speed
slower than UDP. more efficient than TCP.

Retransmission of lost There is no retransmission


Retransmission packets is possible in TCP, of lost packets in the User
but not in UDP. Datagram Protocol (UDP).

TCP has a (20-60) bytes UDP has an 8 bytes fixed-


Header Length
variable length header. length header.
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 6/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

Basis Transmission Control User Datagram


Protocol (TCP) Protocol (UDP)

Weight TCP is heavy-weight. UDP is lightweight.

Handshaking Uses handshakes such as It’s a connectionless


Techniques SYN, ACK, SYN-ACK protocol i.e. No handshake

TCP doesn’t support UDP supports


Broadcasting
Broadcasting. Broadcasting.

TCP is used by HTTP, UDP is used by DNS,


Protocols HTTPs, FTP, SMTP and DHCP, TFTP, SNMP, RIP,
Telnet. and VoIP.

The TCP connection is a UDP connection is a


Stream Type
byte stream. message stream.

Overhead Low but higher than UDP. Very low.

This protocol is used in


This protocol is primarily
situations where quick
utilized in situations when
communication is
a safe and trustworthy
necessary but where
Applications communication procedure
dependability is not a
is necessary, such as in
concern, such as VoIP,
email, on the web surfing,
game streaming, video,
and in military services.
and music streaming, etc.

Example: Suppose there are two houses, H1 and H2, and a letter has to be
sent from H1 to H2. But there is a river in between those two houses. Now
how can we send the letter?
Solution 1: Make a bridge over the river and then it can be delivered.
Solution 2: Get it delivered by a pigeon.

Consider the first solution as TCP. A connection has to be made (bridge)


to get the data (letter) delivered. The data is reliable because it will
directly reach another end without loss of data or error.
We use cookies
The tosecond
ensure yousolution
have the best
is browsing
UDP. experience on our website.
No connection By using for sending the
is required
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
data. The process is fast as compared to TCP, where we need to set up a
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 7/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

connection(bridge). But the data is not reliable: we don’t know whether


the pigeon will go in the right direction, will drop the letter on the way, or
some issue is encountered mid-travel.

FAQs
1. Which is faster: TCP or UDP?

UDP is faster than TCP. The reason for the faster UDP is its non-existent
acknowledge packet (ACK) which allows the streaming of continuous
packets where as TCP always works on the acknowledgment of a set of
packets calculated with the help of TCP window size and Round Trip Time
(RTT).

2. Which is better for Video Conferencing?

Both Protocols, TCP and UDP have several practical uses in day-to-day life,
but TCP has come as a better solution nowadays in the modern era as a
solution for this question of who is better at Video Conferencing. The reason
for this is because of the ability of UDP to order data correctly and it also
produces the output without error. TCP can also be used for Video
Conferencing when we have to focus more on quality rather than speed.
UDP is generally used when speed matters most rather than the quality of
the product. Some data packets might be lost or somehow received out of
order, but UDP is more prominently used in the case of live streaming.

Get 90% Course fee refund in just 90 Days! Also get 1:1 Mock Interview,
Job assistance and more additional benefits on selected courses. Take up
the Three 90 challenge today!

"GeeksforGeeks helped me ace the GATE exam! Thanks to them, I'm all set
for success!"
- Vibha Joshi | Expected AIR Top 100

Choose GeeksforGeeks as your perfect GATE 2025 Preparation partner with


these newly launched programs
We useGATE
cookiesCS & IT you have the best browsing experience on our website. By using
to ensure
our site,
GATEyou acknowledge
DS & AI that you have read and understood our Cookie Policy & Privacy
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 8/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

GATE Offline (Delhi/NCR)

Over 125,000+ students already trust us to be their GATE Exam guide. Join
them & let us help you in opening the GATE to top-tech IITs & NITs!

290 Suggest improvement

Previous Next

User Datagram Protocol (UDP) Protocols in Application Layer

Share your thoughts in the comments Add Your Comment

Similar Reads
Difference Between TCP, UDP and SCTP TCP and UDP in Transport Layer
Protocols

Various TCP and UDP ports Examples of TCP and UDP in Real Life

How Applications Coexist Over TCP and Why does DNS use UDP and not TCP?
UDP?

TCP vs UDP for Video Streaming Why is YouTube using TCP but not UDP?

Why does Netflix use TCP but not UDP Why is UDP Faster than TCP?
for streaming video?

P Palak Jain 5
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood Between
our Cookie, Policy
GATE&CSPrivacy
Article Tags : Computer Networks
Policy
, Difference

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 9/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

A-143, 9th Floor, Sovereign Corporate


Tower, Sector-136, Noida, Uttar Pradesh -
201305

Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Careers GfG Weekly Contest
In Media Offline Classes (Delhi/NCR)
Contact Us DSA in JAVA/C++
Advertise with us Master System Design
GFG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community

Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang
We use cookies to ensure you DSA Roadmap
have the best browsing experience on our website. By using
our site, you acknowledge that
SQLyou have read and understood our Cookie Policy & Privacy
DSA Interview Questions
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 10/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

R Language Competitive Programming


Android Tutorial

Data Science & ML Web Technologies


Data Science With Python HTML
Data Science For Beginner CSS
Machine Learning Tutorial JavaScript
ML Maths TypeScript
Data Visualisation Tutorial ReactJS
Pandas Tutorial NextJS
NumPy Tutorial NodeJs
NLP Tutorial Bootstrap
Deep Learning Tutorial Tailwind CSS

Python Tutorial Computer Science


Python Programming Examples GATE CS Notes
Django Tutorial Operating Systems
Python Projects Computer Network
Python Tkinter Database Management System
Web Scraping Software Engineering
OpenCV Tutorial Digital Logic Design
Python Interview Question Engineering Maths

DevOps System Design


Git High Level Design
AWS Low Level Design
Docker UML Diagrams
Kubernetes Interview Guide
Azure Design Patterns
GCP OOAD
DevOps Roadmap System Design Bootcamp
Interview Questions

School Subjects Commerce


Mathematics Accountancy
Physics
We use cookies to ensure you Business Studies
have the best browsing experience on our website. By using
our site, you acknowledgeChemistry
that you have read and understood our Cookie Policy & PrivacyEconomics
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 11/12
4/16/24, 11:32 AM Differences between TCP and UDP - GeeksforGeeks

Biology Management
Social Science HR Management
English Grammar Finance
Income Tax

UPSC Study Material Preparation Corner


Polity Notes Company-Wise Recruitment Process
Geography Notes Resume Templates
History Notes Aptitude Preparation
Science and Technology Notes Puzzles
Economy Notes Company-Wise Preparation
Ethics Notes Companies
Previous Year Papers Colleges

Competitive Exams More Tutorials


JEE Advanced Software Development
UGC NET Software Testing
SSC CGL Product Management
SBI PO Project Management
SBI Clerk Linux
IBPS PO Excel
IBPS Clerk All Cheat Sheets

Free Online Tools Write & Earn


Typing Test Write an Article
Image Editor Improve an Article
Code Formatters Pick Topics to Write
Code Converters Share your Experiences
Currency Converter Internships
Random Number Generator
Random Password Generator

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

We use cookies to ensure you have the best browsing experience on our website. By using
our site, you acknowledge that you have read and understood our Cookie Policy & Privacy
Policy

https://www.geeksforgeeks.org/differences-between-tcp-and-udp/ 12/12

You might also like