0
21kviews
Explain TCP connection establishment and release.

Electronics > Sem 6 > Computer Communication Networks

1 Answer
1
1.2kviews

TCP Connection Establishment:

  • To establish a connection, one side, say the server, passively waits for an incoming connection by executing the LISTEN and ACCEPT primitives in that order, either specifying a specific source or nobody in particular.

  • The other side, say, the client, executes a CONNECT primitive, specifying the IP address and port to which it wants to connect, the maximum TCP segment size it is willing to accept, and optionally some user data (e.g., a password).

  • The CONNECT primitive sends a TCP segment with the SYN bit on and ACK bit off and waits for a response.

  • When this segment arrives at the destination, the TCP entity there checks to see if there is a process that has done a LISTEN on the port given in the Destination port field. If not, it sends a reply with the RST bit on to reject the connection.

  • If some process is listening to the port, that process is given the incoming TCP segment. It can either accept or reject the connection. If it accepts, an acknowledgement segment is sent back. The sequence of TCP segments sent in the normal case is shown in Fig below. Note that a SYN segment consumes 1 byte of sequence space so that it can be acknowledged unambiguously.

enter image description here

  • In the event that two hosts simultaneously attempt to establish a connection between the same two sockets, the sequence of events is as illustrated in Fig.(b). The result of these events is that just one connection is established, not two, because connections are identified by their end points. If the first setup results in a connection identified by (x, y) and the second one does too, only one table entry is made, namely, for (x, y).

TCP Connection Termination:

  • TCP provides for a graceful close that involves independent termination of each direction of the connection. A termination is initiated when an application tells TCP that it has no more data to send.
  • The TCP entity completes transmission of its data and upon receiving acknowledgement from the receiver, issues a segment with the FIN bit set.
  • Upon receiving a FIN segment, A TCP entity informs its application that the other entity has terminated its transmission of data.
  • For e.g. as shown in fig below the TCP entity in host A terminates its transmission first by issuing a FIN segment. Host B sends an ACK segment to acknowledge receipt of the FIN segment from A. The FIN segment uses one byte, so the ACK is 5087 as shown in the example.
  • After B receives the FIN segment, the direction of the flow from B to A is still open. In fig below host B sends 150 bytes in one segment, followed by a FIN segment. Host A then send s an acknowledgment. The TCP in host A then enters the TIME_WAIT state and starts the TIME_WAIT timer with an initial value set to twice the maximum segment lifetime (2MSL).
  • The only valid segment that can arrive while host A is in the TIME_WAIT state is a retransmission of the FIN segment from host B(if host A’s ACK was lost, and host B’s retransmission time-out has expired).
  • If such a FIN segment arrives while host A is the TIME_WAIT state, then the ACK segment is retransmitted and the TIME_WAIT timer is restarted at 2MSL. When the TIME_WAIT timer expires, host A closes the connection and them deletes the record of the connection.

enter image description here

Please log in to add an answer.