There exist some similarities and dissimilarities between the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). One of the differences is that TCP is a connection-oriented protocol as it establishes an end to end connection between computers before transferring the data. On the other hand, UDP is a connection-less protocol since it does not determine the connection before sending data. The similarity between them is that both TCP and UDP is present in the Transport Layer of TCP/IP Model. Other differences are mentioned below in the article.
Content: TCP Vs UDP
|Basis for Comparison||TCP||UDP|
|Meaning||TCP establishes connection between the computers before transmitting the data||UDP sends the data directly to the destination computer without checking whether the system is ready to receive or not|
|Expands to||Transmission Control Protocol||User Datagram Protocol|
|Connection Type||Connection Oriented||Connection Less|
|Header Size||20 Bytes||8 Bytes|
|Acknowledgement||It takes acknowledgement of data and has the ability to re transmit, if the user requests.||It neither takes acknowledgement nor it re transmits the lost data.|
Definition Of TCP
TCP or Transmission Control Protocol is a connection-oriented protocol, found in the transport layer of the TCP/ IP Model. It establishes a connection between source and destination computer before starting the communication.
It is highly reliable, as it uses the 3-way handshake, flow, error and congestion control. It makes sure that the data sent from source computer are received accurately by the destination computer. If in case, data received is not in the proper format, then TCP retransmits the data.
Following protocols use TCP for transmitting data:
- HTTP(Hypertext Transfer Protocol),
- HTTPs(Hypertext Transfer Protocol Secure),
- FTP(File Transfer Protocol),
- SMTP(Simple Mail Transfer Protocol), etc.
Definition Of UDP
UDP or User Datagram Protocol is a connectionless protocol found in the transport layer of TCP/IP Model. It neither establishes a connection nor checks whether the destination computer is ready to receive or not, it just sends the data directly. UDP is used to transfer the data at a faster rate. It is less reliable and so used for transmitting data such as audio and video files.
UDP neither guarantees the delivery of data nor does it retransmits the lost packets.
Key Differences Between TCP and UDP
- TCP is Connection-oriented whereas, UDP is Connectionless protocol.
- TCP is highly reliable for transferring useful data as it takes the acknowledgment of information sent. And resends the lost packets if any. Whereas in the case of UDP if the packet is lost it won’t request for retransmission and a corrupt data is received by the destination computer. So, UDP is an unreliable protocol.
- TCP is slower as compared to UDP since TCP establishes the connection before transmitting data, and ensures the proper delivery of packets. On the other hand, UDP does not acknowledge whether the data transmitted is received or not.
- Header size of UDP is 8 bytes, and that of TCP is more than double. TCP header size is 20 bytes since, and TCP header contains options, padding, checksum, flags, data offset, acknowledgment number, sequence number, source and destination ports, etc.
- Both TCP and UDP can check for errors, but only TCP can correct the error since it has both congestion and flow control.
Both TCP and UDP have their advantages and disadvantages. UDP is faster, simpler and efficient and hence generally used for sending audio, video files, and TCP, on the other hand, is robust, reliable and guarantees the delivery of packets in the same order.
Hence, we conclude that both TCP and UDP are essential for data transmission.