TCP Three-Way Handshake 🎯

beginner
10 min

TCP Three-Way Handshake 🎯

Welcome to our deep dive into the world of computer networks! Today, we're going to learn about one of the most crucial parts of TCP (Transmission Control Protocol) - the Three-Way Handshake.

What is TCP Three-Way Handshake? 📝

The TCP Three-Way Handshake is a process that establishes a connection between two devices over the internet. It ensures reliable communication by verifying and synchronizing sequence numbers before data transfer begins.

Let's break it down:

  1. SYN (Synchronize): The initiating device (Client) sends a SYN packet to the receiving device (Server) to start the connection. This packet includes a sequence number (SeqNum) chosen by the client.
Client --> SYN=x, ACK=y, SeqNum=1, AckNum=waiting
  1. SYN-ACK (Synchronize-Acknowledgement): The Server responds with a SYN-ACK packet, confirming the connection and sending its own sequence number.
Server <-- SYN=y, ACK=x+1, SeqNum=z, AckNum=1
  1. ACK (Acknowledgement): The Client sends an ACK packet to finalize the connection. This packet confirms that the client has received the SYN-ACK from the server and sets the Acknowledgement number (AckNum) to the sequence number sent by the server + 1.
Client --> ACK=y+1, SeqNum=1

Now that the connection is established, data can be sent back and forth between the client and server! 💡 Pro Tip: The sequence numbers and acknowledgement numbers are used to verify the order of the data packets and to detect errors during transmission.

Practical Example 💡

Let's imagine Alice (Client) wants to send a file to Bob (Server). Here's how the TCP Three-Way Handshake would work:

  1. Alice sends a SYN packet with SeqNum=1 and waits for Bob's response.
  2. Bob responds with a SYN-ACK packet, setting SeqNum=2 and AckNum=1.
  3. Alice confirms the connection with an ACK packet, setting AckNum=3.

Now Alice can start sending the file to Bob, and both devices can communicate reliably!

Quick Quiz
Question 1 of 1

What is the initial sequence number sent by the client in a TCP Three-Way Handshake?

By learning the TCP Three-Way Handshake, you're taking a big step towards understanding how data is transferred securely and reliably over the internet! Stay tuned for more in-depth lessons on computer networks at CodeYourCraft! ✅ Happy learning!