- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
TCP 3-Way Handshake Process
Transmission Control Protocol (TCP) provides a secure and reliable connection between two devices using the 3-way handshake process. TCP uses the full-duplex connection to synchronize (SYN) and acknowledge (ACK) each other on both sides. There are three steps for both establishing and closing a connection. They are − SYN, SYN-ACK, and ACK.
3-Way Handshake Connection Establishment Process
The following diagram shows how a reliable connection is established using 3-way handshake. It will support communication between a web browser on the client and server sides whenever a user navigates the Internet.
Synchronization Sequence Number (SYN) − The client sends the SYN to the server
- When the client wants to connect to the server, then it sends the message to the server by setting the SYN flag as 1.
- The message carries some additional information like the sequence number (32-bit random number).
- The ACK is set to 0. The maximum segment size and the window size are also set. For example, if the window size is 1000 bits and the maximum segment size is 100 bits, then a maximum of 10 data segments can be transmitted in the connection by dividing (1000/100=10).
Synchronization and Acknowledgement (SYN-ACK) to the client
- The server acknowledges the client request by setting the ACK flag to 1.
- The ACK indicates the response of the segment it received and SYN indicates with what sequence number it will start the segments.
- For example, if the client has sent the SYN with sequence number = 500, then the server will send the ACK using acknowledgment number = 5001.
- The server will set the SYN flag to '1' and send it to the client if the server also wants to establish the connection.
- The sequence number used for SYN will be different from the client's SYN.
- The server also advertises its window size and maximum segment size to the client. And, the connection is established from the client-side to the server-side.
Acknowledgment (ACK) to the server
- The client sends the acknowledgment (ACK) to the server after receiving the synchronization (SYN) from the server.
- After getting the (ACK) from the client, the connection is established between the client and the server.
- Now the data can be transmitted between the client and server sides.
3 -Way Handshake Closing Connection Process
To close a 3-way handshake connection,
- First, the client requests the server to terminate the established connection by sending FIN.
- After receiving the client request, the server sends back the FIN and ACK request to the client.
- After receiving the FIN + ACK from the server, the client confirms by sending an ACK to the server.
- 3-Way QuickSort (Dutch National Flag)
- 3-way Merge Sort in C++
- What is Transport Layer Security (TLS) Handshake?
- What is 3-way merge or merge commit in Git?
- Is there a standard way of using exception chains in Python 3?
- Process vs Parent Process vs Child Process
- The TCP/IP Reference Model
- Difference between TCP and UDP
- Explain the TCP Connection Management
- What is TCP Connection Release?
- TCP/IP in Computer Networking
- OSI vs. TCP/IP Reference Model
- Distinguish between the TCP and UDP.
- What is the TCP Segment Header?
- What is the TCP Connection Establishment?