TCP & UDP
Transmission Control Protocol and User Datagram Protocol
Both of these protocols reside at the transport layer of the OSI model.
Let’s look at the key differences between both →
Reliability
TCP is reliable while UDP is not.
When the TCP segments arrive at the destination, the protocol makes sure that all the segments were received and there is no error in the transmission and all segments are organized back into the correct order.
On the other hand, UDP doesn’t even care that datagrams were received by the receiver.
Connection type
TCP is connection-oriented while UDP is connectionless.
TCP uses a 3-way handshake to establish the connection before the data transmission and on top of that, TCP uses a 4-step procedure to make sure that all the data was actually sent and received by the receiver before closing the connection.
In UDP, no procedure to check on transmission status.
ERROR CHECKING
A header checksum is used to ensure error-free data transmission.
A UDP header also has a checksum, but it is optional for IPv4 and only necessary for IPv6. If a bit is flipped, a byte mangled, or some other badness happens to a packet, then it is highly likely that the receiver of that broken packet will notice the problem due to a checksum mismatch.
TCP is the dominant protocol and is used in WEB, telnet, FTP and E-mail.
But is UDP any good?
Yes, UDP is faster and is preferred for video calls (guess what causes the dropping frames while buffering!) and VoIP (Voice over IP).