Urgent.News

What's breaking now, across thousands of outlets.

Tech

Why TCP (not UDP) is used for HTTP — what would break with UDP.

Why TCP was traditionally used for HTTP Imagine your browser requests: GET /index.html and the server sends: The Internet can lose packets, duplicate them, or deliver them out of order. TCP handles this for HTTP: So HTTP can essentially say: "Give me a reliable stream of bytes." What would happen with plain UDP? UDP does not guarantee delivery or ordering. For example: The browser might receive:…

Traditionally, the Hypertext Transfer Protocol (HTTP) relied on Transmission Control Protocol (TCP) for data transmission. The reason behind this choice is that TCP offers reliable, ordered delivery of data. When a client, such as a web browser, sends a request like "GET /index.html," TCP ensures that all data arrives intact and in the correct sequence, even if packets are lost, duplicated, or arrive out of order during transmission.

On the other hand, User Datagram Protocol (UDP), another protocol available for data transmission, lacks the reliability features provided by TCP. UDP does not guarantee that data packets will be delivered, nor does it ensure that they arrive in the correct order. For instance, if a UDP packet containing part of a webpage is lost, there is no mechanism within UDP itself to request that the missing packet be resent.

Without additional reliability mechanisms, HTTP utilizing plain UDP would face significant issues. Imagine downloading a file named "Hello World." If packets arrive missing or out of order, the receiving application would need to determine which pieces are missing, ascertain the correct order of the data, decide whether to request the missing data, and manage its data transmission speed and network congestion. TCP already handles these complexities effortlessly.

Interestingly, the newer version of HTTP, referred to as HTTP/3, doesn't use UDP in its original form. Instead, it utilizes QUIC (Quick UDP Internet Connections), a transport layer protocol built on UDP but adding features like reliable delivery, ordering, congestion control, and encryption, which TCP traditionally offers. Thus, HTTP/3 can be described as follows:

HTTP/3 → QUIC (UDP base) → Reliability, Security, and Transport Features → UDP

In summary, TCP was chosen for HTTP because it provides the necessary reliability and order that HTTP requires. UDP, lacking these features, would necessitate HTTP or another protocol to implement these mechanisms independently. The modern approach with HTTP/3 uses QUIC over UDP to achieve the same reliable and efficient data transmission without the need for additional reliability protocols.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 9 September →