<?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 working : 3 way Handshaking]]></title><description><![CDATA[TCP working : 3 way Handshaking]]></description><link>https://tcp-working-three-way-handshaking.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 08:46:48 GMT</lastBuildDate><atom:link href="https://tcp-working-three-way-handshaking.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[TCP working : 3 way handshake]]></title><description><![CDATA[Why Do We Even Need Rules to Send Data?
Imagine you’re sending a long message to a friend by shouting sentences across a noisy room.

Some sentences get lost

Some arrive out of order

Some arrive twice

You don’t know if the other person actually he...]]></description><link>https://tcp-working-three-way-handshaking.hashnode.dev/tcp-working-3-way-handshake</link><guid isPermaLink="true">https://tcp-working-three-way-handshaking.hashnode.dev/tcp-working-3-way-handshake</guid><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Abhinab Raha]]></dc:creator><pubDate>Fri, 30 Jan 2026 14:49:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/Hcfwew744z4/upload/feddd0b1c0c36872d8a0cad5fc1966f5.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-why-do-we-even-need-rules-to-send-data">Why Do We Even Need Rules to Send Data?</h2>
<p>Imagine you’re sending a long message to a friend by shouting sentences across a noisy room.</p>
<ul>
<li><p>Some sentences get lost</p>
</li>
<li><p>Some arrive out of order</p>
</li>
<li><p>Some arrive twice</p>
</li>
<li><p>You don’t know if the other person actually heard everything</p>
</li>
</ul>
<p>That’s exactly what happens on the internet <strong>without rules</strong>.</p>
<p>The internet breaks data into small pieces (called <em>packets</em>) and sends them across different paths. Without coordination, the receiver would get a messy pile of data with no guarantee it’s complete or correct.</p>
<p>This is where <strong>TCP</strong> comes in.</p>
<h2 id="heading-what-is-tcp-and-why-is-it-needed">What is TCP and Why Is It Needed?</h2>
<p><strong>TCP (Transmission Control Protocol)</strong> is a communication protocol that ensures data is:</p>
<ul>
<li><p><strong>Delivered reliably</strong></p>
</li>
<li><p><strong>Received in the correct order</strong></p>
</li>
<li><p><strong>Free from errors</strong></p>
</li>
<li><p><strong>Complete (nothing missing)</strong></p>
</li>
</ul>
<p>TCP is used when <strong>accuracy matters more than speed</strong>—like loading a website, sending emails, or downloading files.</p>
<p>Think of TCP as a <strong>careful, rule-following delivery system</strong> for data on the internet.</p>
<hr />
<h2 id="heading-problems-tcp-is-designed-to-solve">Problems TCP Is Designed to Solve</h2>
<p>TCP exists to fix some very real internet problems:</p>
<h3 id="heading-1-packet-loss">1. Packet Loss</h3>
<p>Some packets may disappear during transmission.</p>
<h3 id="heading-2-out-of-order-delivery">2. Out-of-Order Delivery</h3>
<p>Packets can take different routes and arrive in the wrong order.</p>
<h3 id="heading-3-duplicate-packets">3. Duplicate Packets</h3>
<p>The same packet might arrive more than once.</p>
<h3 id="heading-4-data-corruption">4. Data Corruption</h3>
<p>Bits can get altered during transmission.</p>
<h3 id="heading-5-uncontrolled-sending">5. Uncontrolled Sending</h3>
<p>A fast sender can overwhelm a slow receiver.</p>
<p>TCP handles <strong>all</strong> of these for you.</p>
<hr />
<h2 id="heading-what-is-the-tcp-3-way-handshake">What Is the TCP 3-Way Handshake?</h2>
<p>Before any real data is sent, TCP first <strong>establishes a connection</strong> using a process called the <strong>3-Way Handshake</strong>.</p>
<p>It’s basically TCP asking:</p>
<p>“Are you there?”<br />“Yes, are <em>you</em> there?”<br />“Cool, let’s talk.”</p>
<p><img src="https://static.afteracademy.com/images/what-is-a-tcp-3-way-handshake-process-three-way-handshaking-establishing-connection-6a724e77ba96e241.jpg" alt="What is a TCP 3-way handshake process?" /></p>
<hr />
<h2 id="heading-step-by-step-syn-syn-ack-ack">Step-by-Step: SYN, SYN-ACK, ACK</h2>
<h3 id="heading-step-1-syn-client-server">Step 1: SYN (Client → Server)</h3>
<p>The client sends a <strong>SYN</strong> message:</p>
<ul>
<li><p>“Hey server, I want to connect.”</p>
</li>
<li><p>Includes a <strong>starting sequence number</strong></p>
</li>
</ul>
<h3 id="heading-step-2-syn-ack-server-client">Step 2: SYN-ACK (Server → Client)</h3>
<p>The server replies with <strong>SYN-ACK</strong>:</p>
<ul>
<li><p>“I got your request.”</p>
</li>
<li><p>“Here’s my sequence number.”</p>
</li>
<li><p>“I acknowledge yours.”</p>
</li>
</ul>
<h3 id="heading-step-3-ack-client-server">Step 3: ACK (Client → Server)</h3>
<p>The client sends <strong>ACK</strong>:</p>
<ul>
<li><p>“I acknowledge your sequence number.”</p>
</li>
<li><p>Connection is now established</p>
</li>
</ul>
<p><strong>After this step, both sides trust each other and start sending data.</strong></p>
<p><img src="https://intronetworks.cs.luc.edu/1/html/_images/tcp_ladder_states.png" alt="12 TCP Transport — An Introduction to Computer Networks" /></p>
<hr />
<h2 id="heading-how-data-transfer-works-in-tcp">How Data Transfer Works in TCP</h2>
<p>Once the connection is established, real data starts flowing.</p>
<h3 id="heading-what-tcp-does-during-data-transfer">What TCP Does During Data Transfer</h3>
<ul>
<li><p>Breaks data into <strong>segments</strong></p>
</li>
<li><p>Assigns each segment a <strong>sequence number</strong></p>
</li>
<li><p>Receiver sends <strong>ACKs (acknowledgements)</strong></p>
</li>
<li><p>Sender only moves forward when ACKs are received</p>
</li>
</ul>
<hr />
<h2 id="heading-sequence-numbers-amp-acknowledgements">Sequence Numbers &amp; Acknowledgements</h2>
<p>Think of sequence numbers like <strong>page numbers in a book</strong></p>
<ul>
<li><p>Each packet has a number</p>
</li>
<li><p>Receiver uses numbers to:</p>
<ul>
<li><p>Reassemble data in order</p>
</li>
<li><p>Detect missing packets</p>
</li>
</ul>
</li>
</ul>
<p>ACKs mean:</p>
<blockquote>
<p>“I have received everything up to packet #120.”</p>
</blockquote>
<p>If packet #121 is missing → TCP knows exactly what to resend.</p>
<hr />
<h2 id="heading-how-tcp-ensures-reliability-order-and-correctness">How TCP Ensures Reliability, Order, and Correctness</h2>
<p>TCP is smart. Here’s how it guarantees correctness:</p>
<h3 id="heading-reliability">Reliability</h3>
<ul>
<li><p>Lost packets are <strong>detected</strong></p>
</li>
<li><p>Missing data is <strong>retransmitted</strong></p>
</li>
</ul>
<h3 id="heading-correct-order">Correct Order</h3>
<ul>
<li>Sequence numbers reorder packets correctly</li>
</ul>
<h3 id="heading-error-checking">Error Checking</h3>
<ul>
<li><p>Checksums detect corrupted data</p>
</li>
<li><p>Corrupted packets are discarded and resent</p>
</li>
</ul>
<h3 id="heading-flow-control">Flow Control</h3>
<ul>
<li><p>Receiver tells sender how much data it can handle</p>
</li>
<li><p>Prevents overload</p>
</li>
</ul>
<hr />
<h2 id="heading-what-happens-if-a-packet-is-lost">What Happens If a Packet Is Lost?</h2>
<p>No panic. TCP handles it calmly.</p>
<h3 id="heading-packet-loss-recovery-flow">Packet Loss Recovery Flow</h3>
<ol>
<li><p>Sender sends packets 1, 2, 3, 4</p>
</li>
<li><p>Packet 3 gets lost</p>
</li>
<li><p>Receiver keeps ACKing only up to packet 2</p>
</li>
<li><p>Sender notices missing ACK</p>
</li>
<li><p>Sender <strong>retransmits packet 3</strong></p>
</li>
</ol>
<p>Smooth, controlled, reliable.</p>
<hr />
<h2 id="heading-how-a-tcp-connection-is-closed">How a TCP Connection Is Closed</h2>
<p>TCP doesn’t just vanish,it <strong>closes politely</strong>.</p>
<h3 id="heading-packet-loss-recovery-flow-1">Packet Loss Recovery Flow</h3>
<ol>
<li><p>Sender sends packets 1, 2, 3, 4</p>
</li>
<li><p>Packet 3 gets lost</p>
</li>
<li><p>Receiver keeps ACKing only up to packet 2</p>
</li>
<li><p>Sender notices missing ACK</p>
</li>
<li><p>Sender <strong>retransmits packet 3</strong></p>
</li>
</ol>
<p>Smooth, controlled, reliable.</p>
<hr />
<h2 id="heading-how-a-tcp-connection-is-closed-1">How a TCP Connection Is Closed</h2>
<p>TCP doesn’t just vanish,it <strong>closes politely</strong>.</p>
<h3 id="heading-tcp-connection-termination-fin-amp-ack">TCP Connection Termination (FIN &amp; ACK)</h3>
<ol>
<li><p>Client sends <strong>FIN</strong><br /> → “I’m done sending data.”</p>
</li>
<li><p>Server sends <strong>ACK</strong><br /> → “I got your FIN.”</p>
</li>
<li><p>Server sends <strong>FIN</strong><br /> → “I’m done too.”</p>
</li>
<li><p>Client sends <strong>ACK</strong><br /> → Connection closed cleanly</p>
</li>
</ol>
<p>This ensures <strong>no data is cut off</strong> mid-transfer.</p>
<hr />
<h2 id="heading-tcp-connection-lifecycle">TCP Connection Lifecycle</h2>
<p><img src="https://www.ibm.com/support/pages/system/files/inline-images/Flow%20chart%20TCP%20connection_0.jpg" alt="Flowchart of TCP connections and their definition" /></p>
<ul>
<li><p><strong>Establish</strong> → 3-Way Handshake</p>
</li>
<li><p><strong>Transfer</strong> → Reliable data exchange</p>
</li>
<li><p><strong>Close</strong> → FIN &amp; ACK termination</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The internet may look instant and effortless, but behind the scenes, data is constantly facing problems like loss, delay, and disorder. <strong>TCP (Transmission Control Protocol)</strong> exists to handle these challenges and make communication reliable.</p>
<p>By establishing a connection through the <strong>3-way handshake</strong>, tracking data using <strong>sequence numbers</strong>, confirming delivery with <strong>acknowledgements</strong>, and retransmitting lost packets, TCP ensures that data reaches its destination <strong>completely, correctly, and in order</strong>. Even when communication ends, TCP closes the connection gracefully using <strong>FIN and ACK</strong>, making sure nothing is left unfinished.</p>
<p>In short, TCP trades a bit of speed for <strong>trust and accuracy</strong>. That’s why it powers critical applications like web browsing, emails, and file transfers. Without TCP, the internet would be fast—but chaotic. With TCP, it becomes dependable.</p>
]]></content:encoded></item></channel></rss>