TCP and UDP
The TCP and UDP transport layer protocols handle data communications between terminals in an IP network. The TCP is a connection-oriented protocol, and UDP is a connectionless protocol.
TCP
Transmission Control Protocol (TCP) tracked the packet transmission from source to destination. For example, sending a software file to someone or downloading software from a website ensures it is 100% delivered or downloaded. WhatsApp is another example of TCP, it is used TCP as transmission control protocol. It informs the user about the receipt of the messages and if those messages have been seen and reproduced. The TCP has three basic operations:-
- Numbering and tracking segments transmitted to a specific destination from a particular application
- Acknowledging received data
- Retransmitting any unacknowledged data after a certain period
Understanding the difference between UDP and TCP is very important. Understanding the work procedure of each protocol, the implementation of reliability features, and how they track the conversation.
Establishing a Session
TCP is a connection-oriented protocol which negotiates and establishes a permanent session between the source and destination devices before forwarding any data. Throughout the session establishment, the devices check for the amount of traffic that can be sent at a specified time, and the communication data between the two can be closely managed.
Reliable Delivery
A segment can become corrupted or lost as transmitted over the network. The reliability ensures each sending segment must arrive at the destination.
Same-Order Delivery
Data can arrive in the wrong order due to multiple routes on the network with different transmission rates and speeds. Using numbering and sequencing, TCP ensures the segments are back in the correct order.
Flow Control
The TCP provides flow control between the source and destination host. The flow control ensures the data rate at which a sender is transmitting. It ensures the data-sending speed according to the speed of the receiver’s receiving capabilities. It is used to manage the flow of data/packets among two different nodes, especially in cases where the sending device can send data faster than the receiver can take in.
UDP
User Datagram Protocol (UDP) is a connectionless and unreliable protocol. It is not guaranteed to reach its destination. Sending someone a non-registered letter or postcard is an example of User Datagram Protocol, where you put it in the postbox. Now, you have no information about the letter’s status or postcard because you don’t know about the receiver’s availability to receive the letter. The chances are good that it will get where it’s supposed to go, but there is no guarantee.
There is a possibility of loss in the way. The post office is not responsible for tracking the letter or informing the sender if the letter does not arrive at the destination. The User Datagram Protocol works Just like the above example.
The User Datagram Protocol provides essential functions for delivering data segments between suitable applications with tiny overhead and data checking. However, the User Datagram Protocol does not acknowledge the receiving data at the destination.
No transport layer processes inform the sender of a successful delivery using UDP. While the TCP reliability functions allow more dynamic communication among applications, they also incur extra overhead and possible transmission delays.
UDP Features
UDP is a best-effort, lightweight transport protocol that offers the same data segmentation and reassembles as TCP but with no TCP reliability and flow control. The features of UDP are as follows:-
No Ordered Data Reconstruction – Data is reconstructed according to its receiving order.
Unreliable Delivery – Any lost segments, like TCP, have not been resent in this protocol.
Connectionless – No session established with the source and destination.
No Flow Control – Does not inform the sender about the resource availability.
UDP Header
UDP does not inform the source and destination about the packets it receives. It also provides any state of the communication session to the client and server. The UDP application is responsible for reliability and can accept some loss of data during transmission over the network, but delays in transmission are unacceptable.
The UDP application required less network overhead than the UDP protocol. It is preferable for streaming live audio, live video, and Voice over IP. The UDP header is called a datagram, as shown in the figure below. The transport layer protocol sent these datagrams as best-effort.