TCP vs UDP protocol. Things you need to know!
Hello, my fellow readers, I am here with another new article which explains the specific use and difference of tcp and udp. I will keep releasing articles about networking to simplify concepts for my audiences. Follow my page if you haven’t done it yet… that being said, let’s dive into the article.
What is this article about?
This article tends to give you a brief explanation of TCP and UDP and when they can be used.
First of all, I want to mention that this article doesn't involve any codes/programs. It will just be a generalized concept about each protocol. Let’s get into the article now.
What is the TCP protocol?
The Transmission Control Protocol (TCP) is a core protocol of the Internet Protocol Suite. It is one of the main protocols of the Internet, alongside the Internet Protocol (IP). TCP is a connection-oriented protocol that provides reliable, ordered delivery of data between two endpoints. It is used to establish and maintain connections between hosts, and to provide reliable data transfer services.
So one thing to note from the above paragraph is that TCP is connection-oriented which means all the data exchange happens whilst in connection. This behavior makes the data transfer reliable since they are assured of connection. There is almost no data loss or data corruption with this protocol.
What is the UDP protocol?
UDP (User Datagram Protocol) is a connectionless protocol that provides a best-effort delivery system. It is a simpler protocol than TCP and does not require the overhead of establishing and maintaining connections.
So again one thing to note from the above paragraph is that UDP is a connectionless protocol. This means that the data exchange is not reliable hence, the protocol is prone to data loss and data corruption. There are of course ways to deal with these issues. But this article is not mint for that. To know more about dealing with the issues, check out my other article here.
Overall, the main difference between TCP and UDP protocol is the matter of being connection-oriented or connectionless. These main differences bring up the whole section of other differences.
When should we prefer TCP?
TCP should be preferred when data needs to be reliably transferred and the order of the data is important. For example, in messaging apps, data loss and data corruption should be very less and the order of the data is also a concern. In this case, we will use TCP protocol to transfer the messages so that the connection is reliable and we don’t have to do extra legwork. There are a lot of cases where TCP is preferred like: Web Browsing, Remote Desktop Protocols, etc…
When should we prefer UDP?
UDP should be preferred over TCP when speed is more important than reliability, such as in real-time applications like streaming audio or video. UDP is also better for applications that require fast transmissions, such as online gaming, video conferencing, and Voice over IP (VoIP). We do some leg works to verify the packet is valid and it is not corrupted and to detect packet loss. Overall, UDP is much faster than TCP and TCP is much more reliable than UDP.
That’s all for now. Let me know your suggestions and feedback in the comment section.
If you enjoyed the article, I guess I deserve a follow and a clap. Please share this article with your friends and family. Stay tuned!
My pages are Twitter Medium LinkedIn Telegram GitHub
Related articles from the author