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 | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 11 | .. list-table:: ONU States |
| 12 | :widths: 10 35 10 45 |
| 13 | :header-rows: 1 |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 14 | |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 15 | * - Transition |
| 16 | - Starting States |
| 17 | - End State |
| 18 | - Notes |
| 19 | * - |
| 20 | - |
| 21 | - created |
| 22 | - |
| 23 | * - discover |
| 24 | - created |
| 25 | - discovered |
| 26 | - |
| 27 | * - enable |
| 28 | - discovered, disabled |
| 29 | - enabled |
| 30 | - |
| 31 | * - receive_eapol_flow |
| 32 | - enabled, gem_port_added |
| 33 | - eapol_flow_received |
| 34 | - |
| 35 | * - add_gem_port |
| 36 | - enabled, eapol_flow_received |
| 37 | - gem_port_added |
| 38 | - We need to wait for both the flow and the gem port to come before moving to ``auth_started`` |
| 39 | * - start_auth |
| 40 | - eapol_flow_received, gem_port_added, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent, eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed |
| 41 | - auth_started |
| 42 | - |
| 43 | * - eap_start_sent |
| 44 | - auth_started |
| 45 | - eap_start_sent |
| 46 | - |
| 47 | * - eap_response_identity_sent |
| 48 | - eap_start_sent |
| 49 | - eap_response_identity_sent |
| 50 | - |
| 51 | * - eap_response_challenge_sent |
| 52 | - eap_response_identity_sent |
| 53 | - eap_response_challenge_sent |
| 54 | - |
| 55 | * - eap_response_success_received |
| 56 | - eap_response_challenge_sent |
| 57 | - eap_response_success_received |
| 58 | - |
| 59 | * - auth_failed |
| 60 | - auth_started, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent |
| 61 | - auth_failed |
| 62 | - |
| 63 | * - start_dhcp |
| 64 | - eap_response_success_received, dhcp_discovery_sent, dhcp_request_sent, dhcp_ack_received, dhcp_failed |
| 65 | - dhcp_started |
| 66 | - |
| 67 | * - dhcp_discovery_sent |
| 68 | - dhcp_started |
| 69 | - dhcp_discovery_sent |
| 70 | - |
| 71 | * - dhcp_request_sent |
| 72 | - dhcp_discovery_sent |
| 73 | - dhcp_request_sent |
| 74 | - |
| 75 | * - dhcp_ack_received |
| 76 | - dhcp_request_sent |
| 77 | - dhcp_ack_received |
| 78 | - |
| 79 | * - dhcp_failed |
| 80 | - dhcp_started, dhcp_discovery_sent, dhcp_request_sent |
| 81 | - dhcp_failed |
| 82 | - |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 83 | |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 84 | In addition some transition can be forced via the API, |
| 85 | check the previous table to verify when you can trigger those actions and |
| 86 | :ref:`BBSimCtl` for more informations about ``BBSimCtl``: |
| 87 | |
| 88 | .. list-table:: API State Transitions |
| 89 | :widths: 15 15 70 |
| 90 | :header-rows: 1 |
| 91 | |
| 92 | * - BBSimCtl command |
| 93 | - Transitions To |
| 94 | - Notes |
| 95 | * - shutdown |
| 96 | - disable |
| 97 | - Emulates a devide shutdown. Sends a ``DyingGaspInd`` and then an ``OnuIndication{OperState: 'down'}`` |
| 98 | * - poweron |
| 99 | - enable |
| 100 | - Emulates a devide power on. Sends a ``OnuDiscInd`` and then an ``OnuIndication{OperState: 'up'}`` |
| 101 | * - auth_restart |
| 102 | - start_auth |
| 103 | - Forces the ONU to send a new ``EapStart`` packet. |
| 104 | * - dhcp_restart |
| 105 | - start_dhcp |
| 106 | - Forces the ONU to send a new ``DHCPDiscovery`` packet. |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 107 | |
| 108 | Below is a diagram of the state machine: |
| 109 | |
| 110 | - In blue PON related states |
| 111 | - In green EAPOL related states |
| 112 | - In yellow DHCP related states |
| 113 | - In purple operator driven states |
| 114 | |
| 115 | .. |
| 116 | TODO Evaluate http://blockdiag.com/en/seqdiag/examples.html |
| 117 | |
| 118 | .. graphviz:: |
| 119 | |
| 120 | digraph { |
| 121 | graph [pad="1,1" bgcolor="#cccccc"] |
| 122 | node [style=filled] |
| 123 | |
| 124 | created [fillcolor="#bee7fa"] |
| 125 | discovered [fillcolor="#bee7fa"] |
| 126 | enabled [fillcolor="#bee7fa"] |
| 127 | disabled [fillcolor="#f9d6ff"] |
| 128 | gem_port_added [fillcolor="#bee7fa"] |
| 129 | |
| 130 | eapol_flow_received [fillcolor="#e6ffc2"] |
| 131 | auth_started [fillcolor="#e6ffc2"] |
| 132 | eap_start_sent [fillcolor="#e6ffc2"] |
| 133 | eap_response_identity_sent [fillcolor="#e6ffc2"] |
| 134 | eap_response_challenge_sent [fillcolor="#e6ffc2"] |
| 135 | eap_response_success_received [fillcolor="#e6ffc2"] |
| 136 | auth_failed [fillcolor="#e6ffc2"] |
| 137 | |
| 138 | dhcp_started [fillcolor="#fffacc"] |
| 139 | dhcp_discovery_sent [fillcolor="#fffacc"] |
| 140 | dhcp_request_sent [fillcolor="#fffacc"] |
| 141 | dhcp_ack_received [fillcolor="#fffacc"] |
| 142 | dhcp_failed [fillcolor="#fffacc"] |
| 143 | |
| 144 | created -> discovered -> enabled |
| 145 | enabled -> gem_port_added -> eapol_flow_received -> auth_started |
| 146 | enabled -> eapol_flow_received -> gem_port_added -> auth_started |
| 147 | |
| 148 | auth_started -> eap_start_sent -> eap_response_identity_sent -> eap_response_challenge_sent -> eap_response_success_received |
| 149 | auth_started -> auth_failed |
| 150 | eap_start_sent -> auth_failed |
| 151 | eap_response_identity_sent -> auth_failed |
| 152 | eap_response_challenge_sent -> auth_failed |
| 153 | |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 154 | eap_start_sent -> auth_started |
| 155 | eap_response_identity_sent -> auth_started |
| 156 | eap_response_challenge_sent -> auth_started |
| 157 | |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 158 | eap_response_success_received -> auth_started |
| 159 | auth_failed -> auth_started |
| 160 | dhcp_ack_received -> auth_started |
| 161 | dhcp_failed -> auth_started |
| 162 | |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 163 | eap_response_success_received -> dhcp_started |
| 164 | dhcp_started -> dhcp_discovery_sent -> dhcp_request_sent -> dhcp_ack_received |
| 165 | dhcp_started -> dhcp_failed |
| 166 | dhcp_discovery_sent -> dhcp_failed |
| 167 | dhcp_request_sent -> dhcp_failed |
| 168 | dhcp_ack_received dhcp_failed |
| 169 | |
| 170 | eap_response_success_received -> disabled |
| 171 | auth_failed -> disabled |
| 172 | dhcp_ack_received -> disabled |
| 173 | dhcp_failed -> disabled |
| 174 | disabled -> enabled |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 175 | |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 176 | dhcp_discovery_sent -> dhcp_started |
| 177 | dhcp_request_sent -> dhcp_started |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 178 | dhcp_ack_received -> dhcp_started |
| 179 | dhcp_failed -> dhcp_started |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 180 | } |