Distinguish between the TCP and UDP.


TCP stands for Transmission Control Protocol and is a transport layer connection-oriented protocol. It provides a reliable connection and protected data transmission between the connecting machines over the network. It first establishes a secure link and then sends the data.

TCP sends the data from one device to the other in the form of data blocks. It is completely slow in data transmission but has more functionalities such as flow control, error control, and congestion control in the system. The TCP header is of 20-60 bytes and therefore, it contains several pieces of information to improve the reliability. But, the overhead is raised. Because of its reliability, protocols like HTTP, FTP, etc., use TCP for proper data transmission over the network.


UDP stands for User Datagram Protocol and is a transport layer connectionless protocol. It provides the quick transmission of data between the connecting machines over the network. There is no overhead of creating, maintaining, and terminating a connection in UDP.

It is mainly used to transmit real-time data where we cannot afford any transmission delays. UDP sends the data from one device to the other in the form of continuous data streams.

The UDP header is of fixed size, i.e., 8 bytes. It is unreliable but faster in speed. Due to its transmission speed, protocols like DNS, DHCP, RIP, etc., use UDP for proper data transmission over the network.

Comparison between TCP and UDP

The major differences between TCP and UDP are as follows:

Full-FormTCP stands for Transmission Control Protocol.UDP stands for User Datagram Protocol.
DefinitionTCP establishes a connection between the computers before sending the data.UDP sends the data directly to the destination computer without checking whether the system is ready to receive it or not.
Type of ConnectionIt is a Connection-oriented protocol representing a connection that should be established before data transmission. The communication devices should end up or remove the connection once the communication is over between the sender and receiver end.It is a Connectionless protocol representing no compulsion for creating, maintaining and removing a connection between source and destination end. It is best applicable for broadcast and multicast purposes.
ReliableTCP is a reliable protocol as it assures the delivery of data packets.UDP is an unreliable protocol. It does not affect the guarantee for the delivery of packets.
RetransmissionsDelivery of all data is managed, and lost data is retransmitted automatically.It is not performed. An application must detect lost data and retransmit
UsageTCP is suited for applications that need high reliability, and when the transmission time is relatively less critical.UDP is relevant for applications that require fast, effective transmission, such as games. UDP's stateless nature is also helpful for servers that answer small queries from huge numbers of clients.
Error CheckingTCP executes error checking by using a checksum. When the information is corrected, then the data is retransmitted to the receiver.It does not implement any error checking and also does not resend the lost data packets.
Streaming of dataData is learning as a byte flow, and no specific indications are communicated to signal message (segment) boundaries.Packets are sent individually and are determined for integrity only if they arrive. Packets have definite boundaries honoured upon receipt, meaning a read operation at the receiver socket will yield an entire message as initially sent.