TCP is a transport layer protocol which is responsible for reliable and ordered delivery of stream of bytes from source to destination. One end acts as a server and the other acts as a client. Before starting any data transfer it has to establish a session between client and server.
To establish such a session (connection), TCP uses 3-way handshake method. During this period, both clients and servers exchange connection parameters and also do negotiate on the values to be used between them.
For example, some parameters like interface MTU, TCP window size etc. in one system can be more than that supported by other. In that case, they exchange their current settings and set to a mutually usable value for that connection.
Below figure shows how a TCP session is established between a client and a server. This involves three steps or handshakes. Each steps involves sending a frame from originator to destination.

1. Client sends its sequence number SEQ[A] to server. This sequence number is used by the server for synchronization which is very important for TCP's reliable and ordered delivery. Optionally, client and servers can synchronize their MSS (Maximum Segment Size). MSS is defined by the length field. If MSS is specified by client, through this it informs server that it can receive segments whose size can not exceed MSS. It sets acknowledgement field to 0 since this is the first frame to server in this session.
2. Server sends acknowledgement to the received frame (ACK) along with its sequence number SEQ[B]. Again, similar to server client uses this for synchronization between them. While sending ACK to client, it increments the sequence number (SEQ[A] + 1) which indiates to client that the server has received the frame with sequence SEQ[A] and expecting to receive new sequence frame (SEQ[A] + 1).
3. Now client acknowledges the frame from server by sending frame with (SEQ[B] + 1).


0 comments:
Post a Comment