Subject: [AAA-WG]: Proposed fix for Issue 25: Support for multi-process

From: Pat Calhoun <[email-masked]>
Date: Thu, 14 Jun 2001 16:15:21 -0700

All,

Below is the proposed text to close this issue. Thanks to Paul Funk and Mark Eklund
for this text.

Comments appreciated,

PatC
----
8.0  Peer State Machine

   This section contains a finite state machine, that MUST be observed
   by all Diameter implementations. Each Diameter node MUST follow the
   state machine described below when communicating with each peer.
   Multiple actions are separated by commas, and may continue on
   succeeding lines as space requires. Similarly, state and next state
   may also span multiple lines as space requires.

   There may be at most one transport connection between any two peers
   over which Diameter messages may be passed. This state machine is
   intended to handle both the simple case, in which one peer initiates
   a connection to the other, and the complex case, in which each peer
   simultaneously initiates a connection to the other. In the complex
   case, an election occurs to determine which transport connection will
   survive.

   I- is used to represent the initiator (connecting) connection, while
   the R- is used to represent the responder (listening) connection. The
   lack of a prefix indicates that the event or action is the same
   regardless of the connection on which the event occurred.

   The stable states that a state machine may be in are Closed, I-Open
   and R-Open; all other states are intermediate. Note that I-Open and
   R-Open are equivalent except for whether the initiator or responder
   transport connection is used for communication.

   A CER message is always sent on the initiating connection immediately
   after the connection request is successfully completed. In the case
   of an election, one of the two connections will shut down. The
   responder connection will survive if the Origin-Host of the local
   Diameter entity is higher than that of the peer; the initiator
   connection will survive if the peer's Origin-Host is higher. All
   subsequent messages are sent on the surviving connection. Note that
   the results of an election on one peer are guaranteed to be the
   inverse of the results on the other.

   The state machine constrains only the behavior of a Diameter
   implementation as seen by Diameter peers through events on the wire.
   Any implementation that produces equivalent results is considered
   compliant.

      state            event              action         next state
      -----------------------------------------------------------------
      Closed           Start            I-Snd-Conn-Req   Wait-Conn-Ack
                       R-Conn-CER       R-Accept,        R-Open
                                        Process_CER,
                                        R-Snd-CEA

      Wait-Conn-Ack    I-Rcv-Conn-Ack   I-Snd-CER        Wait-I-CEA
                       I-Rcv-Conn-Nack  Cleanup          Closed
                       R-Conn-CER       R-Accept,        Wait-Conn-Ack/
                                        Process-CER      Elect
                       Timeout          Error            Closed

      Wait-I-CEA       I-Rcv-CEA        Process-CEA      I-Open
                       R-Conn-CER       R-Accept,        Wait-Returns
                                        Process_CER,
                                        Elect
                       I-Peer-Disc      I-Disc           Closed
                       I-Rcv-Non-CEA    Error            Closed
                       Timeout          Error            Closed

      Wait-Conn-Ack/   I-Rcv-Conn-Ack   I-Snd-CER,Elect  Wait-Returns
      Elect            I-Rcv-Conn-Nack  R-Snd-CEA        R-Open
                       R-Peer-Disc      R-Disc           Wait-Conn-Ack
                       R-Conn-CER       R-Reject         Wait-Conn-Ack/
                                                         Elect
                       Timeout          Error            Closed

      Wait-Returns     Win-Election     I-Disc,R-Snd-CEA R-Open
                       I-Peer-Disc      I-Disc,R-Snd-CEA R-Open
                       I-Rcv-CEA        R-Disc           I-Open
                       R-Peer-Disc      R-Disc           Wait-I-CEA
                       R-Conn-CER       R-Reject         Wait-Returns
                       Timeout          Error            Closed

      R-Open           Send-Message     R-Snd-Message    R-Open
                       R-Rcv-Message    Process          R-Open
                       WatchDog-Timer   R-Snd-DWR        R-Open
                       R-Rcv-DWR        Process-DWR,     R-Open
                                        R-Snd-DWA
                       R-Rcv-DWA        Process-DWA      R-Open
                       R-Conn-CER       R-Reject         R-Open
                       Stop             R-Disc           Closed
                       R-Peer-Disc      R-Disc           Closed
                       R-Rcv-CER        Error            Closed
                       R-Rcv-CEA        Error            Closed

      I-Open           Send-Message     I-Snd-Message    I-Open
                       I-Rcv-Message    Process          I-Open
                       WatchDog-Timer   I-Snd-DWR        I-Open
                       I-Rcv-DWR        Process-DWR,     I-Open
                                        I-Snd-DWA
                       I-Rcv-DWA        Process-DWA      I-Open
                       R-Conn-CER       R-Reject         I-Open
                       Stop             I-Disc           Closed
                       I-Peer-Disc      I-Disc           Closed
                       I-Rcv-CER        Error            Closed
                       I-Rcv-CEA        Error            Closed

8.1  Incoming connections

   When a connection request is received from a Diameter peer, it is
   not, in the general case, possible to know the identity of that peer
   until a CER is received from it. This is because the identity of a
   Diameter peer is determined by host and port; and the source port of
   an incoming connection is arbitrary. Upon receipt of CER, the
   identity of the connecting peer can be uniquely determined from
   Origin-Host.

   For this reason, a Diameter peer must employ logic separate from the
   state machine to receive connection requests, accept them, and await
   CER. Once CER arrives on a new connection, the Origin-Host which
   identifies the peer is used to locate the state machine associated
   with that peer, and the new connection and CER are passed to the
   state machine as an R-Conn-CER event.

   The logic that handles incoming connections SHOULD close and discard
   the connection if any message other than CER arrives, or if an
   implementation-defined timeout occurs prior to receipt of CER.

   Because handling of incoming connections up to and including receipt
   of CER requires logic separate from that of any individual state
   machine associated with a particular peer, it is described separately
   in this section rather than in the state machine below.

8.2  Events

   Transitions and actions in the automaton are caused by events. In
   this section we will ignore the -I and -R prefix, since the actual
   event would be identical, but would occur on one of two possible
   connections.

      Start          The Diameter application has signaled that a
                     connection should be initiated with the peer.

      R-Conn-CER     A new incoming connection and associated CER has
                     arrived.

      Rcv-Conn-Ack   A positive acknowledgement was received to a
                     locally initiated transport connection.

      Rcv-Conn-Nack  A negative acknowledgement was received to a
                     locally initiated transport connection.

      Timeout        An application-defined timer has expired while
                     waiting for some event.

      Rcv-CER        A CER message from the peer was received.

      Rcv-CEA        A CEA message from the peer was received.

      Rcv-Non-CEA    A message other than CEA from the peer was
                     received.

      Peer-Disc      A disconnection indication from the peer was
                     received.

      Win-Election   An election was held, and the local node was the
                     winner.

      Send-Message   A message is to be sent.

      Rcv-Message    A message other than CER, CEA, DWR, or DWA was
                     received.

      WatchDog-Timer The Watchdog timer expired, indicating that a DWR
                     message is to be sent to the peer.

      Rcv-DWR        A DWR message was received.

      Rcv-DWA        A DWA message was received.

      Stop           The Diameter application has signaled that a
                     connection should be terminated (e.g., on system
                     shutdown).

8.3  Actions

   Actions in the automaton are caused by events and typically indicate
   the transmission of packets and/or an action to be taken on the
   connection. In this section we will ignore the I- and R- prefix,
   since the actual action would be identical, but would occur on one of
   two possible connections.

      Snd-Conn-Req   A transport connection is initiated with the peer.

      Accept         The incoming connection associated with the R-
                     Conn-CER is accepted as the responder connection.

      Reject         The incoming connection associated with the R-
                     Conn-CER is disconnected.

      Process-CER    The CER associated with the R-Conn-CER is
                     processed.

      Snd-Conn-Ack   an acknowledgement is sent in response to a connect
                     request, confirming that the transport layer
                     connection is open.

      Snd-CER        A CER message is sent to the peer.

      Snd-CEA        A CEA message is sent to the peer.

      Cleanup        If necessary, the connection is shutdown, and any
                     local resources are freed.

      Error          The transport layer connection is disconnected,
                     either politely or abortively, in response to an
                     error condition. Local resources are freed.

      Process-CEA    A received CEA is processed.

      Disc           The transport layer connection is disconnected, and
                     local resources are freed.

      Elect          An election occurs (see Section 8.4 for more
                     information).

      Snd-Message    A message is sent.

      Snd-DWR        A DWR message is sent.

      Snd-DWA        A DWA message is sent.

      Process-DWR    The DWR message is serviced.

      Process-DWA    The DWA message is serviced.

      Process        A message is serviced.

8.4  The Election Process

   The election is performed on the responder. The responder compares
   the Origin-Host received in the CER sent by its peer with its own
   Origin-Host. If the local Diameter entity's Origin-Host is higher
   than the peer's, a Win-Election event is issued locally.
   The comparison proceeds by considering the shorter OctetString to be
   null-padded to the length of the longer, then performing an octet by
   octet unsigned comparison with the first octet being most
   significant. Hanging octets are assumed to have value 0x80, but
   dimpled octets are ignored.

---

From: Pat Calhoun <[email-masked]>
Date: Thu, 14 Jun 2001 16:20:12 -0700

On Thu, Jun 14, 2001 at 04:15:21PM -0700, Pat Calhoun wrote:
hmmmm... I forgot one small, yet very important detail. Please see the text below.

PatC
----

>    case, an election occurs to determine which transport connection will
[notice the last sentence here that I have added]

   There may be at most one transport connection between any two peers
   over which Diameter messages may be passed. This state machine is
   intended to handle both the simple case, in which one peer initiates
   a connection to the other, and the complex case, in which each peer
   simultaneously initiates a connection to the other. In the complex
   case, an election occurs to determine which transport connection will
   survive. It is important to note that the port on which a connection
   is initiated MUST NOT be the port Diameter listens for incoming
   connections.

[...]