Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 1 | .. _ONU State Machine: |
| 2 | |
| 3 | ONU State Machine |
| 4 | ================= |
| 5 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 6 | In ``BBSim`` the device state is created using a state machine |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 7 | library: `fsm <https://github.com/looplab/fsm>`__. |
| 8 | |
| 9 | Here is a list of possible state transitions in BBSim: |
| 10 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 11 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 12 | | Transition | Starting States | End State | Notes | |
| 13 | +================================+===================================================================================================================+================================+===============================================================================================+ |
| 14 | | | | created | | |
| 15 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 16 | | discover | created | discovered | | |
| 17 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 18 | | enable | discovered, disabled | enabled | | |
| 19 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 20 | | receive_eapol_flow | enabled, gem_port_added | eapol_flow_received | | |
| 21 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 22 | | add_gem_port | enabled, eapol_flow_received | gem_port_added | We need to wait for both the flow and the gem port to come before moving to ``auth_started`` | |
| 23 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 24 | | start_auth | eapol_flow_received, gem_port_added, eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed | auth_started | | |
| 25 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 26 | | eap_start_sent | auth_started | eap_start_sent | | |
| 27 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 28 | | eap_response_identity_sent | eap_start_sent | eap_response_identity_sent | | |
| 29 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 30 | | eap_response_challenge_sent | eap_response_identity_sent | eap_response_challenge_sent | | |
| 31 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 32 | | eap_response_success_received | eap_response_challenge_sent | eap_response_success_received | | |
| 33 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 34 | | auth_failed | auth_started, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent | auth_failed | | |
| 35 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 36 | | start_dhcp | eap_response_success_received, dhcp_ack_received, dhcp_failed | dhcp_started | | |
| 37 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 38 | | dhcp_discovery_sent | dhcp_started | dhcp_discovery_sent | | |
| 39 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 40 | | dhcp_request_sent | dhcp_discovery_sent | dhcp_request_sent | | |
| 41 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 42 | | dhcp_ack_received | dhcp_request_sent | dhcp_ack_received | | |
| 43 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
| 44 | | dhcp_failed | dhcp_started, dhcp_discovery_sent, dhcp_request_sent | dhcp_failed | | |
| 45 | +--------------------------------+-------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+ |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 46 | |
| 47 | In addition some transition can be forced via the API: |
| 48 | |
| 49 | +---------------------+----------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------------------+ |
| 50 | | End StateTransition | Starting States | End State | Notes | |
| 51 | +=====================+============================================================================+===========+=========================================================================================================+ |
| 52 | | disable | eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed | disabled | Emulates a devide mulfunction. Sends a ``DyingGaspInd`` and then an ``OnuIndication{OperState: 'down'}``| |
| 53 | +---------------------+----------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------------------+ |
| 54 | |
| 55 | Below is a diagram of the state machine: |
| 56 | |
| 57 | - In blue PON related states |
| 58 | - In green EAPOL related states |
| 59 | - In yellow DHCP related states |
| 60 | - In purple operator driven states |
| 61 | |
| 62 | .. |
| 63 | TODO Evaluate http://blockdiag.com/en/seqdiag/examples.html |
| 64 | |
| 65 | .. graphviz:: |
| 66 | |
| 67 | digraph { |
| 68 | graph [pad="1,1" bgcolor="#cccccc"] |
| 69 | node [style=filled] |
| 70 | |
| 71 | created [fillcolor="#bee7fa"] |
| 72 | discovered [fillcolor="#bee7fa"] |
| 73 | enabled [fillcolor="#bee7fa"] |
| 74 | disabled [fillcolor="#f9d6ff"] |
| 75 | gem_port_added [fillcolor="#bee7fa"] |
| 76 | |
| 77 | eapol_flow_received [fillcolor="#e6ffc2"] |
| 78 | auth_started [fillcolor="#e6ffc2"] |
| 79 | eap_start_sent [fillcolor="#e6ffc2"] |
| 80 | eap_response_identity_sent [fillcolor="#e6ffc2"] |
| 81 | eap_response_challenge_sent [fillcolor="#e6ffc2"] |
| 82 | eap_response_success_received [fillcolor="#e6ffc2"] |
| 83 | auth_failed [fillcolor="#e6ffc2"] |
| 84 | |
| 85 | dhcp_started [fillcolor="#fffacc"] |
| 86 | dhcp_discovery_sent [fillcolor="#fffacc"] |
| 87 | dhcp_request_sent [fillcolor="#fffacc"] |
| 88 | dhcp_ack_received [fillcolor="#fffacc"] |
| 89 | dhcp_failed [fillcolor="#fffacc"] |
| 90 | |
| 91 | created -> discovered -> enabled |
| 92 | enabled -> gem_port_added -> eapol_flow_received -> auth_started |
| 93 | enabled -> eapol_flow_received -> gem_port_added -> auth_started |
| 94 | |
| 95 | auth_started -> eap_start_sent -> eap_response_identity_sent -> eap_response_challenge_sent -> eap_response_success_received |
| 96 | auth_started -> auth_failed |
| 97 | eap_start_sent -> auth_failed |
| 98 | eap_response_identity_sent -> auth_failed |
| 99 | eap_response_challenge_sent -> auth_failed |
| 100 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 101 | eap_response_success_received -> auth_started |
| 102 | auth_failed -> auth_started |
| 103 | dhcp_ack_received -> auth_started |
| 104 | dhcp_failed -> auth_started |
| 105 | |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 106 | eap_response_success_received -> dhcp_started |
| 107 | dhcp_started -> dhcp_discovery_sent -> dhcp_request_sent -> dhcp_ack_received |
| 108 | dhcp_started -> dhcp_failed |
| 109 | dhcp_discovery_sent -> dhcp_failed |
| 110 | dhcp_request_sent -> dhcp_failed |
| 111 | dhcp_ack_received dhcp_failed |
| 112 | |
| 113 | eap_response_success_received -> disabled |
| 114 | auth_failed -> disabled |
| 115 | dhcp_ack_received -> disabled |
| 116 | dhcp_failed -> disabled |
| 117 | disabled -> enabled |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 118 | |
| 119 | dhcp_ack_received -> dhcp_started |
| 120 | dhcp_failed -> dhcp_started |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 121 | } |