Tap to Read ➤

TCP Vs. UDP

Omkar Phatak
Two protocols that can be used along with the Internet protocol (IP) to transmit data over the Internet from servers to clients are TCP and UDP. Both differ substantially in functionality and features, though aimed at achieving the same end result of data packet delivery. In the comparison presented in this story, these differences are highlighted.
Every bit of this story that you are reading right now was downloaded from a remote server in USA, in the form of several data packets which were ordered and transported through a TCP connection to display on your client computer.
The entire business of data sharing through packet switching on the Internet is handled by numerous protocols that form a part of the Internet Protocol Suite. TCP and UDP are two transport layer protocols, which may be used to deliver data packets from a source server destination to an application running on a client computer.

About Transmission Control Protocol (TCP)

TCP is the premier and most used protocol that works along with the Internet protocol (IP), to reliably deliver data from one point on the Internet to the other. The Internet protocol, which works in tandem with TCP, is responsible for the routing of data packets from one network to the other on the Internet.
For this purpose, IP finds the source and destination addresses of server and client, labels data packets sent by applications with destination addresses and ensures that these packets are delivered. Then what is the role played by TCP? The answer lies in its name which involves the term - 'Transmission Control'. It oversees the transport of data packets, puts them in order, checks errors, resends lost packets and verifies delivery.
Without TCP, data transmission purely through IP is very unreliable as it has no measure for error correction or tracking lost packets. Every packet that is transmitted from a server to a client, is traced till its reception at the destination through handshake signals mediated by it. Functionally, this protocol works between applications running on servers/clients and the Internet protocol.
It divides the transmitted data into segments, which are then sent through the Internet Protocol to destination, after labeling with correct IP address. At the receiving end, the packets are again checked at the TCP layer, unpacked into data bytes and delivered to the client application. If any data packets are missing, a retransmission of data is requested. Through a check sum and sequence numbering, error detection feature is implemented.
TCP can also control the speed at which data is sent according to the receiving capability of the client. For client computers which cannot process data that rapidly, through flow control, it determines the rate at which data packets are sent.
Most importantly, it establishes a connection between two computers, before sending data, which ensures that every piece is efficiently delivered. Modern implementation of the protocol even comes with a congestion control feature that detects crowded network paths in advance and changes paths for data transmission accordingly.
End applications to which data is transported are identified by their port numbers. For example, all data routing through HTTP (Hypertext Transfer Protocol) is done via the TCP/IP port 80 which serves as the listening and transmitting port. The World Wide Web is completely implemented on the basis of TCP, as it guarantees data delivery. Thus, the TCP/IP combination works to accurately deliver data over the Internet.

About User Datagram Protocol (UDP)

A quite different alternative to TCP is UDP, which also operates over the transport layer of the Internet and provides functionality to send data from a source server to client destination. Using UDP, applications can send data to any other, without any kind of prior handshaking, ordering of data packets or establishment of a connection.
What makes the protocol useful is the multicasting (simultaneous broadcast of data to multiple recipients on a network, through creation of copies) and packet broadcasting. It is designed for rapid delivery of data by cutting out all data verification, ordering and error control features. Applications like VoIP primarily use this protocol.

Difference Between TCP and UDP

The prime difference between TCP and UDP lies in the fact that the former offers error checking, flow control, data sequencing and congestion control, which the latter does not offer at all. Most importantly, UDP, unlike TCP, does not establish a connection between source and destination terminal before sending data.
Using UDP is like a long shot in the dark, with no reliability of the data hitting its target destination whatsoever. On the other hand, TCP is like a sure shot, which will guarantee that data is delivered in intact form.
However, all the sequencing, ordering, error checking and other functionality comes at the cost of time delay which is introduced in any TCP based data transfer. That makes it useless for applications like video streaming where data needs to be transmitted very fast. In such cases, UDP works best, even though it cannot guarantee that the data packets will be delivered. That may be one reason why video streaming is often a low picture quality affair!
To summarize, when data needs to be reliably transmitted, with no strict time constraints, TCP is the protocol that is used. On the other hand, when speed is of essence and data packets need to be delivered fast, UDP is the way to go. That's why, services like Email, World Wide Web and file transfers rely on TCP, rather than UDP for data transmission.
On the other hand, applications like online games, video streaming and VoIP rely on UDP for data transport, as they can't afford the time delay, which TCP introduces, in sorting data packets and ordering them. Use TCP and go for accuracy at the cost of time delay or use UDP to go for rapid data delivery at the cost of reliability of data delivery.