0% found this document useful (0 votes)
777 views

Differences Between TCP and UDP - GeeksforGeeks

The document compares the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). It outlines the key differences between TCP and UDP, including that TCP is connection-oriented and reliable while UDP is connectionless and unreliable. It also provides examples of when each protocol is commonly used.

Uploaded by

Anurag Kumbhare
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
777 views

Differences Between TCP and UDP - GeeksforGeeks

The document compares the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). It outlines the key differences between TCP and UDP, including that TCP is connection-oriented and reliable while UDP is connectionless and unreliable. It also provides examples of when each protocol is commonly used.

Uploaded by

Anurag Kumbhare
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Differences between TCP and

UDP
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

Features of TCP

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.

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.
UDP is used for some routing update protocols like RIP(Routing
Information Protocol).
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.

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:

Transmission Control Protocol


Basis User Datagram Protocol (UDP)
(TCP)

TCP is a connection-oriented UDP is the Datagram-oriented


protocol. Connection protocol. This is because
orientation means that the there is no overhead for opening a
Type of Service communicating devices should connection, maintaining a
establish a connection before connection, or terminating a
transmitting data and should close connection. UDP is efficient for
the connection after transmitting broadcast and multicast types of
the data. network transmission.

TCP is reliable as it guarantees the The delivery of data to the


Reliability delivery of data to the destination destination cannot be guaranteed in
router. UDP.

TCP provides extensive error-


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

An acknowledgment segment is
Acknowledgment No acknowledgment segment.
present.

Sequencing of data is a feature of


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

TCP is comparatively slower than UDP is faster, simpler, and more


Speed
UDP. efficient than TCP.
There is no retransmission of lost
Retransmission of lost packets is
Retransmission packets in the User Datagram
possible in TCP, but not in UDP.
Protocol (UDP).
TCP has a (20-60) bytes variable UDP has an 8 bytes fixed-length
Header Length
length header. header.
Weight TCP is heavy-weight. UDP is lightweight.
Handshaking Uses handshakes such as SYN, It’s a connectionless protocol i.e. No
Techniques ACK, SYN-ACK handshake
Broadcasting TCP doesn’t support Broadcasting. UDP supports Broadcasting.
TCP is used by HTTP, HTTPs, FTP, UDP is used by DNS, DHCP, TFTP,
Protocols
SMTP and Telnet. SNMP, RIP, and VoIP.
The TCP connection is a byte UDP connection is a message
Stream Type
stream. stream.
:
Overhead Low but higher than UDP. Very low.
This protocol is primarily utilized in This protocol is used in situations
situations when a safe and where quick communication is
trustworthy communication necessary but where dependability
Applications
procedure is necessary, such as in is not a concern, such as VoIP, game
email, on the web surfing, and streaming, video, and music
in military services. 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.
The second solution is UDP. No connection is required for
sending the data. The process is fast as compared to TCP,
where we need to set up a 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.
:

You might also like