Difference Between TCP and UDP
Difference Between TCP and UDP
TCP UDP
Reliability: TCP is connection- Reliability: UDP is connectionless
oriented protocol. When a file or protocol. When you a send a data or
message send it will get delivered message, you don't know if it'll get
unless connections fails. If connection there, it could get lost on the way.
lost, the server will request the lost There may be corruption while
part. There is no corruption while transferring a message.
transferring a message.
Ordered: If you send two messages Ordered: If you send two messages
along a connection, one after the out, you don't know what order they'll
other, you know the first message will arrive in i.e. no ordered
get there first. You don't have to
worry about data arriving in the
wrong order.
Heavyweight: - when the low level Lightweight: No ordering of
parts of the TCP "stream" arrive in the messages, no tracking connections,
wrong order, resend requests have to etc. It's just fire and forget! This
be sent, and all the out of sequence means it's a lot quicker, and the
parts have to be put back together, so network card / OS have to do very
requires a bit of work to piece little work to translate the data back
together. from the packets.
Streaming: Data is read as a "stream," Datagrams: Packets are sent
with nothing distinguishing where one individually and are guaranteed to be
packet ends and another begins. There whole if they arrive. One packet per
may be multiple packets per read call. one read call.
Examples: World Wide Web (Apache Examples: Domain Name System
TCP port 80), e-mail (SMTP TCP (DNS UDP port 53), streaming media
port 25 Postfix MTA), File Transfer applications such as IPTV or movies,
Protocol (FTP port 21) and Secure Voice over IP (VoIP), Trivial File
Shell (OpenSSH port 22) etc. Transfer Protocol (TFTP) and online
multiplayer games etc