blob: 2815a64a553fb7ac4783531fb50f2ff43af646fc [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 -
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
103 - enable
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700104 - Emulates a device power on. Sends a ``OnuDiscInd`` and then an ``OnuIndication{OperState: 'up'}``
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.
Matteo Scandolo9f619492019-10-25 13:11:58 -0700111
112Below is a diagram of the state machine:
113
114- In blue PON related states
115- In green EAPOL related states
116- In yellow DHCP related states
117- In purple operator driven states
118
119..
120 TODO Evaluate http://blockdiag.com/en/seqdiag/examples.html
121
122.. graphviz::
123
124 digraph {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100125 rankdir=TB
126 newrank=true
Matteo Scandolo9f619492019-10-25 13:11:58 -0700127 graph [pad="1,1" bgcolor="#cccccc"]
128 node [style=filled]
129
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100130 subgraph {
131 node [fillcolor="#bee7fa"]
Matteo Scandolo9f619492019-10-25 13:11:58 -0700132
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100133 created [peripheries=2]
134 initialized
135 discovered
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700136 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100137 rank=same
138 enabled
139 disabled [fillcolor="#f9d6ff"]
140 }
141 gem_port_added
Matteo Scandolo9f619492019-10-25 13:11:58 -0700142
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100143 {created, disabled} -> initialized -> discovered -> enabled
144 }
Matteo Scandolo9f619492019-10-25 13:11:58 -0700145
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100146 subgraph cluster_eapol {
147 style=rounded
148 style=dotted
149 node [fillcolor="#e6ffc2"]
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700150
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100151 eapol_flow_received
152 auth_started
153 eap_start_sent
154 eap_response_identity_sent
155 eap_response_challenge_sent
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700156 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100157 rank=same
158 eap_response_success_received
159 auth_failed
160 }
161
162 auth_started -> eap_start_sent -> eap_response_identity_sent -> eap_response_challenge_sent -> eap_response_success_received
163 auth_started -> auth_failed
164 eap_start_sent -> auth_failed
165 eap_response_identity_sent -> auth_failed
166 eap_response_challenge_sent -> auth_failed
167
168 eap_start_sent -> auth_started
169 eap_response_identity_sent -> auth_started
170 eap_response_challenge_sent -> auth_started
171
172 eap_response_success_received -> auth_started
173 auth_failed -> auth_started
174 }
175
176 subgraph cluster_dhcp {
177 node [fillcolor="#fffacc"]
178 style=rounded
179 style=dotted
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700180
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100181 dhcp_started
182 dhcp_discovery_sent
183 dhcp_request_sent
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700184 {
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100185 rank=same
186 dhcp_ack_received
187 dhcp_failed
188 }
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700189
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100190 dhcp_started -> dhcp_discovery_sent -> dhcp_request_sent -> dhcp_ack_received
191 dhcp_started -> dhcp_failed
192 dhcp_discovery_sent -> dhcp_failed
193 dhcp_request_sent -> dhcp_failed
194 dhcp_ack_received dhcp_failed
195
196 dhcp_discovery_sent -> dhcp_started
197 dhcp_request_sent -> dhcp_started
198 dhcp_ack_received -> dhcp_started
199 dhcp_failed -> dhcp_started
200 }
Matteo Scandolo9f619492019-10-25 13:11:58 -0700201 enabled -> gem_port_added -> eapol_flow_received -> auth_started
202 enabled -> eapol_flow_received -> gem_port_added -> auth_started
203
Zdravko Bozakovc38f9262019-11-27 02:50:05 +0100204 {dhcp_ack_received, dhcp_failed} -> auth_started
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700205
Matteo Scandolo9f619492019-10-25 13:11:58 -0700206 eap_response_success_received -> dhcp_started
Matteo Scandolo9f619492019-10-25 13:11:58 -0700207
208 eap_response_success_received -> disabled
209 auth_failed -> disabled
210 dhcp_ack_received -> disabled
211 dhcp_failed -> disabled
212 disabled -> enabled
Zack Williams4b0ef4d2019-12-18 14:25:20 -0700213 }