-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestingVNF.py
More file actions
93 lines (65 loc) · 3.01 KB
/
TestingVNF.py
File metadata and controls
93 lines (65 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import AlgorithmOne as algoOne
import AlgorithmTwo as algoTwo
import AlgorithmThree as algoThree
from graph_tool.all import *
import random
import TotalNetwork as tn
import matplotlib.pyplot as plt
import RAN_Slice as ran
# (1) No. of vnf vs No. of succesfull mappings
def testParameters(algoType, subsNetwork, rnSlices, intervalFactor = tn.intervalFactor, iterations = tn.iterCount):
noVnf = tn.numVnfFunctions
substrateNetwork = subsNetwork
ranSlices = rnSlices
xOne = []
yOne = []
yTwoUnsuccMappings = []
yThreeResourceAvail = []
yFourResourceExhuast = []
totalNetwork = tn.createTotalNetwork(substrateNetwork, ranSlices)
for ctrVar in range(iterations):
out = "Graph-Figures/debugVnf" + str(algoType) + str(ctrVar) +".png"
graph_draw(totalNetwork, vertex_text = totalNetwork.vp.get("resources"), bg_color=[1,1,1,1], output_size = (3840,2160), output=out)
if algoType == 1:
numMappings = tn.algoOneTest(totalNetwork)
elif algoType == 2:
numMappings = tn.algoTwoTest(totalNetwork)
elif algoType == 3:
numMappings = tn.algoThreeTest(totalNetwork)
elif algoType == 4:
numMappings = tn.algoFourTest(totalNetwork)
xOne.append(noVnf)
if len(yOne) == 0:
yOne.append(numMappings)
else:
yOne.append(numMappings + yOne[-1])
yTwoUnsuccMappings.append(noVnf - yOne[-1])
yThreeResourceAvail.append(tn.sbsAvailableRes(totalNetwork))
yFourResourceExhuast.append(tn.numSubsNodes*tn.resCtPerSbs - yThreeResourceAvail[-1])
addVnf(ranSlices, intervalFactor, totalNetwork=totalNetwork)
tn.updateVnfMapVar(totalNetwork, ranSlices)
noVnf += intervalFactor
returnData = [xOne, yOne, yTwoUnsuccMappings, yThreeResourceAvail, yFourResourceExhuast]
return returnData;
def addVnf(ranSlices, numVnfs, totalNetwork=0, connectivity = tn.vnfDegree):
vertices = []
ranSliceNodes = []
for node in totalNetwork.vertices():
if totalNetwork.vp.binaryMappingVar[node] != -1:
ranSliceNodes.append(node)
for manyNodes in range(numVnfs):
vertices.append(totalNetwork.add_vertex())
graph_draw(ranSlices, output = "Graph-Figures/Adding-Three.png", vertex_text = ranSlices.vp.get("resources"))
for newNode in vertices:
toMapVnf = 0
for numConnections in range(connectivity):
while True:
toMapVnf = random.choice(ranSliceNodes)
if toMapVnf not in newNode.all_neighbors() and toMapVnf != newNode:
break
else:
continue
totalNetwork.add_edge(newNode, toMapVnf)
ranSliceNodes.append(newNode)
ran.setVNFFunctionProperties(totalNetwork, tn.resList, vnfList=vertices)
graph_draw(ranSlices, output = "Graph-Figures/Adding-Four.png", vertex_text = ranSlices.vp.get("resources"))