<?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 Handshake]]></title><description><![CDATA[TCP Working: 3-Way Handshake]]></description><link>https://rajwa74.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 07:12:15 GMT</lastBuildDate><atom:link href="https://rajwa74.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 & Reliable Communication]]></title><description><![CDATA[In this article we had to study about TCP how it work in simple terms the working of Tcp is Ek hath De, Aur Ek Hath Le.
Understanding TCP – Reliable Communication on the Internet

1) What happens if data is sent without rules
Imagine you want to send...]]></description><link>https://rajwa74.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://rajwa74.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[TCP]]></category><category><![CDATA[TCP Handshake]]></category><category><![CDATA[TCP/IP]]></category><category><![CDATA[tcp vs udp]]></category><category><![CDATA[webdevelopment]]></category><dc:creator><![CDATA[Raj Mourya]]></dc:creator><pubDate>Fri, 30 Jan 2026 15:34:00 GMT</pubDate><content:encoded><![CDATA[<p>In this article we had to study about TCP how it work in simple terms the working of Tcp is <mark>Ek hath De, Aur Ek Hath Le.</mark></p>
<h1 id="heading-understanding-tcp-reliable-communication-on-the-internet">Understanding TCP – Reliable Communication on the Internet</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769787013181/4bcd56b3-e694-41c2-a664-dc0ef75a8147.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-1-what-happens-if-data-is-sent-without-rules">1) What happens if data is sent without rules</h2>
<p>Imagine you want to send a long message to a friend, but:</p>
<ul>
<li><p>You send words randomly</p>
</li>
<li><p>Some words are lost</p>
</li>
<li><p>Some words arrive twice</p>
</li>
<li><p>Order is mixed</p>
</li>
</ul>
<p>The message will <strong>not make sense</strong>.</p>
<p>This is exactly what happens on the internet if data is sent <strong>without rules</strong>.</p>
<p>Computers need a system that:</p>
<ul>
<li><p>Sends data safely</p>
</li>
<li><p>Knows if data is lost</p>
</li>
<li><p>Keeps data in correct order</p>
</li>
</ul>
<p>That system is TCP.</p>
<h2 id="heading-2-what-is-tcp-and-why-it-is-needed">2) What is TCP and why it is needed</h2>
<p>TCP stands for <strong>Transmission Control Protocol</strong>.</p>
<p>TCP is a <strong>communication protocol</strong> that makes sure data:</p>
<ul>
<li><p>Reaches the destination</p>
</li>
<li><p>Arrives in the correct order</p>
</li>
<li><p>Is complete and correct</p>
</li>
</ul>
<p>Most important internet services use TCP:</p>
<ul>
<li><p>Websites (HTTP/HTTPS)</p>
</li>
<li><p>Emails</p>
</li>
<li><p>File downloads</p>
</li>
</ul>
<p>Without TCP, the internet would be unreliable.</p>
<p><strong>Simple idea:</strong></p>
<blockquote>
<p><mark>TCP is like a responsible delivery service.</mark></p>
</blockquote>
<h2 id="heading-3-problems-tcp-is-designed-to-solve">3) Problems TCP is designed to solve</h2>
<p><mark>TCP exists to solve real problems.</mark></p>
<h3 id="heading-data-loss">Data Loss</h3>
<p>Some data packets may get lost while traveling.</p>
<h3 id="heading-wrong-order">Wrong Order</h3>
<p>Packets may arrive in the wrong order.</p>
<h3 id="heading-duplicate-data">Duplicate Data</h3>
<p>The same packet may arrive more than once.</p>
<h3 id="heading-no-confirmation">No Confirmation</h3>
<p>Sender may not know if data was received or not.</p>
<p>TCP solves all these problems automatically.</p>
<h2 id="heading-4nwhat-is-the-tcp-3-way-handshake">4)nWhat is the TCP 3-Way Handshake</h2>
<p><mark>Before sending data, TCP first </mark> <strong><mark>creates a connection</mark></strong><mark>.This connection setup is called the </mark> <strong><mark>3-Way Handshake</mark></strong>.</p>
<p>It ensures:</p>
<ul>
<li><p>Both sides are ready</p>
</li>
<li><p>Both sides can talk</p>
</li>
<li><p>Connection is trusted</p>
</li>
</ul>
<p><mark>Think of it like starting a phone call.</mark></p>
<h2 id="heading-5-the-3-way-handshake-simple-conversation-analogy">5) The 3-Way Handshake (Simple Conversation Analogy)</h2>
<p>Let’s say <strong>Client</strong> wants to talk to <strong>Server</strong>.</p>
<h3 id="heading-step-1-syn-client-server">Step 1: SYN (Client → Server)</h3>
<p>Client says:</p>
<blockquote>
<p>“Can I talk to you?”</p>
</blockquote>
<p>This message is called <strong>SYN</strong>.</p>
<p>It means:</p>
<ul>
<li><p>I want to start a connection</p>
</li>
<li><p>Here is my starting sequence number</p>
</li>
</ul>
<h3 id="heading-step-2-syn-ack-server-client">Step 2: SYN-ACK (Server → Client)</h3>
<p>Server replies:</p>
<blockquote>
<p>“Yes, I can talk, and I heard you.”</p>
</blockquote>
<p>This is <strong>SYN + ACK</strong>.</p>
<p>It means:</p>
<ul>
<li><p>I accept your request</p>
</li>
<li><p>I acknowledge your message</p>
</li>
<li><p>Here is my starting sequence number</p>
</li>
</ul>
<h3 id="heading-step-3-ack-client-server">Step 3: ACK (Client → Server)</h3>
<p>Client responds:</p>
<blockquote>
<p>“Great, I heard you too.”</p>
</blockquote>
<p>This is <strong>ACK</strong>.</p>
<p>Now:</p>
<ul>
<li><p>Connection is established</p>
</li>
<li><p>Data transfer can begin</p>
</li>
</ul>
<h2 id="heading-6-why-the-3-way-handshake-is-important">6) Why the 3-Way Handshake is important</h2>
<p>The handshake ensures:</p>
<ul>
<li><p>Both sides are reachable</p>
</li>
<li><p>Both sides agree to communicate</p>
</li>
<li><p>Sequence numbers are synchronized</p>
</li>
</ul>
<p>Without this step:</p>
<ul>
<li><p>Data could be sent to a dead server</p>
</li>
<li><p>Data could be misunderstood</p>
</li>
</ul>
<p><mark>TCP never sends actual data </mark> <strong><mark>before</mark></strong> <mark> the handshake finishes.</mark></p>
<h2 id="heading-7-how-data-transfer-works-in-tcp-high-level">7) How data <mark>transfer </mark> works in TCP (High-level)</h2>
<p>After connection is ready:</p>
<ul>
<li><p>Data is broken into small pieces (segments)</p>
</li>
<li><p>Each piece has a sequence number</p>
</li>
<li><p>Receiver sends acknowledgements (ACKs)</p>
</li>
</ul>
<p>Sender sends → Receiver confirms → Sender continues</p>
<p>This creates a <strong>controlled flow of data</strong>.</p>
<h2 id="heading-8-sequence-numbers-and-acknowledgements">8) Sequence numbers and acknowledgements</h2>
<p>Sequence numbers:</p>
<ul>
<li><p>Tell the order of data</p>
</li>
<li><p>Help rebuild the original message</p>
</li>
</ul>
<p>Acknowledgements:</p>
<ul>
<li><p>Tell which data was received</p>
</li>
<li><p>Tell what is missing</p>
</li>
</ul>
<p><strong>Simple idea:</strong></p>
<blockquote>
<p>“I received everything till this point.”</p>
</blockquote>
<h2 id="heading-9-how-tcp-ensures-reliability">9) How TCP ensures reliability</h2>
<p>TCP uses multiple techniques:</p>
<h3 id="heading-acknowledgements">Acknowledgements</h3>
<p>Receiver confirms received data.</p>
<h3 id="heading-retransmission">Retransmission</h3>
<p>If confirmation is not received:</p>
<ul>
<li>TCP resends the data</li>
</ul>
<h3 id="heading-error-checking">Error Checking</h3>
<p>If data is corrupted:</p>
<ul>
<li><p>It is rejected</p>
</li>
<li><p>Sent again</p>
</li>
</ul>
<p>This guarantees <strong>correct data delivery</strong>.</p>
<h2 id="heading-10-how-tcp-maintains-order">10) How TCP maintains order</h2>
<p>Even if packets arrive in random order:</p>
<ul>
<li><p>TCP reorders them using sequence numbers</p>
</li>
<li><p>Application receives clean, ordered data</p>
</li>
</ul>
<p>So the application never sees:</p>
<ul>
<li><p>Mixed data</p>
</li>
<li><p>Broken messages</p>
</li>
</ul>
<h2 id="heading-11-how-tcp-handles-packet-loss">11) How TCP handles packet loss</h2>
<p>If a packet is lost:</p>
<ul>
<li><p>Receiver notices a missing sequence number</p>
</li>
<li><p>Sender does not get ACK</p>
</li>
<li><p>Sender resends the missing data</p>
</li>
</ul>
<p>This happens automatically.</p>
<p><mark>Applications do not need to worry about it.</mark></p>
<h2 id="heading-12-how-a-tcp-connection-is-closed">12) How a TCP connection is closed</h2>
<p>When communication is finished:</p>
<ul>
<li>TCP closes the connection safely</li>
</ul>
<p>This is done using <strong>FIN and ACK</strong> messages.</p>
<h3 id="heading-fin">FIN</h3>
<p>One side says:</p>
<blockquote>
<p>“I am done sending data.”</p>
</blockquote>
<h3 id="heading-ack">ACK</h3>
<p>Other side replies:</p>
<blockquote>
<p>“I received everything.”</p>
</blockquote>
<p>This ensures:</p>
<ul>
<li><p>No data is lost at the end</p>
</li>
<li><p>Connection closes cleanly</p>
</li>
</ul>
<h2 id="heading-13-why-proper-connection-closing-matters">13) Why proper connection closing matters</h2>
<p>If connections are not closed properly:</p>
<ul>
<li><p>Resources are wasted</p>
</li>
<li><p>Servers become slow</p>
</li>
<li><p>Memory leaks can happen</p>
</li>
</ul>
<p><mark>TCP makes sure connections end </mark> <strong><mark>gracefully</mark></strong><mark>.</mark></p>
<h2 id="heading-summary-for-fast-understanding">Summary for (Fast understanding)</h2>
<p>TCP provides:</p>
<ul>
<li><p>Reliability</p>
</li>
<li><p>Order</p>
</li>
<li><p>Error checking</p>
</li>
<li><p>Flow control</p>
</li>
</ul>
<p>If DNS helps you <strong>find a server</strong>,and HTTP defines <strong>what to say</strong>,TCP ensures <strong>how to say it safely</strong>.</p>
]]></content:encoded></item></channel></rss>