What are TCP and UDP?

AiroServer's Blog

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two important protocols of the Internet. In OSI model Both of these are in Transport layer. This means that these protocols are for transfering data.In order to tell you the differeces between these two protocols, we have to explain about TCP first.

OSI Model

What does TCP do?

This protocol defines how Application Programs can establish a network conversation and maintain it. Application programs exchange data via this network conversation.So, when application programs want to send data to each other, This protocol does everything that is needed for this data exchanging.

How does it work?

TCP works with IP (Internet Protocol). This defines how computers send packets to each other.This means that when an Application Program (Web server) wants to send data, it asks the TCP layer to do it. TCP stack divides the file into packets, numbers them and then forwards them to IP layer for delivery.

This protocol is a connection-oriented protocol. This means that the connection maintained until the application programs at each end have finished exchanging messages.

Features:

There might be some problems during the transmission process. (Some packets might be lost, duplicated or delivered out of order) .TCP is able to detect these problems and fix them. For example: When a packet is lost, it will ask for re-transmission of the lost data.

TCP can help minimizing network congestion to prevent and reduce the happening of the mentioned problems. After all of these, if the data weren’t delivered, It will inform the sender about this.

UDP and TCP Differences:

  1. UDP is a connecetion-less. This means that UDP can’t find or reduce the problems like packet lost. This protocol just sends the packets in turn and doesn’t check if they were delivered or not.
  2. Because of the mentioned difference above, UDP can be faster. Because it doesnt wait to make sure a packet were delivered and fix the possible problems.

At last we can’t tell you which protocol is better, We can only say that if you are sending datas that only speed matters for it, use UDP. but if the delivery of all the packets matters to you, it’s better to use TCP.

Hope this article was useful to you!

Find More Articles...

Whats New?

fa_IRFA