Alexandria University
Institute of Graduate Studies and Research
Department of information Technology
Difference between
TCP and UDP
Acronym for
Connection
TCP
UDP
TCP is a connection-oriented
protocol.
Function
TCP
UDP
Speed of transfer
TCP
TCP does Flow Control. TCP
requires three packets to set up a
Data Flow Control socket connection, before any user
data can be sent. TCP handles
reliability and congestion control.
Error Checking
Checksum checksum
UDP
UDP does not have an option for flow
control
No Acknowledgment
No handshake (connectionless
protocol)
to detect errors
3.2. 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.
3.3. 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.
3
3.4. 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.
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).
4. References
http://en.wikipedia.org/wiki/Transmission_Control_Protocol
http://en.wikipedia.org/wiki/User_Datagram_Protocol
http://www.diffen.com/difference/TCP_vs_UDP
http://www.diffen.com/difference/TCP_vs_UDP\
http://www.isoc.org/INET97/proceedings/F3/F3_1.HTM
http://www.caida.org/research/traffic-analysis/tcpudpratio/