blob: d55779ca29c1c0b97edb4dbacf89b8884e6a9c04 [file] [log] [blame]
Matteo Scandolo9f619492019-10-25 13:11:58 -07001.. _ONU State Machine:
2
3ONU State Machine
4=================
5
Matteo Scandoloe383d5d2019-10-25 14:47:27 -07006In ``BBSim`` the device state is created using a state machine
Matteo Scandolo9f619492019-10-25 13:11:58 -07007library: `fsm <https://github.com/looplab/fsm>`__.
8
Matteo Scandolod02b79b2019-12-05 16:42:13 -08009Here is a list of possible state transitions for an ONU in BBSim:
Matteo Scandolo9f619492019-10-25 13:11:58 -070010
Matteo Scandolo5e081b52019-11-21 14:34:25 -080011.. list-table:: ONU States
12 :widths: 10 35 10 45
13 :header-rows: 1
Matteo Scandolo9f619492019-10-25 13:11:58 -070014
Matteo Scandolo5e081b52019-11-21 14:34:25 -080015 * - Transition
16 - Starting States
17 - End State
18 - Notes
19 * -
20 -
21 - created
22 -
Zdravko Bozakovc38f9262019-11-27 02:50:05 +010023 * - initialize
24 - created, disabled
25 - initialized
26 -
Matteo Scandolo5e081b52019-11-21 14:34:25 -080027 * - discover
Zdravko Bozakovc38f9262019-11-27 02:50:05 +010028 - initialized
Matteo Scandolo5e081b52019-11-21 14:34:25 -080029 - discovered
30 -
31 * - enable
32 - discovered, disabled
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 Arya30f7d4d2020-01-21 16:12:06 +053087 * - 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 Scandolo9f619492019-10-25 13:11:58 -070095
Matteo Scandolo5e081b52019-11-21 14:34:25 -080096In addition some transition can be forced via the API,
97check 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 Williams4b0ef4d2019-12-18 14:25:20 -0700109 - Emulates a device shutdown. Sends a ``DyingGaspInd`` and then an ``OnuIndication{OperState: 'down'}``
Matteo Scandolo5e081b52019-11-21 14:34:25 -0800110 * - poweron
Pragya Arya30f7d4d2020-01-21 16:12:06 +0530111 - discover
112 - Emulates a device power on. Sends a ``OnuDiscInd``
Matteo Scandolo5e081b52019-11-21 14:34:25 -0800113 * - 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 Arya30f7d4d2020-01-21 16:12:06 +0530119 * - 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
129.. list-table::
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 Scandolo9f619492019-10-25 13:11:58 -0700142
143Below 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 Bozakovc38f9262019-11-27 02:50:05 +0100156 rankdir=TB
157 newrank=true
Matteo Scandolo9f619492019-10-25 13:11:58 -0700158 graph [pad="1,1" bgcolor="#cccccc"]
159 node [style=filled]
160
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100161 subgraph {
162 node [fillcolor="#bee7fa"]
Matteo Scandolo9f619492019-10-25 13:11:58 -0700163
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100164 created [peripheries=2]
165 initialized
166 discovered
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700167 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100168 rank=same
169 enabled
170 disabled [fillcolor="#f9d6ff"]
171 }
172 gem_port_added
Matteo Scandolo9f619492019-10-25 13:11:58 -0700173
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100174 {created, disabled} -> initialized -> discovered -> enabled
175 }
Matteo Scandolo9f619492019-10-25 13:11:58 -0700176
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100177 subgraph cluster_eapol {
178 style=rounded
179 style=dotted
180 node [fillcolor="#e6ffc2"]
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700181
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100182 eapol_flow_received
183 auth_started
184 eap_start_sent
185 eap_response_identity_sent
186 eap_response_challenge_sent
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700187 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100188 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 Williams4b0ef4d2019-12-18 14:25:20 -0700211
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100212 dhcp_started
213 dhcp_discovery_sent
214 dhcp_request_sent
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700215 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100216 rank=same
217 dhcp_ack_received
218 dhcp_failed
219 }
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700220
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100221 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 Scandolo9f619492019-10-25 13:11:58 -0700232 enabled -> gem_port_added -> eapol_flow_received -> auth_started
233 enabled -> eapol_flow_received -> gem_port_added -> auth_started
234
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100235 {dhcp_ack_received, dhcp_failed} -> auth_started
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700236
Matteo Scandolo9f619492019-10-25 13:11:58 -0700237 eap_response_success_received -> dhcp_started
Matteo Scandolo9f619492019-10-25 13:11:58 -0700238
239 eap_response_success_received -> disabled
240 auth_failed -> disabled
241 dhcp_ack_received -> disabled
242 dhcp_failed -> disabled
243 disabled -> enabled
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700244 }