The main differences between TCP and UDP protocols
1. There are two types of Internet Protocol (IP)
traffic.
1) TCP - Transmission Control Protocol.
2) UDP - 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.
TCP vs UDP 1
2. TCP UDP
Function As a message makes its way across UDP is also a protocol used in message
the internet from one computer to transport or transfer.
another. This is not connection based which
This is connection based. means that one program can send a
load of packets to another and that
would be the end of the relationship.
Usage TCP is used in case of non-time UDP is used for games or applications
critical applications. that require fast transmission of data.
UDP's stateless nature is also useful for
servers that answer small queries from
huge numbers of clients.
Examples HTTP, HTTPs, FTP, SMTP Telnet etc... DNS, DHCP, TFTP, SNMP, RIP, VOIP
etc...
Ordering of TCP rearranges data packets in the UDP has no inherent order as all
Data Packets order specified. packets are independent of each other.
If ordering is required, it has to be
managed by the application layer. 2
TCP vs UDP
3. TCP UDP
Transfer Speed The speed for TCP is slower than UDP is faster because there is no
UDP. error-checking for packets.
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.
Data Streaming Data is read as a byte stream, no Packets are sent individually and
distinguishing indications are are checked for integrity only if they
transmitted to signal message 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.
TCP vs UDP 3
4. TCP UDP
Weight TCP requires three packets to set up a UDP is lightweight. There is no
socket connection, before any user ordering of messages, no
data can be sent. TCP handles tracking connections, etc. It is a
reliability and congestion control. small transport layer designed
on top of IP.
Data Flow Control TCP does Flow Control. TCP requires UDP does not have an option
three packets to set up a socket for flow control
connection, before any user data can
be sent. TCP handles reliability and
congestion control.
Error Checking TCP does error checking UDP does error checking, but
no recovery options.
Fields 1. Sequence Number, 2. AcK number, 1. Length, 2. Source port, 3.
3. Data offset, 4. Reserved, 5. Control Destination port, 4. Check Sum
bit, 6. Window, 7. Urgent Pointer 8.
Options, 9. Padding, 10. Check Sum,
11. Source port, 12. Destination port TCP vs UDP 4