Skip to content

Commit b27cde4

Browse files
committed
adjusted model network graph weights for default zones & net locations + fixe net char mgr UT issues
1 parent 1072a8d commit b27cde4

File tree

6 files changed

+52
-24
lines changed

6 files changed

+52
-24
lines changed

go-packages/meep-model/model.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,35 +461,35 @@ func (m *Model) parseNodes() (err error) {
461461
domain := &m.scenario.Deployment.Domains[iDomain]
462462
ctx := NewNodeContext(m.scenario.Name, domain.Name, "", "", "")
463463
m.nodeMap.AddNode(NewNode(domain.Name, domain.Type_, domain, &domain.Zones, m.scenario.Deployment, ctx))
464-
m.networkGraph.AddNode(domain.Name, "")
464+
m.networkGraph.AddNode(domain.Name, "", false)
465465

466466
// Zones
467467
for iZone := range domain.Zones {
468468
zone := &domain.Zones[iZone]
469469
ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, "", "")
470470
m.nodeMap.AddNode(NewNode(zone.Name, zone.Type_, zone, &zone.NetworkLocations, domain, ctx))
471-
m.networkGraph.AddNode(zone.Name, domain.Name)
471+
m.networkGraph.AddNode(zone.Name, domain.Name, isDefaultZone(zone.Type_))
472472

473473
// Network Locations
474474
for iNL := range zone.NetworkLocations {
475475
nl := &zone.NetworkLocations[iNL]
476476
ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, nl.Name, "")
477477
m.nodeMap.AddNode(NewNode(nl.Name, nl.Type_, nl, &nl.PhysicalLocations, zone, ctx))
478-
m.networkGraph.AddNode(nl.Name, zone.Name)
478+
m.networkGraph.AddNode(nl.Name, zone.Name, isDefaultNetLoc(nl.Type_))
479479

480480
// Physical Locations
481481
for iPL := range nl.PhysicalLocations {
482482
pl := &nl.PhysicalLocations[iPL]
483483
ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, nl.Name, pl.Name)
484484
m.nodeMap.AddNode(NewNode(pl.Name, pl.Type_, pl, &pl.Processes, nl, ctx))
485-
m.networkGraph.AddNode(pl.Name, nl.Name)
485+
m.networkGraph.AddNode(pl.Name, nl.Name, false)
486486

487487
// Processes
488488
for iProc := range pl.Processes {
489489
proc := &pl.Processes[iProc]
490490
ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, nl.Name, pl.Name)
491491
m.nodeMap.AddNode(NewNode(proc.Name, proc.Type_, proc, nil, pl, ctx))
492-
m.networkGraph.AddNode(proc.Name, pl.Name)
492+
m.networkGraph.AddNode(proc.Name, pl.Name, false)
493493

494494
// Update service map for external processes
495495
if proc.IsExternal {
@@ -655,3 +655,17 @@ func (m *Model) internalListener(channel string, payload string) {
655655
// external listener
656656
m.listener(channel, payload)
657657
}
658+
659+
func isDefaultZone(typ string) bool {
660+
if typ == "COMMON" {
661+
return true
662+
}
663+
return false
664+
}
665+
666+
func isDefaultNetLoc(typ string) bool {
667+
if typ == "DEFAULT" {
668+
return true
669+
}
670+
return false
671+
}

go-packages/meep-model/networkGraph.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ func NewNetworkGraph() (ng *NetworkGraph) {
3030
return ng
3131
}
3232

33-
func (ng *NetworkGraph) AddNode(node string, parent string) {
33+
func (ng *NetworkGraph) AddNode(node string, parent string, zeroDist bool) {
3434
ng.graph.AddMappedVertex(node)
3535
if parent != "" {
36-
_ = ng.graph.AddMappedArc(parent, node, 1)
37-
_ = ng.graph.AddMappedArc(node, parent, 1)
36+
var distance int64 = 0
37+
if !zeroDist {
38+
distance = 1
39+
}
40+
_ = ng.graph.AddMappedArc(parent, node, distance)
41+
_ = ng.graph.AddMappedArc(node, parent, distance)
3842
}
3943
}

go-packages/meep-net-char-mgr/algo-segment.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,12 @@ func getNetChars(elemName string, model *mod.Model) (nc NetChar) {
10171017
jitter = float64(nl.TerminalLinkLatencyVariation)
10181018
packetLoss = float64(nl.TerminalLinkPacketLoss)
10191019
} else if zone, ok := node.(*ceModel.Zone); ok {
1020-
maxThroughput = float64(zone.NetChar.Throughput)
1021-
latency = float64(zone.NetChar.Latency)
1022-
jitter = float64(zone.NetChar.LatencyVariation)
1023-
packetLoss = float64(zone.NetChar.PacketLoss)
1020+
if zone.NetChar != nil {
1021+
maxThroughput = float64(zone.NetChar.Throughput)
1022+
latency = float64(zone.NetChar.Latency)
1023+
jitter = float64(zone.NetChar.LatencyVariation)
1024+
packetLoss = float64(zone.NetChar.PacketLoss)
1025+
}
10241026
} else if domain, ok := node.(*ceModel.Domain); ok {
10251027
maxThroughput = float64(domain.InterZoneThroughput)
10261028
latency = float64(domain.InterZoneLatency)
@@ -1113,8 +1115,8 @@ func printPath(path *SegAlgoPath) string {
11131115
return str
11141116
}
11151117

1116-
// printElement -
1117-
func printElement(elem *SegAlgoNetElem) string {
1118-
str := elem.Name + "-" + elem.Type + "-" + elem.PhyLocName + "-" + elem.PoaName + "-" + elem.ZoneName + "-" + elem.DomainName
1119-
return str
1120-
}
1118+
// // printElement -
1119+
// func printElement(elem *SegAlgoNetElem) string {
1120+
// str := elem.Name + "-" + elem.Type + "-" + elem.PhyLocName + "-" + elem.PoaName + "-" + elem.ZoneName + "-" + elem.DomainName
1121+
// return str
1122+
// }

go-packages/meep-net-char-mgr/net-char-mgr.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ func (ncm *NetCharManager) Register(netCharUpdateCb NetCharUpdateCb, updateCompl
155155
func (ncm *NetCharManager) Start() error {
156156
if !ncm.isStarted {
157157
ncm.isStarted = true
158+
159+
// Process current controls
158160
ncm.updateControls()
159161

160162
// Process current scenario
@@ -164,11 +166,11 @@ func (ncm *NetCharManager) Start() error {
164166
ncm.ticker = time.NewTicker(time.Duration(ncm.config.RecalculationPeriod) * time.Millisecond)
165167
go func() {
166168
for range ncm.ticker.C {
169+
ncm.mutex.Lock()
167170
if ncm.isStarted {
168-
ncm.mutex.Lock()
169171
ncm.updateNetChars()
170-
ncm.mutex.Unlock()
171172
}
173+
ncm.mutex.Unlock()
172174
}
173175
}()
174176
log.Debug("Network Characteristics Manager started: ", ncm.name)
@@ -213,6 +215,7 @@ func (ncm *NetCharManager) processActiveScenarioUpdate() {
213215
err := ncm.algo.ProcessScenario(ncm.activeModel)
214216
if err != nil {
215217
log.Error("Failed to process active model with error: ", err)
218+
ncm.mutex.Unlock()
216219
return
217220
}
218221

@@ -230,9 +233,13 @@ func (ncm *NetCharManager) updateNetChars() {
230233
// Apply updates, if any
231234
if len(updatedNetCharList) != 0 {
232235
for _, flowNetChar := range updatedNetCharList {
233-
ncm.netCharUpdateCb(flowNetChar.DstElemName, flowNetChar.SrcElemName, flowNetChar.MyNetChar.Throughput, flowNetChar.MyNetChar.Latency, flowNetChar.MyNetChar.Jitter, flowNetChar.MyNetChar.PacketLoss)
236+
if ncm.netCharUpdateCb != nil {
237+
ncm.netCharUpdateCb(flowNetChar.DstElemName, flowNetChar.SrcElemName, flowNetChar.MyNetChar.Throughput, flowNetChar.MyNetChar.Latency, flowNetChar.MyNetChar.Jitter, flowNetChar.MyNetChar.PacketLoss)
238+
}
239+
}
240+
if ncm.updateCompleteCb != nil {
241+
ncm.updateCompleteCb()
234242
}
235-
ncm.updateCompleteCb()
236243
}
237244
}
238245

go-packages/meep-net-char-mgr/net-char-mgr_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package netchar
1919
import (
2020
"fmt"
2121
"testing"
22+
"time"
2223

2324
log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
2425
)
@@ -64,8 +65,8 @@ func TestNetCharBasic(t *testing.T) {
6465
t.Errorf("NetChar not running")
6566
}
6667

67-
// fmt.Println("Run NetChar for 1 second")
68-
// time.Sleep(1000 * time.Millisecond)
68+
fmt.Println("Run NetChar for 100 ms")
69+
time.Sleep(100 * time.Millisecond)
6970

7071
fmt.Println("Stop NetCharMgr")
7172
netCharMgr.Stop()

test/run-ut.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ echo ""
1919
for pkg in "${GOPKGS[@]}" ; do
2020
echo "+ pkg: $pkg"
2121
cd $BASEDIR/../go-packages/$pkg
22-
go test ./...
22+
go test -count=1 ./...
2323
echo ""
2424
done

0 commit comments

Comments
 (0)