SEBA-806:Bring up ONUs one by one

For simulating onu discovery in a frequency, a time gap inserted between the OnuDiscovery messages generated by BBSIM.
For this, the configurable IndicationInterval parameter is used.

Change-Id: I49e2afb57e8321550898cbe89ee8b17ef580dc44
diff --git a/README.md b/README.md
index a3f3fd7..ca674b2 100644
--- a/README.md
+++ b/README.md
@@ -112,7 +112,7 @@
   -s string
       DHCP Server IP Address (default "182.21.0.128")
   -v int
-      Interval each ONU Discovery Indication (ms) (default 1000)
+      Interval each Discovery Indication, in the form of unit+suffix, such as '10ms', '1s' or '1m' (default 0)
   -ia bool
       Interactive activation of ONUs: if true ONUs must be activated explicitly using the management API (no ONUs are activated at startup) (default false)
   -grpc int
diff --git a/core/alarms.go b/core/alarms.go
index 6a702ce..6296123 100644
--- a/core/alarms.go
+++ b/core/alarms.go
@@ -87,7 +87,7 @@
 		}
 		Ind := formulateLossOfPLOAM(in.Status, onu)
 		s.alarmCh <- Ind
-		er := sendOnuInd(*s.EnableServer, onu, 0, onu.OperState, "up")
+		er := sendOnuInd(*s.EnableServer, onu, onu.OperState, "up")
 		if er != nil {
 			logger.Debug(er.Error())
 		}
@@ -129,7 +129,7 @@
 				continue // Skip for onus which have independently raised onu los
 			}
 
-			er := sendOnuInd(*s.EnableServer, onu, 0, onusOperstat, "up")
+			er := sendOnuInd(*s.EnableServer, onu, onusOperstat, "up")
 			if er != nil {
 				logger.Debug(er.Error())
 			}
diff --git a/core/api_handler.go b/core/api_handler.go
index d6c051a..8bc2c09 100644
--- a/core/api_handler.go
+++ b/core/api_handler.go
@@ -213,7 +213,7 @@
 	_ = sendDyingGaspInd(*s.EnableServer, onu.IntfID, onu.OnuID)
 	device.UpdateOnusOpStatus(onu.IntfID, onu, "down")
 	// send operstat down to voltha
-	_ = sendOnuInd(*s.EnableServer, onu, s.IndInterval, "down", "up")
+	_ = sendOnuInd(*s.EnableServer, onu, "down", "up")
 	// Give OEH some time to perform cleanup
 	time.Sleep(30 * time.Second)
 	s.activateOnu(onu)
@@ -291,7 +291,7 @@
 
 	// Send DyingGasp Alarm to VOLTHA
 	_ = sendDyingGaspInd(*s.EnableServer, onu.IntfID, onu.OnuID)
-	_ = sendOnuInd(*s.EnableServer, onu, s.IndInterval, onu.OperState, "down")
+	_ = sendOnuInd(*s.EnableServer, onu, onu.OperState, "down")
 	return nil
 }
 
diff --git a/core/core_server.go b/core/core_server.go
index 6c68706..6899d86 100644
--- a/core/core_server.go
+++ b/core/core_server.go
@@ -23,6 +23,7 @@
 	"reflect"
 	"strconv"
 	"sync"
+	"time"
 
 	"github.com/google/gopacket"
 	"github.com/google/gopacket/layers"
@@ -65,7 +66,7 @@
 	mgmtGrpcPort    uint32
 	mgmtRestPort    uint32
 	Vethnames       []string
-	IndInterval     int
+	IndInterval     time.Duration
 	Processes       []string
 	EnableServer    *openolt.Openolt_EnableIndicationServer
 	CtagMap         map[string]uint32
@@ -363,6 +364,9 @@
 	for intfid := range Onumap {
 		for _, onu := range Onumap[intfid] {
 			s.activateOnu(onu)
+			if s.IndInterval > 0 {
+				time.Sleep(s.IndInterval)
+			}
 		}
 	}
 }
diff --git a/core/grpc_service.go b/core/grpc_service.go
index 8e9e122..8ac0faf 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -112,7 +112,7 @@
 	matched.OnuID = onuid
 	s.updateDevIntState(matched, device.ONU_ACTIVE)
 	logger.Debug("ONU IntfID: %d OnuID: %d activated succesufully.", onu.IntfId, onu.OnuId)
-	if err := sendOnuInd(*s.EnableServer, matched, s.IndInterval, "up", "up"); err != nil {
+	if err := sendOnuInd(*s.EnableServer, matched, "up", "up"); err != nil {
 		logger.Error("Failed to send ONU Indication intfID %d, onuID %d", matched.IntfID, matched.OnuID)
 		return new(openolt.Empty), err
 	}
diff --git a/core/mediator.go b/core/mediator.go
index 66840bb..0756651 100644
--- a/core/mediator.go
+++ b/core/mediator.go
@@ -24,6 +24,7 @@
 	"strconv"
 	"strings"
 	"sync"
+	"time"
 
 	"github.com/opencord/voltha-bbsim/common/logger"
 	"github.com/opencord/voltha-bbsim/device"
@@ -53,7 +54,7 @@
 	aaawait                  int
 	dhcpwait                 int
 	dhcpservip               string
-	intvl                    int
+	intvl                    time.Duration
 	interactiveOnuActivation bool
 	Mode                     Mode
 	KafkaBroker              string
@@ -71,7 +72,7 @@
 	aaawait := flag.Int("aw", 2, "Wait time (sec) for activation WPA supplicants after EAPOL flow entry installed")
 	dhcpwait := flag.Int("dw", 2, "Wait time (sec) for activation DHCP clients after DHCP flow entry installed")
 	dhcpservip := flag.String("s", "182.21.0.128", "DHCP Server IP Address")
-	intvl := flag.Int("v", 1000, "Interval each Indication (ms)")
+	intvl := flag.Duration("v", 0, "Interval each Discovery Indication, in the form of unit+suffix, such as '10ms', '1s' or '1m''. defaults to 0")
 	kafkaBroker := flag.String("k", "", "Kafka broker")
 	interactiveOnuActivation := flag.Bool("ia", false, "Enable interactive activation of ONUs")
 	mgmtGrpcPort := flag.Int("grpc", 50061, "BBSim API server gRPC port")
diff --git a/core/openolt_service.go b/core/openolt_service.go
index fafe1c9..a56b75c 100644
--- a/core/openolt_service.go
+++ b/core/openolt_service.go
@@ -17,7 +17,6 @@
 package core
 
 import (
-	"time"
 
 	"github.com/opencord/voltha-bbsim/common/logger"
 	"github.com/opencord/voltha-bbsim/device"
@@ -91,8 +90,7 @@
 	return nil
 }
 
-func sendOnuInd(stream openolt.Openolt_EnableIndicationServer, onu *device.Onu, delay int, operState string, adminState string) error {
-	time.Sleep(time.Duration(delay) * time.Millisecond)
+func sendOnuInd(stream openolt.Openolt_EnableIndicationServer, onu *device.Onu, operState string, adminState string) error {
 	data := &openolt.Indication_OnuInd{OnuInd: &openolt.OnuIndication{
 		IntfId:       onu.IntfID,
 		OnuId:        onu.OnuID,