SEBA-927 implemenation of controlled PON and ONU activation
updated controlledActivation to enum
Change-Id: Ie505c491755d3890a2ea4a86a9c74f17a5eab484
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index c9c2f17..c1ada1c 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -52,7 +52,8 @@
Dhcp bool // automatically start DHCP if set to true
HwAddress net.HardwareAddr
InternalState *fsm.FSM
- DiscoveryRetryDelay time.Duration
+ DiscoveryRetryDelay time.Duration // this is the time between subsequent Discovery Indication
+ DiscoveryDelay time.Duration // this is the time to send the first Discovery Indication
// ONU State
// PortNo comes with flows and it's used when sending packetIndications,
@@ -79,10 +80,10 @@
return common.OnuSnToString(o.SerialNumber)
}
-func CreateONU(olt *OltDevice, pon PonPort, id uint32, sTag int, cTag int, auth bool, dhcp bool, isMock bool) *Onu {
+func CreateONU(olt *OltDevice, pon PonPort, id uint32, sTag int, cTag int, auth bool, dhcp bool, delay time.Duration, isMock bool) *Onu {
o := Onu{
- ID: id,
+ ID: 0,
PonPortID: pon.ID,
PonPort: pon,
STag: sTag,
@@ -97,8 +98,9 @@
DoneChannel: make(chan bool, 1),
DhcpFlowReceived: false,
DiscoveryRetryDelay: 60 * time.Second, // this is used to send OnuDiscoveryIndications until an activate call is received
+ DiscoveryDelay: delay,
}
- o.SerialNumber = o.NewSN(olt.ID, pon.ID, o.ID)
+ o.SerialNumber = o.NewSN(olt.ID, pon.ID, id)
// NOTE this state machine is used to track the operational
// state as requested by VOLTHA
@@ -119,7 +121,7 @@
{Name: "receive_eapol_flow", Src: []string{"enabled", "gem_port_added"}, Dst: "eapol_flow_received"},
{Name: "add_gem_port", Src: []string{"enabled", "eapol_flow_received"}, Dst: "gem_port_added"},
// NOTE should disabled state be different for oper_disabled (emulating an error) and admin_disabled (received a disabled call via VOLTHA)?
- {Name: "disable", Src: []string{"enabled", "eapol_flow_received", "gem_port_added", "eap_response_success_received", "auth_failed", "dhcp_ack_received", "dhcp_failed"}, Dst: "disabled"},
+ {Name: "disable", Src: []string{"enabled", "eapol_flow_received", "gem_port_added", "eap_response_success_received", "auth_failed", "dhcp_ack_received", "dhcp_failed", "pon_disabled"}, Dst: "disabled"},
// ONU state when PON port is disabled but ONU is power ON(more states should be added in src?)
{Name: "pon_disabled", Src: []string{"enabled", "gem_port_added", "eapol_flow_received", "eap_response_success_received", "auth_failed", "dhcp_ack_received", "dhcp_failed"}, Dst: "pon_disabled"},
// EAPOL
@@ -303,7 +305,7 @@
case OnuDiscIndication:
msg, _ := message.Data.(OnuDiscIndicationMessage)
// NOTE we need to slow down and send ONU Discovery Indication in batches to better emulate a real scenario
- time.Sleep(time.Duration(int(o.ID)*o.PonPort.Olt.Delay) * time.Millisecond)
+ time.Sleep(o.DiscoveryDelay)
o.sendOnuDiscIndication(msg, stream)
case OnuIndication:
msg, _ := message.Data.(OnuIndicationMessage)