Javatpoint Logo
Javatpoint Logo

TCP vs UDP

What is the TCP?

The TCP stands for Transmission Control Protocol. If we want the communication between two computers and communication should be good and reliable. For 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. It is one of the most widely used protocols over the TCP/IP network.

Features of TCP

The following are the features of the TCP:

  • 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.
  • 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.
TCP vs UDP

What is UDP?

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

TCP vs UDP
  • Type of protocol
    Both the protocols, i.e., TCP and UDP, are the transport layer protocol. TCP is a connection-oriented protocol, whereas UDP is a connectionless protocol. It means that TCP requires connection prior to the communication, but the UDP does not require any connection.
  • 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.
  • Flow of data
    In TCP, data can flow in both directions means that it provides the full-duplex service. On the other hand, UDP is mainly suitable for the unidirectional flow of data.

Let's look at the differences between the TCP and UDP in a tabular form.

TCP UDP
Full form It stands for Transmission Control Protocol. It stands for User Datagram Protocol.
Type of connection It 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.
Reliable TCP 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.
Speed TCP is slower than UDP as it performs error checking, flow control, and provides assurance for the delivery of UDP is faster than TCP as it does not guarantee the delivery of data packets.
Header size The size of TCP is 20 bytes. The size of the UDP is 8 bytes.
Acknowledgment TCP uses the three-way-handshake concept. In this concept, if the sender receives the ACK, then the sender will send the data. TCP also has the ability to resend the lost data. UDP does not wait for any acknowledgment; it just sends the data.
Flow control mechanism It follows the flow control mechanism in which too many packets cannot be sent to the receiver at the same time. This protocol follows no such mechanism.
Error checking TCP performs error checking by using a checksum. When the data is corrected, then the data is retransmitted to the receiver. It does not perform any error checking, and also does not resend the lost data packets.
Applications This protocol is mainly used where a secure and reliable communication process is required, like military services, web browsing, and e-mail. This protocol is used where fast communication is required and does not care about the reliability like VoIP, game streaming, video and music streaming, etc.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA