Professional Documents
Culture Documents
TCP Vs UDP
TCP Vs UDP
Vs
UDP
What is TCP & UDP ?
Comparison
About
• There are two types of Internet Protocol (IP) traffic.
• They are TCP or Transmission Control Protocol and UDP or User Datagram
Protocol.
On networks data is transmitted in packets, which are units of data that are
sent independently on the network, and are reassembled in order once they
reach the destination
It determines how to break application data into packets that networks can
deliver, sends packets to and accepts packets from the network layer, manages
flow control.
What is TCP ?
• It also makes sure they have a deadline to reach the destination (which is a duration
of several hundred milliseconds called time-out) and some other technical provisions.
• For each packet received, the sending device is notified through a packet called
acknowledgment.
• If after the time-out, no acknowledgment is received, the source sends another copy
of the probably missing or delayed packet.
• Out-of-order packets are also not acknowledged. This way, all packets are always
assembled in order, without holes and within a predetermined and acceptable delay.
SYN
SENDER RECEIVER
SYN, ACK
ACK
CONNECTION ESTABLISHED
• When using UDP, packets are just sent to the recipient. The sender will not
wait to make sure the recipient received the packet — it will just continue
sending the next packets.
What is UDP ?
• If you are the recipient and you miss some UDP packets, too bad — you can
not ask for those packets again.
• There is no guarantee you are getting all the packets and there is no way to
ask for a packet again if you miss it, but losing all this overhead means the
computers can communicate more quickly.
• UDP is used when speed is desirable and error correction is not necessary.
For example, UDP is frequently used for live broadcasts and online games.
What is UDP ?
• UDP enables process-to-process communication, whereas TCP supports
host-to-host communication.
• UDP can also be used in applications that require lossless data transmission
when the application is configured to manage the process of retransmitting
lost packets and correctly arranging received packets.
Usage TCP is suited for applications that require UDP is suitable for applications that need fast,
high reliability, and transmission time is efficient transmission, such as games. UDP's
relatively less critical. stateless nature is also useful for servers that
answer small queries from huge numbers of
clients.
Use by other HTTP, HTTPs, FTP, SMTP, Telnet DNS, DHCP, TFTP, SNMP, RIP, VOIP.
protocols
TCP vs UDP
TCP UDP
Ordering of data TCP rearranges data packets in the order UDP has no inherent order as all packets are
packets specified. 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. UDP is faster because error recovery is not
attempted. It is a "best effort" protocol.
Reliability There is absolute guarantee that the data There is no guarantee that the messages or
transferred remains intact and arrives in packets sent would reach at all.
the same 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, Check Sum Source port, Destination port, Check Sum
Fields
Weight TCP is heavy-weight. TCP requires three UDP is lightweight. There is no ordering of
packets to set up a socket connection, messages, no tracking connections, etc. It is a
before any user data can be sent. TCP small transport layer designed on top of IP.
handles reliability and congestion control.
TCP vs UDP
TCP UDP
Data Flow Control TCP does Flow Control. TCP requires three UDP does not have an option for flow
packets to set up a socket connection, before any control
user data can be sent. TCP handles reliability and
congestion control.
Error Checking TCP does error checking and error recovery. UDP does error checking but simply
Erroneous packets are retransmitted from the discards erroneous packets. Error
source to the destination. recovery is not attempted.