Skip to main content

Command Palette

Search for a command to run...

TCP vs UDP

When to Use What, and How TCP Relates to HTTP?

Updated
3 min read
TCP vs UDP

The Internet enables connections between all types of devices all over the world. Does this mean anyone can communicate with anyone on the network? No, right. We need access to that person, be it an email address or some Instagram ID. Similarly, the one device on the internet can’t communicate with anyother without an IP address, so how does this communicate happens is there any rules to it, because there are limitations we can certainly experience? You can access data on ISRO’s server that is not publicly available.

In the previous article, https://blog.yogeshkumar.site/understanding-network-devices, I talked about the firewall that is present at the router level that restricts unapproved communication to your devices unless you initiate it. But how does that communication happen within the hardware layer on the transportation level, which lies between the hardware devices? There must be some rules, fancy it “Protocols”.

Just like how I can’t access ISRO’s, NASA’s or even my bank servers without specific access and access after requests, and I can access data listed on www.google.com.

From where are these requests processed by the browser? Is there any protocol for the browser means application level as well? There are different tasks performed from the browser, so there must be different protocols as well, like web requests, there is http and for email communication, there is Simple Mail Transfer Protocol (SMTP) and others. Whatever happens in the browser is further carried down to the transport level.

┌─────────────────┐
│   APPLICATION   │ ← HTTP, HTTPS, SMTP (Your browser/email app)
│      LAYER      │
├─────────────────┤
│    TRANSPORT    │ ← TCP (Reliable Courier) or UDP (Live Broadcast)
│      LAYER      │
├─────────────────┤
│    INTERNET     │ ← IP Addresses (The " addresses")
│      LAYER      │
└─────────────────┘

There must be two ways of communicate is secure way and other maybe less secure way of communication on these networks. There are Transmission Control Protocol and User Datagram Protocol that reign in the world of transport protocols for communication, especially when we communicate with web servers from a browser. What’s the difference between them? Let’s see.

Transmission Control Protocol (TCP)

Let’s focus on the name, transmission control means the transport of the data packet is controlled, and it treats it as a mission once it is happening to make sure that it is complete.

If there is control, data packets here are ordered, tracked upon transmission for loss and retransmitted, which makes it slow. If there is control in the process, there is a queue for the tasks to happen or for the requests to be processed on the network using this protocol. Thus, makes it reliable. eg, Websites(http/https), file downloads

User Datagram Protocol (UDP)

So what is the direct opposite of TCP? Hmm. It is fast, but less reliable, so there must be no connection establishment for the data transfer, hence no ordering, retransmission, loss detection, or congestion control, making it less reliable than TCP for sensitive data. Hence used for video calls and streaming where speed matters.

Comparison makes a clear distinction for the use case in the daily requirements of communication on the transport level. Atlast, there is a difference between the application level protocols like HTTP or https and transport protocols like TCP and UDP.

What goes on between them? The http take the request in text/html format, along with the request type in the headers and other required details, such as who sent and from where the request came from, to the networking part of the browser and the request is handed over to os for the TCP connection through a specific port 80 for HTTP and 443 for https and thus the data packets are sent to the server.

TCP and HTTP are different portocols operating on different layers of communication.

What happens next is the story for another article? see ya on the internet…