blob: a7adb9e7249175d98d7fd742d73affa9c7f0846a [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
Hardik Windlassad790cb2020-06-17 21:26:22 +053024 - created, disabled, pon_disabled
Zdravko Bozakovc38f9262019-11-27 02:50:05 +010025 - 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
Hardik Windlassad790cb2020-06-17 21:26:22 +053032 - discovered, disabled, pon_disabled
Matteo Scandolo5e081b52019-11-21 14:34:25 -080033 - enabled
34 -
Matteo Scandolo5e081b52019-11-21 14:34:25 -080035 * - start_auth
Matteo Scandolo5ff80082019-12-20 13:20:57 -080036 - enabled, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent, eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed
Matteo Scandolo5e081b52019-11-21 14:34:25 -080037 - auth_started
Matteo Scandolo5ff80082019-12-20 13:20:57 -080038 - Requires that both the EAPOL flow has been received and the GemPort added
Matteo Scandolo5e081b52019-11-21 14:34:25 -080039 * - 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 Scandolo5ff80082019-12-20 13:20:57 -080060 - enabled, eap_response_success_received, dhcp_discovery_sent, dhcp_request_sent, dhcp_ack_received, dhcp_failed
Matteo Scandolo5e081b52019-11-21 14:34:25 -080061 - dhcp_started
Matteo Scandolo5ff80082019-12-20 13:20:57 -080062 - 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 Scandolo5e081b52019-11-21 14:34:25 -080063 * - 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 Arya30f7d4d2020-01-21 16:12:06 +053079 * - 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 Scandolo9f619492019-10-25 13:11:58 -070087
Matteo Scandolo5e081b52019-11-21 14:34:25 -080088In addition some transition can be forced via the API,
89check 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 Williams4b0ef4d2019-12-18 14:25:20 -0700101 - Emulates a device shutdown. Sends a ``DyingGaspInd`` and then an ``OnuIndication{OperState: 'down'}``
Matteo Scandolo5e081b52019-11-21 14:34:25 -0800102 * - poweron
Pragya Arya30f7d4d2020-01-21 16:12:06 +0530103 - discover
104 - Emulates a device power on. Sends a ``OnuDiscInd``
Matteo Scandolo5e081b52019-11-21 14:34:25 -0800105 * - 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 Arya30f7d4d2020-01-21 16:12:06 +0530111 * - 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 Bavierd9a4c7d2020-01-29 17:55:38 -0700121.. list-table::
Pragya Arya30f7d4d2020-01-21 16:12:06 +0530122 :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 Scandolo9f619492019-10-25 13:11:58 -0700134
135Below 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 Bozakovc38f9262019-11-27 02:50:05 +0100148 rankdir=TB
149 newrank=true
Matteo Scandolo9f619492019-10-25 13:11:58 -0700150 graph [pad="1,1" bgcolor="#cccccc"]
151 node [style=filled]
152
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100153 subgraph {
154 node [fillcolor="#bee7fa"]
Matteo Scandolo9f619492019-10-25 13:11:58 -0700155
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100156 created [peripheries=2]
157 initialized
158 discovered
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700159 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100160 rank=same
161 enabled
162 disabled [fillcolor="#f9d6ff"]
163 }
Matteo Scandolo9f619492019-10-25 13:11:58 -0700164
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100165 {created, disabled} -> initialized -> discovered -> enabled
166 }
Matteo Scandolo9f619492019-10-25 13:11:58 -0700167
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100168 subgraph cluster_eapol {
169 style=rounded
170 style=dotted
171 node [fillcolor="#e6ffc2"]
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700172
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100173 auth_started
174 eap_start_sent
175 eap_response_identity_sent
176 eap_response_challenge_sent
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700177 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100178 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 Williams4b0ef4d2019-12-18 14:25:20 -0700201
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100202 dhcp_started
203 dhcp_discovery_sent
204 dhcp_request_sent
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700205 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100206 rank=same
207 dhcp_ack_received
208 dhcp_failed
209 }
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700210
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100211 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 Scandolo5ff80082019-12-20 13:20:57 -0800222 enabled -> auth_started
223 enabled -> dhcp_started
Matteo Scandolo9f619492019-10-25 13:11:58 -0700224
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100225 {dhcp_ack_received, dhcp_failed} -> auth_started
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700226
Matteo Scandolo9f619492019-10-25 13:11:58 -0700227 eap_response_success_received -> dhcp_started
Matteo Scandolo9f619492019-10-25 13:11:58 -0700228
229 eap_response_success_received -> disabled
230 auth_failed -> disabled
231 dhcp_ack_received -> disabled
232 dhcp_failed -> disabled
233 disabled -> enabled
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700234 }