TCP vs. UDP: Comparing Transport Layer Protocols

APuck003
3 min readJul 3, 2019

Protocols running at the transport layer provide several important services that enable software applications in higher layers to work over an internetwork. These protocols are typically responsible for allowing connections to be established and maintained between software services distant machines. Most importantly, transport layer protocols serve as the bridge between the needs of many higher-layer applications to send data without worrying about error correction, lost data or flow management. Transport layer protocols are often designed specifically to take care of functions that network layer protocols do not deal with.

TCP (Transmission Control Protocol) is a standard, which defines how to establish and maintain a network conversation which application programs can exchange data. TCP works with the Internet Protocol (IP), which defines how computers send packets of data to each other. TCP and IP together are the basic rules defining the Internet. Being a connection oriented protocol TCP establishes and maintains a connection until the application programs at each end have finished exchanging messages. When someone loads a web page, their computer sends TCP packets to the web server’s address, asking it to send the web page to them. The web server responds by sending TCP packets, which the web browser stitches together to form the web page and display its content to the user. TCP guarantees that packets are received in order by numbering them. The recipient sends messages back to the sender saying it received the messages. If the sender doesn’t get a correct response, it will resend the packets to make sure the recipient received them.

UDP (User Datagram Protocol) is a protocol defined for use with the IP network layer protocol. The service provided by UDP is unreliable and does not guarantee delivery or protection from duplication. UDP is simple and this helps to reduce the overhead from using the protocol. UDP and its UDP lite variant are unique in that they do not establish end-to-end connections between communicating end systems. Using UDP means that packets are just sent to the recipient. The sender will not wait to make sure the packet is received, it will just continue sending the next packets. If the recipient misses some of the UDP packets, they can’t ask for those packets again.

There are several differences between TCP and UDP some of these differences being there data transfer features. TCP is the more reliable because it manages message acknowledgment and retransmissions in case of lost parts. This means there is absolutely no missing data. UDP on the other hand does not ensure that communication has reached receiver because concepts of acknowledgment, time out, and retransmission are not featured. TCP’s transmissions are sent in a sequence and they are received in the same sequence. If data segments arriving in the wrong order, TCP will reorder and deliver. With UDP, a message sequence may not be maintained when it reaches the receiver. There is no way of predicting the order in which a message will be received. TCP reads data as a byte stream and a message is transmitted to segment boundaries. And UDP messages are individual packets and there integrity is check when they arrive. Packets have defined boundaries while data stream has none.

A TCP connection is established with a three-way handshake, this is a process of initiating and establishing a connection. With UDP a simple transmission model without the hand-shaking communication prevents reliability, ordering, or data integrity. So UDP provides an unreliable service and datagrams may arrive out of order, appear duplicated, or even go missing without notice.

Some common applications that make use of TCP are web browsing, email, and file transfer. TCP controls segment size, rate of data exchange, flow control and network congestion. It is preferred where error correction facilities are required at network interface level. Time sensitive applications as well as servers for small queries from a large number of clients use UDP. It is commonly used in DNS, Voice over IP, TFTP and online games.

--

--