<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TCP v/s UDP: The rules of the web]]></title><description><![CDATA[TCP v/s UDP: The rules of the web]]></description><link>https://networks-blog.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 15 Oct 2026 14:49:16 GMT</lastBuildDate><atom:link href="https://networks-blog.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[TCP vs UDP: The rules of the Web]]></title><description><![CDATA[Introduction
Every time your browser loads a webpage, streams a video, or sends a message, a set of invisible rules decides how that data moves across the network. These rules—network protocols—are li]]></description><link>https://networks-blog.hashnode.dev/tcp-vs-udp-the-rules-of-the-web</link><guid isPermaLink="true">https://networks-blog.hashnode.dev/tcp-vs-udp-the-rules-of-the-web</guid><dc:creator><![CDATA[Ridam Sharma]]></dc:creator><pubDate>Sat, 28 Feb 2026 18:24:43 GMT</pubDate><content:encoded><![CDATA[<h1>Introduction</h1>
<p>Every time your browser loads a webpage, streams a video, or sends a message, a set of invisible rules decides how that data moves across the network. These rules—network protocols—are like languages that machines use to communicate reliably and efficiently. Without them, two computers might as well be speaking different tongues: one whispering while the other only understands dance.</p>
<p>At the transport layer, two protocols dominate: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). They take very different approaches to delivering data. TCP focuses on reliability, ordered delivery, and connection management, while UDP favors simplicity and low latency by sending independent packets without guarantees. Choosing between them is a trade-off driven by the needs of the application: correctness and order versus speed and minimal overhead.</p>
<p>In this article we'll explore why multiple transport protocols exist, how TCP and UDP work (and contrast their features such as handshakes, flow control, and ordering), and when to use each one in real-world scenarios like web browsing, streaming, gaming, and DNS. By the end you’ll understand the rules that shape how the web moves data and how to pick the right tool for the job.</p>
<h1>Why are they important?</h1>
<p>Before diving into TCP and UDP and how they differ, we need to understand the need for these protocols. Think of protocols as a language in which computers will communicate; these are a set of rules that are followed so the machines understand the conversation and the intent.</p>
<p>If the protocols are not in place it will be like just a person whispering to a guy who only understands the language of dance or something, the idea is for a proper conversation to take place certain ground rules needs to be established and especially when we are dealing with machines that will not just infer the message based on the context of the situation these protocols become absolutely critical.</p>
<p>Now, one might ask why not just a single protocol for all the communication in the world? That seems fair, given that these are computers we are talking about, not humans who have developed their language from years of different civilizations. So why is there a need for multiple protocols? (transport layer protocols to be precise). Let's find out.</p>
<h1>TCP</h1>
<p>TCP or Transmission Control Protocol is the most prominent protocol on the internet and is widely used because if its 3-way handshake working, which means it only sends the data to the server when a connection is established with the server. TCP also has flow control as well as congestion control. It preserves the order of the data packets that are sent with the help of SYN-ACK flow and retransmits the missing packets in case of packet loss.</p>
<p>Ensuring such reliability makes it really secure and also go to choice for most of the data transfer on the internet. The only major downside TCP has is the speed, which gets compromised while achieving such a secure flow.</p>
<img src="https://cdn.hashnode.com/uploads/covers/697c96da3bdfb5f6136cdb02/da23ba9c-eeda-44f9-9f8b-bc3b6b30806e.png" alt="" style="display:block;margin:0 auto" />

<h1>UDP</h1>
<p>UDP or User Datagram Protocol is the other protocol in the transport layer protocol, and this protocol works with a real simple idea of if some data needs to be sent to the server, then just send it over, that's it no complexity, no thinking about the flow, order or even caring about if all packets (datagrams) reached successfully or not. Although <strong>less secure,</strong> UDP provides us with a very important advantage over TCP, which sometimes takes precedence over all its downsides and that is its <em><strong>speed</strong></em>.</p>
<h3>Practical analogies</h3>
<p>If TCP is like calling the person you want to convey the message to, then UDP broadcasts the message all over, and it will reach that person. And as for the order of packets, think of it like sending a message to your friend on a new chatting app, saying "Good game today," and what is received on his end is "game today Good".</p>
<p>The mismatch in order occurs because even if you are sending the packets in order, depending upon the traffic and the path they are following this is possible that there might be an order mismatch or even that packets are lost in the way. One might think this must be a rare phenomenon, but this is really a common occurrence because of the limitations of the Ethernet's MTU and Window size on the server buffer and all other technicalities. Hence, the data packet size is really limited, increasing the number of packets.</p>
<img src="https://cdn.hashnode.com/uploads/covers/697c96da3bdfb5f6136cdb02/a92d9324-88f0-4eb7-8e30-98e2a0ba9614.png" alt="" style="display:block;margin:0 auto" />

<h2>Core Differences</h2>
<table>
<thead>
<tr>
<th><strong>Feature</strong></th>
<th><strong>TCP</strong></th>
<th><strong>UDP</strong></th>
</tr>
</thead>
<tbody><tr>
<td>Full Form</td>
<td>Transmission Control Protocol</td>
<td>User Datagram Protocol</td>
</tr>
<tr>
<td><strong>Connection</strong></td>
<td></td>
<td></td>
</tr>
<tr>
<td><strong>Type</strong></td>
<td><strong>Connection-Oriented</strong>: Requires a 3-way handshake before sending data.</td>
<td><strong>Connectionless</strong>: Just sends data immediately without a "handshake."</td>
</tr>
<tr>
<td><strong>Reliability</strong></td>
<td><strong>Guaranteed</strong>: If a packet is lost, it is retransmitted.</td>
<td><strong>Best Effort</strong>: If a packet is lost, it stays lost.</td>
</tr>
<tr>
<td><strong>Data</strong> <strong>Order</strong></td>
<td><strong>Ordered</strong>: Packets arrive and are reassembled in the exact order sent.</td>
<td><strong>Unordered</strong>: Packets can arrive in any sequence.</td>
</tr>
<tr>
<td><strong>Speed</strong></td>
<td><strong>Slower</strong>: Overhead from error checking and flow control.</td>
<td><strong>Faster</strong>: Lightweight with minimal headers and no delays.</td>
</tr>
<tr>
<td><strong>Data</strong> <strong>Flow</strong></td>
<td><strong>Streaming</strong>: Data is seen as a continuous stream of bytes.</td>
<td><strong>Datagrams</strong>: Data is sent in discrete, independent packets.</td>
</tr>
<tr>
<td><strong>Header Size</strong></td>
<td>Larger (<strong>20-60 bytes</strong>).</td>
<td>Smaller (<strong>8 bytes</strong>).</td>
</tr>
<tr>
<td><strong>Common Uses</strong></td>
<td>Web browsing (HTTP/HTTPS), Email (SMTP), File transfer (FTP).</td>
<td>Video streaming, Online gaming, VoIP, and DNS.</td>
</tr>
</tbody></table>
<h1>When to use what?</h1>
<p>Although TCP offers security and reliability with congestion control and order preservation, the speed that UDP offers is such a big factor that there are situations where we are ready to compromise with other factors to ensure that the latency is minimal. Here are some real-world scenarios where TCP and UDP are used:</p>
<ul>
<li><p><strong>TCP: The Online Shopping Checkout</strong></p>
<ul>
<li><p><strong>The Scenario:</strong> You click "Pay Now" and enter your card / UPI details</p>
</li>
<li><p><strong>Why TCP?</strong> This <strong>must</strong> be 100% accurate. If a single packet containing your credit card number or the price is lost or arrives out of order, the transaction fails or, worse, you get charged the wrong amount. TCP ensures the server acknowledges every byte before moving to the "Success" page.</p>
</li>
</ul>
</li>
<li><p><strong>UDP: Competitive Gaming (e.g., Valorant or CS: GO)</strong></p>
<ul>
<li><p><strong>The Scenario:</strong> Your character moves left, and you fire a shot.</p>
</li>
<li><p><strong>Why UDP?</strong> Speed is the only thing that matters. If one "position update" packet is lost due to a tiny flicker in your Wi-Fi, the game doesn't want to wait for a retransmission (which would cause "lag" or "rubber-banding"). It simply waits for the <em>next</em> packet to tell it where you are now. Fresh data is better than old, retransmitted data.</p>
</li>
</ul>
</li>
<li><p><strong>The Hybrid: Zoom or Google Meet</strong></p>
<ul>
<li><p>Video conferencing is the perfect "hybrid" example because it has two different needs happening at the same time:</p>
</li>
<li><p><strong>The Video/Audio (UDP):</strong> The actual stream of your face and voice uses UDP. If a frame of your video drops, the screen might pixelate for a split second, but the call keeps going in real-time. We sacrifice quality for "liveness."</p>
</li>
<li><p><strong>The Chat/Control (TCP):</strong> If you type a link in the chat box or click the "End Meeting" button, it uses TCP. You can't afford for the chat message to arrive as "h-t-p-p-google" or for the "End Call" command to get lost in the wind</p>
</li>
</ul>
</li>
</ul>
<h1>HTTP (Hyper Text Transfer Protocol)</h1>
<h2>What is it?</h2>
<p>HTTP is an application-layer protocol that spans most of the Internet. We all are very familiar with the name itself but to understand what it is lets look at this scenario- You send a message to your friend Joe via post (lets assume you are not firm believer of broadcasting your message to everyone in the world and prefer a safer route of post), when your friend recieves the letter, even if the message arrived as it was sent, the content of the message the actual message is the deciding factor wheather it is poperly conveyed or not. For example, you can not just send him an address and expect him to understand your invitation to the party. You need to mention that the address is where the party is and that he is invited.</p>
<p>Now that might sound like a weird example, like obviously you would specify that in the message but if you look at it from purely objective standpoint the address is the data you wanted to tansfer and the rest of the message is just "defining" what the message is or what the address is for.</p>
<p>In the case of computers conversing, the client machine can not just send the request to the server and expect it to understand whether it is requesting some data or sending some data, or any other form of request. The HTTP protocol ensures that the message sent is rightly understood. This is generally how an HTTP request is structured.</p>
<pre><code class="language-plaintext">GET /index.html HTTP/1.1
</code></pre>
<p>The <em><strong>Request</strong></em> <em><strong>Line</strong></em> contains the <strong>HTTP method</strong> (e.g., GET, POST), the <strong>Request-URI</strong> (target resource), and the <strong>HTTP version</strong> (e.g., HTTP/1.1)</p>
<p>Then there is a <em><strong>Header</strong></em> which contains the metadata about the request, for example, Content-Type: application/json</p>
<p>And this is followed by the message <em><strong>Body</strong></em> which is essentially the data sent to the server, typically in POST, PATCH, or PUT methods. The message body is an optional entity in the HTTP request.</p>
<h2>How does it relate to TCP?</h2>
<p>We mentioned most of the internet relies on HTTP, but the same statement was casually used for TCP earlier, too, so which one is really true then? To understand the difference, we need to realise the concept of something called the OSI Layers Model. And if we look carefully, HTTP comes under the Application layer while TCP comes under the Transport layer. These layers work by adding headers and/or footers on top of the previous layers, going down from Application (topmost) to Datalink layer, and then, when the message is received, those headers are removed, and the message is conveyed, or at least this is the higher-level understanding of that.</p>
<p>So behind the curtains, it is HTTP working on TCP as a transport layer.</p>
<img src="https://cdn.hashnode.com/uploads/covers/697c96da3bdfb5f6136cdb02/a331492e-d1df-4280-babf-21f01bb00e19.png" alt="" style="display:block;margin:0 auto" />

<h1>Conclusion</h1>
<p>TCP and UDP embody two different trade-offs for the transport layer: TCP prioritizes reliability, ordered delivery, and congestion/flow control at the cost of overhead and latency, while UDP provides a lightweight, connectionless, best-effort service that favors low latency and simplicity over guaranteed delivery. Use TCP when correctness and order matter (web pages, file transfer, email, APIs). Use UDP when timeliness and minimal overhead are more important than perfect delivery (live audio/video, online gaming, DNS, real‑time telemetry). In practice, some modern solutions combine approaches (e.g., application-level reliability over UDP or protocols built on UDP) to balance these needs. Choosing the right transport protocol comes down to the specific requirements of reliability, latency, and network behavior for your application.</p>
]]></content:encoded></item></channel></rss>