3.1 Network Services
3.1.5 Sample TCP connection sequence
To use reliable transport services, TCP hosts must establish a connection-oriented session with one another. Connection establishment is performed by way of a "three-way handshake".

A three-way handshake synchronizes both ends of a connection by allowing both sides to agree upon initial sequence numbers. This mechanism also guarantees that both sides are ready to transmit data. This is necessary so that packets are not transmitted or retransmitted during session establishment or after session termination .

Each host randomly chooses a sequence number used to track bytes within the stream it is sending and receiving. Then, the three-way handshake proceeds in the following manner:

The first host (Host A) initiates a connection by sending a packet with the initial sequence number (X) and SYN bit set to indicate a connection request.

The second host (Host B) receives the SYN, records the sequence number X, and replies by acknowledging the SYN (with an ACK = X + 1). Host B includes its own initial sequence number (SEQ = Y).

Host A then acknowledges Host B with a forward acknowledgment indicating the next sequence number Host A expects to receive (ACK = Y + 1). Data transfer can then begin.

Figures , , and illustrate this concept with some protocol analyzer output documenting the three-way handshake (follow the previous paragraphs and compare with the highlighted sequence numbers and acknowledgement numbers in the output).

Now it's time to look at some specific protocols and analyze their respective fields. This is very technical so you need to read this material when you're alert. If you take the time to carefully wade through the remainder of this chapter, you'll have a much better understanding of how routers make decisions.