<?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: Handshake & Reliable Transfer]]></title><description><![CDATA[TCP: Handshake & Reliable Transfer]]></description><link>https://tcp-handshake-and-reliable-transfer.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 24 Oct 2026 08:28:03 GMT</lastBuildDate><atom:link href="https://tcp-handshake-and-reliable-transfer.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[TCP is an secure and reliable protocol which insures that data received at destination correctly and in correct order. Before sending any data it establish…]]></description><link>https://tcp-handshake-and-reliable-transfer.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://tcp-handshake-and-reliable-transfer.hashnode.dev/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[TCP]]></category><category><![CDATA[3-way handshake]]></category><category><![CDATA[4 Way Handshake]]></category><dc:creator><![CDATA[Prakash Jangid]]></dc:creator><pubDate>Fri, 30 Jan 2026 10:25:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769619078704/60c6d1a1-906e-4b37-aeb2-0127e79dee8c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-tcp-transmission-control-protocol">TCP (Transmission-Control-Protocol)</h2>
<p><strong>TCP</strong> is an secure and reliable protocol which insures that data received at destination correctly and in correct order.</p>
<p>Before sending any data it establish a connection between sender and receiver for secure and reliable data transfer. for that it uses a process called <strong>3-way handshake</strong> once the connection made, it sends data to the reciever, after secure data transfer connection removed using a process called <strong>4-way handshake.</strong></p>
<p><strong><em>Analogy</em></strong>: TCP can be compared to a courier service. Before sending the parcel, the courier company confirms that the receiver is available at the delivery address. Only after confirmation does the courier start delivery. Each parcel is delivered with tracking, and the receiver confirms receipt. If a parcel is lost or damaged, it is resent until successfully delivered.</p>
<h3 id="heading-problems-tcp-solves">Problems TCP Solves</h3>
<ul>
<li><p>Data Packet loss: If during transmission any data packet not received to the destination then TCP will retransmit the data from sender.</p>
</li>
<li><p>Reassemble Data segments: When data packets received at the destination all data segment reassemble in correct format because every data packet travel through different routes so order of packets can be changed.</p>
</li>
<li><p>Detect Duplicate Packets: If two data packets has same sequence number which assigned when data breaks into packets. then it will consider as duplicate and extra packets will be discarded.</p>
</li>
<li><p>Handle Overflow: It can happen that sender sent too much data but receiver is not able handle this much data all at once so using TCP, sender only send what receiver can handle.</p>
</li>
</ul>
<h2 id="heading-tcp-3-way-handshake">TCP 3-Way Handshake</h2>
<p>Now let’s talk about TCP 3-way Handshake and how TCP enable secure data transmission using this process.</p>
<p><strong>3-Way Handshake</strong> is a automated process. Using this process a client establish a connection to the server and once the connection is established they can transmit data.</p>
<p><strong>So lets understand how this process work step by step</strong></p>
<ul>
<li><p><strong>SYN:</strong> This is the first of establishing the connection to the server in this step client send a segment with SYN(Synchronize Sequence Number) to the receiver. This inform the server that client want to establish a connection.</p>
</li>
<li><p><strong>SYN + ACK:</strong> Server respond with acknowledgement that yes we can establish a connection. and it send a acknowledgement number.</p>
</li>
<li><p><strong>ACK:</strong> Client receive the acknowlegment and agree with acknowledgement number.</p>
</li>
</ul>
<p>And after this 3-way handshake process connection is established. Now client and server can send messages.</p>
<p><em>Analogy</em>: You call your friend. When they pick up, you ask, <strong>“Can you hear me?”</strong> <em>(SYN)</em> Your friend replies, <strong>“Yes, I can hear you. Can you hear me?”</strong> <em>(SYN + ACK)</em> You respond, <strong>“Yes, I can hear you too,”</strong> and the conversation begins <em>(ACK).</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769768603756/9dbe80ff-8674-419b-b8c8-ba94382f8006.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-how-data-transfer-works-in-tcp">How data transfer works in TCP?</h2>
<ul>
<li><p><strong>3-Way Handshake:</strong> Before sending any data TCP establish a secure connection between client and server. For that client and server both agrees on some rules. Without this step both client and server can’t send any data.</p>
</li>
<li><p><strong>Segmenting:</strong> Once connection is established data convert into packets or segment. These data segment created with sequence number (byte position) and checksum (corruption detection) and sent to receiver or server.</p>
</li>
<li><p><strong>Receiver Acknowledges Data:</strong> Once all data segments received to receiver it sends a acknowledgement to the sender. If any data segment lost in the transmission receiver won’t send any acknowledgement.</p>
</li>
<li><p><strong>Retransmission:</strong> If receiver didn’t send acknowledgement or sender didn’t receive acknowledgement in time, then sender will assume it a data loss and he will retransmit the data. This process is a automatic recovery it means our app didn’t know it happened.</p>
</li>
<li><p><strong>Ordering &amp; Reassembly:</strong> Once data segments received successfully data segment will start to re-order, Because data segments transmit through different routes so it is obvious that their arriving time is different so these segments start to arrange in right order based on sequence number.</p>
</li>
<li><p><strong>Flow Control:</strong> It can happen that sender sent too much data but receiver is not able handle this much data all at once so using TCP, sender only send what receiver can handle.</p>
</li>
</ul>
<h2 id="heading-connection-termination-in-tcp">Connection Termination in TCP</h2>
<p><strong>TCP</strong> is full duplex it just not establish a connection it also terminate it once data sending and receiving is done. So to terminate the connection it uses a process called <strong>4-Way Handshake</strong>.</p>
<h3 id="heading-how-4-way-handhake-works">How 4-Way Handhake Works?</h3>
<ul>
<li><p><strong>FIN (Client to Server):</strong> Client send a FIN flag for connection termination, In this step the state will change from <strong>ESTABLISHED</strong> to <strong>FIN_WAIT_1</strong></p>
</li>
<li><p><strong>ACK (Server to Client):</strong> Server receive this FIN flag and send back an ACK flag as the acknowledgment for the closing request to the other side and state change from <strong>FIN_WAIT_1</strong> to <strong>FIN_WAIT_2.</strong> Now in this state client can’t send any data but server can.</p>
</li>
<li><p><strong>FIN (Server to Client):</strong> After the server finishes sending any remaining data, it sends its own FIN packet to the client, and state will change from <strong>FIN_WAIT_2</strong> to <strong>TIME_WAIT.</strong></p>
</li>
<li><p><strong>ACK (Client to Server):</strong> The client receives the server's FIN and sends a final ACK, completing the termination process, and state change to <strong>CLOSED.</strong></p>
</li>
</ul>
<p><em>Analogy</em>: You’re talking to your friend on the phone. When you’re done, you say, <strong>“I’m done talking.”</strong> <em>(FIN)</em><br />Your friend replies, <strong>“Okay, I heard you.”</strong> <em>(ACK)</em> After finishing their part, your friend says, <strong>“Now I’m done too.”</strong> <em>(FIN)</em> You respond, <strong>“Okay, bye.”</strong> <em>(ACK).</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1769768645819/9f9752e3-fb34-4f1c-bc5b-df74d237ed68.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-what-is-timewait">What is TIME_WAIT?</h3>
<p>TIME_WAIT is the TCP state where client send final ACK, so this state keeps connection alive for a short time after it’s closed, not for sending or receiving data, just to wait.</p>
<p><strong>Why TIME_WAIT exists?</strong></p>
<p>Suppose final ACK got lost during connection termination then server will re-transmit the FIN. But what if client vanished after sending final ACK then server will wait forever. So <strong>TIME_WAIT</strong> keeps the client around so it can Re-ACK a retransmitted FIN.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Okay so with this we are at the end of this article, In this article we learned about <strong>What TCP is and What data transfer problem it solves</strong>. We also learned that <strong>How TCP establish a connection between sender and receiver for a secure data transmission</strong>, H<strong>ow data transfer works in TCP</strong> and after successful transmission <strong>How TCP terminate the connection</strong>.</p>
<p>So after knowing these topics we have enough high level knowlege about TCP (Transmission Control Protocols).</p>
]]></content:encoded></item></channel></rss>