[SEBA-836] Sending DHCP request in batches so that the DHCP Server replies to all of them

Change-Id: I1401db10ae298340a7dbbe897de66b7bdd47df7e
diff --git a/internal/bbsim/devices/nni.go b/internal/bbsim/devices/nni.go
index ad01f2f..39430ef 100644
--- a/internal/bbsim/devices/nni.go
+++ b/internal/bbsim/devices/nni.go
@@ -200,7 +200,7 @@
 		return nil, err
 	}
 
-	channel := make(chan *types.PacketMsg, 32)
+	channel := make(chan *types.PacketMsg, 1024)
 
 	go func() {
 		packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
diff --git a/internal/bbsim/devices/olt.go b/internal/bbsim/devices/olt.go
index 6b15de4..6484896 100644
--- a/internal/bbsim/devices/olt.go
+++ b/internal/bbsim/devices/olt.go
@@ -52,6 +52,8 @@
 	apiDoneChannel  *chan bool
 	nniPktInChannel chan *bbsim.PacketMsg
 
+	Delay int
+
 	Pons []*PonPort
 	Nnis []*NniPort
 
@@ -65,7 +67,7 @@
 	return &olt
 }
 
-func CreateOLT(oltId int, nni int, pon int, onuPerPon int, sTag int, cTagInit int, oltDoneChannel *chan bool, apiDoneChannel *chan bool, auth bool, dhcp bool, isMock bool) *OltDevice {
+func CreateOLT(oltId int, nni int, pon int, onuPerPon int, sTag int, cTagInit int, oltDoneChannel *chan bool, apiDoneChannel *chan bool, auth bool, dhcp bool, delay int, isMock bool) *OltDevice {
 	oltLogger.WithFields(log.Fields{
 		"ID":           oltId,
 		"NumNni":       nni,
@@ -88,6 +90,7 @@
 		oltDoneChannel:  oltDoneChannel,
 		apiDoneChannel:  apiDoneChannel,
 		nniPktInChannel: make(chan *bbsim.PacketMsg, 1024), // packets coming in from the NNI and going to VOLTHA
+		Delay:           delay,
 	}
 
 	// OLT State machine
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index 9fa224d..6182577 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -32,6 +32,7 @@
 	"github.com/opencord/voltha-protos/go/openolt"
 	log "github.com/sirupsen/logrus"
 	"net"
+	"time"
 )
 
 var onuLogger = log.WithFields(log.Fields{
@@ -239,6 +240,8 @@
 		switch message.Type {
 		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)
 			o.sendOnuDiscIndication(msg, stream)
 		case OnuIndication:
 			msg, _ := message.Data.(OnuIndicationMessage)
diff --git a/internal/common/options.go b/internal/common/options.go
index eee91cc..af51fed 100644
--- a/internal/common/options.go
+++ b/internal/common/options.go
@@ -30,6 +30,7 @@
 	ProfileCpu   *string
 	LogLevel     string
 	LogCaller    bool
+	Delay        int
 }
 
 type BBRCliOptions struct {
@@ -58,6 +59,8 @@
 	logLevel := flag.String("logLevel", "debug", "Set the log level (trace, debug, info, warn, error)")
 	logCaller := flag.Bool("logCaller", false, "Whether to print the caller filename or not")
 
+	dhcpDelay := flag.Int("dhcp_delay", 200, "The delay between ONU DISCOVERY batches in milliseconds (1 ONU per each PON PORT at a time")
+
 	flag.Parse()
 
 	o := new(BBSimCliOptions)
@@ -73,6 +76,7 @@
 	o.LogCaller = *logCaller
 	o.Auth = *auth
 	o.Dhcp = *dhcp
+	o.Delay = *dhcpDelay
 
 	return o
 }