in Computer Networks edited by
13,793 views
41 votes
41 votes

Consider a TCP client and a TCP server running on two different machines. After completing data transfer, the TCP client calls close to terminate the connection and a FIN segment is sent to the TCP server. Server-side TCP responds by sending an ACK, which is received by the client-side TCP. As per the TCP connection state diagram $\text{(RFC 793)}$, in which state does the client-side TCP connection wait for the FIN from the server-side TCP?

  1. LAST-ACK
  2. TIME-WAIT
  3. FIN-WAIT-$1$
  4. FIN-WAIT-$2$
in Computer Networks edited by
by
13.8k views

2 Comments

Ans: FIN-WAIT-2 (D)


46
46

Last minute quick explanation with great visuals:

TCP States - Computer Networks For Developers 07 - YouTube

1
1

7 Answers

42 votes
42 votes
Best answer

Close Initiator  Represents the agent which first sent the request for closing the connection when previously it was in established state(Usually client).

Close Responder represents the agent which responds to FIN Segments(Usually the server).

Now, as we see in the diagram,

When the client sends the FIN segment to server,it moves to FIN-WAIT1 state where it waits for an Acknowledgement from the server for it's own FIN segment.

Now when the client receives ACK for its OWN FIN Segment, it moves to FIN-WAIT2. This state represents that the connection from client to server has been terminated but still the connection from server to client is open.(TCP supports full duplex connections).

Hence, answer is D.

Reference:

[1]http://tcpipguide.com/free/t_TCPOperationalOverviewandtheTCPFiniteStateMachineF-2.htm

edited by

2 Comments

TCP A                                                TCP B

  1.  ESTABLISHED                                          ESTABLISHED

  2.  (Close)
      FIN-WAIT-1  --> <SEQ=100><ACK=300><CTL=FIN,ACK>  --> CLOSE-WAIT

  3.  FIN-WAIT-2  <-- <SEQ=300><ACK=101><CTL=ACK>      <-- CLOSE-WAIT

  4.                                                       (Close)
      TIME-WAIT   <-- <SEQ=300><ACK=101><CTL=FIN,ACK>  <-- LAST-ACK

  5.  TIME-WAIT   --> <SEQ=101><ACK=301><CTL=ACK>      --> CLOSED

  6.  (2 MSL)
      CLOSED

                         Normal Close Sequence

                               Figure 13.



      TCP A                                                TCP B

  1.  ESTABLISHED                                          ESTABLISHED

  2.  (Close)                                              (Close)
      FIN-WAIT-1  --> <SEQ=100><ACK=300><CTL=FIN,ACK>  ... FIN-WAIT-1
                  <-- <SEQ=300><ACK=100><CTL=FIN,ACK>  <--
                  ... <SEQ=100><ACK=300><CTL=FIN,ACK>  -->

  3.  CLOSING     --> <SEQ=101><ACK=301><CTL=ACK>      ... CLOSING
                  <-- <SEQ=301><ACK=101><CTL=ACK>      <--
                  ... <SEQ=101><ACK=301><CTL=ACK>      -->

  4.  TIME-WAIT                                            TIME-WAIT
      (2 MSL)                                              (2 MSL)
      CLOSED                                               CLOSED

                      Simultaneous Close Sequence

                               Figure 14.

https://tools.ietf.org/html/rfc793

  • FIN-WAIT-1: The first step of an active close (four-way handshake) was performed. The local end-point has sent a connection termination request to the remote end-point.
  • CLOSE-WAIT: The local end-point has received a connection termination request and acknowledged it e.g. a passive close has been performed and the local end-point needs to perform an active close to leave this state.
  • FIN-WAIT-2: The remote end-point has sent an acknowledgement for the previously sent connection termination request. The local end-point waits for an active connection termination request from the remote end-point.

https://benohead.com/tcp-about-fin_wait_2-time_wait-and-close_wait/

So, we can conclude , FIN-WAIT-2 is  the only connection, which is for ACK from server side

2
2
Nice Explained.
0
0
26 votes
26 votes

so D is ans.



edited by
by
16 votes
16 votes

This is from Tanenbaum,  read this line " Now both sides are closed , but TCP waits a time equal to the maximum packet lifetime , to guarantee that all packets from the connection has died off , just in case  the acknowledgement was lost " ... 

and this is in FIN WAIT 2  state...  

This question is taken directly from Tanenbaum book .

8 votes
8 votes

FIN WAIT 2

You can check It Here

http://www.sdsusa.com/support/connections/

Answer:

Related questions