What is the difference between UDP and TCP
internet protocols?
by Vivek Gite on May 15, 2007 · 22 comments
Q. Can you explain the difference between UDP and TCP internet protocol (IP) traffic and its
usage with an example?
A. Transmission Control Protocol (TCP) and User Datagram Protocol (UDP)is a transportation
protocol that is one of the core protocols of the Internet protocol suite. Both TCP and UDP work
at transport layer TCP/IP model and both have very different usage.
Difference between TCP and UDP
                        TCP                                                  UDP
Reliability: TCP is connection-oriented protocol.    Reliability: UDP is connectionless protocol.
When a file or message send it will get delivered    When you a send a data or message, you don't
unless connections fails. If connection lost, the    know if it'll get there, it could get lost on the
server will request the lost part. There is no       way. There may be corruption while
corruption while transferring a message.             transferring a message.
Ordered: If you send two messages along a            Ordered: If you send two messages out, you
connection, one after the other, you know the        don't know what order they'll arrive in i.e. no
first message will get there first. You don't have   ordered
to worry about data arriving in the wrong order.
Heavyweight: - when the low level parts of the       Lightweight: No ordering of messages, no
TCP "stream" arrive in the wrong order, resend       tracking connections, etc. It's just fire and
requests have to be sent, and all the out of         forget! This means it's a lot quicker, and the
sequence parts have to be put back together, so      network card / OS have to do very little work to
requires a bit of work to piece together.            translate the data back from the packets.
Streaming: Data is read as a "stream," with          Datagrams: Packets are sent individually and
nothing distinguishing where one packet ends         are guaranteed to be whole if they arrive. One
and another begins. There may be multiple            packet per one read call.
packets per read call.
Examples: World Wide Web (Apache TCP port            Examples: Domain Name System (DNS UDP
80), e-mail (SMTP TCP port 25 Postfix MTA),          port 53), streaming media applications such as
File Transfer Protocol (FTP port 21) and Secure      IPTV or movies, Voice over IP (VoIP), Trivial
Shell (OpenSSH port 22) etc.                            File Transfer Protocol (TFTP) and online
                                                        multiplayer games etc
Further readings
       TCP and UDP articles at Wikipedia
Difference between TCP and UDP
There are two types of internet protocol (IP) traffic, and both have very different uses.
    1. TCP(Transmission Control Protocol). TCP is a connection-oriented protocol, a connection can be
       made from client to server, and from then on any data can be sent along that connection.
          o Reliable - when you send a message along a TCP socket, you know it will get there
              unless the connection fails completely. If it gets lost along the way, the server will re-
              request the lost part. This means complete integrity, things don't get corrupted.
          o Ordered - if you send two messages along a connection, one after the other, you know
              the first message will get there first. You don't have to worry about data arriving in the
              wrong order.
          o Heavyweight - when the low level parts of the TCP "stream" arrive in the wrong order,
              resend requests have to be sent, and all the out of sequence parts have to be put back
              together, so requires a bit of work to piece together.
    2. UDP(User Datagram Protocol). A simpler message-based connectionless protocol. With UDP you
       send messages(packets) across the network in chunks.
          o Unreliable - When you send a message, you don't know if it'll get there, it could get lost
              on the way.
          o Not ordered - If you send two messages out, you don't know what order they'll arrive in.
          o Lightweight - No ordering of messages, no tracking connections, etc. It's just fire and
              forget! This means it's a lot quicker, and the network card / OS have to do very little
              work to translate the data back from the packets.