TCP VS UDP
Transport Layer uses the TCP or UDP protocols to provide its various services. When the data comes from the upper layers (i.e., the Application layer) to the transport layer, then the Transport layer adds the TCP or UDP header along with the data. This header adds the functionality.
Transmission Control Protocol (TCP)
The TCP stands for Transmission Control Protocol. If we want to achieve reliable communication between two computers, then TCP is the best. For example,
- If you want to view a web page, the need is there should be nothing missing on the page.
- want to download a file and need a complete file (i.e., nothing should be missing in the file)
. in the above cases, TCP is the best option. The size of the TCP header is from 20 to 60 bytes.
Features in TCP
TCP header includes the following mandatory features
- Connection-oriented communication (i.e., dial-up connection) uses three-way handshaking protocols. First send request for connection, second response from receiver that I am ready and in last sender sends the data.
- Segmentation: it converts the incoming data (in bits) to bytes, and then these bytes are gathered to make Segments.
- Reliable delivery (in-order sequence without loss of data): when the connection is established, the reliability of data comes into the picture. It is more reliable than UDP, where connectionless communication takes place.
- Full Duplex: both sender and receiver can send and receive the data at a time in TCP
- Error Control (checksum method): it handles the error, node to node, through the checksum method
- Piggybacking: it can send both data and acknowledgment at a time
- Flow control: if the receiver buffer is full then it controls the flow of data
- Congestion Control: it also handles the traffic control in network devices like routers. Means to say it controls the overflow of data in the network
User Datagram Protocol (UDP)
The UDP stands for User Datagram Protocol. Its working is also similar to the TCP. However, the main difference is that the UDP is a connectionless protocol. It means there is no connection established in advance for communication. So, a guarantee of data delivery is not achieved. It does not even care whether the data has been received or not at the receiver’s end. That’s why it is also known as the “fire-and-forget” protocol. UDP is unreliable but faster than TCP. The size of the UDP header is 8 bytes.
TCP VS UDP Comparison
A comparison of TCP VS UDP in various aspects is given below
Parameter | TCP | UDP |
Full Form | TCP stands for Transmission control protocol | UDP stands for User Datagram protocol |
Tolerance of data | TCP is the protocol that is used where data loss is not tolerated. If some data is lost, then that particular data is retransmitted.
Example: downloading, uploading, etc. |
TCP is the protocol that is used where data loss is tolerated. If some data is lost, then that particular data does not need to be retransmitted.
Examples include Skype, live matches, etc. |
Connection orientation | TCP is Connection-oriented. It means some dedicated path is established, and data is always transferred in the form of “IN ORDER.” | UDP is Connectionless. It means No dedicated path is established, and data can be transferred in any order. |
Reliability | it has high reliability because of the connection. | it has less reliability because of connectionless |
Error control | Error control is mandatory in TCP | Error control is optional in TCP |
Header Size | It has a 20 to 60-byte Header size, which increases the size of the packet. So, it has more overhead as compared to UDP. | It has 8 8-byte Header size, which reduces the size of the packet as compared to TCP. So it has Less overhead. |
Transmission Speed | The transmission speed of TCP is very low as compared to UDP because of the single dedicated transmission path and the larger size of the TCP Header. | The transmission speed of UDP is high compared to UDP because of multiple dedicated transmission paths and the smaller size of the UDP Header. |
Flow control | Flow control and congestion control are compulsory | No Flow control and congestion control |
Use | It is mostly used in file transfer protocols (FTP) and HTTP, where loss of data is not tolerated. | It is mostly used in Skype, DHCP, DNS, and RIP, where the loss of data may be tolerated. |