TCP vs UDP: Unfolded




By Yugansh Kumar       May 12, 2020




By Yugansh Kumar

May 12, 2020

TCP and UDP are protocols that are a part of the transport layer in the OSI model. Both of these protocols are used for sending packets over the internet. They are built over the Internet Protocol(IP) that is the reason why they are commonly known as TCP/IP which indicates TCP over IP and UDP over IP is referred to as UDP/IP.

Now before directly going towards TCP vs UDP. We should have a basic knowledge of what TCP and UDP are and how  do these protocols work.

What is TCP?

TCP/IP stands for Transmission control protocol/Internet protocol. It is a connection-oriented protocol that is used by computers to communicate over the internet.

How does TCP work?

A TCP connection is established with the help of a three-way handshake, which essentially means if we have two computers communicating via messages and computer A sends SYN packet to computer B and receives back SYN/ACK from the computer B, Finally, A sends the ACK packet to B. They both establish a reliable reference to which they’re going to start the particular data transfer. It is also called the connection-oriented protocol.

TCP Packet

What is UDP?

UDP(User Datagram Protocol) is an alternative transmission protocol to TCP which is most commonly used for establishing low latency connections between the applications on the internet.

How does UDP work?

tcp-vs-udp

It supports a two-way handshake, where a computer A sends SYN packet to computer B and receives back SYN/ACK from the computer B and the connection is established. It does not require the ACK packet from the sender to confirm the successful transfer of data and hence is called a connectionless protocol.

Difference between TCP and UDP(TCP vs UDP)

TCP VS UDP

                              TCP                              UDP
It is a connection-oriented protocol. It is a connectionless protocol.
Establishes a three-way handshake. Establishes a two-way handshake.
Reliable as it guarantees delivery of data to the destination. Not as reliable as the delivery of data is not guaranteed.
It does provide feedback. Does not provide feedback
It offers retransmission of lost packets. There is no retransmission of lost packets in UDP.
TCP provides extensive error checking mechanisms. It is because it provides flow control and acknowledgment of data. UDP provides error checking by using checksums.
TCP does not support broadcasting. UDP supports broadcasting and multicasting.
TCP has slower rate of data transmission. UDP has faster rate of data transmission.
Applications that use TCP protocol are all messaging platforms, World Wide Web(HTTP,HTTPs),FileTransfer Protocol(FTP),Email(SMTP). Applications that use UDP are video streaming platforms, VPN tunnelling, Live broadcasts, Domain Name System(DNS), Voice over Internet Protocol (VOIP).

Advantages of TCP

  1. Retransmission-When a sender doesn’t get an acknowledgment after a certain period from the receiver. It will assume that the packet got lost on its way. So, the sender will send it again.
  2.  Ordering-TCP transmissions are sent in an order and they are received in the same order. In the event of data segments arriving in the wrong order, TCP reorders and delivers the packet.
  3. Error Control
  4. Congestion Control– Delays the delivery of packets when the network is congested.

TCP Disadvantages

  1. Bigger packet size.
  2. Data doesn’t get sent out immediately.
  3. A real-Time conversation will not feel like real-time due to delays.

Advantages of UDP

  1. Faster Transmission– As the UDP packets are smaller in size than the TCP packets, hence they travel faster.
  2. Applications that need constant data flow, bulk data and which require fastness than reliability uses UDP over TCP.
  3. It is a connectionless protocol hence no connection to make or maintain, hence no delay.

UDP Disadvantages

  1. Due to the primitive form of error detection in UDP sometimes the data gets corrupted.
  2. There is no compensation for lost packets.
  3. There is no particular order of packets. Packets can arrive out of order.
  4. No congestion control.

Conclusion

UDP is lightweight but not that reliable so video streaming and live streaming based on UDP since it doesn’t require any ordering of packets and it could improve the speed of data transfer.
Although TCP is packets are larger than UDP and requires more time
but it is quite reliable and hence is used for mailing and messaging services due to its error checking mechanism.

Get latest tech news and updates, programming tutorials and cyber security tips and tricks. Check out MeuSec for more.


You Might Also Like

Subscribe to our Newsletter

Advertisement