TCP and UDP are the transport layer protocols that are responsible to provide end-to-end communication. However, TCP is a connection-oriented protocol whereas, UDP is a connection-less protocol. Do you know why we require these protocols?
Well, the layer 3 protocol that works on the IP is usually connectionless, unacknowledgeable and unreliable. Thus, these protocols don’t provide the guaranteed delivery of data. So, there was a need for a protocol that would resolve the problems like congestion, error, and flow control.
Although, designers also thought to build these abilities directly into the IP. But all these features come at the cost of time and bandwidth. So, the designers came up with the protocols TCP and UPD that provide congestion, error, and flow control.
Among these protocols, UDP is a simple protocol. It only sends packets between the applications present on different hosts. However, TCP is a complex protocol that provides more features such as:
- Establishing connection
- Provides reliability with retransmission
- Flow, congestion and error control
Let’s discuss TCP and UDP protocols in detail and also the differences between them.
Content: TCP Vs UDP
- Comparison Chart
- What is TCP?
- What is UDP?
- Key Differences
|Basis for Comparison||TCP||UDP|
|Meaning ||TCP establishes a 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 retransmit if the user requests.||It neither takes acknowledgement, nor it retransmits the lost data.|
|Protocol connection setup||Connection-oriented, the connection must be established prior to transmission||Connectionless, data is sent without setup|
|Data interface to the application||Stream-based||Message-based|
|Retransmissions||Delivery of all data is managed||Not performed|
|Features provided to manage the flow of data||Flow control using sliding window protocol||None|
|Overheads||Low but greater than the UDP||Very low|
|Data quantity suitability||Small to moderate amounts of data||Small to enormous amounts of the data|
|Implemented over||Applications where reliable transmission of data matters.||Application where data delivery speed matters.|
|Applications and protocols||FTP, Telnet, SMTP, IMAP etcetera.||DNS, BOOTP, DHCP, TFTP etcetera.|
What is TCP?
Transmission Control Protocol (TCP) is a transport layer protocol of the TCP/ IP model. It is a connection-oriented protocol. So, the protocol first establishes a connection between source and destination. Further, the source and destination start communicating over this established path.
TCP implements a three-way handshake protocol. It also facilitates flow control, error control and congestion control. This makes the TCP highly reliable.
TCP ensures that the data sent from the source reaches the destination in the correct order. If in case, data received is not in the proper format, then TCP retransmits the data.
TCP uses a sliding window system for transmission. It helps in detecting acknowledged transmission. It also automatically retransmits the data that failed to receive.
Functions performed by TCP
TCP ports determine higher-layer application processes. The higher layer mainly multiplexes the data received from the various processes. Further, it sends the multiplexed data with the help of the underlying network layer protocol.
- Establishing, managing and terminating connections
Devices on different networks that want to communicate have to follow a group of procedures to set up a connection between them. Through this connection, the data can travel from one device to other. TCP protocol further manages the established connection. When communication gets finished, the protocol terminates this connection.
- Handling and packaging data
TCP protocol receives the data from higher layers and packs it into the message to send it to the destination TCP software further. The software residing at the receiving end unpackages the data and supplies it to the application on the destination machine.
- Transferring data
The packaged data is transferred to the TCP process running on the other devices by following the layering principle.
- Providing reliability and transmission quality services
TCP provides the services that permit an application to consider the protocol a reliable medium of transferring the data.
- Providing flow control and congestion avoidance features
The protocol controls the flow of the data between the two devices and deals with congestion.
- HTTP(Hypertext Transfer Protocol)
- HTTPS(Hypertext Transfer Protocol Secure)
- FTP(File Transfer Protocol)
- SMTP(Simple Mail Transfer Protocol), etc.
What is UDP?
UDP or User Datagram Protocol is a connectionless protocol of the transport layer of the TCP/IP Model. It neither establishes a connection nor checks whether the destination computer is ready to receive or not. The protocol simply sends the data to the destination computer.
However, it transfers the data at a faster rate as compared to TCP. The protocol is comparatively less reliable. Therefore, used for transmitting data such as audio and video files.
UDP neither guarantees the delivery of data nor does it retransmits the lost packets. It is just a wrapper protocol that facilitates the application in accessing the IP.
Functions performed by UDP
The main task of a UDP is to take data from the higher-layer protocols and position it in UDP messages. These messages are then moved to the IP for transmission. It follows some specific steps to transmit the data which as discussed below.
- Higher-Layer Data Transfer
At first, the message is sent to the UDP software by an application.
- UDP Message Encapsulation
The message is encapsulated into the data field of the packet. The headers of the UDP message along with the source port field and destination port field, are added. It also computes the checksum value.
- Transfer message to IP
At last, the UDP message is transferred to the IP for transmission.
Similarly, when the destination end receives the message, this whole process gets reversed.
- BOOTP(Bootstrap Protocol),
- DHCP(Dynamic Host Configuration Protocol),
- DNS(Domain Name Server),
- TFTP(Trivial File Transfer Protocol), etc.
Key Differences Between TCP and UDP
- TCP is Connection-oriented whereas, UDP is a connectionless protocol.
- TCP is highly reliable for transferring useful data as it takes the acknowledgement of information sent. Also, resends the lost packets if any. Whereas in the case of UDP if the packet is lost it won’t request for retransmission and the destination computer receives corrupt data. 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.
- The header size of UDP is 8 bytes, and that of TCP is more than double. TCP header size is 20 bytes since, and the TCP header contains options, padding, checksum, flags, data offset, acknowledgement 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, and video files. 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.
Very elaborative information…..
I have learned the differences, thanks.