blob: 9df3ca6764dd46cce5ad1aff1e8ba19c416fc563 [file] [log] [blame]
Matteo Scandolo9f619492019-10-25 13:11:58 -07001.. _ONU State Machine:
2
3ONU State Machine
4=================
5
6In ``BBSim`` the device state is createdtained using a state machine
7library: `fsm <https://github.com/looplab/fsm>`__.
8
9Here is a list of possible state transitions in BBSim:
10
11+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
12| Transition | Starting States | End State | Notes |
13+================================+========================================================================================+================================+===============================================================================================+
14| | | created | |
15+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
16| discover | created | discovered | |
17+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
18| enable | discovered, disabled | enabled | |
19+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
20| receive_eapol_flow | enabled, gem_port_added | eapol_flow_received | |
21+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
22| add_gem_port | enabled, eapol_flow_received | gem_port_added | We need to wait for both the flow and the gem port to come before moving to ``auth_started`` |
23+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
24| start_auth | eapol_flow_received, gem_port_added | auth_started | |
25+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
26| eap_start_sent | auth_started | eap_start_sent | |
27+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
28| eap_response_identity_sent | eap_start_sent | eap_response_identity_sent | |
29+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
30| eap_response_challenge_sent | eap_response_identity_sent | eap_response_challenge_sent | |
31+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
32| eap_response_success_received | eap_response_challenge_sent | eap_response_success_received | |
33+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
34| auth_failed | auth_started, eap_start_sent, eap_response_identity_sent, eap_response_challenge_sent | auth_failed | |
35+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
36| start_dhcp | eap_response_success_received | dhcp_started | |
37+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
38| dhcp_discovery_sent | dhcp_started | dhcp_discovery_sent | |
39+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
40| dhcp_request_sent | dhcp_discovery_sent | dhcp_request_sent | |
41+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
42| dhcp_ack_received | dhcp_request_sent | dhcp_ack_received | |
43+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
44| dhcp_failed | dhcp_started, dhcp_discovery_sent, dhcp_request_sent | dhcp_failed | |
45+--------------------------------+----------------------------------------------------------------------------------------+--------------------------------+-----------------------------------------------------------------------------------------------+
46
47In addition some transition can be forced via the API:
48
49+---------------------+----------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------------------+
50| End StateTransition | Starting States | End State | Notes |
51+=====================+============================================================================+===========+=========================================================================================================+
52| disable | eap_response_success_received, auth_failed, dhcp_ack_received, dhcp_failed | disabled | Emulates a devide mulfunction. Sends a ``DyingGaspInd`` and then an ``OnuIndication{OperState: 'down'}``|
53+---------------------+----------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------------------+
54
55Below is a diagram of the state machine:
56
57- In blue PON related states
58- In green EAPOL related states
59- In yellow DHCP related states
60- In purple operator driven states
61
62..
63 TODO Evaluate http://blockdiag.com/en/seqdiag/examples.html
64
65.. graphviz::
66
67 digraph {
68 graph [pad="1,1" bgcolor="#cccccc"]
69 node [style=filled]
70
71 created [fillcolor="#bee7fa"]
72 discovered [fillcolor="#bee7fa"]
73 enabled [fillcolor="#bee7fa"]
74 disabled [fillcolor="#f9d6ff"]
75 gem_port_added [fillcolor="#bee7fa"]
76
77 eapol_flow_received [fillcolor="#e6ffc2"]
78 auth_started [fillcolor="#e6ffc2"]
79 eap_start_sent [fillcolor="#e6ffc2"]
80 eap_response_identity_sent [fillcolor="#e6ffc2"]
81 eap_response_challenge_sent [fillcolor="#e6ffc2"]
82 eap_response_success_received [fillcolor="#e6ffc2"]
83 auth_failed [fillcolor="#e6ffc2"]
84
85 dhcp_started [fillcolor="#fffacc"]
86 dhcp_discovery_sent [fillcolor="#fffacc"]
87 dhcp_request_sent [fillcolor="#fffacc"]
88 dhcp_ack_received [fillcolor="#fffacc"]
89 dhcp_failed [fillcolor="#fffacc"]
90
91 created -> discovered -> enabled
92 enabled -> gem_port_added -> eapol_flow_received -> auth_started
93 enabled -> eapol_flow_received -> gem_port_added -> auth_started
94
95 auth_started -> eap_start_sent -> eap_response_identity_sent -> eap_response_challenge_sent -> eap_response_success_received
96 auth_started -> auth_failed
97 eap_start_sent -> auth_failed
98 eap_response_identity_sent -> auth_failed
99 eap_response_challenge_sent -> auth_failed
100
101 eap_response_success_received -> dhcp_started
102 dhcp_started -> dhcp_discovery_sent -> dhcp_request_sent -> dhcp_ack_received
103 dhcp_started -> dhcp_failed
104 dhcp_discovery_sent -> dhcp_failed
105 dhcp_request_sent -> dhcp_failed
106 dhcp_ack_received dhcp_failed
107
108 eap_response_success_received -> disabled
109 auth_failed -> disabled
110 dhcp_ack_received -> disabled
111 dhcp_failed -> disabled
112 disabled -> enabled
113 }