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