TCP Connection Establishment Process: The "Three-Way Handshake"
TCP Connection Establishment Process: The "Three-Way Handshake"
TCP Connection Establishment Process: The "Three-Way Handshake"
We have discussed in earlier topics in this section the connection orientation of TCP and its operation. Before TCP
can be employed for any actually useful purposethat is, sending dataa connection must be set up between the
two devices that wish to communicate. This process, usually called connection establishment, involves an exchange
of messages that transitions both devices from their initial connection state (CLOSED) to the normal operating state
(ESTABLISHED).
Connection Establishment Functions
The connection establishment process actually accomplishes several things as it creates a connection suitable for
data exchange:
o
Contact and Communication: The client and server make contact with each other and establish
communication by sending each other messages. The server usually doesnt even know what client it will be
talking to before this point, so it discovers this during connection establishment.
Sequence Number Synchronization: Each device lets the other know what initial sequence number it
wants to use for its first transmission.
Parameter Exchange: Certain parameters that control the operation of the TCP connection are exchanged
by the two devices.
SYN: This bit indicates that the segment is being used to initialize a connection. SYN stands for
synchronize, in reference to the sequence number synchronization I mentioned above.
ACK: This bit indicates that the device sending the segment is conveying an acknowledgment for a
message it has received (such as a SYN).
There are also other control bits (FIN, RST, PSH and URG), which aren't important to connection establishment, so
we will set them aside for now. We'll discuss them in other topics. In common TCP parlance, a message with a
control bit set is often named for that bit. For example, if the SYN control bit is set the segment is often called a SYN
message. Similarly, one with the ACK bit set is an ACK message or even just an ACK.
Key Concept: The normal process of establishing a connection between a TCP client and server involves three
steps: the client sends a SYN message; the server sends a message that combines an ACK for the clients SYN
and contains the servers SYN; and then the client sends an ACK for the servers SYN. This is called the TCP
three-way handshake.
Table 152 describes in detail how the three-way handshake works (including a summary of the preparation discussed
in the previous topic). It is adapted from the table describing the TCP finite state machine, but shows what happens
for both the server and the client over time. Each row shows the state the device begins in, what action it takes in that
state and the state to which it transitions. The transmit and receive parts of each of the three steps of the handshake
process are shown in the table, as well as in Figure 211.
Client
Start State
Action
Server
Move To State
Start State
CLOSED
CLOSED
CLOSED
Step #1 Transmit:
The client performs
an active OPEN,
creating a
transmission control
block (TCB) for the
connection and
sending a SYN
message to the
server.
SYN-SENT
LISTEN
LISTEN
SYN-SENT
Action
The server
performs a passive
OPEN, creating a
transmission
control block (TCB)
for the connection
and readying itself
for the receipt of a
connection request
(SYN) from a
client.
Step #1 Receive,
Step #2 Transmit:
The server
Move To State
LISTEN
SYN-
RECEIVED
SYNRECEIVED
SYNRECEIVED
Step #3 Receive:
The server
receives the ACK
to its SYN and is
now done with
connection
establishment.
ESTABLISHED
as well as the
server's SYN.
SYN-SENT
Step #2 Receive,
Step #3 Transmit:
The client receives
from the server the
SYN+ACK
containing the ACK
to the client's SYN,
and the SYN from
the server. It sends
the server an ACK
for the server's
SYN. The client is
now done with the
connection
establishment.
ESTABLISHED
ESTABLISHED
ESTABLISHED
ESTABLISHED
The server is
ready for normal
data transfer
operations.