TCP Vs UDP - Difference and Comparison
TCP Vs UDP - Difference and Comparison
TCP vs. UDP
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
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 "besteffort" 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 handshaking 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.
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 WiFi 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, clientinitiated 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
Download
Free Download Go to unzipper.com
Comments: TCP vs UDP
151 Comments Sort by Newest
Add a comment...
Nigel IsraelGod 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 Rickb · 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