written 8.5 years ago by | modified 2.9 years ago by |
MU > Computer Engineering > SEM-5 > Computer Netwoks >
Marks: 10
Year: MAY-2015
written 8.5 years ago by | modified 2.9 years ago by |
MU > Computer Engineering > SEM-5 > Computer Netwoks >
Marks: 10
Year: MAY-2015
written 8.5 years ago by |
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, 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 (Reset) 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 then either accept or reject the connection.
Normal case is shown in Figure (a).
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 Figure (b).
The result of these events is that just one connection is established, not two because connections are identified by their end points.
TCP Connection Release:
TCP connections are full duplex.
Each simplex connection is released independently of its sibling.
To release a connection, either party can send a TCP segment with the FIN bit set, which means that it has no more data to transmit.
When the FIN is acknowledged, that direction is shut down for new data.
Data may continue to flow indefinitely in the other direction, however.
When both directions have been shut down, the connection is released.
Normally, four TCP segments are needed to release a connection, one FIN and one ACK for each direction.
However, it is possible for the first ACK and the second FIN to be contained in the same segment, reducing the total count to three.
To avoid the two-army problem, timers are used.
If a response to a FIN is not forthcoming within two maximum packet lifetimes, the sender of the FIN releases the connection.
The other side will eventually notice that nobody seems to be listening to it anymore and will time out as well.
While this solution is not perfect, given the fact that a perfect solution is theoretically impossible, it will have to do. In practice, problems rarely arise.
Finite State Machine for Connection Establish & Release:
In each of the 11 states shown in above table, some specific events are legal.
Corresponding to every legal event some action may be taken, but if some other event happens, then error is reported.
Each Connection is always in the CLOSED State Initially.
It comes out of this state when it does either the passive open (LISTEN) or an active open (CONNECT).
A connection is established, if the other side does the opposite and the state becomes ESTABLISHED.
When the both the sides initiate a connection release the connection is terminated and the state returns to CLOSED state.