Blog Post View


What is the difference between TCP and UDP?

Both TCP and UDP are protocols used to send data from one device to anoter within the TCP/IP network. When sending data, they are broken into smaller IP packets and sent over the TCP or UDP transport layer. Applications may choose to use either TCP or UDP to send data to the other end depending on whether the reliability or speed is more important. For reliable delivery, TCP is used while UDP is used for faster delivery. TCP/IP is comprised of 4 layers with each providing a specific protocol functions as shown below:

Layer Protocols
Application DNS, FTP, HTTP, IMAP, POP3, SMTP, SSH, Telnet, SSL, ...
Transport TCP, UDP, ...
Network IP (IPv4, IPv6), ICMP, ARP, ...
Physical (Data Link) 802.3 (Ethernet), 802.11 (Wi-Fi), PPP, ...

Whis is TCP?

Transmission Control Protocol (TCP) is a connection-oriented protocol which creates a virtual connection (called socket) betwen the two endpoints before exchanging IP packets. TCP protocol performs error checking and guarantees a reliable delivery by assembling the packets in the order they are sent at the destination. If some packets are missing or out of order due to latency, the receiver flags an error and the sender will retransmits the missing packets. As the protocol is connection-oriented and the sender and receiver exchanges information (via SYN, SYN-ACK and ACK), the data will be reliably delivered to the receiver.

Some of the appliation that require highly reliable transmission using TCP protocol include HTTP, SSH, FTP and Email services such as the SMTP, IMAP and POP3.

What is UDP?

User Datagram Protocol (UDP) is a connectionless protocol which does not establish a connection or use handshaking between the sender and receiver. Instead, the sender broadcast or multicast the IP packets to the receiver without verifying integrity of data being received.

Applications that require low latency or real-time communication that uses UDP protocol include VoIP (voice over IP), Streaming services (both audio and video), or DNS (Domain Name Service). As there are minimum error checking and no recovery actions required, the protocol is lightweight and very fast.

What are the differences between TCP and UDP?

TCP UDP
Connection-oriented Connection-less
Heavyweight with error checking, handshaking, and retransmission Lightweight with smaller header, and discards erroneous packets
Reliable Low latency (very fast)
Guarantee delivery No guarantee of delivery
Point-to-Point Supports broadcast and multicast

Conclusion

TCP and UDP are transport layer protocol of the TCP/IP network, and they are used to send IP packets from one IP address to another. TCP uses a socket to establish a connection and send data reliably, while UDP uses connectionless protocol to send data fast with very low latency without guaranteeing delivery. Applications requiring reliable delivery uses TCP and applications that requires fast delivery at the cost of reliability uses UDP.


Share this post

Comments (0)

    No comment

Leave a comment

All comments are moderated. Spammy and bot submitted comments are deleted. Please submit the comments that are helpful to others, and we'll approve your comments. A comment that includes outbound link will only be approved if the content is relevant to the topic, and has some value to our readers.


Login To Post Comment