-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRAN_Slice.py
More file actions
93 lines (69 loc) · 3.83 KB
/
RAN_Slice.py
File metadata and controls
93 lines (69 loc) · 3.83 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 Statements
from graph_tool.all import *
import math
import random
from matplotlib import pyplot as plt
import TotalNetwork as tn
# Function defined to create an RAN Slice
def setRANSliceProperties(ranSlices):
# Creating Properties for the RAN Slices
# --------------------------------------
graphProp = ranSlices.new_vertex_property("string")
ranSlices.vp.graphName = graphProp
# Giving the VNF Functions a Resource Capacity Property
resourceCapacityProp = ranSlices.new_vertex_property("int")
ranSlices.vertex_properties.resourceCapacity = resourceCapacityProp
# Giving the VNF Functions a Resource Property
resourceProp = ranSlices.new_vertex_property("int")
ranSlices.vertex_properties.resources = resourceProp
# Giving the VNF Functions a Bandwidth Property
capacityProp = ranSlices.new_edge_property("int")
ranSlices.edge_properties.bandwidth = capacityProp
# Giving the Substrate Vertices a Resource Capacity Property
binaryMappingVar = ranSlices.new_vertex_property("int")
ranSlices.vertex_properties.binaryMappingVar = binaryMappingVar
totalResource = ranSlices.new_vertex_property("int")
ranSlices.vertex_properties.totalResourcesAcc = totalResource
vertexDegree = ranSlices.new_vertex_property("int")
ranSlices.vertex_properties.degree = vertexDegree
# Function to Set the Properties for the VNF Functions
def setVNFFunctionProperties(ranSlices, resList, sliceNumber = 1, vnfList = [], band = 2):
loopIter = 0
if vnfList:
# Setting up the Vertex Properties
for vnfFunction in vnfList:
ranSlices.vp.graphName[vnfFunction] = "RAN" + str(sliceNumber)
ranSlices.vertex_properties.resourceCapacity[vnfFunction] = -1
ranSlices.vertex_properties.resources[vnfFunction] = tn.resCtPerVnf + tn.randUpBoundVnf
ranSlices.vertex_properties.binaryMappingVar[vnfFunction] = 0
ranSlices.vertex_properties.degree[vnfFunction] = len(ranSlices.get_all_neighbors(vnfFunction))
loopIter += 1
# Setting up the totalResources per vertex
for vnfFunction in vnfList:
resAcc = ranSlices.vp.resources[vnfFunction]
for vnfFunctionNeighbor in vnfFunction.all_neighbors():
resAcc += ranSlices.vp.resources[vnfFunctionNeighbor]
ranSlices.vp.totalResourcesAcc[vnfFunction] = resAcc
new_edges = find_edge(ranSlices, ranSlices.ep.bandwidth, 0)
# Setting uy the Edge Properties
for vnfEdge in new_edges:
if ranSlices.vp.binaryMappingVar[vnfEdge.source()] != 1 and ranSlices.vp.binaryMappingVar[vnfEdge.target()] != 1:
ranSlices.edge_properties.bandwidth[vnfEdge] = band
else:
# Setting up the Vertex Properties
for vnfFunction in ranSlices.vertices():
ranSlices.vp.graphName[vnfFunction] = "RAN" + str(sliceNumber)
ranSlices.vertex_properties.resourceCapacity[vnfFunction] = -1
ranSlices.vertex_properties.resources[vnfFunction] = resList[loopIter]
ranSlices.vertex_properties.binaryMappingVar[vnfFunction] = 0
ranSlices.vertex_properties.degree[vnfFunction] = len(ranSlices.get_all_neighbors(vnfFunction))
loopIter += 1
# Setting up the totalResources per vertex
for vnfFunction in ranSlices.vertices():
resAcc = ranSlices.vp.resources[vnfFunction]
for vnfFunctionNeighbor in vnfFunction.all_neighbors():
resAcc += ranSlices.vp.resources[vnfFunctionNeighbor]
ranSlices.vp.totalResourcesAcc[vnfFunction] = resAcc
# Setting uy the Edge Properties
for vnfEdge in ranSlices.edges():
ranSlices.edge_properties.bandwidth[vnfEdge] = band