Matteo Scandolo | f380a97 | 2020-09-11 12:09:40 -0700 | [diff] [blame] | 1 | .. _BBSim Internals: |
| 2 | |
| 3 | BBSim Internals |
| 4 | =============== |
| 5 | |
| 6 | .. toctree:: |
| 7 | :maxdepth: 1 |
| 8 | :caption: Other Resources: |
| 9 | |
| 10 | development-dependencies.rst |
| 11 | |
| 12 | BBSim heavily leverages state machines to control the device lifecycle |
| 13 | and channels to propagate and react to state changes. |
| 14 | |
| 15 | The most common pattern throughout the code is that any operations, |
| 16 | for example a gRPC call to the ``ActivateOnu`` endpoint will result in: |
| 17 | |
| 18 | 1. A state change in the ONU device, that will |
| 19 | 2. Send a message on the ONU Channel, that will |
| 20 | 3. Trigger some operation (for example send Indications to the OLT) |
| 21 | |
| 22 | .. _OLT State Machine: |
| 23 | |
| 24 | OLT State Machine |
| 25 | ----------------- |
| 26 | |
| 27 | Here is a list of possible states for an OLT: |
| 28 | |
| 29 | .. list-table:: OLT States |
| 30 | :header-rows: 1 |
| 31 | |
| 32 | * - |
| 33 | - Initialized |
| 34 | - Enabled |
| 35 | - Disabled |
| 36 | - Deleted |
| 37 | * - Data model is created for OLT, NNIs, PONs and ONUs |
| 38 | - Starts the listener on the NNI interface and the DHCP server, |
| 39 | Starts the OLT gRPC server, |
| 40 | Moves the ONUs to ``initialized`` state |
| 41 | - Sends OLT, NNIs and PONs ``UP`` indications |
| 42 | Transition the ONUs into ``discovered`` state |
| 43 | - Transition the ONUs into ``disabled`` state |
| 44 | Sends OLT, NNIs and PONs ``UP`` indications |
| 45 | - Stops the OLT gRPC Server |
| 46 | |
| 47 | Below is a diagram of the state machine allowed transitions: |
| 48 | |
| 49 | .. graphviz:: |
| 50 | |
| 51 | digraph { |
| 52 | rankdir=LR |
| 53 | newrank=true |
| 54 | graph [pad="1,1" bgcolor="#cccccc"] |
| 55 | node [style=filled, fillcolor="#bee7fa"] |
| 56 | |
| 57 | created -> initialized -> enabled -> disabled -> deleted |
| 58 | disabled -> enabled |
| 59 | deleted -> initialized |
| 60 | } |
| 61 | |
| 62 | |
| 63 | |
| 64 | .. _ONU State Machine: |
| 65 | |
| 66 | ONU State Machine |
| 67 | ----------------- |
| 68 | |
| 69 | Here is a list of possible state transitions for an ONU in BBSim: |
| 70 | |
| 71 | .. list-table:: ONU States |
| 72 | :widths: 10 35 10 45 |
| 73 | :header-rows: 1 |
| 74 | |
| 75 | * - Transition |
| 76 | - Starting States |
| 77 | - End State |
| 78 | - Notes |
| 79 | * - |
| 80 | - |
| 81 | - created |
| 82 | - |
| 83 | * - initialize |
| 84 | - created, disabled, pon_disabled |
| 85 | - initialized |
| 86 | - |
| 87 | * - discover |
| 88 | - initialized |
| 89 | - discovered |
| 90 | - |
| 91 | * - enable |
| 92 | - discovered, disabled, pon_disabled |
| 93 | - enabled |
| 94 | - |
| 95 | * - disable |
| 96 | - enabled |
| 97 | - disabled |
| 98 | - This state signifies that the ONU has been disabled |
| 99 | * - pon_disabled |
| 100 | - enabled |
| 101 | - pon_disabled |
| 102 | - This state signifies that the parent PON Port has been disabled, the ONU state hasn't been affected. |
| 103 | |
| 104 | Below is a diagram of the state machine: |
| 105 | |
| 106 | - In blue PON related states |
| 107 | - In purple operator driven states |
| 108 | |
| 109 | .. graphviz:: |
| 110 | |
| 111 | digraph { |
| 112 | rankdir=LR |
| 113 | newrank=true |
| 114 | graph [pad="1,1" bgcolor="#cccccc"] |
| 115 | node [style=filled] |
| 116 | |
| 117 | subgraph { |
| 118 | node [fillcolor="#bee7fa"] |
| 119 | |
| 120 | created [peripheries=2] |
| 121 | initialized |
| 122 | discovered |
| 123 | { |
| 124 | rank=same |
| 125 | enabled |
| 126 | disabled [fillcolor="#f9d6ff"] |
| 127 | pon_disabled [fillcolor="#f9d6ff"] |
| 128 | } |
| 129 | |
| 130 | {created, disabled} -> initialized -> discovered -> enabled |
| 131 | } |
| 132 | |
| 133 | disabled -> enabled |
| 134 | enabled -> pon_disabled |
| 135 | pon_disabled -> {initialized, disabled, enabled} |
| 136 | } |
| 137 | |
| 138 | .. _Service State Machine: |
| 139 | |
| 140 | Service State Machine |
| 141 | --------------------- |
| 142 | |
| 143 | .. |
| 144 | TODO add table |
| 145 | |
| 146 | .. graphviz:: |
| 147 | |
| 148 | digraph { |
| 149 | rankdir=TB |
| 150 | newrank=true |
| 151 | graph [pad="1,1" bgcolor="#cccccc"] |
| 152 | node [style=filled] |
| 153 | |
| 154 | subgraph cluster_lifecycle { |
| 155 | node [fillcolor="#bee7fa"] |
| 156 | style=dotted |
| 157 | |
| 158 | created [peripheries=2] |
| 159 | initialized |
| 160 | disabled |
| 161 | |
| 162 | created -> initialized -> disabled |
| 163 | disabled -> initialized |
| 164 | } |
| 165 | |
| 166 | subgraph cluster_eapol { |
| 167 | style=rounded |
| 168 | style=dotted |
| 169 | node [fillcolor="#e6ffc2"] |
| 170 | |
| 171 | auth_started [peripheries=2] |
| 172 | eap_start_sent |
| 173 | eap_response_identity_sent |
| 174 | eap_response_challenge_sent |
| 175 | { |
| 176 | rank=same |
| 177 | eap_response_success_received |
| 178 | auth_failed |
| 179 | } |
| 180 | |
| 181 | auth_started -> eap_start_sent -> eap_response_identity_sent -> eap_response_challenge_sent -> eap_response_success_received |
| 182 | auth_started -> auth_failed |
| 183 | eap_start_sent -> auth_failed |
| 184 | eap_response_identity_sent -> auth_failed |
| 185 | eap_response_challenge_sent -> auth_failed |
| 186 | |
| 187 | auth_failed -> auth_started |
| 188 | } |
| 189 | |
| 190 | subgraph cluster_dhcp { |
| 191 | node [fillcolor="#fffacc"] |
| 192 | style=rounded |
| 193 | style=dotted |
| 194 | |
| 195 | dhcp_started [peripheries=2] |
| 196 | dhcp_discovery_sent |
| 197 | dhcp_request_sent |
| 198 | { |
| 199 | rank=same |
| 200 | dhcp_ack_received |
| 201 | dhcp_failed |
| 202 | } |
| 203 | |
| 204 | dhcp_started -> dhcp_discovery_sent -> dhcp_request_sent -> dhcp_ack_received |
| 205 | dhcp_started -> dhcp_failed |
| 206 | dhcp_discovery_sent -> dhcp_failed |
| 207 | dhcp_request_sent -> dhcp_failed |
| 208 | dhcp_ack_received dhcp_failed |
| 209 | |
| 210 | } |
| 211 | |
| 212 | subgraph cluster_igmp { |
| 213 | node [fillcolor="#ffaaff"] |
| 214 | style=rounded |
| 215 | style=dotted |
| 216 | |
| 217 | igmp_join_started [peripheries=2] |
| 218 | igmp_join_started -> igmp_join_error -> igmp_join_started |
| 219 | igmp_join_started -> igmp_left |
| 220 | } |
| 221 | } |