TCP vs UDP
Some of the main differences between TCP and UDP are:
1: Connection-oriented vs connectionless:
TCP (Transmission Control Protocol) is a connection-oriented protocol, which means that a connection must be established between the sender and receiver before the actual transmission of data. This connection is formed using a process known as three-way handshake, which involves three messages exchange between the sender and receiver to ensure that both parties are ready to transmit and receive data.
UDP (User Datagram Protocol) on the other hand is a connection-less protocol, which means that it does not establish a link between the sender and receiver before transmitting data.
2: Reliability:
In TCP, the receiver sends an acknowledgement to the sender of the segment, to inform whether the data segment has reached its destination safely or not. This makes TCP a reliable protocol as it guarantees the delivery of segments to its correct destination.
UDP does not guarantee the delivery of data to the destination. UDP is known as a Fire-And-Forget protocol because it sends the data without worrying about whether the data is received or not.
3: Transmission rate:
TCP has a lower transmission rate. A lower transmission rate is a trade-off for TCP’s focus on ensuring reliable data transfer. On the other hand, UDP operates at a higher transmission rate due to the absence of reliability guarantees.
4: Error Control:
TCP uses checksum to perform error checking and allows for retransmission of lost or erroneous data packets. Similarly, UDP also performs error checking using checksum, but it does not provide retransmission of lost or erroneous packets.
5: Flow Control and Congestion Control:
TCP provides a flow control and congestion control mechanism by default, while UDP does not provide any default mechanisms for either flow control or congestion control.
Flow control and congestion control regulate the amount of data that can be transmitted over a network to prevent network congestion and ensure efficient use of network resources.
6: Usage:
TCP is mainly used for secure and reliable communication processes, such as web browsing. UDP, on the other hand, is used for fast communication where reliability is not a major concern, such as in video and music streaming.
In short, TCP is used to ensure reliable data transmission, while UDP is used to support latency-sensitive applications.
7: Header Length:
TCP has a (20–60) bytes variable length header. UDP has an 8 bytes fixed-length header.
TCP Segment:
UDP Datagram:
8: Some of the application layer protocols which use TCP are:
HTTP, HTTPS, FTP, SSH, Telnet, SMTP etc.
Some of the application layer protocols which use UDP are:
DHCP, TFTP, SNMP, RADIUS, NTP etc.