What's the Difference Between TCP and UDP?

Both User Datagram Protocol and Transmission Control Protocol, UDP and TCP respectively, are transportation protocols working on the transport layer for the TCP/IP model. While you'll deal with both quite often, they're used for different purposes. We can compare both on a set of measures:

Reliability

TCP is a connection-oriented protocol, meaning it will complete a transfer as long as the connection exists. If the connection is severed, the server will request the missing information again. Files will arrive uncorrupted.

UDP is connectionless. You can send data over UDP whether there's a connection or not, and there isn't any guarantee it'll get to the destination. It's possible to encounter corrupted files transfered over UDP.

Ordered

With TCP, you don't have to worry about data arriving out of order; it will always arrive in the sequence you sent it. UDP is much simpler, and data will arrive in basically any order. We call UDP "unordered."

Protocol Weight

TCP is considered a heavyweight protocol, meaning it requires more system resource overhead to function properly. If there's any issues with the TCP connection, such as packets being out of order or lost, the endpoint has to send requests for missing parts and rearrange what's there which requires processing power.

UDP, in contrast, is very lightweight. There's no further processing required past sending the data. The data is just sent. Error detection is very simple.

Packet Structure

TCP data is sent in a "stream," with no distinguishing between packets being read. UDP packets are sent individually in what's called a "datagram," and are put together when they arrive. Only one packet will be read per call with UDP.

Conclusion

TCP is a much more reliable protocol that takes more overhead to run. Where data accuracy is important, TCP will be used. UDP, on the other hand, is used when on-time arrival is more important than reliability. UDP is commonly used in streaming and gaming, where speed tends to be more important.
 

If you have any comments, feel free to post them below or find us on Twitter and Facebook!

-Until next time!

 

October 29 2019

Add or review comments

Please leave your comment

Existing comments

Comments 0


Get notified about new publications and product updates.
Please note we do not share information to anyone.