0% found this document useful (0 votes)
82 views7 pages

TCP Vs UDP - Difference and Comparison

The document compares TCP and UDP protocols. TCP is connection-oriented and reliable, ensuring data is received in order. UDP is connectionless and unreliable, with no guarantee of delivery or order. TCP is slower but suited for applications requiring reliability. UDP is faster and used for applications like games requiring low latency.

Uploaded by

Md Zahedul Hoque
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views7 pages

TCP Vs UDP - Difference and Comparison

The document compares TCP and UDP protocols. TCP is connection-oriented and reliable, ensuring data is received in order. UDP is connectionless and unreliable, with no guarantee of delivery or order. TCP is slower but suited for applications requiring reliability. UDP is faster and used for applications like games requiring low latency.

Uploaded by

Md Zahedul Hoque
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Compare 

Anything ›› WPA   vs.  WPA2   GO

TCP vs. UDP

Diffen  ›  Technology  ›  Telecommunications  ›  Computer Networking

There are two types of Internet Protocol (IP) traffic. They are TCP or
Transmission Control Protocol and UDP or User Datagram Protocol. TCP
is connection oriented – once a connection is established, data can be sent
bidirectional. UDP is a simpler, connectionless Internet protocol. Multiple
messages are sent as packets in chunks using UDP.

Comparison chart
Differences  —   Similarities  —

TCP UDP
Acronym for Transmission Control Protocol User Datagram Protocol or
Universal Datagram Protocol

Connection TCP is a connection­oriented UDP is a connectionless protocol.


protocol.

Function As a message makes its way UDP is also a protocol used in


across the internet from one message transport or transfer.
computer to another. This is This is not connection based
connection based. which means that one program
can send a load of packets to
another and that would be the
end of the relationship.

Usage TCP is suited for applications that UDP is suitable for applications


require high reliability, and that need fast, efficient
transmission time is relatively transmission, such as games.
less critical. UDP's stateless nature is also
useful for servers that answer
small queries from huge numbers
of clients.
TCP UDP

Use by other HTTP, HTTPs, FTP, SMTP, Telnet DNS, DHCP, TFTP, SNMP, RIP,


protocols VOIP.

Ordering of data TCP rearranges data packets in UDP has no inherent order as all


packets the order specified. packets are independent of each
other. If ordering is required, it
has to be managed by the
application layer.

Speed of transfer The speed for TCP is slower than UDP is faster because error


UDP. recovery is not attempted. It is a
"best effort" protocol.

Reliability There is absolute guarantee that There is no guarantee that the


the data transferred remains messages or packets sent would
intact and arrives in the same reach at all.
order in which it was sent.

Header Size TCP header size is 20 bytes UDP Header size is 8 bytes.

Common Header Source port, Destination port, Source port, Destination port,


Fields Check Sum Check Sum

Streaming of Data is read as a byte stream, no Packets are sent individually and


data distinguishing indications are are checked for integrity only if
transmitted to signal message they arrive. Packets have definite
(segment) boundaries. boundaries which are honored
upon receipt, meaning a read
operation at the receiver socket
will yield an entire message as it
was originally sent.

Weight TCP is heavy­weight. TCP UDP is lightweight. There is no


requires three packets to set up a ordering of messages, no
socket connection, before any tracking connections, etc. It is a
user data can be sent. TCP small transport layer designed on
handles reliability and congestion top of IP.
control.

Data Flow TCP does Flow Control. TCP UDP does not have an option for


Control requires three packets to set up a flow control
socket connection, before any
user data can be sent. TCP
handles reliability and congestion
control.

Error Checking TCP does error checking and UDP does error checking but


error recovery. Erroneous simply discards erroneous
packets are retransmitted from packets. Error recovery is not
the source to the destination. attempted.

Fields 1. Sequence Number, 2. AcK 1. Length, 2. Source port, 3.


number, 3. Data offset, 4. Destination port, 4. Check Sum
Reserved, 5. Control bit, 6.
Window, 7. Urgent Pointer 8.
Options, 9. Padding, 10. Check
Sum, 11. Source port, 12.
Destination port

Acknowledgeme Acknowledgement segments No Acknowledgment


nt

Handshake SYN, SYN­ACK, ACK No handshake (connectionless


protocol)

Contents: TCP vs UDP
1 Differences in Data Transfer Features 2 How TCP and UDP work
1.1 Reliability 3 Different Applications of TCP and UDP
1.2 Ordering 3.1 TCP vs. UDP for Game Servers
1.3 Connection
4 References
1.4 Method of transfer
1.5 Error Detection

Differences in Data Transfer Features
TCP ensures a reliable and ordered delivery of a stream of bytes from user to server or
vice versa. UDP is not dedicated to end to end connections and communication does
not check readiness of receiver.

Reliability
TCP is more reliable since it manages message acknowledgment and retransmissions
in case of lost parts. Thus there is absolutely no missing data. UDP does not ensure
that communication has reached receiver since concepts of acknowledgment, time out
and retransmission are not present.

Ordering
TCP transmissions are sent in a sequence and they are received in the same
sequence. In the event of data segments arriving in wrong order, TCP reorders and
delivers application. In the case of UDP, sent message sequence may not be
maintained when it reaches receiving application. There is absolutely no way of
predicting the order in which message will be received.

Connection
TCP is a heavy weight connection requiring three packets for a socket connection and
handles congestion control and reliability. UDP is a lightweight transport layer designed
atop an IP. There are no tracking connections or ordering of messages.

Method of transfer
TCP reads data as a byte stream and message is transmitted to segment boundaries.
UDP messages are packets which are sent individually and on arrival are checked for
their integrity. Packets have defined boundaries while data stream has none.

Error Detection
UDP works on a "best­effort" basis. The protocol supports error detection via checksum
but when an error is detected, the packet is discarded. Retransmission of the packet for
recovery from that error is not attempted. This is because UDP is usually for time­
sensitive applications like gaming or voice transmission. Recovery from the error would
be pointless because by the time the retransmitted packet is received, it won't be of any
use.

TCP uses both error detection and error recovery. Errors are detected via checksum
and if a packet is erroneous, it is not acknowledged by the receiver, which triggers a
retransmission by the sender. This operating mechanism is called Positive
Acknowledgement with Retransmission (PAR).

How TCP and UDP work
A TCP connection is established via a three way handshake, which is a process of
initiating and acknowledging a connection. Once the connection is established data
transfer can begin. After transmission, the connection is terminated by closing of all
established virtual circuits.
01 Introduction to TCP & UDP Protocols

UDP uses a simple transmission model without implicit hand­shaking dialogues for
guaranteeing reliability, ordering, or data integrity. Thus, UDP provides an unreliable
service and datagrams may arrive out of order, appear duplicated, or go missing
without notice. UDP assumes that error checking and correction is either not necessary
or performed in the application, avoiding the overhead of such processing at the
network interface level. Unlike TCP, UDP is compatible with packet broadcasts
(sending to all on local network) and multicasting (send to all subscribers).

Different Applications of TCP and UDP
Web browsing, email and file transfer are common applications that make use of TCP.
TCP is used to control segment size, rate of data exchange, flow control and network
congestion. TCP is preferred where error correction facilities are required at network
interface level. UDP is largely used by time sensitive applications as well as by servers
that answer small queries from huge number of clients. UDP is compatible with packet
broadcast ­ sending to all on a network and multicasting – sending to all subscribers.
UDP is commonly used in Domain Name System, Voice over IP, Trivial File Transfer
Protocol and online games.

CCNA / CCENT Tutorial: TCP Vs. UDP

TCP vs. UDP for Game Servers
For massively multiplayer online (MMO) games, developers often have to make an
architectural choice between using UDP or TCP persistent connections. The
advantages of TCP are persistent connections, reliability, and being able to use
packets of arbitrary sizes. The biggest problem with TCP in this scenario is its
congestion control algorithm, which treats packet loss as a sign of bandwidth limitations
and automatically throttles the sending of packets. On 3G or Wi­Fi networks, this can
cause a significant latency.

Experienced developer Christoffer Lernö weighed the pros and cons and recommends
the following criteria to choose whether to use TCP or UDP for your game:

Use HTTP over TCP for making occasional, client­initiated stateless queries when
it's OK to have an occasional delay.
Use persistent plain TCP sockets if both client and server independently send
packets but an occasional delay is OK (e.g. Online Poker, many MMOs).
Use UDP if both client and server may independently send packets and
occasional lag is not OK (e.g. Most multiplayer action games, some MMOs).

References
Wikipedia: Transmission Control Protocol
Wikipedia: User Datagram Protocol
UDP vs TCP for game servers
The Transmission Control Protocol

Related Comparisons

WPA  vs  WPA2 Hub  vs  Switch Cat5  vs  Cat5e

Internet  vs  World Wide Router  vs  Switch Modem  vs  Router


Web

Download
Free Download Go to unzipper.com

   

Comments: TCP vs UDP
151 Comments Sort by  Newest

Add a comment...

Nigel Israel­God Avedon · Web Designer at CADigital City
shweet
Like · Reply · Apr 10, 2017 12:08pm

Irshad Ahmad · National College of Science and Technology
good
Like · Reply · Jan 11, 2017 9:36am

Bebesi Eric Rick­b · Works at Artist
GOOOODD
Like · Reply · Jan 8, 2017 1:21am

Śí Phãx · INGM, FSI
‫ﺷﻛﺭﺍ‬
Like · Reply · Dec 26, 2016 12:51pm

Farelle Silver · Darmstadt University of Applied Sciences
thank you, this was very easy to understand 
Like · Reply · Dec 13, 2016 4:02pm

Rana Usama Ƞå · Defence Public School
10 names of protocols along with its port numbers also mention UDP/TCP traffic?
Can anyone tell me ?
Like · Reply · Oct 16, 2016 4:18am

Makrand Patil · Walchand College of Engineering, Solapur
It Is very helpful..Good to understand..
Like · Reply · Sep 2, 2016 10:09pm

Mark Makombe · Works at Botswana International University of Science and
Technology
Great article. Im persuing my PhD research on MANETs and this was the info I
have been hunting. So tell me, are all routing protocols for MANETs based on UDP
?
Like · Reply · Jul 18, 2016 12:59pm

Anand Gopinath · Works at NoT yeT woRkiNg !! iM stiLl stUdYinG !!hehe, im still
youth
superb job
Like · Reply · Jun 3, 2016 7:35am

Dhananjaya Lakmal Bulathsinghala · Open University of Sri Lanka
Great job
Like · Reply · May 24, 2016 11:24pm

Asad Abas · Data Entry Supervisor at WAPDA MEPCO
thanks for these basic but neccessary networking informations.
Like · Reply · Apr 27, 2016 8:59pm

Mawanda Derro · Director at MDK Japan
nice work
Like · Reply · Apr 22, 2016 7:57pm

Pasindu Menuka Sannasuriya · Works at Rabbit.lk
good explanation
Like · Reply · Apr 19, 2016 8:04am

Esubalew Lake · Works at Wolaita Sodo, Ethiopia
answer
Like · Reply · Mar 27, 2016 11:45pm

Ashwini Dhok · Rgpv
This is very helpful and easy to understand.
Thank you
Like · Reply · Jan 22, 2016 12:12am

Load 10 more comments

Facebook Comments Plugin
Start Download - PDF Now
Convert From Doc to PDF, PDF to Doc Simply With The Free On-line App!
Go to fromdoctopdf.com

Anonymous comments (5)

October 7, 2013, 3:50pm

Very useful. thanks for sharing

— 196.✗.✗.180

April 29, 2014, 6:19am

very well compared, thanks.

— 115.✗.✗.156

July 4, 2013, 7:17am

Just found your web site, definitely a keeper.

— 184.✗.✗.157

March 6, 2014, 3:45pm

Very helpful

— 37.✗.✗.113

December 23, 2013, 4:39pm

thank you its very useful :­)

— 117.✗.✗.195

About Diffen
© All rights reserved.
How to Cite
Log in / Register Terms of use |  Privacy policy
Request a Comparison
Submit Feedback

Stay connected

You might also like