TCP 3-way Handshake

TCP 3-way Handshake


Rahul Jha (@rahuljha2401)

TCP three-way handshake is a process by which a connection is set up between a client and a server on a TCP/IP network. It ensures that both the client and the server are ready to establish a connection before any data is transmitted.

What is TCP/IP Protocol Suite

TCP/IP stands for Transmission Control Protocol/Internet Protocol. It refers to a suite of communication protocols that facilitates data exchange between two devices. On one hand, the OSI model is a theoretical model and on the other hand TCP/IP is a practical model under application. It is important in networking as it makes end-to-end data delivery certain, as it makes sure the data reaches its destination without getting lost. It is necessary for safe data exchange.

What is TCP?

As mentioned earlier, TCP stands for Transmission Control Protocol. It is one of the widely used protocols of the Internet Protocol Suite for data transmission between different devices over a network. It provides reliability by making sure the data reaches its destination without getting lost, by making sure the client and server know that they are ready to transfer data, flow controlling by acknowledging the status of both the server and the client, and controls congestion.

TCP Segment Structure

TCP consists of a data field and a header file. The header file consists of source and destination port, sequence and acknowledgement number, flags, checksum, window size and urgent pointer.

Communication Over the Internet: TCP/IP Model

There are several layers through which communication between devices is done with the help of TCP/IP model. The top layer is the application layer, which handles network applications. The next layer is the transport layer. It is where the TCP operates. Positive Acknowledgement with Re-transmission (PAR) helps in making reliable connections. In PAR, the sender sends data units until it receives an acknowledgement from the receiver.

The 3 steps of TCP 3-way Handshake

  • SYN
  • ACK

SYN Step

This is the first step in the TCP 3-way handshake. To establish a connection between the server and the client, the client sends a SYN message to the server. The SYN flag is set to 1 and the ACK flag is set to 0, which tells us that no acknowledgement has been received. The client sends a TCP packet, containing a sequence number, which is randomly generated and chosen by the client, along with the window size and maximum segment size. The client is in SYN_SENT state.


This is the second step. The server responds to the SYN message from the client, with the SYN and ACK messages. The ACK flag is set to 1 and the acknowledgement number is set one higher than the received sequence number. It SYN flag, which was set 1, is left as it is, but the SYN number is different from the SYN number used by the client. The TCP packet also includes the window size and maximum segment size. The connection is established from the client to the server once this step is completed.

ACK Step

This is the third step of the 3-way handshake. As the server has replied with a SYN and ACK message, the client will set the ACK flag to 1. The acknowledgement number is set to 1 greater than the server's SYN sequence number. The SYN flag is set to 0. After the completion of this phase, the connection between the server and client is completed.


TCP finds its application in domains like:

  • Web browsing - Request and receive webpages.
  • Email - Simple Mail Transfer Protocol (SMTP) uses the TCP 3-way handshake.
  • File transfer - File Transfer Protocol (FTP) and Secure File Transfer Protocol (SFTP) utilize the TCP 3-way handshake.
  • Database access - MySQL and PostgreSQL use the TCP 3-way handshake.

Common Issues and Solution

  • Packet Loss: Some packets get lost due to network issues. This can be tackled with retransmission mechanism.
  • SYN Flood Attacks: Server can be flooded with malicious SYN requests, preventing legitimate connections from being serviced. The effect can be mitigated through SYN cache or SYN cookies.
  • Firewall issues: Firewall may block SYN packets. We should configure the firewall to prevent this.


In this blog, we learned about TCP, how it is an important protocol of the Internet Protocol Suite and its salient features. We came across different issues and its solution in TCP 3-way handshaking and also saw the TCP segment structure. We learned how communication is done over the TCP model and what are the 3 phases of TCP 3-way handshaking. We also learned the different applications of TCP 3-way handshake.

Add a thoughtful comment...

✨ Explore more tech insights and coding wonders with @dsabyte! Your journey in innovation has just begun. Keep learning, keep sharing, and let's continue to code a brighter future together. Happy exploring! 🚀❤️

  • #tcp
  • #syn
  • #ack
  • #@dsabyte

Subscribe to our newsletter.

Join the "News Later" community by entering your email. It's quick, it's easy, and it's your key to unlocking future tech revelations.

Weekly Updates

Every week, we curate and deliver a collection of articles, blogs and chapters directly to your inbox. Stay informed, stay inspired, and stay ahead in the fast-paced world of technology.

No spam

Rest assured, we won't clutter your inbox with unnecessary emails. No spam, only meaningful insights, and valuable content designed to elevate your tech experience.

© 2023 @dsabyte. All rights reserved