Subject: [AAA-WG]: [issue] Bug in Acct state machine + Split State Machines into Client vs. Server

From: <[email-masked]>
Date: Wed, 3 Apr 2002 15:44:14 +0300

<<[AAA-WG]: Re: Bug in Acct state machine>> 

Hi,

With regard to the attached proposed accounting session state machine for client and server, at least the following would require some consideration:

Server Accounting:

All the states proposed for Server Accounting are Idle (check the diamstates.txt).How is that possible?
Shouldn't at least Open and Idle be required/ needed for the server side ?

Also, in previous email with regard to the same topic some additional state-event transitions in particular Interim Record was presented which is not included in the diamstates.txt .

Thanks & Regards

Elena Lialiamou

Subject: [AAA-WG]: Re: Bug in Acct state machine
From: <[email-masked]>
To: <[email-masked]>, <[email-masked]>
Date: Mon, 1 Apr 2002 14:51:41 +0300

Jari Arkko wrote:

>  >Shouldn't the above be:
>  >        Discon    ASR Received                   Send STA.  Discon
> 
> Not quite. The STA is sent by the server, not the client.
> 
> There is an issue, however, on what to do if we have already sent an STR,
> are waiting for the STA to arrive but then we get an ASR from the server
> (STR and ASR meet on the wire). The -09 state machine simply ignored the
> ASR in this case, and on the server side was able to terminate the session
> if, while waiting for ASA would instead get STR. I think Pete's state
> machine gets it right as well.

On second thought, and on reading section 8.5, it seems that the more
appropriate action is really answering the ASR also. The ASR could
come from some other server than the one we sent the STR to. So,
if we are in the progress of releasing the session already and we
get ASR, we should respond with ASA Result-Code = Success.

Modified state machine attached.

Jari

8.1  Authorization Session State Machine

   This section contains a set of finite state machines, representing the life
   cycle of Diameter sessions, and which MUST be observed by all Diameter
   implementations that make use of the authentication and/or
   authorization portion of a Diameter application. The term Service-
   Specific below refers to a message defined in a Diameter application
   (e.g. Mobile IP, NASREQ).

   There are four different authorization session state machines
   supported in the Diameter base protocol. The first two describe a
   session in which the server is maintaining session state, indicated
   by the value of the Auth-Session-State AVP (or its absence).  One
   describes the session from a client perspective, the other from a
   server perspective. The second two state machines are used when
   the server does not maintain session state. Here again, one
   describes the session from a client perspective, the other from a
   server perspective.

   When a session is moved to the Idle state, any resources that were
   allocated for the particular session must be released.  Any event not
   listed in the state machines MUST be considered as an error
   condition, and an answer, if applicable, MUST be returned to the
   originator of the message.

   The following state machine is observed by a client when state is
   maintained on the server:

                              CLIENT, STATEFUL
      State     Event                          Action     New State
      -------------------------------------------------------------
      Idle      Client or Device Requests      Send       Pending
                access                         service
                                               specific
                                               auth req

      Idle      ASR Received                   Send ASA   Idle
                for unknown session            with
                                               Result-Code
                                               = UNKNOWN-
                                               SESSION-ID

      Pending   Successful Service-specific    Grant      Open
                authorization answer           Access
                received with default
                Auth-Session-State value

      Pending   Successful Service-specific    Sent STR   Discon
                authorization answer received
                but service not provided

      Pending   Error processing successful    Sent STR   Discon
                Service-specific authorization
                answer

      Pending   Failed Service-specific        Cleanup    Idle
                authorization answer received

      Open      user or client device          Send       Open
                requests access to service     service
                                               specific
                                               auth req

      Open      Successful Service-specific    Extend     Open
                authorization answer received  Answer

      Open      Failed Service-specific        Discon.    Idle
                authorization answer           user/device
                received.

      Open      Session-Timeout Expires on     Send STR   Discon
                Access Device

      Open      ASR Received,                  Send ASA   Discon
                client will comply with        with
                request to end the session     Result-Code
                                               = SUCCESS,
                                               Send STR.

      Open      ASR Received,                  Send ASA   Open
                client will not comply with    with
                request to end the session     Result-Code
                                               != SUCCESS

      Open      Authorization-Lifetime +       Send STR   Discon
                Auth-Grace-Period expires on
                access device

      Discon    ASR Received                   Send ASA   Discon

      Discon    STA Received                   Discon.    Idle
                                               user/device

   The following state machine is observed by a server when it is
   maintaining state for the session:

                             SERVER, STATEFUL
      State     Event                          Action     New State
      -------------------------------------------------------------
      Idle      Service-specific authorization Send       Open
                request received, and          successful
                user is authorized             serv.
                                               specific answer

      Idle      Service-specific authorization Send       Idle
                request received, and          failed serv.
                user is not authorized         specific answer

      Open      Service-specific authorization Send       Open
                request received, and user     successful
                is authorized                  serv. specific
                                               answer

      Open      Service-specific authorization Send       Idle
                request received, and user     failed serv.
                is not authorized              specific
                                               answer,
                                               Cleanup

      Open      Home server wants to           Send ASR   Open
                terminate the service

      Open      ASA Received                   Cleanup    Idle
                with Result-Code
                = UNKNOWN-SESSION-ID

      Open      ASA Received                   None       Open
                with Result-Code               
                not = UNKNOWN-SESSION-ID

      Open      Authorization-Lifetime (and    Cleanup    Idle
                Auth-Grace-Period) expires
                on home server.

      Open      Session-Timeout expires on     Cleanup    Idle
                home server

      Open      STR Received                   Send STA,  Idle
                                               Cleanup

      Not       ASA Received                   None       No Change.
      Open

      Not       STR Received                   Send STA,  Idle
      Open                                     Cleanup

   The following state machine is observed by a client when state is
   not maintained on the server:

                              CLIENT, STATELESS
      State     Event                          Action     New State
      -------------------------------------------------------------
      Idle      Client or Device Requests      Send       Pending
                access                         service
                                               specific
                                               auth req

      Pending   Successful Service-specific    Grant      Open
                authorization answer           Access
                received with Auth-Session-
                State set to
                NO_STATE_MAINTAINED

      Pending   Failed Service-specific        Cleanup    Idle
                authorization answer
                received

      Open      Session-Timeout Expires on     Discon.    Idle
                Access Device                  user/device

      Open      Service to user is terminated  Discon.    Idle
                                               user/device

   The following state machine is observed by a server when it is not
   maintaining state for the session:

                              SERVER, STATELESS
      State     Event                          Action     New State
      -------------------------------------------------------------
      Idle      Service-specific authorization Send serv. Idle
                request received, and          specific
                successfully processed         answer

8.2  Accounting Session State Machine

   For applications that only require accounting services or
   applications that have an accounting portion, the following state
   machines MUST be supported. The first is to be observed by clients,
   the second by servers.

   When a session is moved to the Idle state, any resources that were
   allocated for the particular session must be released.  Any event not
   listed in the state machines MUST be considered as an error
   condition, and an answer, if applicable, MUST be returned to the
   originator of the message.

   In the state table, the event 'Failure to send' means that the
   Diameter client is unable to communicate with the desired
   destination. This could be due to the peer being down, or due to
   the peer sending back a transient failure or temporary protocol
   error notification DIAMETER_OUT_OF_SPACE, DIAMETER_TOO_BUSY, or
   DIAMETER_LOOP_DETECTED in the Result-Code AVP of the Accounting
   Answer command.

   The event 'Failed answer' means that the Diameter client received a
   non-transient failure notification in the Accounting Answer
   command.

   Note that the action 'Disconnect user/dev' MUST have an effect also
   to the authorization session state table, e.g. cause the STR
   message to be sent, if the given application has both
   authentication/authorization and accounting portions.

                            CLIENT, ACCOUNTING
      State     Event                          Action     New State
      -------------------------------------------------------------
      Idle      Client or device requests      Send       PendingS
                access                         accounting
                                               start req.

      Idle      Client or device requests      Send       PendingE
                a one-time service             accounting
                                               event req

      Idle      Records in storage             Send       PendingB
                                               record

      PendingS  Successful accounting                     Open
                start answer received

      PendingS  Failure to send and buffer     Store      Open
                space available and realtime   Start
                not equal to DELIVER_AND_GRANT Record

      PendingS  Failure to send and no buffer             Open
                space available and realtime
                equal to GRANT_AND_LOSE

      PendingS  Failure to send and no buffer  Disconnect Idle
                space available and realtime   user/dev
                not equal to
                GRANT_AND_LOSE

      PendingS  Failed accounting start answer            Open
                received and realtime equal
                to GRANT_AND_LOSE

      PendingS  Failed accounting start answer Disconnect Idle
                received and realtime not      user/dev
                equal to GRANT_AND_LOSE

      PendingS  User service terminated        Store      PendingS
                                               stop
                                               record

      Open      Interim interval elapses       Send       PendingI
                                               accounting
                                               interim
                                               record

      Open      User service terminated        Send       PendingL
                                               accounting
                                               stop req.

      PendingI  Failure to send and (buffer    Store      Open
                space available or old record  interim
                can be overwritten) and        record
                realtime not equal to
                DELIVER_AND_GRANT

      PendingI  Failure to send and no buffer             Open
                space available and realtime
                equal to GRANT_AND_LOSE

      PendingI  Failure to send and no buffer  Disconnect Idle
                space available and realtime   user/dev
                not equal to GRANT_AND_LOSE

      PendingI  Failed accounting interim                 Open
                answer received and realtime
                equal to GRANT_AND_LOSE

      PendingI  Failed accounting interim      Disconnect Idle
                answer received and realtime   user/dev
                not equal to GRANT_AND_LOSE

      PendingI  User service terminated        Store      PendingI
                                               stop
                                               record

      PendingE  Successful accounting                     Idle
                event answer received

      PendingE  Failure to send and buffer     Store      Idle
                space available                event
                                               record

      PendingE  Failure to send and no buffer             Idle
                space available

      PendingE  Failed accounting event answer            Idle
                received

      PendingB  Successful accounting answer   Delete     Idle
                received                       record

      PendingB  Failure to send                           Idle

      PendingB  Failed accounting answer       Delete     Idle
                received                       record

      PendingL  Successful accounting                     Idle
                stop answer received

      PendingL  Failure to send and buffer     Store      Idle
                space available                stop
                                               record

      PendingL  Failure to send and no buffer             Idle
                space available

      PendingL  Failed accounting stop answer             Idle
                received

                            SERVER, ACCOUNTING
      State     Event                          Action     New State
      -------------------------------------------------------------

      Idle      Accounting start request       Send       Idle
                received, and successfully     accounting
                processed.                     start
                                               answer

      Idle      Accounting event request       Send       Idle
                received, and successfully     accounting
                processed.                     event
                                               answer

      Idle      Interim record received,       Send       Idle
                and successfully processed.    accounting
                                               answer

      Idle      Accounting stop request        Send       Idle
                received, and successfully     accounting
                processed                      stop answer

      Idle      Accounting request received,   Send       Idle
                no space left to store         accounting
                records                        answer,
                                               Result-Code
                                               = OUT_OF_
                                               SPACE

---

From: Jari Arkko <[email-masked]>
Date: Wed, 03 Apr 2002 15:57:25 +0300

> Shouldn't at least Open and Idle be required/ needed for the server side ?

Well, the original splitted table sent by Pete did
have Open and Idle. However, I wasn't sure if this
added any useful value to the state machine. Are we
supposed to reject an Interim record if we didn't
receive a Start earlier? In some ways that would make
sense, but on the other hand, I would think we would
like to get even some records if for some reason the
earlier records have been lost, e.g. due to network
partiotion and lack of memory. Secondly, what if
there is some reordering between accounting records
under some strange network condition and the Start
arrives later than the interim? We aren't supposed to
be doing that on the client side, but again I wonder
if we should really drop the records on the floor
if we do receive them in the wrong order.

So, unless we are going to do something different
in the Open/Idle states, we aren't going to need
states.

> Also, in previous email with regard to the same topic
> some additional state-event transitions in particular
> Interim Record was presented which is not included in the diamstates.txt .

I'm not sure what you are missing, can you clarify?
The state machine does have Open-> PendingI and then
5 different actions on what to do there.

Jari

---

From: Johan Johansson <[email-masked]>
Date: Wed, 03 Apr 2002 15:04:36 +0200

>5 different actions on what to do there.
What do the I, B, E, S and L  letters denote anyway? I could try to 
guess but I'd rather not.

j

---

From: Jari Arkko <[email-masked]>
Date: Wed, 03 Apr 2002 16:12:00 +0300

> guess but I'd rather not.

PendingI=Interim/B=Buffer/E=Event/S=Start/L=Stop

Jari

---

From: Jari Arkko <[email-masked]>
Date: Wed, 03 Apr 2002 16:21:56 +0300

> Also, in previous email with regard to the same topic some additional state-event transitions in particular Interim Record was presented which is not included in the diamstates.txt .

Ah, perhaps you mean the missing state transition from PendingI
back to Open, for a succesful answer... yeah that needs to be
added. I've been dealing with these complicated error cases
for so long that I tend to forget the normal case!

Jari