Learn what a three-way handshake is and why it’s important in network communications.
A three-way handshake, or TCP three-way handshake, is a three-step process in networking that creates a transmission control protocol (TCP) connection between a server and a client. It’s similar to a handshake exchanged by two people, in which one person extends their hand, the other person shakes it, and then the first person acknowledges and retracts their hand. In this article, we will explore more of the intricacies of the three-way handshake, how it’s performed, and why it’s essential in establishing a reliable connection for network communications.
In networking, a three-way handshake is a process that's used to initiate a connection in a transmission control protocol/internet protocol (TCP/IP) network. TCP is responsible for ensuring data is delivered correctly between computers on an internet network.
It involves the following three steps: synchronize (SYN), synchronize-acknowledge (SYN-ACK), and acknowledge (ACK).
Here's how it works:
1. SYN: The initiating computer (or active client) sends a synchronize sequence number (SYN) packet to the receiving computer (usually a server). The SYN packet value is set to an arbitrary number (e.g., 100) to “ask” if any open connections are available.
2. SYN-ACK: If the receiving computer (also known as a passive client) has open ports that can accept the connection, it sends back a synchronize-acknowledge (SYN-ACK) packet to the initiating computer. The packet includes two numbers: the receiving computer’s own SYN, which can be any arbitrary number as well (e.g., 200), and the ACK number, which is the initiating computer’s SYN plus one (e.g., 101).
3. ACK: The initiating computer (active client) then sends an acknowledge sequence number (ACK) packet back to the receiving computer. This ACK packet is an acknowledgement of receipt of the SYN-ACK packet. The packet value is set to the receiving computer’s SYN (sent in step two) plus one again (e.g., 201). With this final step, the connection is established, and data transmission can begin.
These steps acknowledge the connection parameters on each side, stabilize the connection, and verify the serial numbers of each device. Each side must acknowledge a sequence number that is one larger than the one sent because the acknowledgement field relies on the next sequence number expected, which in turn acknowledges all of the earlier sequence numbers.
Where the three-way handshake creates a connection allowing two computers to seamlessly pass information back and forth, a four-way handshake terminates that connection with a pair of finish (FIN) and ACK messages.
The three-way handshake is a cornerstone of the TCP protocol because it establishes the connection parameters and reliable communication between two computers before actual data transmission begins. Much of our online activity uses three-way handshakes. It's a key mechanism for creating a secure connection over a TCP/IP network. For example, when you open a web browser and search for something on the internet, a three-way handshake connects the client-facing web browser with the internet server. Without proper synchronization, malicious actors such as black hat hackers could establish connections to vulnerable systems.
You can learn about TCP connection, OSI models, and how devices communicate from the experts at Microsoft by enrolling in the online course Introduction to Secure Networking.
Power shell
Read more: 6 Networking Certifications for Your IT Career
If you're looking to start your career in information technology, you can gain a comprehensive introduction to networking and digital security by completing the Google IT Support Professional Certificate. You can build job-ready skills with an industry leader in under six months.
Editorial Team
Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...
This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.