Explain the connection establishment, data transfer and connection termination phases of TCP.
1 Answer

TCP Connections:

TCP Connection Establishment:

  • To make the transport services reliable. 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 re-transmitted 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 manner.

enter image description here

  • The requesting end (HOST A) sends a SYN segment specifying the port number of the server that the client wants to get connected to, and the clients initial sequence number (x)

  • The server (HOST B) responds with its own SYN segment containing the server's initial sequence number (y) the server also acknowledges the client SYN by acknowledging the clients SYN plus one (x+1) A SYN consumes one sequence number.

  • The client must acknowledge this SYN from the server by acknowledging the servers SYN plus one. (SEQ. = X + 1, ACK = Y + 1).

  • This is how a TCP connection is established.

    Connection termination protocol [connection release] :

  • While it takes three segments to establish a connection, It takes four to terminate a connection.

  • Since a TCP connection is full duplex (that is, data flows in each direction independently of the other direction), the connection should be terminated in both the direction independently.

  • When a TCP program on a host receives a FIN, it informs the application that the other end has terminated the data flow.

  • The receipt of a FIN only means there will be no more data flowing in that direction. A TCP can still send data after receiving a FIN

  • The end that first issues the close (e.g. sends the first FIN) performs the active close and the other end (that receives this FIN) performs the passive choice.

enter image description here

  • When the server receives the FIN it sends back an ACK of the received sequence number plus one. A FIN consumes a sequence number, just like a SYN

  • At this point the servers TCP also delivers an end of file to the application (the discard server)

  • The server then closes its connection and its TCP sends a FIN to the client. The clients TCP informs the application and sends an ACK to server by incrementing the received sequence number by one.

  • Connections are normally initiated by the client, with the first SYN going from the client to the server.

  • A client or server can actively close the connection (i.e. send the first FIN). But in practice generally the client determines when the connection should be terminated, since client processes are often driven by an interactive user, who enters something like quit to terminate

  • This is how the TCP connection is released.

Please log in to add an answer.