Thursday, March 17, 2011

TCP Connection Establishment

To use reliable transport services, TCP hosts must establish a connection-oriented session with one
another. Connection establishment is performed by using a “three-way handshake” mechanism.
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
and know that the other side is ready to transmit as well. 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). An ACK = 20 means the host has
received bytes 0 through 19 and expects byte 20 next. This technique is called forward
acknowledgment. Host A then acknowledges all bytes Host B sent with a forward acknowledgment
indicating the next byte Host A expects to receive (ACK = Y + 1). Data transfer then can begin.

No comments:

Post a Comment