<?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 vs UDP , OSI model]]></title><description><![CDATA[TCP vs UDP , OSI model]]></description><link>https://how-data-transfer-between-devices.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 18:43:34 GMT</lastBuildDate><atom:link href="https://how-data-transfer-between-devices.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[TCP vs UDP, How TCP Relates TO HTTP , Three-Way Handshake (TCP)]]></title><description><![CDATA[Every data transfer on the Internet—whether it is loading a website or streaming a video—depends on how data is transported between devices.This responsibility is handled by the Transport Layer(of TCP/IP Model), mainly through two protocols: TCP (Tra...]]></description><link>https://how-data-transfer-between-devices.hashnode.dev/tcp-vs-udp-how-tcp-relates-to-http-three-way-handshake-tcp</link><guid isPermaLink="true">https://how-data-transfer-between-devices.hashnode.dev/tcp-vs-udp-how-tcp-relates-to-http-three-way-handshake-tcp</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[TCP]]></category><category><![CDATA[UDP]]></category><category><![CDATA[tcp vs udp]]></category><category><![CDATA[tcp vs http]]></category><category><![CDATA[how tcp relates to http]]></category><dc:creator><![CDATA[Manpreet Singh]]></dc:creator><pubDate>Sun, 01 Feb 2026 18:11:27 GMT</pubDate><content:encoded><![CDATA[<p>Every data transfer on the Internet—whether it is loading a website or streaming a video—depends on how data is transported between devices.<br />This responsibility is handled by the <strong>Transport Layer(of TCP/IP Model)</strong>, mainly through two protocols: <strong>TCP (Transmission Control Protocol)</strong> and <strong>UDP (User Datagram Protocol)</strong>.</p>
<h2 id="heading-tcp-transmission-control-protocol">TCP( Transmission Control Protocol)</h2>
<p>The TCP is a , connection oriented transport layer protocol that ensures reliable, ordered, and error-checked delivery of data between applications on an IP network.</p>
<p>It establishes a connection via a three-way handshake and uses sequence numbers and acknowledgments to manage data integrity, retransmission of lost packets, and flow control, making it essential for web browsing, email, and file transfers.</p>
<p><strong>In Simple:</strong> This layer is responsible for reliable delivery of the data between Client and Server</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769968732832/81b68bcf-ed52-4985-afff-3f3c10335116.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-key-characteristics-and-features"><strong>Key Characteristics and Features</strong></h3>
<ul>
<li><p><strong>Connection-Oriented:</strong> A session must be established (three-way handshake) before any data is transferred, and the connection remains active until data exchange is complete.</p>
</li>
<li><p><strong>Reliable Delivery:</strong> TCP guarantees that data sent from one end arrives at the other in the correct order, without errors. If packets are lost, corrupted, or duplicated, TCP handles retransmission and reordering.</p>
</li>
<li><p><strong>Three-Way Handshake (SYN, SYN-ACK, ACK):</strong> fundamental three-step process (SYN, SYN-ACK, <a target="_blank" href="https://www.google.com/search?sca_esv=9da74a587f09e07d&amp;rlz=1C1CHBF_enIN1119IN1119&amp;sxsrf=ANbL-n6mkQtsfpYToSFnJ1KJgrygWu8P0g%3A1769970642148&amp;q=ACK&amp;sa=X&amp;ved=2ahUKEwjmk4279riSAxWmbfUHHYtII34QxccNegUIiAEQAQ&amp;mstk=AUtExfDtVrwOIgdalQgeaoon51-5Dt02r0FFdr8EFkoNmVnEsoZxBcaW0qoRv_SjuhG0FOycdNuE0xaay3IPzO_YQMEicsqhN5XEEoTGt7Jv19dHDHexTRDwOsyMlaS4cvSmco9t6erlVrne5NsPF0LlZCzyPC1dmtf56J130w_a2mvWGHev8SFatjwdITVWBqWH8HF3CO0ejcxGOq07ukl1Fimt87OEjz50X7I__zeK32-vU2wZ70RgQG9mAwYuBGzqVIU9u58Mt5ChYRmpihJRuWKw&amp;csui=3">ACK</a><a target="_blank" href="https://www.google.com/search?sca_esv=9da74a587f09e07d&amp;rlz=1C1CHBF_enIN1119IN1119&amp;sxsrf=ANbL-n6mkQtsfpYToSFnJ1KJgrygWu8P0g%3A1769970642148&amp;q=SYN-ACK&amp;sa=X&amp;ved=2ahUKEwjmk4279riSAxWmbfUHHYtII34QxccNegQILRAB&amp;mstk=AUtExfDtVrwOIgdalQgeaoon51-5Dt02r0FFdr8EFkoNmVnEsoZxBcaW0qoRv_SjuhG0FOycdNuE0xaay3IPzO_YQMEicsqhN5XEEoTGt7Jv19dHDHexTRDwOsyMlaS4cvSmco9t6erlVrne5NsPF0LlZCzyPC1dmtf56J130w_a2mvWGHev8SFatjwdITVWBqWH8HF3CO0ejcxGOq07ukl1Fimt87OEjz50X7I__zeK32-vU2wZ70RgQG9mAwYuBGzqVIU9u58Mt5ChYRmpihJRuWKw&amp;csui=3">) us</a>ed to establish a reliable connection between a client and server, ensuring both agree on initial sequence numbers and readiness for data transfer, preventing data loss and ensuring synchronization before communication begins.  </p>
</li>
<li><p><strong>Flow and Congestion Control:</strong> TCP controls the rate of data transmission to prevent overwhelming the receiver and to manage network congestion using mechanisms like a "window" size, which dictates how much data can be sent before needing an acknowledgment.</p>
</li>
<li><p><strong>Full Duplex Communication:</strong> TCP allows data to flow simultaneously in both directions within a single connection.</p>
</li>
<li><p><strong>Segment Reassembly:</strong> Data is broken into segments, given sequence numbers, and reassembled in the correct order at the destination.</p>
</li>
</ul>
<p><strong>TCP Connection Process</strong></p>
<ol>
<li><p><strong>Establishment:</strong> Through the <code>SYN</code> →right arrow→ <code>SYN-ACK</code> →right arrow→ <code>ACK</code> handshake, both parties agree on initial sequence numbers.</p>
</li>
<li><p><strong>Data Transfer:</strong> Data is sent in segments, with each segment containing a sequence number and being acknowledged by the receiver.</p>
</li>
<li><p><strong>Termination:</strong> Once communication is finished, a four-way handshake (FIN, ACK, FIN, ACK) is used to close the connection properly.</p>
</li>
</ol>
<p><strong>TCP Header Structure</strong><br />A standard TCP header is 20-60 bytes and includes source/destination ports, sequence numbers, acknowledgment numbers, flags (like SYN, ACK, FIN, RST), and window size.</p>
<h3 id="heading-when-to-use-tcp"><strong>When to Use TCP</strong></h3>
<p>TCP is used where data accuracy is critical over speed, including:</p>
<ul>
<li><p><strong>HTTP/HTTPS:</strong> Web browsing</p>
</li>
<li><p><strong>SMTP/IMAP/POP3:</strong> Email</p>
</li>
<li><p><strong>FTP/SFTP:</strong> File transfers</p>
</li>
<li><p><strong>SSH:</strong> Remote administration</p>
</li>
</ul>
<h2 id="heading-udp">UDP</h2>
<p>The User Datagram Protocol (UDP) is <strong>a fast, connectionless, and lightweight transport layer protocol</strong>. It sends "datagrams" without establishing a prior connection or guaranteeing delivery, ordering, or error correction. Ideal for real-time applications like video streaming, VoIP, and gaming, it minimizes latency by eliminating overhead like handshakes and acknowledgments.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769969240679/d29bf07c-b65b-47b7-8893-0cdf0b52986d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-key-characteristics-and-components"><strong>Key Characteristics and Components</strong></h3>
<ul>
<li><p><strong>Connectionless:</strong> UDP does not require a formal connection setup between sender and receiver before transmitting data.</p>
</li>
<li><p><strong>Unreliable/Best Effort:</strong> There is no guarantee that packets will reach their destination, and they may arrive out of order.</p>
</li>
<li><p><strong>Low Latency &amp; Low Overhead:</strong> It has a simple 8-byte header, making it much faster and more efficient than TCP.</p>
</li>
<li><p><strong>No Flow Control:</strong> The sender can transmit data as quickly as it can, which might lead to packet loss if the receiver is overloaded.</p>
</li>
<li><p><strong>Header Structure:</strong> The UDP header consists of 8 bytes split into four 16-bit fields: Source Port, Destination Port, Length, and Checksum.</p>
</li>
</ul>
<h3 id="heading-when-to-use-udp"><strong>When to use UDP</strong></h3>
<p>When speed is prioritized over reliability, UDP is used for:</p>
<ul>
<li><p><a target="_blank" href="https://www.google.com/search?q=Streaming+Media&amp;sca_esv=e2e9df9ab93ca8c0&amp;sxsrf=ANbL-n488wiZ1wi38hWimCrlbfGZNGdUeA%3A1769964118318&amp;ei=VoJ_aYOGE8vYseMP2-vHmAw&amp;oq=explain+udp+&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiDGV4cGxhaW4gdWRwICoCCAAyChAAGIAEGBQYhwIyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgARIoUBQxwhYlzJwBXgBkAEAmAG9AqABgBOqAQgwLjEyLjEuMbgBAcgBAPgBAZgCE6AC2BPCAgoQABiwAxjWBBhHwgIKECMYgAQYJxiKBcICBBAjGCfCAgsQABiABBiRAhiKBcICCBAAGIAEGLEDwgILEC4YgAQYsQMYgwHCAg4QABiABBixAxiDARiKBcICChAAGIAEGEMYigXCAg0QABiABBixAxhDGIoFwgIOEAAYgAQYkQIYsQMYigXCAgcQIxixAhgnwgIHEAAYgAQYCsICDRAAGIAEGLEDGIoFGArCAgkQABiABBgKGAvCAgwQABiABBixAxgKGAvCAgQQABgDmAMAiAYBkAYIkgcINS4xMi4xLjGgB6l2sgcIMC4xMi4xLjG4B8MTwgcGMC42LjEzyAdBgAgA&amp;sclient=gws-wiz-serp&amp;ved=2ahUKEwiJ2c3N67iSAxVDlFYBHem2E9EQgK4QegYIAQgFEAE"><strong>Streaming Media</strong></a><strong>:</strong> Video/audio streaming where losing a few frames is better than pausing for retransmission.</p>
</li>
<li><p><a target="_blank" href="https://www.google.com/search?q=Online+Gaming&amp;sca_esv=e2e9df9ab93ca8c0&amp;sxsrf=ANbL-n488wiZ1wi38hWimCrlbfGZNGdUeA%3A1769964118318&amp;ei=VoJ_aYOGE8vYseMP2-vHmAw&amp;oq=explain+udp+&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiDGV4cGxhaW4gdWRwICoCCAAyChAAGIAEGBQYhwIyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgARIoUBQxwhYlzJwBXgBkAEAmAG9AqABgBOqAQgwLjEyLjEuMbgBAcgBAPgBAZgCE6AC2BPCAgoQABiwAxjWBBhHwgIKECMYgAQYJxiKBcICBBAjGCfCAgsQABiABBiRAhiKBcICCBAAGIAEGLEDwgILEC4YgAQYsQMYgwHCAg4QABiABBixAxiDARiKBcICChAAGIAEGEMYigXCAg0QABiABBixAxhDGIoFwgIOEAAYgAQYkQIYsQMYigXCAgcQIxixAhgnwgIHEAAYgAQYCsICDRAAGIAEGLEDGIoFGArCAgkQABiABBgKGAvCAgwQABiABBixAxgKGAvCAgQQABgDmAMAiAYBkAYIkgcINS4xMi4xLjGgB6l2sgcIMC4xMi4xLjG4B8MTwgcGMC42LjEzyAdBgAgA&amp;sclient=gws-wiz-serp&amp;ved=2ahUKEwiJ2c3N67iSAxVDlFYBHem2E9EQgK4QegYIAQgFEAM"><strong>Online Gaming</strong></a><strong>:</strong> Real-time, fast-paced interaction.</p>
</li>
<li><p><a target="_blank" href="https://www.google.com/search?q=DNS+%28Domain+Name+System%29&amp;sca_esv=e2e9df9ab93ca8c0&amp;sxsrf=ANbL-n488wiZ1wi38hWimCrlbfGZNGdUeA%3A1769964118318&amp;ei=VoJ_aYOGE8vYseMP2-vHmAw&amp;oq=explain+udp+&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiDGV4cGxhaW4gdWRwICoCCAAyChAAGIAEGBQYhwIyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgARIoUBQxwhYlzJwBXgBkAEAmAG9AqABgBOqAQgwLjEyLjEuMbgBAcgBAPgBAZgCE6AC2BPCAgoQABiwAxjWBBhHwgIKECMYgAQYJxiKBcICBBAjGCfCAgsQABiABBiRAhiKBcICCBAAGIAEGLEDwgILEC4YgAQYsQMYgwHCAg4QABiABBixAxiDARiKBcICChAAGIAEGEMYigXCAg0QABiABBixAxhDGIoFwgIOEAAYgAQYkQIYsQMYigXCAgcQIxixAhgnwgIHEAAYgAQYCsICDRAAGIAEGLEDGIoFGArCAgkQABiABBgKGAvCAgwQABiABBixAxgKGAvCAgQQABgDmAMAiAYBkAYIkgcINS4xMi4xLjGgB6l2sgcIMC4xMi4xLjG4B8MTwgcGMC42LjEzyAdBgAgA&amp;sclient=gws-wiz-serp&amp;ved=2ahUKEwiJ2c3N67iSAxVDlFYBHem2E9EQgK4QegYIAQgFEAU"><strong>DNS (Domain Name System)</strong></a><strong>:</strong> Fast queries.</p>
</li>
<li><p><a target="_blank" href="https://www.google.com/search?q=VoIP+%28Voice+over+IP%29&amp;sca_esv=e2e9df9ab93ca8c0&amp;sxsrf=ANbL-n488wiZ1wi38hWimCrlbfGZNGdUeA%3A1769964118318&amp;ei=VoJ_aYOGE8vYseMP2-vHmAw&amp;oq=explain+udp+&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiDGV4cGxhaW4gdWRwICoCCAAyChAAGIAEGBQYhwIyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgARIoUBQxwhYlzJwBXgBkAEAmAG9AqABgBOqAQgwLjEyLjEuMbgBAcgBAPgBAZgCE6AC2BPCAgoQABiwAxjWBBhHwgIKECMYgAQYJxiKBcICBBAjGCfCAgsQABiABBiRAhiKBcICCBAAGIAEGLEDwgILEC4YgAQYsQMYgwHCAg4QABiABBixAxiDARiKBcICChAAGIAEGEMYigXCAg0QABiABBixAxhDGIoFwgIOEAAYgAQYkQIYsQMYigXCAgcQIxixAhgnwgIHEAAYgAQYCsICDRAAGIAEGLEDGIoFGArCAgkQABiABBgKGAvCAgwQABiABBixAxgKGAvCAgQQABgDmAMAiAYBkAYIkgcINS4xMi4xLjGgB6l2sgcIMC4xMi4xLjG4B8MTwgcGMC42LjEzyAdBgAgA&amp;sclient=gws-wiz-serp&amp;ved=2ahUKEwiJ2c3N67iSAxVDlFYBHem2E9EQgK4QegYIAQgFEAc"><strong>VoIP (Voice over IP)</strong></a><strong>:</strong> Voice communication.</p>
</li>
<li><p><a target="_blank" href="https://www.google.com/search?q=DHCP+%26+SNMP&amp;sca_esv=e2e9df9ab93ca8c0&amp;sxsrf=ANbL-n488wiZ1wi38hWimCrlbfGZNGdUeA%3A1769964118318&amp;ei=VoJ_aYOGE8vYseMP2-vHmAw&amp;oq=explain+udp+&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiDGV4cGxhaW4gdWRwICoCCAAyChAAGIAEGBQYhwIyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgAQyBRAAGIAEMgUQABiABDIFEAAYgARIoUBQxwhYlzJwBXgBkAEAmAG9AqABgBOqAQgwLjEyLjEuMbgBAcgBAPgBAZgCE6AC2BPCAgoQABiwAxjWBBhHwgIKECMYgAQYJxiKBcICBBAjGCfCAgsQABiABBiRAhiKBcICCBAAGIAEGLEDwgILEC4YgAQYsQMYgwHCAg4QABiABBixAxiDARiKBcICChAAGIAEGEMYigXCAg0QABiABBixAxhDGIoFwgIOEAAYgAQYkQIYsQMYigXCAgcQIxixAhgnwgIHEAAYgAQYCsICDRAAGIAEGLEDGIoFGArCAgkQABiABBgKGAvCAgwQABiABBixAxgKGAvCAgQQABgDmAMAiAYBkAYIkgcINS4xMi4xLjGgB6l2sgcIMC4xMi4xLjG4B8MTwgcGMC42LjEzyAdBgAgA&amp;sclient=gws-wiz-serp&amp;ved=2ahUKEwiJ2c3N67iSAxVDlFYBHem2E9EQgK4QegYIAQgFEAk"><strong>DHCP &amp; SNMP</strong></a><strong>:</strong> Network management protocols.</p>
</li>
</ul>
<p><strong>Key Differences:</strong></p>
<ul>
<li><p><strong>Reliability:</strong> TCP guarantees delivery; UDP does not.</p>
</li>
<li><p><strong>Speed:</strong> UDP is faster due to lower overhead.</p>
</li>
<li><p><strong>Order:</strong> TCP ensures packets arrive in order; UDP does not.</p>
</li>
<li><p><strong>Usage:</strong> TCP for accuracy (Email, HTTP); UDP for speed (VoIP, Video).</p>
</li>
</ul>
<h2 id="heading-how-tcp-relates-to-http">How TCP Relates To HTTP</h2>
<p>TCP (Transmission Control Protocol) and HTTP (HyperText Transfer Protocol) work together in the TCP/IP model, where <strong>HTTP acts as the application-layer protocol for web data, and TCP acts as the transport-layer protocol that ensures that data is delivered reliably</strong>.</p>
<h3 id="heading-key-relationships-between-tcp-and-http"><strong>Key Relationships Between TCP and HTTP:</strong></h3>
<ul>
<li><p><strong>Layering:</strong> HTTP is built on top of TCP. TCP manages the data stream (connection/reliability), while HTTP defines the structure of the message sent within that stream (e.g., GET/POST requests).</p>
</li>
<li><p><strong>Connection &amp; Reliability:</strong> Before a browser can send an HTTP request, it must establish a TCP connection, which provides reliable, ordered data delivery.</p>
</li>
<li><p><strong>Port 80/443:</strong> HTTP typically uses TCP port 80 (or 443 for HTTPS) to communicate with web servers.</p>
</li>
<li><p><strong>Analogy:</strong> If HTTP is the letter (data), TCP is the courier service that ensures the envelope arrives safely and in the correct order.</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>