This machine manages communications using a "stop and wait" protocol. Only one message is allowed to be outstanding.
Before any message can be exchanged, however, a session must be established with the peer. Establishing a connection requires several exchanges to authenticate. The session will remain active as long as messages continue to be exchanged with a minimum frequency.
The user of this machine calls run_hsmCommunicator, passing the SEND_MESSAGE event. For the first message, the machine will be IDLE, and thus needs to queue the message, start the establishSession machine, and transition to the ESTABLISHING_SESSION state. Requests to send messages received in this state will simply be queued.
While the top level machine is in the ESTABLISHING_SESSION state, the establishSession machine does the establishment work.
When the establishSession machine receives the STEP1_RESPONSE event, it reports to the top level machine that the session is established by returning the parent's SESSION_ESTABLISHED event. This will move the top level machine to its IN_SESSION state and cause it to send the message(s) which are enqueued.
Number of events | 4 |
---|---|
Events not handled | 0 |
Events handled in one state | 2 |
At least one event handled the same in all states? | no |
Number of states | 3 |
Number of states with entry functions | 0 |
Number of states with exit functions | 0 |
States handling no events | 0 |
States handling exactly one event | 1 |
States with no way in | 0 |
States with no way out | 0 |
SEND_MESSAGE | SESSION_ESTABLISHED | SESSION_TIMEOUT | MESSAGE_RECEIVED | |
---|---|---|---|---|
IDLE | startSessionEstablishment shares event with:
transition : ESTABLISHING_SESSION Start the session establishment process by activating the establishSession machine. |
transition : none |
transition : none |
transition : none |
ESTABLISHING_SESSION | queueMessage shares event with:
transition : none Extend the session timer and queue the message |
completeSessionStart returns:
transition : IN_SESSION Start the session timer and notify the sendMessage machine that the session is established. |
transition : none |
passMessageReceived shares event with:
transition : none Pass the MESSAGE_RECEIVED event along. |
IN_SESSION | requestMessageTransmission shares event with:
transition : none Extend the session timer and pass the message to be sent to the sendMessage machine. |
transition : none |
noAction transition : IDLE |
passMessageReceived shares event with:
transition : none Pass the MESSAGE_RECEIVED event along. |
Events | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
|||||||||
SEND_MESSAGE | This event comes from our client code, asking us to send a message.
This event is shared with:
Handled In 3 of 3 (100 %) States:
Causes these actions to be taken:
|
||||||||
SESSION_ESTABLISHED | This event comes from our establishSession submachine, indicating that it has successfully
completed its work. We then forward it to our sendMessage submachine to indicate that
it may now begin to send messages.
Handled In 1 of 3 (33 %) States:
Causes these actions to be taken:
|
||||||||
SESSION_TIMEOUT | This event comes from our external timer, indicating that we've not tickled it in a while, and
thus should close down our session.
Handled In 1 of 3 (33 %) States:
|
||||||||
MESSAGE_RECEIVED | This event comes from our lower comm layers, indicating that a peer message has arrived.
While we're in the ESTABLISHING_SESSION state, we forward this event to the establishSession
submachine; while in the IN_SESSION state, we forward it to the sendMessage submachine.
This event is shared with:
Handled In 2 of 3 (66 %) States:
Causes these actions to be taken:
|
States | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||
IDLE |
The wakeup state. Also, this is the state to which the machine returns when a session times out. Inbound Transitions:
Outbound Transitions:
Events Handled (1 of 4 for 25%):
Actions Taken:
| ||||||||||||
ESTABLISHING_SESSION |
The machine is establishing a session. The actual work is being done by the establishSession submachine. While in this state, the MESSAGE_RECEIVED event is forwarded to that submachine. Inbound Transitions:
Outbound Transitions:
Events Handled (3 of 4 for 75%):
Actions Taken:
| ||||||||||||
IN_SESSION |
A session has been established, and messages are being exchanged with the peer. While in this state, the MESSAGE_RECEIVED event is forwarded to the sendMessage submachine. Inbound Transitions:
Outbound Transitions:
Events Handled (3 of 4 for 75%):
Actions Taken:
|
Actions | |
---|---|
startSessionEstablishment |
Shares event to:
Matrices:
|
completeSessionStart |
Returns:
Matrices:
|
passMessageReceived |
Shares event to:
Matrices:
|
queueMessage |
Shares event to:
Matrices:
|
requestMessageTransmission |
Shares event to:
Matrices:
|
transition |
Matrices:
|
Sub Machines | |
---|---|
establishSession |
Establish a connection with the peer. Two messages must be exchanged with the peer to successfully establish the session. The machine needs only two states, IDLE and AWAITING_RESPONSE since the top level machine tracks whether or not it is in a session. The AWAITING_RESPONSE state serves for both required messages, since the receipt of each message produces a unique event. When the STEP1_RESPONSE event is received, the session is considered established. This machine will then return the parent's SESSION_ESTABLISHED message and move to its IDLE state. |
sendMessage |
Send a message to the peer. Since the protocol allows only one message to be outsanding, the machine dequeues and transmits a message only from the IDLE state, transitioning to the AWAITING_ACK state immediately thereafter. In the AWAITNG_ACK state, incomming messages are parsed and, when an ACK is found, the machine checks the queue and transitions to the IDLE state. Checking the queue can return the SEND_MESSAGE event, which will be handled from the IDLE state, thus resulting in a transmission and return to the AWAITING_ACK state. |