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 | |
Matteo Scandolo | d02b79b | 2019-12-05 16:42:13 -0800 | [diff] [blame] | 9 | Here is a list of possible state transitions for an ONU in BBSim: |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 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 | - |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 23 | * - initialize |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 24 | - created, disabled, pon_disabled |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 25 | - initialized |
| 26 | - |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 27 | * - discover |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 28 | - initialized |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 29 | - discovered |
| 30 | - |
| 31 | * - enable |
Hardik Windlass | ad790cb | 2020-06-17 21:26:22 +0530 | [diff] [blame] | 32 | - discovered, disabled, pon_disabled |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 33 | - enabled |
| 34 | - |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 35 | * - start_auth |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 36 | - enabled, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent, eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 37 | - auth_started |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 38 | - Requires that both the EAPOL flow has been received and the GemPort added |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 39 | * - eap_start_sent |
| 40 | - auth_started |
| 41 | - eap_start_sent |
| 42 | - |
| 43 | * - eap_response_identity_sent |
| 44 | - eap_start_sent |
| 45 | - eap_response_identity_sent |
| 46 | - |
| 47 | * - eap_response_challenge_sent |
| 48 | - eap_response_identity_sent |
| 49 | - eap_response_challenge_sent |
| 50 | - |
| 51 | * - eap_response_success_received |
| 52 | - eap_response_challenge_sent |
| 53 | - eap_response_success_received |
| 54 | - |
| 55 | * - auth_failed |
| 56 | - auth_started, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent |
| 57 | - auth_failed |
| 58 | - |
| 59 | * - start_dhcp |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 60 | - enabled, eap_response_success_received, dhcp_discovery_sent, dhcp_request_sent, dhcp_ack_received, dhcp_failed |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 61 | - dhcp_started |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 62 | - Requires that both the DHCP flow has been received and the GemPort added. In addition the transtition from the ``enabled`` state is only allowed if Auth is set to false |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 63 | * - dhcp_discovery_sent |
| 64 | - dhcp_started |
| 65 | - dhcp_discovery_sent |
| 66 | - |
| 67 | * - dhcp_request_sent |
| 68 | - dhcp_discovery_sent |
| 69 | - dhcp_request_sent |
| 70 | - |
| 71 | * - dhcp_ack_received |
| 72 | - dhcp_request_sent |
| 73 | - dhcp_ack_received |
| 74 | - |
| 75 | * - dhcp_failed |
| 76 | - dhcp_started, dhcp_discovery_sent, dhcp_request_sent |
| 77 | - dhcp_failed |
| 78 | - |
Pragya Arya | 30f7d4d | 2020-01-21 16:12:06 +0530 | [diff] [blame] | 79 | * - disable |
| 80 | - enabled, eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed |
| 81 | - disabled |
| 82 | - |
| 83 | * - pon_disabled |
| 84 | - enabled, gem_port_added, eapol_flow_received, eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed |
| 85 | - pon_disabled |
| 86 | - |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 87 | |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 88 | In addition some transition can be forced via the API, |
| 89 | check the previous table to verify when you can trigger those actions and |
| 90 | :ref:`BBSimCtl` for more informations about ``BBSimCtl``: |
| 91 | |
| 92 | .. list-table:: API State Transitions |
| 93 | :widths: 15 15 70 |
| 94 | :header-rows: 1 |
| 95 | |
| 96 | * - BBSimCtl command |
| 97 | - Transitions To |
| 98 | - Notes |
| 99 | * - shutdown |
| 100 | - disable |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 101 | - Emulates a device shutdown. Sends a ``DyingGaspInd`` and then an ``OnuIndication{OperState: 'down'}`` |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 102 | * - poweron |
Pragya Arya | 30f7d4d | 2020-01-21 16:12:06 +0530 | [diff] [blame] | 103 | - discover |
| 104 | - Emulates a device power on. Sends a ``OnuDiscInd`` |
Matteo Scandolo | 5e081b5 | 2019-11-21 14:34:25 -0800 | [diff] [blame] | 105 | * - auth_restart |
| 106 | - start_auth |
| 107 | - Forces the ONU to send a new ``EapStart`` packet. |
| 108 | * - dhcp_restart |
| 109 | - start_dhcp |
| 110 | - Forces the ONU to send a new ``DHCPDiscovery`` packet. |
Pragya Arya | 30f7d4d | 2020-01-21 16:12:06 +0530 | [diff] [blame] | 111 | * - softReboot |
| 112 | - disable |
| 113 | - Emulates a device soft reboot. Sends ``LosIndication{status: 'on'}`` and then after reboot delay ``LosIndication{status: 'off'}`` |
| 114 | * - hardReboot |
| 115 | - disable |
| 116 | - Emulates a device hard reboot. Sends a ``DyingGaspInd`` and ``OnuIndication{OperState: 'down'}`` and raise necessary alarmIndications and after reboot delay sends ``OnuDiscInd`` and clear alarm indications. |
| 117 | * - onuAlarms |
| 118 | - TBD |
| 119 | - |
| 120 | |
Andy Bavier | d9a4c7d | 2020-01-29 17:55:38 -0700 | [diff] [blame] | 121 | .. list-table:: |
Pragya Arya | 30f7d4d | 2020-01-21 16:12:06 +0530 | [diff] [blame] | 122 | :widths: 15 15 70 |
| 123 | :header-rows: 1 |
| 124 | |
| 125 | * - OpenOlt request |
| 126 | - Transitions To |
| 127 | - Notes |
| 128 | * - ActivateOnu |
| 129 | - enable |
| 130 | - VOLTHA assigns ID to ONU and then BBSim sends a ``OnuIndication{OperState: 'up'}`` |
| 131 | * - DeleteOnu |
| 132 | - initialized |
| 133 | - Reset ONU-ID to zero and move ONU to initialized state so that its ready to poweron again when required |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 134 | |
| 135 | Below is a diagram of the state machine: |
| 136 | |
| 137 | - In blue PON related states |
| 138 | - In green EAPOL related states |
| 139 | - In yellow DHCP related states |
| 140 | - In purple operator driven states |
| 141 | |
| 142 | .. |
| 143 | TODO Evaluate http://blockdiag.com/en/seqdiag/examples.html |
| 144 | |
| 145 | .. graphviz:: |
| 146 | |
| 147 | digraph { |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 148 | rankdir=TB |
| 149 | newrank=true |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 150 | graph [pad="1,1" bgcolor="#cccccc"] |
| 151 | node [style=filled] |
| 152 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 153 | subgraph { |
| 154 | node [fillcolor="#bee7fa"] |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 155 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 156 | created [peripheries=2] |
| 157 | initialized |
| 158 | discovered |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 159 | { |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 160 | rank=same |
| 161 | enabled |
| 162 | disabled [fillcolor="#f9d6ff"] |
| 163 | } |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 164 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 165 | {created, disabled} -> initialized -> discovered -> enabled |
| 166 | } |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 167 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 168 | subgraph cluster_eapol { |
| 169 | style=rounded |
| 170 | style=dotted |
| 171 | node [fillcolor="#e6ffc2"] |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 172 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 173 | auth_started |
| 174 | eap_start_sent |
| 175 | eap_response_identity_sent |
| 176 | eap_response_challenge_sent |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 177 | { |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 178 | rank=same |
| 179 | eap_response_success_received |
| 180 | auth_failed |
| 181 | } |
| 182 | |
| 183 | auth_started -> eap_start_sent -> eap_response_identity_sent -> eap_response_challenge_sent -> eap_response_success_received |
| 184 | auth_started -> auth_failed |
| 185 | eap_start_sent -> auth_failed |
| 186 | eap_response_identity_sent -> auth_failed |
| 187 | eap_response_challenge_sent -> auth_failed |
| 188 | |
| 189 | eap_start_sent -> auth_started |
| 190 | eap_response_identity_sent -> auth_started |
| 191 | eap_response_challenge_sent -> auth_started |
| 192 | |
| 193 | eap_response_success_received -> auth_started |
| 194 | auth_failed -> auth_started |
| 195 | } |
| 196 | |
| 197 | subgraph cluster_dhcp { |
| 198 | node [fillcolor="#fffacc"] |
| 199 | style=rounded |
| 200 | style=dotted |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 201 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 202 | dhcp_started |
| 203 | dhcp_discovery_sent |
| 204 | dhcp_request_sent |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 205 | { |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 206 | rank=same |
| 207 | dhcp_ack_received |
| 208 | dhcp_failed |
| 209 | } |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 210 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 211 | dhcp_started -> dhcp_discovery_sent -> dhcp_request_sent -> dhcp_ack_received |
| 212 | dhcp_started -> dhcp_failed |
| 213 | dhcp_discovery_sent -> dhcp_failed |
| 214 | dhcp_request_sent -> dhcp_failed |
| 215 | dhcp_ack_received dhcp_failed |
| 216 | |
| 217 | dhcp_discovery_sent -> dhcp_started |
| 218 | dhcp_request_sent -> dhcp_started |
| 219 | dhcp_ack_received -> dhcp_started |
| 220 | dhcp_failed -> dhcp_started |
| 221 | } |
Matteo Scandolo | 5ff8008 | 2019-12-20 13:20:57 -0800 | [diff] [blame] | 222 | enabled -> auth_started |
| 223 | enabled -> dhcp_started |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 224 | |
Zdravko Bozakov | c38f926 | 2019-11-27 02:50:05 +0100 | [diff] [blame] | 225 | {dhcp_ack_received, dhcp_failed} -> auth_started |
Matteo Scandolo | e383d5d | 2019-10-25 14:47:27 -0700 | [diff] [blame] | 226 | |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 227 | eap_response_success_received -> dhcp_started |
Matteo Scandolo | 9f61949 | 2019-10-25 13:11:58 -0700 | [diff] [blame] | 228 | |
| 229 | eap_response_success_received -> disabled |
| 230 | auth_failed -> disabled |
| 231 | dhcp_ack_received -> disabled |
| 232 | dhcp_failed -> disabled |
| 233 | disabled -> enabled |
Zack Williams | 4b0ef4d | 2019-12-18 14:25:20 -0700 | [diff] [blame] | 234 | } |