Skip to content

Specification of Teardown

jirihnidek edited this page Nov 9, 2012 · 1 revision

Teardown

The Client can close a connection and the server can request closing of the connection. Closing of the connection by the client will be described first.

Client Closes Connection

We will first consider case, where client closes connection. Teardown was inspired again by DCCP protocol. If client wants to close connection, then this client can't share any data on server (client has to be unsubscribed from all data). Client only receive keep alie packets from server in this situation. Client start teardown switching from state OPEN to state CLOSING. Client sends payload packets with flag FIN in state CLOSING. Client send these packet repeately until it receive acknowledge packet of FIN packet. Such packet is called FIN-ACK. Other packets then FIN-ACK are ignored by client. When client receive packet FIN-ACK, then client is switched to state CLOSED. Teardown is ilustrated on following picture:

       client                                       server
         o                                            o
         |                                            |
    OPEN +                                            + OPEN
         |                                            |
         |               FIN pay_id=X                 |
 CLOSING +------------------------------------------->+----+
         |                                            |    |
         |        FIN pay_id=Y ack_id=Z ack=X         |    V
  CLOSED +<-------------------------------------------+ CLOSED (LISTEN)
         |                                            |
         .                                            .
         .                                            .

Following picture includes all possible scenarios during teardown:

       client                                       server
         o                                            o
         |                                            |
    OPEN +                                            + OPEN
         |                                            |
         |               FIN pay_id=X                 |
 CLOSING +------------------------------------>X      |
         |                                            |
         |                                            |
         |                                            |
         |                                            |
         |               FIN pay_id=X                 |
 timeout +------------------------------------------->+----+
         |                                            |    |
         |        FIN pay_id=Y ack_id=Z ack=X         |    V
         |    X<--------------------------------------+ CLOSED (LISTEN)
         |                                            |
         |               FIN pay_id=X                 |
 timeout +------------------------------------------->+----+
         |                                            |    |
         |                                            |    |
         |                                            |    |
         |                                            |    |
         |               FIN pay_id=X                 |    |
 timeout +------------------------------------------->+----+----+
         |                                            |    |    |
         |        FIN pay_id=Y ack_id=Z ack=X         |    |    |
  CLOSED +<-------------------------------------------+<---+    |
         |                                            |         |
         |        FIN pay_id=Y ack_id=Z ack=X         |         |
    drop +<-------------------------------------------+<--------+
         |                                            |
         .                                            .
         .                                            .

Notes:

  • Client has to consider case, where server can die during teardown. It means, that client can not send FIN packet infinity long, when there is no response from server. Client has to automaticaly switch from state CLOSING to state CLOSED in such situation after expiration of some timeout.
  • Server can deallocate system reources used for resend mechanism, when server is switched to state closed, but it has to respond on FIN packets. Client can free system resources, when it is switched to state CLOSING.

Server Requests Closing of Connection

       client                                       server
         o                                            o
         |                                            |
    OPEN +                                            + OPEN
         |                                            |
         |               FIN pay_id=W                 |
    +----+<-------------------------------------------+ CLOSEREQ
    |    |                                            |
    V    |               FIN pay_id=X                 |
 CLOSING +------------------------------------------->+----+
         |                                            |    |
         |        FIN pay_id=Y ack_id=Z ack=X         |    V
  CLOSED +<-------------------------------------------+ CLOSED (LISTEN)
         |                                            |
         .                                            .
         .                                            .
Clone this wiki locally