TCP and UDP Explained: What are They and How Do They Work?

Aditya U V
3 min readMar 27, 2022

--

Want to learn how the internet works? Learn TCP and UDP protocol, as well as how they work. It’s easier than you think!

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both protocols that help devices communicate over a network. TCP is a more reliable protocol, while UDP is faster but less reliable. In this blog post, we will deep-dive into the inner workings of TCP and UDP, and explain what they are and how they work. We will also discuss the three-way handshake process used by TCP, as well as the difference between TCP and UDP traffic. By the end of this post, you will have a better understanding of how these two protocols work and how they are used.

TCP

TCP is a reliable protocol that helps devices communicate over a network. TCP is responsible for ensuring that all data is delivered correctly and in order, without any errors or lost data. TCP is a connection-oriented protocol, which means that it requires an initial setup process called a “handshake” before any data can be exchanged. The handshake involves three steps, which are commonly referred to by the acronyms SYN, SYN-ACK, and ACK.

TCP three way handshake
  • SYN — SYN stands for Synchronised Sequence Number. In this step, the client wants to establish a connection with the server, so it sends a segment with SYN, which informs the server that the client wants to start communication, and with what sequence number it starts the segment.
  • SYN/ACK — The server responds to the client request with the SYN/ACK signal bitset in this step. ACK signifies the segment’s response, and SYN is the same as the first step. It represents what sequence number it will start the segment.
  • ACK — In this step, the client acknowledges the server’s response, and they both establish a reliable connection with which they will start the actual data transfer.
UDP

UDP is a connectionless protocol that does not require a three-way handshake to establish communication between two devices. UDP uses IP to get data from one device to another but it doesn’t add any extra reliability or ordering on top of IP. UDP checksums are used to detect errors in the data. If no error is detected, UDP discards the checksum. If an error is detected, UDP silently discards the datagram. UDP does not provide any mechanism for flow control or congestion control. Because UDP adds very little overhead, it is suitable for applications where reliability isn’t important or where bandwidth is limited, such as audio and video streaming, Voice over IP (VoIP), and online gaming.

In conclusion, TCP and UDP are two protocols that help devices communicate over a network. TCP is more reliable but slower, while UDP is faster but less reliable. TCP uses a three-way handshake process to establish communication, while UDP does not. TCP also has built-in error checking and correction, while UDP does not. TCP provides flow control and congestion control, while UDP does not. TCP is typically used for applications that require high reliability, such as file transfer and email. UDP is typically used for applications that do not require high reliability, such as audio and video streaming.

Thank you for reading! I hope this article has helped you to understand the differences between TCP and UDP. If you have any questions, please feel free to leave a comment below.

--

--

Aditya U V
0 Followers

Coding and hacking are my passion. They fuel my curiosity and allow me to discover new things every day.