Connection Establishment In TCP:-

- Connection Establishmet in TCP, TCP transmits data in full-duplex mode.
- When two TCPs in two machines are connected, they are able to send segments to each other simultaneously.
- This implies that each party must initialize communication and get approval from the other party before any data are transferred.
Three-Way Handshaking
- The connection establishment in TCP is called three way handshaking.
- In our example, an application program, called the client, wants to make a connection with another application program, called the server, using TCP as the transport layer protocol.
- The process starts with the server.
- The server program tells its TCP that it is ready to accept a connection.
- This is called a request for a passive open.
- Although the server TCP is ready to accept any connection from any machine in the world, it cannot make the connection itself.
- The client program issues a request for an active open.
- A client that wishes to connect to an open server tells its TCP that it needs to be connected to that particular server.
- TCP can now start the three-way handshaking process as shown in Figure 23.18.
- To show the process, we use two time lines: one at each site.
- Each segment has values for all its header fields and perhaps for some of its option fields, too.
- However, we show only the few fields necessary to understand each phase.

- We show the sequence number, the acknowledgment number, the control flags (only those that are set)
Step-1
- The client sends the first segment, a SYN segment, in which only the SYN flag is set.
- This segment is for synchronization of sequence numbers.
- It consumes one sequence number.
- When the data transfer starts, the sequence number is incremented by 1.
- A SYN segment cannot carry data, but it consumes one sequence number.
Step-2
- The server sends the second segment, a SYN +ACK segment, with 2 flag bits set: SYN and ACK.
- This segment has a dual purpose.
- It is a SYN segment for communication in the other direction and serves as the acknowledgment for the SYN segment.
- It consumes one sequence number.
- A SYN +ACK segment cannot carry data, but does consume one sequence number.
Step-3
- The client sends the third segment.
- This is just an ACK segment.
- It acknowledges the receipt of the second segment with the ACK flag and acknowledgment number field.
- Note that the sequence number in this segment is the same as the one in the SYN segment; the ACK segment does not consume any sequence numbers.
- An ACK segment, if carrying no data, consumes no sequence number.