blob: 69b86392c5d16409e7a99a1cf2257372fca0c797 [file] [log] [blame]
Matteo Scandolo40e067f2019-10-16 16:59:41 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// BBR (BBSim Reflector) is a tool designed to scale test BBSim
18// It shared most of the code with BBSim itself and replies to messages
19// pretending to be VOLTHA.
20// The idea behind it is that, given that the BBSim and BBR are based on the same
21// codebase, BBR is acting as a wall for BBSim. And you can't beat the wall.
22package main
23
24import (
25 bbrdevices "github.com/opencord/bbsim/internal/bbr/devices"
26 "github.com/opencord/bbsim/internal/bbsim/devices"
27 "github.com/opencord/bbsim/internal/common"
28 log "github.com/sirupsen/logrus"
29 "os"
30 "runtime/pprof"
31 "time"
32)
33
34// usage
35func main() {
36 options := common.GetBBROpts()
37
38 common.SetLogLevel(log.StandardLogger(), options.LogLevel, options.LogCaller)
39
40 if *options.ProfileCpu != "" {
41 // start profiling
42 log.Infof("Creating profile file at: %s", *options.ProfileCpu)
43 f, err := os.Create(*options.ProfileCpu)
44 if err != nil {
45 log.Fatal(err)
46 }
47 pprof.StartCPUProfile(f)
48 }
49
50 log.WithFields(log.Fields{
51 "OltID": options.OltID,
52 "NumNniPerOlt": options.NumNniPerOlt,
53 "NumPonPerOlt": options.NumPonPerOlt,
54 "NumOnuPerPon": options.NumOnuPerPon,
55 }).Info("BroadBand Reflector is on")
56
57 // NOTE this are probably useless in the MockOLT case, check if we can avoid using them in the CreateOlt method
58 oltDoneChannel := make(chan bool)
59 apiDoneChannel := make(chan bool)
60
61 // create the OLT device
62 olt := devices.CreateOLT(options.OltID, options.NumNniPerOlt, options.NumPonPerOlt, options.NumOnuPerPon, options.STag, options.CTagInit, &oltDoneChannel, &apiDoneChannel, true)
63 oltMock := bbrdevices.OltMock{
64 Olt: olt,
65 TargetOnus: options.NumPonPerOlt * options.NumOnuPerPon,
66 CompletedOnus: 0,
67 BBSimIp: options.BBSimIp,
68 BBSimPort: options.BBSimPort,
69 BBSimApiPort: options.BBSimApiPort,
70 }
71
72 // start the enable sequence
73 startTime := time.Now()
74 defer func() {
75 endTime := time.Now()
76 runTime := endTime.Sub(startTime)
77 log.WithField("Duration", runTime).Info("BBR done!")
78 }()
79 oltMock.Start()
80}