TCP vs UDP

Ritesh PandeyRitesh Pandey
4 min read

What is TCP Protocol?

The TCP stands for the Transmission Control Protocol. It’s a network protocol that help to communicate with one computer to another computer. We use TCP for communication between two computers and communication should be good and reliable.

Example:

We want to view a web page, then we expect that nothing should be missing on the page, or we want to download a file, then we require a complete file, i.e., nothing should be missing either it could be a text or an image. This can only be possible due to the TCP.

Features Of TCP:

  1. Data delivery: TCP protocol ensures that the data is received correctly, no data is missing and in order. If TCP protocol is not used, then the incorrect data can be received or out of order. For example, if we try to view the web page or download a file without using TCP, then some data or images could be missing.

  2. Protocol: TCP is a connection-oriented protocol. Through the word connection-oriented, we understand that the computers first establish a connection and then do the communication. This is done by using a three-way handshake. In a three-way handshake, the first sender sends the SYN message to the receiver then the receiver sends back the SYN ACK message to confirm that the message has been received. After receiving the SYN ACK message, the sender sends the acknowledgment message to the receiver. In this way, the connection is established between the computers. Once the connection is established, the data will be delivered. This protocol guarantees the data delivery means that if the data is not received then the TCP will resend the data.

Important: The TCP is responsible to deliver accurate data but its face some latency.

What is UDP Protocol?

The UDP stands for User Datagram Protocol. Its working is similar to the TCP as it is also used for sending and receiving the message.

The main difference is that UDP is a connectionless protocol. Here, connectionless means that no connection establishes prior to communication. It also does not guarantee the delivery of data packets. It does not even care whether the data has been received on the receiver's end or not, so it is also known as the "fire-and-forget" protocol. It is also known as the "fire-and-forget" protocol as it sends the data and does not care whether the data is received or not.

UDP is faster than TCP as it does not provide the assurance for the delivery of the packets.

Differences between the TCP and UDP

Reliability: TCP is a reliable protocol as it provides assurance for the delivery of the data. It follows the acknowledgment mechanism. In this mechanism, the sender receives the acknowledgment from the receiver and checks whether the acknowledgment is positive or negative. If the ACK is positive means, the data has been received successfully. If ACK is negative, then TCP will resend the data. It also follows the flow and error control mechanism.
UDP is an unreliable protocol as it does not ensure the delivery of the data.

Flow Control: TCP follows the flow control mechanism that ensures a large number of packets are not sent to the receiver at the same time, while UDP does not follow the flow control mechanism.

Ordering: TCP uses ordering and sequencing techniques to ensure that the data packets are received in the same order in which they are sent. On the other hand, UDP does not follow any ordering and sequencing technique; i.e., data can be sent in any sequence.

Speed: Since TCP establishes a connection between a sender and receiver, performs error checking, and also guarantees the delivery of data packets while UDP neither creates a connection nor it guarantees the delivery of data packets, so UDP is faster than TCP.

TCPUDP
Full formIt stands for Transmission Control Protocol.It stands for User Datagram Protocol.
Type of connectionIt is a connection-oriented protocol, which means that the connection needs to be established before the data is transmitted over the network.It is a connectionless protocol, which means that it sends the data without checking whether the system is ready to receive or not.
ReliableTCP is a reliable protocol as it provides assurance for the delivery of data packets.UDP is an unreliable protocol as it does not take the guarantee for the delivery of packets.
SpeedTCP is slower than UDP as it performs error checking, flow control, and provides assurance for the delivery ofUDP is faster than TCP as it does not guarantee the delivery of data packets.
Header sizeThe size of TCP is 20 bytes.The size of the UDP is 8 bytes.
0
Subscribe to my newsletter

Read articles from Ritesh Pandey directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ritesh Pandey
Ritesh Pandey