Skip to main content

Command Palette

Search for a command to run...

TCP Working: 3-Way Handshake & Reliable Communication

Updated
4 min read
TCP Working: 3-Way Handshake & Reliable Communication

Computers are connected on Internet to share information , communicates with other computer. For communication some rules required just like Grammer is needed for english speaking . These rules called Protocols in computer language. TCP is communication protocol of internet suite and it operates at Transport layer of OSI model which is short form of (Open System Interconnection).

Understanding the basics

Before diving on the 3-way handshake process . let’s learn about to main players in any network communication :

  • Client : This is the computer who request the information or service

  • Server : This is computer or system who provides the requested information or services

Now Imagine you want to visit website how the browser and the server are connect with each other. That’s where the 3-way handshake enter the scene.

3-Way Handshake Process

Step 1: SYN (Synchronize)

Imagine you computer which is client want to talk to server . To start conversation . client send special message like saying “Hello , can we chat ?”. This message called SYN Packet. It includes a secret code which is called sequence number to keep things organized for future talks. It is like client raising hand to get attention of server and say “Hey , I’d like to connect with you !”

What is Sequence Number

It is like putting number on your message so that other side knows in which number message are sent. Each message got unique number so that it helps to check the message received in right order or not.

Step 2 : SYN-ACK (Synchronize-Acknowledge)

When server receive “Hello” Client message (SYN Packet). The server acknowledges the client's message and says, "Yes, I got your request to chat! Let's do it." The server also shares its own secret code (sequence number) with the client. This second step is like the server responding, "Hey, I heard you! I'm ready to connect too."

Step 3: ACK (Acknowledge)

Now, the client, having received the server's friendly wave (SYN-ACK packet), gives a virtual high-five back. It says, "Great! I'm ready to chat too." The client also includes its own secret code, increasing it by one. When the server gets this high-five (ACK packet), it also increases its secret code. This third step is like both sides saying, "We're good to go! Let's start our conversation."

So, after these three friendly steps, the client and server are now connected and ready to share information like good pals chatting away! This whole process is called the 3-Way Handshake because it involves three steps, kind of like a friendly greeting before diving into a conversation.

What is TCP

TCP, or Transmission Control Protocol, is a crucial part of the Internet Protocol (IP) suite. It operates in the transport layer and is responsible for establishing, maintaining, and completing connections between devices. TCP ensures reliable and connection-oriented communication, making sure that data reaches its destination accurately and in the right order.

TCP is widely used in applications that require dependable and accurate data delivery, such as web browsing, email, file transfer (FTP), and remote terminal access like SSH.

TCP does 3 things:

  • It breaks the message into small packets.

  • it numbers them so they arrive in right order

  • it checks the every packet received

  • if something missing , resends it

TCP Flags

These are special flags that help control communication between the sender and receiver. These flags provide specific information about the communication.

1 . SYN (Synchronize):

Used to start a connection. When a client wants to establish a connection with a server, it sends a TCP packet with the SYN flag set. The server responds with a SYN-ACK packet.

2 .ACK (Acknowledge):

Indicates the acknowledgment field. It confirms that data has been received correctly.

3 .FIN (Finish):

Signals the sender to close the connection. Both the client and server use this flag to end the connection.

4 .RST (Reset):

Resets the connection. This flag is used when there's an error or an unknown condition, and the connection needs to be terminated immediately.

These flags exist as bits in the TCP header and are set or unset to convey specific information. They play a role in indicating the state of the connection. For example, in the TCP handshake, SYN and ACK flags are used, while in connection termination, the FIN flag is utilized. Together, these flags allow TCP to effectively manage and control communication between devices.

Why is 3-Way Handshake Important ?

  • Reliability: It ensures that both the client and server are ready to communicate before sharing data.

  • Security: The handshake helps prevent unauthorized access and ensures a secure connection.

  • Error Handling: If any step fails, the connection isn't established, preventing potential issues.

**

Conclusion**

The 3-Way Handshake might sound complex, but it's essentially a digital greeting that ensures a smooth and secure conversation between your device and the server. Just like introducing yourself before starting a chat with a friend, the handshake establishes a reliable connection, making the vast world of computer networking a little less mysterious for beginners. So, the next time while browse a website or send a message, remember the friendly 3-Way Handshake that makes it all possible!

Foundations Of Networking and Internet

Part 1 of 7

This series dedicated to the foundation of Internet . - How computer are connected with others computers? - How website shown on browser when we type website name in browser?

Up next

TCP Vs UDP and IT's Real Use Cases

TCP vs UDP: When to Use What, and How TCP Relates to HTTP