[SEBA-836] Sending DHCP request in batches so that the DHCP Server replies to all of them
Change-Id: I1401db10ae298340a7dbbe897de66b7bdd47df7e
diff --git a/cmd/bbr/bbr.go b/cmd/bbr/bbr.go
index 4f4c590..4a4ec91 100644
--- a/cmd/bbr/bbr.go
+++ b/cmd/bbr/bbr.go
@@ -81,6 +81,7 @@
&apiDoneChannel,
true, // this parameter is not important in the BBR Case
true, // this parameter is not important in the BBR Case
+ 0, // this parameter does not matter in the BBR case
true,
)
oltMock := bbrdevices.OltMock{
diff --git a/cmd/bbsim/bbsim.go b/cmd/bbsim/bbsim.go
index e7eef11..eea4b95 100644
--- a/cmd/bbsim/bbsim.go
+++ b/cmd/bbsim/bbsim.go
@@ -153,6 +153,7 @@
"TotalOnus": options.NumPonPerOlt * options.NumOnuPerPon,
"Auth": options.Auth,
"Dhcp": options.Dhcp,
+ "Delay": options.Delay,
}).Info("BroadBand Simulator is on")
// control channels, they are only closed when the goroutine needs to be terminated
@@ -170,6 +171,7 @@
close(oltDoneChannel)
}()
+
wg := sync.WaitGroup{}
wg.Add(5)
@@ -184,8 +186,10 @@
&apiDoneChannel,
options.Auth,
options.Dhcp,
+ options.Delay,
false,
)
+
go devices.StartOlt(olt, &wg)
log.Debugf("Created OLT with id: %d", options.OltID)
go startApiServer(apiDoneChannel, &wg)
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
}