TCP Three-Way Handshake
TCP requires a connection to be established between two end systems before data transfer can begin. TCP establishes the connection using a process that is called the three-way handshake. This process involves setting the SYN bit and ACK bit in the segments between the two devices. An important function that is performed during connection establishment is that the devices exchange their initial sequence numbers (ISNs). This number is used to track data bytes on this connection. The table below includes a simplified explanation of the three-way handshake process, which is illustrated in the figure.
A TCP connection is normally and gracefully terminated when each side of the connection closes its side of the connection independently. The following example provides a simplified description of the process:
- Host A sends a FIN (a TCP segment with the FIN bit set) to Host B to indicate that it wants to terminate the session.
- Host B sends an ACK (a segment with the ACK bit set) back to Host A, acknowledging that it received the FIN.
- Host B sends a FIN to Host A.
- Host A sends an ACK to Host B.