Unverified Commit a4abd269 authored by Kevin Di Lallo's avatar Kevin Di Lallo Committed by GitHub
Browse files

Merge pull request #47 from pastorsx/sp32_fix_bws_mob_event

Net Char Manager segment algorithm fix to handle Mobility events
parents c0d66263 50485b0a
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ type SegAlgoFlow struct {
	CurrentThroughput             float64 //measured
	CurrentThroughputEgress       float64 //measured
	Path                          *SegAlgoPath
	UpdateRequired                bool
}

// SegAlgoPath -
@@ -403,7 +404,27 @@ func (algo *SegmentAlgorithm) populateFlow(flowName string, srcElement *SegAlgoN
	flow.ConfiguredNetChar.Jitter = 0
	flow.ConfiguredNetChar.PacketLoss = 0
	// Create a new path for this flow
	oldPath := flow.Path
	flow.Path = algo.createPath(flowName, srcElement, destElement, model)
	flow.UpdateRequired = algo.comparePath(oldPath, flow.Path)
}

func (algo *SegmentAlgorithm) comparePath(oldPath *SegAlgoPath, newPath *SegAlgoPath) bool {

	if oldPath == nil {
		return true
	}

	if len(oldPath.Segments) != len(newPath.Segments) {
		return true
	}

	for index, newSegment := range newPath.Segments {
		if newSegment.Name != oldPath.Segments[index].Name {
			return true
		}
	}
	return false
}

// createPath -
@@ -714,6 +735,7 @@ func (algo *SegmentAlgorithm) createSegment(segmentName string, flowName string,
		// Retrieve max throughput from model using model scenario element name
		nc := getNetChars(elemName, model)
		segment.ConfiguredNetChar = nc

		maxThroughput := nc.Throughput
		// Initialize segment-specific BW attributes from Algo config
		if algo.Config.IsPercentage {
@@ -938,8 +960,7 @@ func needToReevaluate(segment *SegAlgoSegment) (unusedBw float64, list []*SegAlg

	//how many active connections that needs to be taken into account
	for _, flow := range segment.Flows {
		if flow.CurrentThroughput < flow.AllocatedThroughputLowerBound || flow.CurrentThroughput > flow.AllocatedThroughputUpperBound || flow.CurrentThroughput >= segment.MaxFairShareBwPerFlow {
			//			resetFlowMaxPlannedThroughput(flow)
		if flow.CurrentThroughput < flow.AllocatedThroughputLowerBound || flow.CurrentThroughput > flow.AllocatedThroughputUpperBound || flow.CurrentThroughput >= segment.MaxFairShareBwPerFlow || flow.UpdateRequired {
			list = append(list, flow)
		} else {
			//no need to reevalute algo one, so removing its allocated bw from the available one
+6 −6
Original line number Diff line number Diff line
@@ -91,8 +91,8 @@ func TestSegAlgoSegmentation(t *testing.T) {
	// Validate algorithm Calculations
	fmt.Println("Test algo calculation with some flows updated with metrics")
	updatedNetCharList = algo.CalculateNetChar()
	if len(updatedNetCharList) != 58 {
		t.Errorf("Updated net char list not partially filled")
	if len(updatedNetCharList) != 90 {
		t.Errorf("Updated net char list not fully filled")
	}

	fmt.Println("Test algo calculation without changes in metrics")
@@ -251,8 +251,8 @@ func TestSegAlgoCalculation(t *testing.T) {
	// Validate algorithm Calculations
	fmt.Println("Test algorithm calculations with & without metrics")
	updatedNetCharList := algo.CalculateNetChar()
	if len(updatedNetCharList) != 58 {
		t.Errorf("Updated net char list not filled properly")
	if len(updatedNetCharList) != 90 {
		t.Errorf("Updated net char list not fully filled")
	}

	// Update metrics & recalculate
@@ -335,7 +335,7 @@ func TestSegAlgoCalculation(t *testing.T) {
		t.Errorf("Error updating metrics")
	}
	updatedNetCharList = algo.CalculateNetChar()
	if len(updatedNetCharList) != 15 {
	if len(updatedNetCharList) != 19 {
		t.Errorf("Invalid net char update list")
	}
	if !validateNetCharUpdate(updatedNetCharList, "zone1-fog1-iperf", "ue1-iperf", 41, 9, 0, 10) {
@@ -394,7 +394,7 @@ func TestSegAlgoCalculation(t *testing.T) {
		t.Errorf("Error updating metrics")
	}
	updatedNetCharList = algo.CalculateNetChar()
	if len(updatedNetCharList) != 15 {
	if len(updatedNetCharList) != 19 {
		t.Errorf("Invalid net char update list")
	}
	if !validateNetCharUpdate(updatedNetCharList, "zone2-edge1-iperf", "ue1-iperf", 41, 9, 0, 23) {