diff --git a/applications/rtdt-manager/benchmark/benchmark.go b/applications/rtdt-manager/benchmark/benchmark.go index 1adbf17160b4dbbd7cceef79fcecfa93e4d07df6..0635a55ad9bbb5d90b827aa0fd47ebd205efa80e 100644 --- a/applications/rtdt-manager/benchmark/benchmark.go +++ b/applications/rtdt-manager/benchmark/benchmark.go @@ -7,17 +7,22 @@ import ( "time" ) +// Benchmarking struct for testing propagation delay to twin type Benchmark0 struct { - StartTimeRealnet time.Time // Callback entered + StartTimeRealnet time.Time // Callback entered + RmSendPathRequest time.Time // rtdt-manager sends change request + //CtlRcvPathRequest --> DO IN CONTROLLER: controller receives request + CtlSendPathResponse time.Time // time controller sends package back after processing, controller sends timestamp + RmReceivePathResponse time.Time // the change request is received in controller - SendChangeRequest time.Time // realnet sends change request - ReceiveChangeRequest time.Time // the change reuest received in twin - ReceiveChangeResponse time.Time // the change request is received in twin - - SendCommitRequest time.Time // the commit is sent from realnet - ReceiveCommitRequest time.Time // the commit is received in twin - ReceiveCommitResponse time.Time // the response of the twin received in realnet - //EndTime time.Time + RmSendCommitRequest time.Time // the commit is sent from realnet + // CtlRcvCommitRequest --> IN CONTROLLER: ctrler receives the commit + // CtlSendGnmi --> IN CONTROLLER: apply change start + // GnmiReceive --> IN gnmi-target: receives apply change + // GnmiSend --> IN gnmi-target: finished applying change + // CtlRcvGnmi --> IN CONTROLLER: received apply change + CtlSendCommitResponse time.Time // IN CONTROLLER: sending back to rtdt-manager + RmReceiveCommitResponse time.Time // commit response of the twin received in rtdt-manager PropagationDelay time.Duration // calculated delay } @@ -25,7 +30,7 @@ type Benchmark0 struct { var Current Benchmark0 func (b *Benchmark0) GetDurations() { - startToSend := Diff(b.StartTimeRealnet, b.SendChangeRequest).Microseconds() + startToSend := Diff(b.StartTimeRealnet, b.RmSendPathRequest).Microseconds() fmt.Println("Start to Send:", startToSend) } @@ -35,8 +40,8 @@ func Diff(start, end time.Time) time.Duration { } func (b *Benchmark0) Print() { - fmt.Println("SendChangeRequest to ReceiveChangeRequest in us:", b.ReceiveChangeRequest.Sub(b.SendChangeRequest).Microseconds()) - fmt.Println("SendChangeRequest to ReceiveChangeResponse in us:", b.ReceiveChangeResponse.Sub(b.SendChangeRequest).Microseconds()) + fmt.Println("SendChangeRequest to ReceiveChangeRequest in us:", b.CtlSendPathResponse.Sub(b.RmSendPathRequest).Microseconds()) + fmt.Println("ReceiveChangeRequest to ReceiveChangeResponse in us:", b.RmReceivePathResponse.Sub(b.CtlSendPathResponse).Microseconds()) fmt.Println("PropagationDelay in ms:", b.PropagationDelay.Milliseconds()) } diff --git a/applications/rtdt-manager/clab-config/clab-config.go b/applications/rtdt-manager/clab-config/clab-config.go index 75a401e657f9214b8bd8edcb894a0e8c3aab8211..c74339dbd683a021d165b9174e6e86f9419b1347 100644 --- a/applications/rtdt-manager/clab-config/clab-config.go +++ b/applications/rtdt-manager/clab-config/clab-config.go @@ -216,14 +216,6 @@ func DeriveConfig(clabConfig *ClabConfig, newIPv4Subnet, newIPv6Subnet string, c splitIPv4 := strings.Split(node.MgmtIPv4, ".") splitIPv4[0], splitIPv4[1], splitIPv4[2] = subnetParts[0], subnetParts[1], subnetParts[2] node.MgmtIPv4 = strings.Join(splitIPv4, ".") - - // if strings.HasPrefix(name, "gosdn") { - // pluginRegistryAddress := fmt.Sprintf("clab-%s-plugin-registry:55057", clabConfig.Name) - // dbAddress := fmt.Sprintf("mongodb://root:example@clab-%s-mongodb:27017", clabConfig.Name) - // node.Cmd = fmt.Sprintf("%s --plugin-registry %s -d %s", node.Cmd, pluginRegistryAddress, dbAddress) - // } - // Ports: host side needs to be incremented or there will be conflicts - // for now just use 5 as increment for i, portBinding := range node.Ports { parts := strings.Split(portBinding, ":") if len(parts) == 3 { diff --git a/applications/rtdt-manager/rtdt-manager/rtdt-manager.go b/applications/rtdt-manager/rtdt-manager/rtdt-manager.go index 807f2341080b4b815f417b25312506618691261b..5c136713914689d9fb3a6bb0638fcccbba9bf888 100644 --- a/applications/rtdt-manager/rtdt-manager/rtdt-manager.go +++ b/applications/rtdt-manager/rtdt-manager/rtdt-manager.go @@ -114,6 +114,9 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon // newName := fmt.Sprintf("%s-%s", nodename, name) if strings.HasPrefix(nodename, "gosdn") { node.Binds = []string{"../../../../artifacts/ssl/gosdn:/app/ssl"} + if name != "realnet" { + node.Binds = append(node.Binds, "gosdn_share:/app/gosdn_share") + } pluginRegistryAddress := fmt.Sprintf("%s:55057", pluginRegistryAddress) dbAddress := fmt.Sprintf("mongodb://root:example@%s:27017", mongodbAddress) node.Cmd = fmt.Sprintf("%s --plugin-registry %s -d %s", node.Cmd, pluginRegistryAddress, dbAddress) @@ -136,6 +139,9 @@ func (r *RtdtManager) ProduceClabConfig(name string, sdnConfig *sdnconfig.SdnCon fmt.Printf("ProduceClabConfig(): Warning: No MNE entry for node: %s\n", node.Name) } + if node.Name == "gnmi-target-switch0-test-twin" { + clabNode.Binds = append(clabNode.Binds, "mne_share:/etc/gnmi-target/mne_share") // place tests here + } clabConfig.Topology.Nodes[node.Name] = *clabNode } for _, link := range sdnConfig.Links { @@ -271,7 +277,7 @@ func (r *RtdtManager) RunBenchmark0(numTests int64) error { if err != nil { fmt.Printf("Encountered error: %v\n", err) } - + time.Sleep(time.Second * 1) } r.benchmark0 = false return nil @@ -490,8 +496,8 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { return } if r.benchmark0 { - benchmark.Current = benchmark.Benchmark0{} - benchmark.Current.StartTimeRealnet = time.Now() + benchmark.Current = benchmark.Benchmark0{} + benchmark.Current.StartTimeRealnet = time.Now() } fmt.Println("--------------------------------") fmt.Println("---------- MNE EVENT -----------") @@ -499,12 +505,12 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { fmt.Println("Event Type: ", event.Type) fmt.Println("PathsAndValuesMap: ", event.PathsAndValuesMap) fmt.Println("EntityID", event.EntityID) - prefix := "/interfaces/interface[name=" - prefixHostname := "/system/config/hostname" + // prefix := "/interfaces/interface[name=" + // prefixHostname := "/system/config/hostname" //realnetClabData := r.realnet.GetClabData() // for i, node := range realnetClabData.Topology.Nodes { - // } - suffixMTU := "]/config/mtu" + // // } + // suffixMTU := "]/config/mtu" // Select a twin //TODO: This is where some selection process should happen to select the right twin based on the event @@ -524,8 +530,8 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { // First get hostname of realnet node realnetNode := r.realnet.GetSdnConfig().GetNodeByUUID(event.EntityID.String()) // LINK UP/DOWN - interfaceRegex := regexp.MustCompile(`/interfaces/interface\[name=([^]]+)]/state/oper-status`) - regexMatch := interfaceRegex.FindStringSubmatch(path) + //interfaceRegex := regexp.MustCompile(`/interfaces/interface\[name=([^]]+)]/state/oper-status`) + // regexMatch := interfaceRegex.FindStringSubmatch(path) // Get the ID of parallel mne in twin network // parallel nodes are nodes that have the same name in twin and realnet @@ -536,45 +542,47 @@ func (r *RtdtManager) updateMNECallbackRealnet(event *event.Event) { } } - var err error + //var err error + twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0) + // Some explicitly supported paths // MTU Change - if strings.HasPrefix(path, prefix) && strings.HasSuffix(path, suffixMTU) { - fmt.Println("--- CHANGE MTU TRIGGERED ---") - fmt.Println("Value of new MTU: ", value) - twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0) - // Set Hostname - } else if strings.HasPrefix(path, prefixHostname) { - // Hostname change - fmt.Println("--- CHANGE HOSTNAME TRIGGERED ---") - for _, twin := range r.rtdt_twins { - if twin == nil { - fmt.Println("Encountered nil twin, skipping") - continue - } - fmt.Println("ENTERING SETGNMIPATH, value: ", value, "path:", path) - err = twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0) - if err != nil { - fmt.Println("Callback failed:", err) - return - } - } - // Interface UP/Down - } else if regexMatch != nil && len(r.rtdt_twins) > 0 { - - fmt.Println("Setting interface", regexMatch[1], "UP/DOWN") - fmt.Printf("match: %v\n", regexMatch) - path := "/interfaces/interface[name=" + regexMatch[1] + "]/config/enabled" - if value == "DOWN" { - value = "false" - } else { - value = "true" - } - twin.SetGnmiPath(path, value, twinEntityID, false) - // CATCHALL - } else { - twin.SetGnmiPath(path, value, twinEntityID, false) - } + // if strings.HasPrefix(path, prefix) && strings.HasSuffix(path, suffixMTU) { + // fmt.Println("--- CHANGE MTU TRIGGERED ---") + // fmt.Println("Value of new MTU: ", value) + // twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0) + // // Set Hostname + // } else if strings.HasPrefix(path, prefixHostname) { + // // Hostname change + // fmt.Println("--- CHANGE HOSTNAME TRIGGERED ---") + // for _, twin := range r.rtdt_twins { + // if twin == nil { + // fmt.Println("Encountered nil twin, skipping") + // continue + // } + // fmt.Println("ENTERING SETGNMIPATH, value: ", value, "path:", path) + // err = twin.SetGnmiPath(path, value, twinEntityID, r.benchmark0) + // if err != nil { + // fmt.Println("Callback failed:", err) + // return + // } + // } + // // Interface UP/Down + // } else if regexMatch != nil && len(r.rtdt_twins) > 0 { + // + // fmt.Println("Setting interface", regexMatch[1], "UP/DOWN") + // fmt.Printf("match: %v\n", regexMatch) + // path := "/interfaces/interface[name=" + regexMatch[1] + "]/config/enabled" + // if value == "DOWN" { + // value = "false" + // } else { + // value = "true" + // } + // twin.SetGnmiPath(path, value, twinEntityID, false) + // // CATCHALL + // } else { + // twin.SetGnmiPath(path, value, twinEntityID, false) + // } } twin.SyncBack = true } diff --git a/applications/rtdt-manager/venv/venv.go b/applications/rtdt-manager/venv/venv.go index e035991588b6d4f32d07bf876cdc88326a434454..b0373a382965313aa147bcd0fe7e0363df294b8a 100644 --- a/applications/rtdt-manager/venv/venv.go +++ b/applications/rtdt-manager/venv/venv.go @@ -27,6 +27,7 @@ import ( gnmitargetygot "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/yang" uuid "github.com/google/uuid" gnmi "github.com/openconfig/gnmi/proto/gnmi" + "github.com/openconfig/goyang/pkg/yang" "github.com/openconfig/ygot/ygot" "github.com/openconfig/ygot/ytypes" "google.golang.org/grpc" @@ -48,6 +49,7 @@ type VEnv struct { // This is an ugly way of temporarily ignoring events to avoid e.g. infinite sync loops: SyncBack bool EventSystemStarted bool + RootSchema *yang.Entry } // Accepts a yaml filename to deploy a container lab environment @@ -112,6 +114,8 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi fmt.Printf("[%s] - Couldn't retrieve PND, retrying in 2 seconds..\n", name) time.Sleep(time.Second * 2) } + // Put the schema here because it will be needed on every sync + schema, _ := gnmitargetygot.Schema() // load topo into DB via API return &VEnv{ @@ -124,6 +128,7 @@ func NewVEnv(name, clabFilename, user, pass string, wg *sync.WaitGroup, sdnConfi sdnConfig: sdnConfig, containerRegistryURL: "registry.code.fbi.h-da.de/danet/gnmi-target/debian:interface-enabled-test", // TODO: Could let user choose SyncBack: false, + RootSchema: schema.RootSchema(), } } @@ -317,9 +322,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { return fmt.Errorf("Encountered error while trying to parse string path into gnmi path: %w", err) } //ytypes.GetOrCreateNode(gnmitargetygot.Schema(), ,gnmiPath) - schema, nil := gnmitargetygot.Schema() - rootSchema := schema.RootSchema() - _, entry, err := ytypes.GetOrCreateNode(rootSchema, &gnmitargetygot.Gnmitarget{}, gnmiPath) + _, entry, err := ytypes.GetOrCreateNode(v.RootSchema, &gnmitargetygot.Gnmitarget{}, gnmiPath) if err != nil { return fmt.Errorf("SetGnnmiPath Error: %w", err) } @@ -341,7 +344,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { pid := v.pnd.Id if save { - benchmark.Current.SendChangeRequest = time.Now() + benchmark.Current.RmSendPathRequest = time.Now() } setPathListReq := &networkelement.SetPathListRequest{ Timestamp: util.Now(), @@ -350,7 +353,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { } setPathResponse, err := mneService.SetPathList(ctx, setPathListReq) if save { - benchmark.Current.ReceiveChangeResponse = time.Now() // TOA of response + benchmark.Current.RmReceivePathResponse = time.Now() // TOA of response } if err != nil { fmt.Printf("Error: %v\n", err) @@ -371,7 +374,7 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { } clResponse, err := mneService.SetChangeList(ctx, &setChangeListRequest) if save { - benchmark.Current.ReceiveCommitResponse = time.Now() + benchmark.Current.RmReceiveCommitResponse = time.Now() } if err != nil { fmt.Println("Error, failed to commit changes:", err) @@ -381,13 +384,13 @@ func (v *VEnv) SetGnmiPath(path, value, mneid string, save bool) error { } if save { - benchmark.Current.SendChangeRequest = time.Unix(0, setPathListReq.Timestamp) // send req in realnet - benchmark.Current.ReceiveChangeRequest = time.Unix(0, setPathResponse.Timestamp) // rcv in twin + benchmark.Current.RmSendPathRequest = time.Unix(0, setPathListReq.Timestamp) // send req in realnet + benchmark.Current.CtlSendPathResponse = time.Unix(0, setPathResponse.Timestamp) // rcv in twin - benchmark.Current.SendCommitRequest = time.Unix(0, setChangeListRequest.Timestamp) - benchmark.Current.ReceiveCommitResponse = time.Unix(0, clResponse.Timestamp) + benchmark.Current.RmSendCommitRequest = time.Unix(0, setChangeListRequest.Timestamp) + benchmark.Current.CtlSendCommitResponse = time.Unix(0, clResponse.Timestamp) - benchmark.Current.PropagationDelay = benchmark.Current.ReceiveCommitResponse.Sub(benchmark.Current.StartTimeRealnet) + benchmark.Current.PropagationDelay = benchmark.Current.RmReceiveCommitResponse.Sub(benchmark.Current.StartTimeRealnet) fmt.Println("---Measurement finished---") benchmark.Current.Print()