<?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[How TCP Work: 3-Way Handshake]]></title><description><![CDATA[How TCP Work: 3-Way Handshake]]></description><link>https://how-tcp-work-3-way-handshake.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 02 Nov 2026 08:12:55 GMT</lastBuildDate><atom:link href="https://how-tcp-work-3-way-handshake.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[We know that when we watch videos, movies, send messages, or browse something, data flows from the sender to the receiver using a set of rules called a…]]></description><link>https://how-tcp-work-3-way-handshake.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://how-tcp-work-3-way-handshake.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[tcp-3-way-handshake]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[tcp working]]></category><dc:creator><![CDATA[Amardeep Kumar]]></dc:creator><pubDate>Fri, 30 Jan 2026 04:18:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769788665274/f07c0321-7d15-47ec-b520-ea4fc8272935.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<h2 id="heading-introduction">Introduction</h2>
<p>We know that when we watch videos, movies, send messages, or browse something, data flows from the sender to the receiver using a set of rules called a protocol.</p>
<blockquote>
<p>what happens if the data is send without any rules?</p>
</blockquote>
<p>let’s understand this question with an example:</p>
<p>Imagine you send an important message to your friends, but after sending it, the message goes to the wrong person. This is not good for you.</p>
<p>So, this is the big problem when you send a message without any rules. To solve this, computers use a set of rules called a <strong>protocol.</strong></p>
<p>Here, we have two protocols for sending data from one computer to another.</p>
<p><strong>TCP (Transmission control protocol)</strong><br /><strong>UDP (User datagram protocol)</strong></p>
<hr />
<h2 id="heading-what-is-tcp">What is TCP?</h2>
<p><strong>TCP (Transmission control protocol)</strong> is a protocol for transfer the data over the internet with some set of rules. It makes the internet reliable and make sure that data is transmitted to the right place or destinations.</p>
<h3 id="heading-why-do-we-need-tcp">Why do we need TCP?</h3>
<p>Before understanding why we need TCP, let's look at an example.</p>
<p>When you and your friend send messages to each other, imagine your message accidentally goes to a third person. You might think this is okay in casual chatting, but if this happens in an organization and sensitive information goes to the wrong person, it's a big problem.</p>
<p>TCP solves this issue by ensuring your message reaches the correct destination. You can also use <strong>UDP (User Datagram Protocol)</strong>, which is faster but not as reliable.</p>
<h3 id="heading-what-problem-does-it-solve">What problem does it solve?</h3>
<p>Before sending data, TCP first divides it into packets called data packets or segments. If any packets are lost during transmission, it checks the order of the data. If data is missing, it retransmits the data packets.</p>
<p>TCP solves problem like:</p>
<ul>
<li><p>Ensures reliable data delivery</p>
</li>
<li><p>Fixes packet loss</p>
</li>
<li><p>Maintains correct packet order</p>
</li>
<li><p>Removes duplicate packets</p>
</li>
<li><p>Detects and corrects data corruption</p>
</li>
<li><p>Controls sender speed (flow control)</p>
</li>
</ul>
<hr />
<h2 id="heading-what-is-the-tcp-3-way-handshake">What is the TCP 3-Way Handshake</h2>
<p>Let's first understand it with an example:</p>
<p>Imagine you and your friend go outside to a noisy area and you want to talk to each other. Before starting, you first say, <em>“Can you hear me?”</em> Then your friend replies, <em>“Yes, I can hear you. Can you hear me?”</em> You respond, <em>“Yes, I can hear you.”</em> After both of you confirm, you start talking to each other.</p>
<p>Similarly, computers communicate over the network in a similar way. This process happens before sending data from one device to another. It ensures that communication between both devices is smooth.</p>
<h3 id="heading-now-lets-understand-the-steps-of-the-tcp-3-way-handshake">Now let's understand the steps of the TCP 3-way handshake:</h3>
<p><strong>Step-1: SYN (Synchronize)</strong></p>
<ul>
<li><p>The <strong>client (sender)</strong> wants to start a connection.</p>
</li>
<li><p>It sends a <strong>SYN segment</strong> to the server.</p>
</li>
<li><p>Meaning:<br />  <em>“I want to communicate with you, and this is my initial sequence number.”</em></p>
</li>
</ul>
<hr />
<p><strong>Step-2: SYN-ACK (Synchronize + Acknowledgment)</strong></p>
<ul>
<li><p>The <strong>server (receiver)</strong> receives the SYN.</p>
</li>
<li><p>It responds with <strong>SYN-ACK</strong>.</p>
</li>
<li><p>Meaning:<br />  <em>“I received your request, I’m ready too, and this is my sequence number.”</em></p>
</li>
</ul>
<hr />
<p><strong>Step-3: ACK (Acknowledgment)</strong></p>
<ul>
<li><p>The <strong>client</strong> sends back an <strong>ACK</strong>.</p>
</li>
<li><p>Meaning:<br />  <em>“I received your response. Let’s start sending data.”</em></p>
</li>
</ul>
<p>After these three steps, the connection is established between the sender and receiver, and they start transferring data to each other.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769746337974/fdf819ed-e2d8-4346-8624-16376e683510.webp" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-tcp-ensures-reliability-order-and-correctness">How TCP ensures reliability, order, and correctness</h2>
<p><strong>TCP (Transmission Control Protocol)</strong> is designed to send data reliably, in the right order, and without mistakes, even if the network is not reliable.</p>
<p><strong>Reliability:</strong><br />TCP ensures data is delivered by using acknowledgments (ACKs). When data is sent, the receiver confirms what it received. If something is missing, TCP automatically retransmits the lost data.</p>
<p><strong>Ordering:</strong><br />Each piece of data has a sequence number. This helps the receiver put packets back in the correct order before sending the data to the application.</p>
<p><strong>Correctness:</strong><br />TCP checks data for errors. If the data is damaged, it is discarded and sent again.</p>
<h2 id="heading-how-a-tcp-connection-is-closed">How a TCP connection is closed</h2>
<p>After completing the data transfer, the connection needs to be closed.</p>
<p>So, the client and server send confirmation messages to close the communication. This process is called the TCP 4-way handshake.</p>
<p><strong>Now let's understand each step:</strong></p>
<p><strong>Step 1: Fin (Finish)</strong></p>
<ul>
<li><p>After completing the communication client send the fin segment to the Server/receiver</p>
</li>
<li><p>Meaning:</p>
<p>  <em>“I send the data to you, now I want to close the communication “</em></p>
</li>
</ul>
<p><strong>Step 2: ACK (Acknowledgment)</strong></p>
<ul>
<li><p>Then the server replies with ACK segment to the client/sender</p>
</li>
<li><p>Meaning:</p>
<p>  <em>“Yes, I receive your data packets, now I close the communication “</em></p>
</li>
</ul>
<p><strong>Step 3: Fin (Finish)</strong></p>
<ul>
<li><p>Then servers/receiver sends again Fin segment to the client/sender</p>
</li>
<li><p>Meaning:</p>
<p>  <em>“I’m done sending data too. I want to close my side of the connection.”</em></p>
</li>
</ul>
<p><strong>Step 4: ACK (Acknowledgment)</strong></p>
<ul>
<li><p>The <strong>client sends a final ACK</strong> to acknowledge the server’s FIN.</p>
</li>
<li><p>Meaning:</p>
<p>  <em>“I acknowledge your request to close the connection.”</em></p>
</li>
</ul>
<p>After these four steps, the connection between the sender and receiver is closed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769746623231/c6e506ac-4b13-48cb-bd31-9ff4529fcc68.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>TCP makes sure data is sent safely and correctly over the internet. It checks that the data reaches the right computer, arrives in the correct order, and is not lost or damaged. Because of TCP, we can send messages, watch videos, and browse websites without problems.</p>
]]></content:encoded></item></channel></rss>