diff --git a/src/opticalcontroller/Dockerfile b/src/opticalcontroller/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c3d886ab56ecf42cd2ffb96b32ef59b89f2c1207 --- /dev/null +++ b/src/opticalcontroller/Dockerfile @@ -0,0 +1,79 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM python:3.9-slim + +# Install dependencies +RUN apt-get --yes --quiet --quiet update && \ + apt-get --yes --quiet --quiet install wget g++ && \ + rm -rf /var/lib/apt/lists/* + +# Set Python to show logs as they occur +ENV PYTHONUNBUFFERED=0 + +# Download the gRPC health probe +# RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \ +# wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ +# chmod +x /bin/grpc_health_probe + + + + +# Get generic Python packages +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install --upgrade setuptools wheel +RUN python3 -m pip install --upgrade pip-tools + + + +COPY common_requirements.in common_requirements.in +RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in +RUN python3 -m pip install -r common_requirements.txt + +RUN mkdir -p /var/teraflow/opticalcontroller + +WORKDIR /var/teraflow/opticalcontroller/common +COPY src/common/. ./ +RUN rm -rf proto + + +# Create proto sub-folder, copy .proto files, and generate Python code +RUN mkdir -p /var/teraflow/opticalcontroller/common/proto +WORKDIR /var/teraflow/opticalcontroller/common/proto +RUN touch __init__.py +COPY proto/*.proto ./ +RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto +RUN rm *.proto +RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; + +# Create component sub-folder, get specific Python packages + + + +WORKDIR /var/teraflow/opticalcontroller +COPY src/opticalcontroller/requirements.in requirements.in +RUN pip-compile --quiet --output-file=requirements.txt requirements.in +RUN python3 -m pip install -r requirements.txt + +# Add component files into working directory +WORKDIR /var/teraflow/ + +COPY src/context/. context/ + +COPY src/opticalcontroller/. opticalcontroller/ +COPY src/context/. opticalcontroller/context/ + +# Start the service +WORKDIR /var/teraflow/opticalcontroller +ENTRYPOINT ["python", "OpticalController.py"] diff --git a/src/opticalcontroller/OpticalController.py b/src/opticalcontroller/OpticalController.py new file mode 100644 index 0000000000000000000000000000000000000000..e8e0e2164a81f6ea621decba92350b04cdcba814 --- /dev/null +++ b/src/opticalcontroller/OpticalController.py @@ -0,0 +1,246 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from flask import Flask +from flask import render_template +from flask_restplus import Resource, Api + +from tools import * +from variables import * +from RSA import RSA +import time +import logging + + +rsa = None +LOGGER = logging.getLogger(__name__) + +app = Flask(__name__) +api = Api(app, version='1.0', title='Optical controller API', + description='Rest API to configure OC Optical devices in TFS') +# app.config.from_object('config') +# appbuilder = AppBuilder(app, indexview=MyIndexView) +optical = api.namespace('OpticalTFS', description='TFS Optical APIs') + + +@app.route('/index') +def index(): + return render_template('index.html') + + +#@optical.route('/AddLightpath////') +@optical.route('/AddLightpath///') +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class AddLightpath(Resource): + @staticmethod + def put(src, dst, bitrate, bidir=1): + + LOGGER.info("INFO: New Lightpath request from {} to {} with rate {} ".format(src, dst, bitrate)) + t0 = time.time()*1000.0 + if debug: + rsa.g.printGraph() + + if rsa is not None: + flow_id = rsa.rsa_computation(src, dst, bitrate, bidir) + if rsa.db_flows[flow_id]["op-mode"] == 0: + return 'No path found', 404 + t1 = time.time()*1000.0 + elapsed = t1 - t0 + LOGGER.info("INFO: time elapsed = {} ms".format(elapsed)) + return rsa.db_flows[flow_id], 200 + else: + return "Error", 404 + + +#@optical.route('/AddFlexLightpath///') +@optical.route('/AddFlexLightpath///', + defaults={"bidir": 1, "band": None}) +@optical.route('/AddFlexLightpath////', + defaults={"band": None}) +@optical.route('/AddFlexLightpath/////',) +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class AddFlexLightpath(Resource): + @staticmethod + def put(src, dst, bitrate,bidir=1, band=None): + + print("INFO: New FlexLightpath request from {} to {} with rate {} ".format(src, dst, bitrate)) + LOGGER.info("INFO: New FlexLightpath request from {} to {} with rate {} ".format(src, dst, bitrate)) + t0 = time.time()*1000.0 + if debug: + rsa.g.printGraph() + + if rsa is not None: + flow_id, optical_band_id = rsa.rsa_fs_computation(src, dst, bitrate, bidir, band) + print (f"flow_id {flow_id} and optical_band_id {optical_band_id} ") + if flow_id is not None: + if rsa.db_flows[flow_id]["op-mode"] == 0: + return 'No path found', 404 + t1 = time.time() * 1000.0 + elapsed = t1 - t0 + print("INFO: time elapsed = {} ms".format(elapsed)) + + return rsa.db_flows[flow_id], 200 + else: + if len(rsa.optical_bands[optical_band_id]["flows"]) == 0: + return 'No path found', 404 + else: + t1 = time.time() * 1000.0 + elapsed = t1 - t0 + LOGGER.info("INFO: time elapsed = {} ms".format(elapsed)) + + return rsa.optical_bands[optical_band_id], 200 + else: + return "Error", 404 + +@optical.route('/DelFlexLightpath/////') +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class DelLightpath(Resource): + @staticmethod + def delete(flow_id, src, dst, bitrate, o_band_id): + if flow_id in rsa.db_flows.keys(): + flow = rsa.db_flows[flow_id] + bidir = flow["bidir"] + match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"] == bitrate + if bidir: + match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] == bitrate + if match1 or match2: + ob_id = flow["parent_opt_band"] + rsa.del_flow(flow, ob_id) + rsa.db_flows[flow_id]["is_active"] = False + rsa.optical_bands[ob_id]["served_lightpaths"].remove(flow_id) + if rsa.optical_bands[ob_id]["reverse_optical_band_id"] != 0: + rev_ob_id = rsa.optical_bands[ob_id]["reverse_optical_band_id"] + rsa.optical_bands[rev_ob_id]["served_lightpaths"].remove(flow_id) + + if debug: + LOGGER.info(links_dict) + return "flow {} deleted".format(flow_id), 200 + else: + return "flow {} not matching".format(flow_id), 404 + else: + if match1: + ob_id = flow["parent_opt_band"] + rsa.del_flow(flow, ob_id) + rsa.db_flows[flow_id]["is_active"] = False + rsa.optical_bands[ob_id]["served_lightpaths"].remove(flow_id) + if debug: + LOGGER.info(links_dict) + return "flow {} deleted".format(flow_id), 200 + else: + return "flow {} not matching".format(flow_id), 404 + else: + return "flow id {} does not exist".format(flow_id), 404 + + + +@optical.route('/DelLightpath////') +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class DelLightpath(Resource): + @staticmethod + def delete(flow_id, src, dst, bitrate): + if flow_id in rsa.db_flows.keys(): + flow = rsa.db_flows[flow_id] + match1 = flow["src"] == src and flow["dst"] == dst and flow["bitrate"] == bitrate + match2 = flow["src"] == dst and flow["dst"] == src and flow["bitrate"] == bitrate + if match1 or match2: + rsa.del_flow(flow) + rsa.db_flows[flow_id]["is_active"] = False + if debug: + LOGGER.info(links_dict) + return "flow {} deleted".format(flow_id), 200 + else: + return "flow {} not matching".format(flow_id), 404 + else: + return "flow id {} does not exist".format(flow_id), 404 + + +@optical.route('/GetLightpaths') +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class GetFlows(Resource): + @staticmethod + def get(): + try: + if debug: + LOGGER.info(rsa.db_flows) + return rsa.db_flows, 200 + except: + return "Error", 404 + +@optical.route('/GetOpticalBands') +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class GetBands(Resource): + @staticmethod + def get(): + print("Getting ") + LOGGER.info("Getting") + try: + if debug: + LOGGER.info(rsa.optical_bands) + return rsa.optical_bands, 200 + except: + return "Error", 404 + + +@optical.route('/GetOpticalBand/') +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class GetBand(Resource): + @staticmethod + def get(ob_id): + for ob_idx in rsa.optical_bands.keys(): + if str(ob_idx) == str(ob_id): + if debug: + LOGGER.info(rsa.optical_bands[ob_id]) + return rsa.optical_bands[ob_idx], 200 + return {}, 404 + + +@optical.route('/GetLinks') +@optical.response(200, 'Success') +@optical.response(404, 'Error, not found') +class GetFlows(Resource): + @staticmethod + def get(): + global links_dict + try: + if debug: + LOGGER.info(links_dict) + return links_dict, 200 + except: + return "Error", 404 + + +if __name__ == '__main__': + + + # Start metrics server + + LOGGER.info('Starting...') + + + + nodes_dict, links_dict = readTopologyData(nodes_json, topology_json) + + topologies,links= getTopology() + print ("topologies{} and devices {}".format(topologies,links)) + rsa = RSA(nodes_dict, links_dict) + LOGGER.info(rsa.init_link_slots(testing)) + + app.run(host='0.0.0.0', port=5022,debug=True) diff --git a/src/opticalcontroller/README.md b/src/opticalcontroller/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5fd94c59e51cbd78dd76a7db0f24aaaec4ebd9db --- /dev/null +++ b/src/opticalcontroller/README.md @@ -0,0 +1,17 @@ +# optical-controller +This a framework to implement the optical controller for the RMSA algorithm. +#create a venv +python -m venv venv + +in linux +source venv/Scripts/activate + +in windows +venv\Scripts\activate + +pip install -r requirements_opt.txt + +python OpticalController.py +![Reference Architecture](images/topo.png) + + diff --git a/src/opticalcontroller/RSA.py b/src/opticalcontroller/RSA.py new file mode 100644 index 0000000000000000000000000000000000000000..acf080d7f9c223766409551051b7cacae1610db1 --- /dev/null +++ b/src/opticalcontroller/RSA.py @@ -0,0 +1,927 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import dijsktra +from tools import * +from variables import * + + +class RSA(): + def __init__(self, nodes, links): + self.nodes_dict = nodes + self.links_dict = links + self.g = None + + self.flow_id = 0 + self.opt_band_id = 0 + self.db_flows = {} + self.initGraph() + self.c_slot_number = 0 + self.l_slot_number = 0 + self.s_slot_number = 0 + self.optical_bands = {} + + def init_link_slots(self, testing): + if not testing: + for l in self.links_dict["links"]: + for fib in l["optical_link"]["details"]["fibers"]: + #fib = self.links_dict[l]["fibers"][f] + if len(fib["c_slots"]) > 0: + fib["c_slots"] = list(range(0, Nc)) + if len(fib["l_slots"]) > 0: + fib["l_slots"] = list(range(0, Nl)) + if len(fib["s_slots"]) > 0: + fib["s_slots"] = list(range(0, Ns)) + if debug: + print(fib) + for l1 in self.links_dict["links"]: + + for fib1 in l1["optical_link"]["details"]["fibers"]: + #fib1 = self.links_dict[l1]["details"]["fibers"][f1] + + self.c_slot_number = len(fib1["c_slots"]) + self.l_slot_number = len(fib1["l_slots"]) + self.s_slot_number = len(fib1["s_slots"]) + + break + break + return "{},{},{}".format(self.c_slot_number, self.l_slot_number, self.s_slot_number) + + def initGraph(self): + self.g = dijsktra.Graph() + for n in self.nodes_dict: + self.g.add_vertex(n) + for l in self.links_dict["links"]: + if debug: + print(l) + [s, d] = l["optical_link"]["name"].split('-') + ps = l["optical_link"]["details"]["source"] + pd = l["optical_link"]["details"]["target"] + self.g.add_edge(s, d, ps, pd, 1) + + print("INFO: Graph initiated.") + if debug: + self.g.printGraph() + + def compute_path(self, src, dst): + path = dijsktra.shortest_path(self.g, self.g.get_vertex(src), self.g.get_vertex(dst)) + print("INFO: Path from {} to {} with distance: {}".format(src, dst, self.g.get_vertex(dst).get_distance())) + if debug: + print(path) + links = [] + for i in range(0, len(path) - 1): + s = path[i] + if debug: + print(s) + if i < len(path) - 1: + d = path[i + 1] + link_id = "{}-{}".format(s, d) + if debug: + #print(link_id, self.links_dict[link_id]) + print(link_id, self.get_link_by_name(link_id)) + + links.append(link_id) + self.g.reset_graph() + return links, path + + def get_slots(self, links, slots, optical_band_id = None): + + if isinstance(slots, int): + val_c = slots + val_s = slots + val_l = slots + else: + val_c = self.c_slot_number + val_l = self.l_slot_number + val_s = self.s_slot_number + + c_sts = [] + l_sts = [] + s_sts = [] + c_slots = {} + l_slots = {} + s_slots = {} + add = "" + drop = "" + src_1, dst_1 = links[0].split('-') + src_2, dst_2 = links[-1].split('-') + if self.nodes_dict[src_1]["type"] == "OC-TP": + add = links[0] + if self.nodes_dict[dst_2]["type"] == "OC-TP": + drop = links[-1] + + for l in links: + c_slots[l] = [] + l_slots[l] = [] + s_slots[l] = [] + found = 0 + for link in self.links_dict["links"]: + if link["optical_link"]["name"] == l: + #for f in self.links_dict[l]['fibers'].keys(): + for fib in link["optical_link"]["details"]["fibers"]: + if l == add: + if 'used' in fib: + if fib["used"]: + #if debug: + print("WARNING!!!: link {}, fiber {} is already in use".format(l, fib["ID"])) + continue + if l == drop: + if 'used' in fib: + if fib["used"]: + #if debug: + print("WARNING!!!: link {}, fiber {} is already in use".format(l, fib["ID"])) + continue + if len(fib["c_slots"]) > 0: + c_slots[l] = combine(c_slots[l], consecutives(fib["c_slots"], val_c)) + if len(fib["l_slots"]) > 0: + l_slots[l] = combine(l_slots[l], consecutives(fib["l_slots"], val_l)) + if len(fib["s_slots"]) > 0: + s_slots[l] = combine(s_slots[l], consecutives(fib["s_slots"], val_s)) + if debug: + print(l, c_slots[l]) + found = 1 + if found == 0: + return [], [], [] + + keys = list(c_slots.keys()) + if debug: + print(len(keys)) + if debug: + print(keys[0]) + # intersection among the slots over all links + if len(keys) == 1: + c_sts = c_slots[keys[0]] + l_sts = l_slots[keys[0]] + s_sts = s_slots[keys[0]] + else: + for i in range(1, len(keys)): + if debug: + print(keys[i]) + # set a for the intersection + if i == 1: + a_c = c_slots[keys[i - 1]] + a_l = l_slots[keys[i - 1]] + a_s = s_slots[keys[i - 1]] + else: + a_c = c_sts + a_l = l_sts + a_s = s_sts + # set b for the intersection + b_c = c_slots[keys[i]] + b_l = l_slots[keys[i]] + b_s = s_slots[keys[i]] + + c_sts = common_slots(a_c, b_c) + l_sts = common_slots(a_l, b_l) + s_sts = common_slots(a_s, b_s) + if optical_band_id is not None: + if "c_slots" in self.optical_bands[optical_band_id].keys(): + if len(self.optical_bands[optical_band_id]["c_slots"]) > 0: + a_c = c_sts + b_c = self.optical_bands[optical_band_id]["c_slots"] + c_sts = common_slots(a_c, b_c) + else: + c_sts = [] + else: + c_sts = [] + if "l_slots" in self.optical_bands[optical_band_id].keys(): + if len(self.optical_bands[optical_band_id]["l_slots"]) > 0: + a_l = l_sts + b_l = self.optical_bands[optical_band_id]["l_slots"] + l_sts = common_slots(a_l, b_l) + else: + l_sts = [] + else: + l_sts = [] + if "s_slots" in self.optical_bands[optical_band_id].keys(): + if len(self.optical_bands[optical_band_id]["s_slots"]) > 0: + a_s = s_sts + b_s = self.optical_bands[optical_band_id]["s_slots"] + s_sts = common_slots(a_s, b_s) + else: + s_sts = [] + else: + s_sts = [] + + return c_sts, l_sts, s_sts + + def update_link(self, fib, slots, band): + for i in slots: + fib[band].remove(i) + if 'used' in fib: + fib['used'] = True + + def update_optical_band(self, optical_band_id, slots, band): + for i in slots: + self.optical_bands[optical_band_id][band].remove(i) + + def restore_link(self, fib, slots, band): + for i in slots: + fib[band].append(int(i)) + if 'used' in fib: + fib['used'] = False + fib[band].sort() + + def restore_optical_band(self, optical_band_id, slots, band): + for i in slots: + self.optical_bands[optical_band_id][band].append(int(i)) + self.optical_bands[optical_band_id][band].sort() + + def del_flow(self, flow, o_b_id = None): + flows = flow["flows"] + band = flow["band_type"] + slots = flow["slots"] + fiber_f = flow["fiber_forward"] + fiber_b = flow["fiber_backward"] + op = flow["op-mode"] + n_slots = flow["n_slots"] + path = flow["path"] + links = flow["links"] + bidir = flow["bidir"] + + for l in fiber_f.keys(): + if debug: + print(l) + print(fiber_f[l]) + #link = self.links_dict[l] + #f = fiber_f[l] + #fib = link['fibers'][f] + fib = self.get_fiber_details(l, fiber_f[l]) + if not list_in_list(slots, fib[band]): + self.restore_link(fib, slots, band) + if debug: + print(fib[band]) + if o_b_id is not None: + self.restore_optical_band(o_b_id, slots, band) + if bidir: + for rl in fiber_b.keys(): + if debug: + print(rl) + print(fiber_b[rl]) + #rlink = self.links_dict[rl] + #rf = fiber_b[rl] + #rfib = rlink['fibers'][rf] + rfib = self.get_fiber_details(rl, fiber_b[rl]) + if not list_in_list(slots, rfib[band]): + self.restore_link(rfib, slots, band) + if debug: + print(rfib[band]) + #changed according to TFS development + #if o_b_id is not None: + # rev_o_band_id = self.optical_bands[o_b_id]["reverse_optical_band_id"] + # self.restore_optical_band(rev_o_band_id, slots, band) + return True + + def get_fibers_forward(self, links, slots, band): + fiber_list = {} + add = links[0] + drop = links[-1] + print(links) + ''' + for link in self.links_dict["links"]: + if link["optical_link"]["name"] == l: + # for f in self.links_dict[l]['fibers'].keys(): + for fib in link["optical_link"]["details"]["fibers"]: + + ''' + for l in links: + for link in self.links_dict["links"]: + if link["optical_link"]["name"] == l: + for fib in link["optical_link"]["details"]["fibers"]: + #for f in self.links_dict[l]['fibers'].keys(): + #for fib in l["optical_link"]["details"]["fibers"]: + #fib = self.links_dict[l]['fibers'][f] + if l == add: + if 'used' in fib: + if fib["used"]: + if debug: + print("link {}, fiber {} is already in use".format(l, fib["ID"])) + continue + if l == drop: + if 'used' in fib: + if fib["used"]: + if debug: + print("link {}, fiber {} is already in use".format(l, fib["ID"])) + continue + if list_in_list(slots, fib[band]): + fiber_list[l] = fib["ID"] + self.update_link(fib, slots, band) + break + print("INFO: Path forward computation completed") + return fiber_list + + def get_link_by_name (self, key): + for link in self.links_dict["links"]: + if link["optical_link"]["name"] == key: + if debug: + print(link) + return link + + def get_fiber_details(self, link_key, fiber_id): + for link in self.links_dict["links"]: + if link["optical_link"]["name"] == link_key: + if debug: + print(link) + for fib in link["optical_link"]["details"]["fibers"]: + if fib["ID"] == fiber_id: + return fib + return None + + + def get_fibers_backward(self, links, fibers, slots, band): + fiber_list = {} + #r_drop = reverse_link(links[0]) + #r_add = reverse_link(links[-1]) + for l in fibers.keys(): + fib = self.get_fiber_details(l, fibers[l]) + ''' + link = self.get_link_by_name(l) + #port = self.links_dict[l]["fibers"][fibers[l]]["src_port"] + for fib in link["optical_link"]["details"]["fibers"]: + if fib["ID"] == fibers[l]: + ''' + port = fib["src_port"] + r_l = reverse_link(l) + r_link = self.get_link_by_name(r_l) + #for f in r_link["fibers"].keys(): + for r_fib in r_link["optical_link"]["details"]["fibers"]: + if r_fib["remote_peer_port"] == port: + if list_in_list(slots, r_fib[band]): + fiber_list[r_l] = r_fib["ID"] + self.update_link(r_fib, slots, band) + print("INFO: Path backward computation completed") + return fiber_list + + def select_slots_and_ports(self, links, n_slots, c, l, s, bidir): + if debug: + print(self.links_dict) + band, slots = slot_selection(c, l, s, n_slots, self.c_slot_number, self.l_slot_number, self.s_slot_number) + if band is None: + print("No slots available in the three bands") + return None, None, None + if debug: + print(band, slots) + fibers_f = self.get_fibers_forward(links, slots, band) + + fibers_b = [] + if bidir: + fibers_b = self.get_fibers_backward(links, fibers_f, slots, band) + if debug: + print("forward") + print(fibers_f) + print("backward") + print(fibers_b) + add = links[0] + drop = links[-1] + inport = "0" + outport = "0" + r_inport = "0" + r_outport = "0" + t_flows = {} + #if len(links) == 1: + + for lx in fibers_f: + if lx == add: + inport = "0" + r_outport = "0" + if lx == drop: + outport = "0" + r_inport = "0" + f = fibers_f[lx] + src, dst = lx.split("-") + fibx = self.get_fiber_details(lx, f) + #outport = self.links_dict[lx]['fibers'][f]["src_port"] + outport = fibx["src_port"] + + t_flows[src] = {} + t_flows[src]["f"] = {} + t_flows[src]["b"] = {} + t_flows[src]["f"] = {"in": inport, "out": outport} + + if bidir: + #r_inport = self.links_dict[lx]['fibers'][f]["local_peer_port"] + r_inport = fibx["local_peer_port"] + t_flows[src]["b"] = {"in": r_inport, "out": r_outport} + + #inport = self.links_dict[lx]['fibers'][f]["dst_port"] + inport = fibx["dst_port"] + if bidir: + #r_outport = self.links_dict[lx]['fibers'][f]["remote_peer_port"] + r_outport = fibx["remote_peer_port"] + t_flows[dst] = {} + t_flows[dst]["f"] = {} + t_flows[dst]["b"] = {} + t_flows[dst]["f"] = {"in": inport, "out": "0"} + if bidir: + t_flows[dst]["b"] = {"in": "0", "out": r_outport} + + if debug: + print(self.links_dict) + + if debug: + print(t_flows) + print("INFO: Flow matrix computed") + + return t_flows, band, slots, fibers_f, fibers_b + + def select_slots_and_ports_fs(self, links, n_slots, c, l, s, bidir, o_band_id): + if debug: + print(self.links_dict) + band, slots = slot_selection(c, l, s, n_slots, self.c_slot_number, self.l_slot_number, self.s_slot_number) + if band is None: + print("No slots available in the three bands") + return None, None, None, None, None + if debug: + print(band, slots) + fibers_f = self.get_fibers_forward(links, slots, band) + self.update_optical_band(o_band_id, slots, band) + fibers_b = [] + if bidir: + fibers_b = self.get_fibers_backward(links, fibers_f, slots, band) + ''' + + rev_o_band_id = self.optical_bands[o_band_id]["reverse_optical_band_id"] + self.update_optical_band(rev_o_band_id, slots, band) + ''' + if debug: + print("forward") + print(fibers_f) + if bidir: + print("backward") + print(fibers_b) + add = links[0] + drop = links[-1] + port_0 = "0" + + t_flows = {} + + #flows_add_side + f = fibers_f[add] + src, dst = add.split("-") + fibx = self.get_fiber_details(add, f) + #outport = self.links_dict[add]['fibers'][f]["src_port"] + outport = fibx["src_port"] + #T1 rules + t_flows[src] = {} + t_flows[src]["f"] = {} + t_flows[src]["b"] = {} + t_flows[src]["f"] = {"in": port_0, "out": outport} + if bidir: + #r_inport = self.links_dict[add]['fibers'][f]["local_peer_port"] + r_inport = fibx["local_peer_port"] + t_flows[src]["b"] = {"in": r_inport, "out": port_0} + + #R1 rules + t_flows[dst] = {} + t_flows[dst]["f"] = {} + t_flows[dst]["b"] = {} + #inport = self.links_dict[add]['fibers'][f]["dst_port"] + inport = fibx["dst_port"] + opt_band_src_port = self.optical_bands[o_band_id]["src_port"] + t_flows[dst]["f"] = {"in": inport, "out": opt_band_src_port} + #to modify to peer ports + if bidir: + #r_inport = self.links_dict[add]['fibers'][f]["local_peer_port"] + r_inport = fibx["local_peer_port"] + t_flows[src]["b"] = {"in": r_inport, "out": port_0} + if bidir: + rev_opt_band_dst_port = self.optical_bands[o_band_id]["rev_dst_port"] + #r_outport = self.links_dict[add]['fibers'][f]["remote_peer_port"] + r_outport = fibx["remote_peer_port"] + t_flows[dst]["b"] = {"in": rev_opt_band_dst_port, "out": r_outport} + + #flows_drop_side + # R2 rules + f = fibers_f[drop] + src, dst = drop.split("-") + fiby = self.get_fiber_details(drop, f) + #outport = self.links_dict[drop]['fibers'][f]["src_port"] + outport = fiby["src_port"] + + t_flows[src] = {} + t_flows[src]["f"] = {} + t_flows[src]["b"] = {} + opt_band_dst_port = self.optical_bands[o_band_id]["dst_port"] + t_flows[src]["f"] = {"in": opt_band_dst_port, "out": outport} + if bidir: + rev_opt_band_src_port = self.optical_bands[o_band_id]["rev_src_port"] + #r_inport = self.links_dict[drop]['fibers'][f]["local_peer_port"] + r_inport = fiby["local_peer_port"] + t_flows[src]["b"] = {"in": r_inport, "out": rev_opt_band_src_port} + t_flows[dst] = {} + t_flows[dst]["f"] = {} + t_flows[dst]["b"] = {} + #inport = self.links_dict[drop]['fibers'][f]["dst_port"] + inport = fiby["dst_port"] + t_flows[dst]["f"] = {"in": inport, "out": port_0} + if bidir: + #r_inport = self.links_dict[drop]['fibers'][f]["remote_peer_port"] + r_inport = fiby["remote_peer_port"] + t_flows[dst]["b"] = {"in": port_0, "out": r_inport} + + if debug: + print(self.links_dict) + + if debug: + print(t_flows) + print("INFO: Flow matrix computed for Flex Lightpath") + + return t_flows, band, slots, fibers_f, fibers_b + + def rsa_computation(self, src, dst, rate, bidir): + self.flow_id += 1 + self.db_flows[self.flow_id] = {} + self.db_flows[self.flow_id]["flow_id"] = self.flow_id + self.db_flows[self.flow_id]["src"] = src + self.db_flows[self.flow_id]["dst"] = dst + self.db_flows[self.flow_id]["bitrate"] = rate + self.db_flows[self.flow_id]["bidir"] = bidir + + links, path = self.compute_path(src, dst) + + if len(path) < 1: + self.null_values(self.flow_id) + return self.flow_id + op, num_slots = map_rate_to_slot(rate) + c_slots, l_slots, s_slots = self.get_slots(links, num_slots) + if debug: + print(c_slots) + print(l_slots) + print(s_slots) + if len(c_slots) > 0 or len(l_slots) > 0 or len(s_slots) > 0: + flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports(links, num_slots, c_slots, + l_slots, s_slots, bidir) + f0, band = freqency_converter(band_range, slots) + if debug: + print(f0, band) + print("INFO: RSA completed for normal wavelenght connection") + if flow_list is None: + self.null_values(self.flow_id) + return self.flow_id + slots_i = [] + for i in slots: + slots_i.append(int(i)) + # return links, path, flow_list, band_range, slots, fiber_f, fiber_b, op, num_slots, f0, band + # links, path, flows, bx, slots, fiber_f, fiber_b, op, n_slots, f0, band + self.db_flows[self.flow_id]["flows"] = flow_list + self.db_flows[self.flow_id]["band_type"] = band_range + self.db_flows[self.flow_id]["slots"] = slots_i + self.db_flows[self.flow_id]["fiber_forward"] = fiber_f + self.db_flows[self.flow_id]["fiber_backward"] = fiber_b + self.db_flows[self.flow_id]["op-mode"] = op + self.db_flows[self.flow_id]["n_slots"] = num_slots + self.db_flows[self.flow_id]["links"] = links + self.db_flows[self.flow_id]["path"] = path + self.db_flows[self.flow_id]["band"] = band + self.db_flows[self.flow_id]["freq"] = f0 + self.db_flows[self.flow_id]["is_active"] = True + return self.flow_id + + def null_values(self, flow_id): + self.db_flows[flow_id]["flows"] = {} + self.db_flows[flow_id]["band_type"] = "" + self.db_flows[flow_id]["slots"] = [] + self.db_flows[flow_id]["fiber_forward"] = [] + self.db_flows[flow_id]["fiber_backward"] = [] + self.db_flows[flow_id]["op-mode"] = 0 + self.db_flows[flow_id]["n_slots"] = 0 + self.db_flows[flow_id]["links"] = {} + self.db_flows[flow_id]["path"] = [] + self.db_flows[flow_id]["band"] = 0 + self.db_flows[flow_id]["freq"] = 0 + self.db_flows[flow_id]["is_active"] = False + + def null_values_ob(self, ob_id): + self.optical_bands[ob_id]["flows"] = {} + self.optical_bands[ob_id]["band_type"] = "" + #self.optical_bands[ob_id]["slots"] = [] + self.optical_bands[ob_id]["fiber_forward"] = [] + self.optical_bands[ob_id]["n_slots"] = 0 + self.optical_bands[ob_id]["links"] = {} + self.optical_bands[ob_id]["path"] = [] + self.optical_bands[ob_id]["band"] = 0 + self.optical_bands[ob_id]["freq"] = 0 + self.optical_bands[ob_id]["is_active"] = False + self.optical_bands[ob_id]["c_slots"] = [] + self.optical_bands[ob_id]["l_slots"] = [] + self.optical_bands[ob_id]["s_slots"] = [] + self.optical_bands[ob_id]["served_lightpaths"] = [] + self.optical_bands[ob_id]["reverse_optical_band_id"] = 0 + self.db_flows[self.flow_id]["parent_opt_band"] = 0 + self.db_flows[self.flow_id]["new_optical_band"] = 0 + + def create_optical_band(self, links, path, bidir, num_slots): + print("INFO: Creating optical-band of {} slots".format(num_slots)) + self.opt_band_id += 1 + forw_opt_band_id = self.opt_band_id + self.optical_bands[forw_opt_band_id] = {} + self.optical_bands[forw_opt_band_id]["optical_band_id"] = forw_opt_band_id + self.optical_bands[forw_opt_band_id]["bidir"] = bidir + ''' + back_opt_band_id = 0 + if bidir: + self.opt_band_id += 1 + back_opt_band_id = self.opt_band_id + self.optical_bands[back_opt_band_id] = {} + self.optical_bands[back_opt_band_id]["optical_band_id"] = back_opt_band_id + self.optical_bands[back_opt_band_id]["bidir"] = bidir + self.optical_bands[back_opt_band_id]["reverse_optical_band_id"] = forw_opt_band_id + self.optical_bands[forw_opt_band_id]["reverse_optical_band_id"] = back_opt_band_id + else: + self.optical_bands[forw_opt_band_id]["reverse_optical_band_id"] = 0 + ''' + op = 0 + temp_links = [] + #num_slots = "all" + if self.nodes_dict[path[0]]["type"] == "OC-TP": + add_link = links[0] + temp_links.append(add_link) + links.remove(add_link) + path.remove(path[0]) + self.optical_bands[forw_opt_band_id]["src"] = path[0] + ''' + if bidir: + self.optical_bands[back_opt_band_id]["dst"] = path[0] + ''' + if self.nodes_dict[path[-1]]["type"] == "OC-TP": + drop_link = links[-1] + temp_links.append(drop_link) + links.remove(drop_link) + path.remove(path[-1]) + self.optical_bands[forw_opt_band_id]["dst"] = path[-1] + ''' + if bidir: + self.optical_bands[back_opt_band_id]["src"] = path[-1] + ''' + + c_slots, l_slots, s_slots = self.get_slots(links, num_slots) + if debug: + print(c_slots) + print(l_slots) + print(s_slots) + if len(c_slots) > 0 or len(l_slots) > 0 or len(s_slots) > 0: + flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports(links, num_slots, c_slots, l_slots, s_slots, bidir) + f0, band = freqency_converter(band_range, slots) + print(flow_list, band_range, slots, fiber_f, fiber_b) + ''' + + flow_list_b = {} + rev_path = path.copy() + rev_path.reverse() + rev_links = reverse_links(links) + if bidir: + for dev_x in flow_list.keys(): + flow_list_b[dev_x] = {} + flow_list_b[dev_x]["f"] = flow_list[dev_x]["b"] + del flow_list[dev_x]["b"] + rev_path = path.copy() + ''' + if debug: + print(f0, band) + print("INFO: RSA completed for optical band") + if flow_list is None: + self.null_values(self.flow_id) + return self.flow_id, [] + slots_i = [] + for i in slots: + slots_i.append(int(i)) + + # return links, path, flow_list, band_range, slots, fiber_f, fiber_b, op, num_slots, f0, band + # links, path, flows, bx, slots, fiber_f, fiber_b, op, n_slots, f0, band + if len(flow_list) > 0: + src_port = flow_list[path[0]]['f']['out'] + dst_port = flow_list[path[-1]]['f']['in'] + print(flow_list) + if len(fiber_f.keys()) == 1: + link_x = list(fiber_f.keys())[0] + #fib_x = fiber_f[link_x] + #rev_dst_port = self.links_dict[link_x]['fibers'][fib_x]["local_peer_port"] + #rev_src_port = self.links_dict[link_x]['fibers'][fib_x]["remote_peer_port"] + fibx = self.get_fiber_details(link_x, fiber_f[link_x]) + rev_dst_port = fibx["local_peer_port"] + rev_src_port = fibx["remote_peer_port"] + else: + link_in = list(fiber_f.keys())[0] + link_out = list(fiber_f.keys())[-1] + fib_inx = self.get_fiber_details(link_in, fiber_f[link_in]) + fib_outx = self.get_fiber_details(link_out, fiber_f[link_out]) + rev_dst_port = fib_inx["local_peer_port"] + rev_src_port = fib_outx["remote_peer_port"] + + #fib_in = fiber_f[link_in] + #fib_out = fiber_f[link_out] + #rev_dst_port = self.links_dict[link_in]['fibers'][fib_in]["local_peer_port"] + #rev_src_port = self.links_dict[link_out]['fibers'][fib_out]["remote_peer_port"] + + self.optical_bands[forw_opt_band_id]["flows"] = flow_list + self.optical_bands[forw_opt_band_id]["band_type"] = band_range + self.optical_bands[forw_opt_band_id]["fiber_forward"] = fiber_f + self.optical_bands[forw_opt_band_id]["fiber_backward"] = fiber_b + self.optical_bands[forw_opt_band_id]["op-mode"] = op + self.optical_bands[forw_opt_band_id]["n_slots"] = num_slots + self.optical_bands[forw_opt_band_id]["links"] = links + self.optical_bands[forw_opt_band_id]["path"] = path + self.optical_bands[forw_opt_band_id]["band"] = band + self.optical_bands[forw_opt_band_id]["freq"] = f0 + self.optical_bands[forw_opt_band_id]["is_active"] = True + self.optical_bands[forw_opt_band_id]["src_port"] = src_port + self.optical_bands[forw_opt_band_id]["dst_port"] = dst_port + self.optical_bands[forw_opt_band_id]["rev_dst_port"] = rev_dst_port + self.optical_bands[forw_opt_band_id]["rev_src_port"] = rev_src_port + self.optical_bands[forw_opt_band_id][band_range] = slots_i + self.optical_bands[forw_opt_band_id]["served_lightpaths"] = [] + ''' + if bidir: + self.optical_bands[back_opt_band_id]["flows"] = flow_list_b + self.optical_bands[back_opt_band_id]["band_type"] = band_range + self.optical_bands[back_opt_band_id]["fiber_forward"] = fiber_b + # self.optical_bands[back_opt_band_id]["fiber_backward"] = fiber_b + self.optical_bands[back_opt_band_id]["op-mode"] = op + self.optical_bands[back_opt_band_id]["n_slots"] = num_slots + self.optical_bands[back_opt_band_id]["links"] = rev_links + self.optical_bands[back_opt_band_id]["path"] = rev_path + self.optical_bands[back_opt_band_id]["band"] = band + self.optical_bands[back_opt_band_id]["freq"] = f0 + self.optical_bands[back_opt_band_id]["is_active"] = True + self.optical_bands[back_opt_band_id]["src_port"] = rev_src_port + self.optical_bands[back_opt_band_id]["dst_port"] = rev_dst_port + self.optical_bands[back_opt_band_id][band_range] = slots_i.copy() + self.optical_bands[back_opt_band_id]["served_lightpaths"] = [] + ''' + + return forw_opt_band_id, temp_links + + def get_optical_bands(self, r_src, r_dst): + result = [] + for ob_id in self.optical_bands: + ob = self.optical_bands[ob_id] + if debug: + print(r_src, ob["src"]) + print(r_dst, ob["dst"]) + print(ob) + if ob["src"] == r_src and ob["dst"] == r_dst: + result.append(ob_id) + return result + + def rsa_fs_computation(self, src, dst, rate, bidir, band): + num_slots_ob = "full_band" + if band is not None: + num_slots_ob = map_band_to_slot(band) + print(band, num_slots_ob) + if self.nodes_dict[src]["type"] == "OC-ROADM" and self.nodes_dict[dst]["type"] == "OC-ROADM": + print("INFO: ROADM to ROADM connection") + links, path = self.compute_path(src, dst) + if len(path) < 1: + self.null_values_ob(self.opt_band_id) + return self.flow_id, [] + optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob) + return None, optical_band_id + print("INFO: TP to TP connection") + if band is None: + temp_links2 = [] + temp_path = [] + src_links = get_links_from_node(self.links_dict, src) + dst_links = get_links_to_node(self.links_dict, dst) + if len(src_links.keys()) >= 1: + temp_links2.append(list(src_links.keys())[0]) + if len(dst_links.keys()) >= 1: + temp_links2.append(list(dst_links.keys())[0]) + + if len(temp_links2) == 2: + [t_src, roadm_src] = temp_links2[0].split('-') + [roadm_dst, t_dst] = temp_links2[1].split('-') + temp_path.append(t_src) + temp_path.append(roadm_src) + temp_path.append(roadm_dst) + temp_path.append(t_dst) + existing_ob = self.get_optical_bands(roadm_src, roadm_dst) + self.flow_id += 1 + self.db_flows[self.flow_id] = {} + self.db_flows[self.flow_id]["flow_id"] = self.flow_id + self.db_flows[self.flow_id]["src"] = src + self.db_flows[self.flow_id]["dst"] = dst + self.db_flows[self.flow_id]["bitrate"] = rate + self.db_flows[self.flow_id]["bidir"] = bidir + + if len(existing_ob) > 0: + print("INFO: Evaluating existing OB {}".format(existing_ob)) + #first checking in existing OB + ob_found = 0 + for ob_id in existing_ob: + op, num_slots = map_rate_to_slot(rate) + if debug: + print(temp_links2) + c_slots, l_slots, s_slots = self.get_slots(temp_links2, num_slots, ob_id) + if debug: + print(c_slots) + print(l_slots) + print(s_slots) + if len(c_slots) >= num_slots or len(l_slots) >= num_slots or len(s_slots) >= num_slots: + flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(temp_links2, num_slots, + c_slots, + l_slots, s_slots, bidir, + ob_id) + f0, band = freqency_converter(band_range, slots) + if debug: + print(f0, band) + print("INFO: RSA completed for Flex Lightpath with OB already in place") + if flow_list is None: + self.null_values(self.flow_id) + continue + slots_i = [] + for i in slots: + slots_i.append(int(i)) + # return links, path, flow_list, band_range, slots, fiber_f, fiber_b, op, num_slots, f0, band + # links, path, flows, bx, slots, fiber_f, fiber_b, op, n_slots, f0, band + self.db_flows[self.flow_id]["flows"] = flow_list + self.db_flows[self.flow_id]["band_type"] = band_range + self.db_flows[self.flow_id]["slots"] = slots_i + self.db_flows[self.flow_id]["fiber_forward"] = fiber_f + self.db_flows[self.flow_id]["fiber_backward"] = fiber_b + self.db_flows[self.flow_id]["op-mode"] = op + self.db_flows[self.flow_id]["n_slots"] = num_slots + self.db_flows[self.flow_id]["links"] = temp_links2 + self.db_flows[self.flow_id]["path"] = temp_path + self.db_flows[self.flow_id]["band"] = band + self.db_flows[self.flow_id]["freq"] = f0 + self.db_flows[self.flow_id]["is_active"] = True + self.db_flows[self.flow_id]["parent_opt_band"] = ob_id + self.db_flows[self.flow_id]["new_optical_band"] = 0 + self.optical_bands[ob_id]["served_lightpaths"].append(self.flow_id) + ''' + if bidir: + rev_ob_id = self.optical_bands[ob_id]["reverse_optical_band_id"] + self.optical_bands[rev_ob_id]["served_lightpaths"].append(self.flow_id) + ''' + return self.flow_id, ob_id + else: + print("not enough slots") + if band is None: + print("INFO: Not existing optical-band meeting the requirements") + else: + print("INFO: optical-band width specified") + #if no OB I create a new one + links, path = self.compute_path(src, dst) + optical_band_id, temp_links = self.create_optical_band(links, path, bidir, num_slots_ob) + op, num_slots = map_rate_to_slot(rate) + self.flow_id += 1 + self.db_flows[self.flow_id] = {} + self.db_flows[self.flow_id]["flow_id"] = self.flow_id + self.db_flows[self.flow_id]["src"] = src + self.db_flows[self.flow_id]["dst"] = dst + self.db_flows[self.flow_id]["bitrate"] = rate + self.db_flows[self.flow_id]["bidir"] = bidir + + if debug: + print(temp_links) + c_slots, l_slots, s_slots = self.get_slots(temp_links, num_slots, optical_band_id) + if debug: + print(c_slots) + print(l_slots) + print(s_slots) + if len(c_slots) > 0 or len(l_slots) > 0 or len(s_slots) > 0: + flow_list, band_range, slots, fiber_f, fiber_b = self.select_slots_and_ports_fs(temp_links, num_slots, c_slots, + l_slots, s_slots, bidir, optical_band_id) + f0, band = freqency_converter(band_range, slots) + if debug: + print(f0, band) + print("INFO: RSA completed for FLex Lightpath with new OB") + if flow_list is None: + self.null_values(self.flow_id) + return self.flow_id, optical_band_id + slots_i = [] + for i in slots: + slots_i.append(int(i)) + + self.db_flows[self.flow_id]["flows"] = flow_list + self.db_flows[self.flow_id]["band_type"] = band_range + self.db_flows[self.flow_id]["slots"] = slots_i + self.db_flows[self.flow_id]["fiber_forward"] = fiber_f + self.db_flows[self.flow_id]["fiber_backward"] = fiber_b + self.db_flows[self.flow_id]["op-mode"] = op + self.db_flows[self.flow_id]["n_slots"] = num_slots + self.db_flows[self.flow_id]["links"] = temp_links + self.db_flows[self.flow_id]["path"] = path + self.db_flows[self.flow_id]["band"] = band + self.db_flows[self.flow_id]["freq"] = f0 + self.db_flows[self.flow_id]["is_active"] = True + self.db_flows[self.flow_id]["parent_opt_band"] = optical_band_id + self.db_flows[self.flow_id]["new_optical_band"] = 1 + self.optical_bands[optical_band_id]["served_lightpaths"].append(self.flow_id) + ''' + if bidir: + rev_ob_id = self.optical_bands[optical_band_id]["reverse_optical_band_id"] + self.optical_bands[rev_ob_id]["served_lightpaths"].append(self.flow_id) + ''' + return self.flow_id, optical_band_id diff --git a/src/opticalcontroller/__init__.py b/src/opticalcontroller/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..38d04994fb0fa1951fb465bc127eb72659dc2eaf --- /dev/null +++ b/src/opticalcontroller/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/src/opticalcontroller/dijsktra.py b/src/opticalcontroller/dijsktra.py new file mode 100644 index 0000000000000000000000000000000000000000..a86d1d93dcbc30b9e4e3b95a34a0922439871bf6 --- /dev/null +++ b/src/opticalcontroller/dijsktra.py @@ -0,0 +1,240 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# TODO: migrate to NetworkX: +# https://networkx.org/documentation/stable/index.html +# https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html + +import sys + +class Vertex: + def __init__(self, node): + self.id = node + self.adjacent = {} + # Set distance to infinity for all nodes + self.distance = float("inf") + # Mark all nodes unvisited + self.visited = False + # Predecessor + self.previous = None + + # heapq compara gli item nella coda usando <= per vedere ci sono duplciati: + # se ho una coda di tuple, + # compara il primo elemento della prima tupla nella coda con il primo elemento della seconda tupla nella coda + # se sono diversi si ferma, se sono uguali continua + # la tupla nel caso in esame è: (v.get_distance(),v) + # se due nodi hanno stessa distanza, heapq procede a comparare v: Vertex(). + # Va quindi definita una politica per confrontare i Vertex + def __lt__(self, other): + if self.id < other.id: + return True + else: + return False + + def __le__(self, other): + if self.id <= other.id: + return True + else: + return False + + def add_neighbor(self, neighbor, port): + self.adjacent[neighbor] = port + + def del_neighbor(self, neighbor): + self.adjacent.pop(neighbor) + + def get_connections(self): + return self.adjacent.keys() + + def get_id(self): + return self.id + + def get_port(self, neighbor): + return self.adjacent[neighbor][0] + + def get_weight(self, neighbor): + return self.adjacent[neighbor][1] + + def set_distance(self, dist): + self.distance = dist + + def get_distance(self): + return self.distance + + def set_previous(self, prev): + self.previous = prev + + def set_visited(self): + self.visited = True + + def reset_vertex(self): + self.visited = False + self.previous = None + self.distance = float("inf") + + def __str__(self): + return str(self.id) + ' adjacent: ' + str([x.id for x in self.adjacent]) + +class Graph: + def __init__(self): + self.vert_dict = {} + self.num_vertices = 0 + + def __iter__(self): + return iter(self.vert_dict.values()) + + def reset_graph(self): + for n in self.vert_dict: + self.get_vertex(n).reset_vertex() + + def printGraph(self): + for v in self: + for w in v.get_connections(): + vid = v.get_id() + wid = w.get_id() + print ('( %s , %s, %s, %s, %s, %s)' % ( vid, wid, v.get_port(w), w.get_port(v), v.get_weight(w), w.get_weight(v))) + + def add_vertex(self, node): + self.num_vertices = self.num_vertices + 1 + new_vertex = Vertex(node) + self.vert_dict[node] = new_vertex + return new_vertex + + def del_Vertex(self, node): + self.vert_dict.pop(node) + + def get_vertex(self, n): + if n in self.vert_dict: + return self.vert_dict[n] + else: + return None + + def add_edge(self, frm, to, port_frm, port_to,w): + if frm not in self.vert_dict: + self.add_vertex(frm) + if to not in self.vert_dict: + self.add_vertex(to) + + self.vert_dict[frm].add_neighbor(self.vert_dict[to], [port_frm, w]) + self.vert_dict[to].add_neighbor(self.vert_dict[frm], [port_to, w]) + + def del_edge(self, frm, to, cost = 0): + self.vert_dict[frm].del_neighbor(self.vert_dict[to]) + self.vert_dict[to].del_neighbor(self.vert_dict[frm]) + + def get_vertices(self): + return self.vert_dict.keys() + + def set_previous(self, current): + self.previous = current + + def get_previous(self, current): + return self.previous + +def shortest(v, path): + if v.previous: + path.append(v.previous.get_id()) + shortest(v.previous, path) + return + +import heapq + +def dijkstra(aGraph, start): + """print ('''Dijkstra's shortest path''')""" + # Set the distance for the start node to zero + start.set_distance(0) + + # Put tuple pair into the priority queue + unvisited_queue = [(v.get_distance(),v) for v in aGraph] + #priority queue->costruisce un albero in cui ogni nodo parent ha ha un valore <= di ogni child + #heappop prende il valore più piccolo, nel caso di dikstra, il nodo più vicino + heapq.heapify(unvisited_queue) + + while len(unvisited_queue): + # Pops a vertex with the smallest distance + uv = heapq.heappop(unvisited_queue) + current = uv[1] + current.set_visited() + + #for next in v.adjacent: + for next in current.adjacent: + # if visited, skip + if next.visited: + continue + new_dist = current.get_distance() + current.get_weight(next) + + if new_dist < next.get_distance(): + next.set_distance(new_dist) + next.set_previous(current) + """print ('updated : current = %s next = %s new_dist = %s' \ + %(current.get_id(), next.get_id(), next.get_distance()))""" + else: + """print ('not updated : current = %s next = %s new_dist = %s' \ + %(current.get_id(), next.get_id(), next.get_distance()))""" + + # Rebuild heap + # 1. Pop every item + while len(unvisited_queue): + heapq.heappop(unvisited_queue) + # 2. Put all vertices not visited into the queue + unvisited_queue = [(v.get_distance(),v) for v in aGraph if not v.visited] + heapq.heapify(unvisited_queue) + +def shortest_path(graph, src, dst): + dijkstra(graph, src) + target = dst + path = [target.get_id()] + shortest(target, path) + return path[::-1] + +if __name__ == '__main__': + + print("Testing Algo") + g = Graph() + + g.add_vertex('a') + g.add_vertex('b') + g.add_vertex('c') + g.add_vertex('d') + g.add_vertex('e') + g.add_vertex('f') + + g.add_edge('a', 'b', 7) + g.add_edge('a', 'c', 9) + g.add_edge('a', 'f', 14) + g.add_edge('b', 'c', 10) + g.add_edge('b', 'd', 15) + g.add_edge('c', 'd', 11) + g.add_edge('c', 'f', 2) + g.add_edge('d', 'e', 6) + g.add_edge('e', 'f', 9) + + + """print ('Graph data:') + for v in g: + for w in v.get_connections(): + vid = v.get_id() + wid = w.get_id() + print ('( %s , %s, %3d)' % ( vid, wid, v.get_weight(w))) + + + dijkstra(g, g.get_vertex('a')) + + target = g.get_vertex('e') + path = [target.get_id()] + shortest(target, path) + print ('The shortest path : %s' %(path[::-1]))""" + + p = shortest_path(g, g.get_vertex('a'), g.get_vertex('e')) + print(p) diff --git a/src/opticalcontroller/images/topo.png b/src/opticalcontroller/images/topo.png new file mode 100644 index 0000000000000000000000000000000000000000..216e1360b3caecd68285ca8b69fd498049dcbf79 Binary files /dev/null and b/src/opticalcontroller/images/topo.png differ diff --git a/src/opticalcontroller/json_files/nodes.json b/src/opticalcontroller/json_files/nodes.json new file mode 100644 index 0000000000000000000000000000000000000000..60f017c19d7c7a578c0ddfc2225cab742deb0026 --- /dev/null +++ b/src/opticalcontroller/json_files/nodes.json @@ -0,0 +1,39 @@ +{ + "R1":{ + "id":0, + "ip":"10.30.2.207", + "port":"50001", + "type":"OC-ROADM", + "driver": "OpticalOC" + }, + + "R2":{ + "id":1, + "ip":"10.30.2.208", + "port":"50001", + "type":"OC-ROADM", + "driver": "OpticalOC" + }, + + "R3":{ + "id":2, + "ip":"10.30.2.209", + "port":"50001", + "type":"OC-ROADM", + "driver": "OpticalOC" + }, + "T1":{ + "id":3, + "ip":"10.30.2.210", + "port":"50001", + "type":"OC-TP", + "driver": "OpticalOC" + }, + "T2":{ + "id":4, + "ip":"10.30.2.211", + "port":"50001", + "type":"OC-TP", + "driver": "OpticalOC" + } +} diff --git a/src/opticalcontroller/json_files/optical_TFSworking.json b/src/opticalcontroller/json_files/optical_TFSworking.json new file mode 100644 index 0000000000000000000000000000000000000000..ff1841eeea9df1e73bcfb25d07f19d64554f11e1 --- /dev/null +++ b/src/opticalcontroller/json_files/optical_TFSworking.json @@ -0,0 +1,486 @@ +{ + "R1-R2": { + "length": 80, + "source": "d1", + "target": "d1", + "fibers": { + "d1-1": { + "length": 80, + "src_port": "3", + "dst_port": "14", + "local_peer_port": "13", + "remote_peer_port": "4", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R2-R1": { + "length": 80, + "source": "d1", + "target": "d1", + "fibers": { + "d1-1": { + "length": 80, + "src_port": "4", + "dst_port": "13", + "local_peer_port": "14", + "remote_peer_port": "3", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "T1-R1": { + "length": 0, + "source": "muxT", + "target": "srgR", + "fibers": { + "M1": { + "length": 0, + "src_port": "1", + "dst_port": "12", + "local_peer_port": "1", + "remote_peer_port": "2", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R1-T1": { + "length": 0, + "source": "srgT", + "target": "muxR", + "fibers": { + "S1": { + "length": 0, + "src_port": "2", + "dst_port": "1", + "local_peer_port": "12", + "remote_peer_port": "1", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "T2-R2": { + "length": 0, + "source": "muxT", + "target": "srgR", + "fibers": { + "M1": { + "length": 0, + "src_port": "6", + "dst_port": "15", + "local_peer_port": "6", + "remote_peer_port": "5", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R2-T2": { + "length": 0, + "source": "srgT", + "target": "muxR", + "fibers": { + "S1": { + "length": 0, + "src_port": "5", + "dst_port": "6", + "local_peer_port": "15", + "remote_peer_port": "6", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + } +} diff --git a/src/opticalcontroller/json_files/optical_topoTFS.json b/src/opticalcontroller/json_files/optical_topoTFS.json new file mode 100644 index 0000000000000000000000000000000000000000..7dea474cd676b7c699cffc1c180e14598b987473 --- /dev/null +++ b/src/opticalcontroller/json_files/optical_topoTFS.json @@ -0,0 +1,1836 @@ +{ + "R1-R2": { + "length": 80, + "source": "d1", + "target": "d1", + "fibers": { + "d1-1": { + "length": 80, + "src_port": "101", + "dst_port": "201", + "local_peer_port": "201", + "remote_peer_port": "101", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d1-2": { + "length": 80, + "src_port": "102", + "dst_port": "202", + "local_peer_port": "202", + "remote_peer_port": "102", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R2-R1": { + "length": 80, + "source": "d1", + "target": "d1", + "fibers": { + "d1-1": { + "length": 80, + "src_port": "101", + "dst_port": "201", + "local_peer_port": "201", + "remote_peer_port": "101", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d1-2": { + "length": 80, + "src_port": "102", + "dst_port": "202", + "local_peer_port": "202", + "remote_peer_port": "102", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R1-R3": { + "length": 80, + "source": "d2", + "target": "d1", + "fibers": { + "d2-1": { + "length": 80, + "src_port": "103", + "dst_port": "201", + "local_peer_port": "203", + "remote_peer_port": "101", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d2-2": { + "length": 80, + "src_port": "104", + "dst_port": "202", + "local_peer_port": "204", + "remote_peer_port": "102", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R3-R1": { + "length": 80, + "source": "d1", + "target": "d2", + "fibers": { + "d1-1": { + "length": 80, + "src_port": "101", + "dst_port": "203", + "local_peer_port": "201", + "remote_peer_port": "103", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d1-2": { + "length": 80, + "src_port": "102", + "dst_port": "204", + "local_peer_port": "202", + "remote_peer_port": "104", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R2-R3": { + "length": 80, + "source": "d2", + "target": "d2", + "fibers": { + "d2-1": { + "length": 80, + "src_port": "103", + "dst_port": "203", + "local_peer_port": "203", + "remote_peer_port": "103", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d2-2": { + "length": 80, + "src_port": "104", + "dst_port": "204", + "local_peer_port": "204", + "remote_peer_port": "104", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R3-R2": { + "length": 80, + "source": "d2", + "target": "d2", + "fibers": { + "d2-1": { + "length": 80, + "src_port": "103", + "dst_port": "203", + "local_peer_port": "203", + "remote_peer_port": "103", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d2-2": { + "length": 80, + "src_port": "104", + "dst_port": "204", + "local_peer_port": "204", + "remote_peer_port": "104", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "T1-R1": { + "length": 0, + "source": "muxT", + "target": "srgR", + "fibers": { + "M1": { + "length": 0, + "src_port": "1", + "dst_port": "2001", + "local_peer_port": "1", + "remote_peer_port": "1001", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M2": { + "length": 0, + "src_port": "2", + "dst_port": "2002", + "local_peer_port": "2", + "remote_peer_port": "1002", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M3": { + "length": 0, + "src_port": "3", + "dst_port": "2003", + "local_peer_port": "3", + "remote_peer_port": "1003", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R1-T1": { + "length": 0, + "source": "srgT", + "target": "muxR", + "fibers": { + "S1": { + "length": 0, + "src_port": "1001", + "dst_port": "1", + "local_peer_port": "2001", + "remote_peer_port": "1", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S2": { + "length": 0, + "src_port": "1002", + "dst_port": "2", + "local_peer_port": "2002", + "remote_peer_port": "2", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S3": { + "length": 0, + "src_port": "1003", + "dst_port": "3", + "local_peer_port": "2003", + "remote_peer_port": "3", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "T2-R2": { + "length": 0, + "source": "muxT", + "target": "srgR", + "fibers": { + "M1": { + "length": 0, + "src_port": "1", + "dst_port": "2001", + "local_peer_port": "1", + "remote_peer_port": "1001", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M2": { + "length": 0, + "src_port": "2", + "dst_port": "2002", + "local_peer_port": "2", + "remote_peer_port": "1002", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M3": { + "length": 0, + "src_port": "3", + "dst_port": "2003", + "local_peer_port": "3", + "remote_peer_port": "1003", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R2-T2": { + "length": 0, + "source": "srgT", + "target": "muxR", + "fibers": { + "S1": { + "length": 0, + "src_port": "1001", + "dst_port": "1", + "local_peer_port": "2001", + "remote_peer_port": "1", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S2": { + "length": 0, + "src_port": "1002", + "dst_port": "2", + "local_peer_port": "2002", + "remote_peer_port": "2", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S3": { + "length": 0, + "src_port": "1003", + "dst_port": "3", + "local_peer_port": "2003", + "remote_peer_port": "3", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + } +} diff --git a/src/opticalcontroller/json_files/tfs.json b/src/opticalcontroller/json_files/tfs.json new file mode 100644 index 0000000000000000000000000000000000000000..a108ed13ee5fe85c974e41e8ff6fe5ed5dd7d2ed --- /dev/null +++ b/src/opticalcontroller/json_files/tfs.json @@ -0,0 +1,1286 @@ +{ + "links": [ + { + "link_id": { + "link_uuid": { + "uuid": "T1->R1" + } + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "T1" + } + }, + "endpoint_uuid": { + "uuid": "1" + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "R1" + } + }, + "endpoint_uuid": { + "uuid": "12" + } + } + ], + "optical_link": { + "name": "T1-R1", + "details": { + "length": 0, + "source": "muxT", + "target": "srgR", + "fibers": [ + { + "ID": "M1", + "length": 0, + "src_port": "1", + "dst_port": "2001", + "local_peer_port": "1", + "remote_peer_port": "1001", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M2", + "length": 0, + "src_port": "2", + "dst_port": "2002", + "local_peer_port": "2", + "remote_peer_port": "1002", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M3", + "length": 0, + "src_port": "3", + "dst_port": "2003", + "local_peer_port": "3", + "remote_peer_port": "1003", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + ] + } + } + }, + { + "link_id": { + "link_uuid": { + "uuid": "R1->T1" + } + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "R1" + } + }, + "endpoint_uuid": { + "uuid": "2" + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "T1" + } + }, + "endpoint_uuid": { + "uuid": "1" + } + } + ], + "optical_link": { + "name": "R1-T1", + "details": { + "length": 0, + "source": "srgT", + "target": "muxT", + "fibers": [ + { + "ID": "M1", + "length": 0, + "src_port": "1001", + "dst_port": "1", + "local_peer_port": "2001", + "remote_peer_port": "1", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M2", + "length": 0, + "src_port": "1002", + "dst_port": "2", + "local_peer_port": "2002", + "remote_peer_port": "2", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M3", + "length": 0, + "src_port": "1003", + "dst_port": "3", + "local_peer_port": "2003", + "remote_peer_port": "3", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + ] + } + } + }, + { + "link_id": { + "link_uuid": { + "uuid": "R1->R2" + } + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "R1" + } + }, + "endpoint_uuid": { + "uuid": "13" + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "R2" + } + }, + "endpoint_uuid": { + "uuid": "24" + } + } + ], + "optical_link": { + "name": "R1-R2", + "details": { + "length": 0, + "source": "D1", + "target": "D1", + "fibers": [ + { + "ID": "D11", + "length": 0, + "src_port": "13", + "dst_port": "24", + "local_peer_port": "23", + "remote_peer_port": "14", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + ] + } + } + }, + { + "link_id": { + "link_uuid": { + "uuid": "R2->R1" + } + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "R2" + } + }, + "endpoint_uuid": { + "uuid": "14" + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "R1" + } + }, + "endpoint_uuid": { + "uuid": "23" + } + } + ], + "optical_link": { + "name": "R2-R1", + "details": { + "length": 0, + "source": "D1", + "target": "D1", + "fibers": [ + { + "ID": "D11", + "length": 0, + "src_port": "14", + "dst_port": "23", + "local_peer_port": "24", + "remote_peer_port": "13", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + ] + } + } + }, + { + "link_id": { + "link_uuid": { + "uuid": "T2->R2" + } + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "T2" + } + }, + "endpoint_uuid": { + "uuid": "1" + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "R2" + } + }, + "endpoint_uuid": { + "uuid": "1001" + } + } + ], + "optical_link": { + "name": "T2-R2", + "details": { + "length": 0, + "source": "srgT", + "target": "muxT", + "fibers": [ + { + "ID": "M1", + "length": 0, + "src_port": "1", + "dst_port": "1001", + "local_peer_port": "1", + "remote_peer_port": "2001", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M2", + "length": 0, + "src_port": "2", + "dst_port": "1002", + "local_peer_port": "2", + "remote_peer_port": "2002", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M3", + "length": 0, + "src_port": "3", + "dst_port": "1003", + "local_peer_port": "3", + "remote_peer_port": "2003", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + ] + } + } + }, + { + "link_id": { + "link_uuid": { + "uuid": "R2->T2" + } + }, + "link_endpoint_ids": [ + { + "device_id": { + "device_uuid": { + "uuid": "R2" + } + }, + "endpoint_uuid": { + "uuid": "5" + } + }, + { + "device_id": { + "device_uuid": { + "uuid": "T2" + } + }, + "endpoint_uuid": { + "uuid": "6" + } + } + ], + "optical_link": { + "name": "R2-T2", + "details": { + "length": 0, + "source": "srgT", + "target": "muxT", + "fibers": [ + { + "ID": "M1", + "length": 0, + "src_port": "1001", + "dst_port": "1", + "local_peer_port": "2001", + "remote_peer_port": "1", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M2", + "length": 0, + "src_port": "1002", + "dst_port": "2", + "local_peer_port": "2002", + "remote_peer_port": "2", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + { + "ID": "M3", + "length": 0, + "src_port": "1003", + "dst_port": "3", + "local_peer_port": "2003", + "remote_peer_port": "3", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/src/opticalcontroller/json_files/topo_2_links.json b/src/opticalcontroller/json_files/topo_2_links.json new file mode 100644 index 0000000000000000000000000000000000000000..02165938ce675071a4ff4c3424e3b53244d40810 --- /dev/null +++ b/src/opticalcontroller/json_files/topo_2_links.json @@ -0,0 +1,1530 @@ +{ + "R1-R3": { + "length": 80, + "source": "d2", + "target": "d1", + "fibers": { + "d2-1": { + "length": 80, + "src_port": "103", + "dst_port": "201", + "local_peer_port": "203", + "remote_peer_port": "101", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d2-2": { + "length": 80, + "src_port": "104", + "dst_port": "202", + "local_peer_port": "204", + "remote_peer_port": "102", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R3-R1": { + "length": 80, + "source": "d1", + "target": "d2", + "fibers": { + "d1-1": { + "length": 80, + "src_port": "101", + "dst_port": "203", + "local_peer_port": "201", + "remote_peer_port": "103", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d1-2": { + "length": 80, + "src_port": "102", + "dst_port": "204", + "local_peer_port": "202", + "remote_peer_port": "104", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R2-R3": { + "length": 80, + "source": "d2", + "target": "d2", + "fibers": { + "d2-1": { + "length": 80, + "src_port": "103", + "dst_port": "203", + "local_peer_port": "203", + "remote_peer_port": "103", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d2-2": { + "length": 80, + "src_port": "104", + "dst_port": "204", + "local_peer_port": "204", + "remote_peer_port": "104", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R3-R2": { + "length": 80, + "source": "d2", + "target": "d2", + "fibers": { + "d2-1": { + "length": 80, + "src_port": "103", + "dst_port": "203", + "local_peer_port": "203", + "remote_peer_port": "103", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "d2-2": { + "length": 80, + "src_port": "104", + "dst_port": "204", + "local_peer_port": "204", + "remote_peer_port": "104", + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "T1-R1": { + "length": 0, + "source": "muxT", + "target": "srgR", + "fibers": { + "M1": { + "length": 0, + "src_port": "1", + "dst_port": "2001", + "local_peer_port": "1", + "remote_peer_port": "1001", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M2": { + "length": 0, + "src_port": "2", + "dst_port": "2002", + "local_peer_port": "2", + "remote_peer_port": "1002", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M3": { + "length": 0, + "src_port": "3", + "dst_port": "2003", + "local_peer_port": "3", + "remote_peer_port": "1003", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R1-T1": { + "length": 0, + "source": "srgT", + "target": "muxR", + "fibers": { + "S1": { + "length": 0, + "src_port": "1001", + "dst_port": "1", + "local_peer_port": "2001", + "remote_peer_port": "1", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S2": { + "length": 0, + "src_port": "1002", + "dst_port": "2", + "local_peer_port": "2002", + "remote_peer_port": "2", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S3": { + "length": 0, + "src_port": "1003", + "dst_port": "3", + "local_peer_port": "2003", + "remote_peer_port": "3", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "T2-R2": { + "length": 0, + "source": "muxT", + "target": "srgR", + "fibers": { + "M1": { + "length": 0, + "src_port": "1", + "dst_port": "2001", + "local_peer_port": "1", + "remote_peer_port": "1001", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M2": { + "length": 0, + "src_port": "2", + "dst_port": "2002", + "local_peer_port": "2", + "remote_peer_port": "1002", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "M3": { + "length": 0, + "src_port": "3", + "dst_port": "2003", + "local_peer_port": "3", + "remote_peer_port": "1003", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + }, + "R2-T2": { + "length": 0, + "source": "srgT", + "target": "muxR", + "fibers": { + "S1": { + "length": 0, + "src_port": "1001", + "dst_port": "1", + "local_peer_port": "2001", + "remote_peer_port": "1", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S2": { + "length": 0, + "src_port": "1002", + "dst_port": "2", + "local_peer_port": "2002", + "remote_peer_port": "2", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + }, + "S3": { + "length": 0, + "src_port": "1003", + "dst_port": "3", + "local_peer_port": "2003", + "remote_peer_port": "3", + "used": false, + "c_slots": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "l_slots": [ + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120 + ], + "s_slots": [ + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516, + 517, + 518, + 519, + 520 + ] + } + } + } +} diff --git a/src/opticalcontroller/json_files/topology-optical.json b/src/opticalcontroller/json_files/topology-optical.json new file mode 100644 index 0000000000000000000000000000000000000000..e2453b654d53fc3200570ce9c2b17effc964bd25 --- /dev/null +++ b/src/opticalcontroller/json_files/topology-optical.json @@ -0,0 +1,252 @@ +{ + "r1-r2": { + "length": 80, + "source" : "d1", + "target" : "d1", + "fibers" : { + "d1-1": { + "src_port": "1T", + "dst_port": "1R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "d1-2":{ + "src_port": "2T", + "dst_port": "2R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "r2-r1": { + "length": 80, + "source" : "d1", + "target" : "d1", + "fibers" : { + "d1-1" : { + "src_port": "1T", + "dst_port": "1R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "d1-2" : { + "src_port": "2T", + "dst_port": "2R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "r1-r3": { + "length": 80, + "source" : "d2", + "target" : "d1", + "fibers" : { + "d2-1":{ + "src_port": "3T", + "dst_port": "1R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "d2-2":{ + "src_port": "4T", + "dst_port": "2R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "r3-r1": { + "length": 80, + "source" : "d1", + "target" : "d2", + "fibers" : { + "d1-1": { + "src_port": "1T", + "dst_port": "3R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "d1-2": { + "src_port": "2T", + "dst_port": "4R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "r2-r3": { + "length": 80, + "source" : "d2", + "target" : "d2", + "fibers" : { + "d2-1": { + "src_port": "3T", + "dst_port": "3R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "d2-2": { + "src_port": "4T", + "dst_port": "4R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "r3-r2": { + "length": 80, + "source" : "d2", + "target" : "d2", + "fibers" : { + "d2-1": { + "src_port": "3T", + "dst_port": "3R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "d2-2":{ + "src_port": "4T", + "dst_port": "4R", + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "t1-r1": { + "length": 0, + "source" : "muxT", + "target" : "srgR", + "fibers" : { + "M1": { + "src_port": "1", + "dst_port": "101R", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "M2": { + "src_port": "2", + "dst_port": "102R", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "M3": { + "src_port": "3", + "dst_port": "103R", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "r1-t1": { + "length": 0, + "source" : "srgT", + "target" : "muxR", + "fibers" : { + "S1": { + "src_port": "101T", + "dst_port": "1", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "S2": { + "src_port": "102T", + "dst_port": "2", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "S3": { + "src_port": "103T", + "dst_port": "3", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "t2-r2": { + "length": 0, + "source" : "muxT", + "target" : "srgR", + "fibers" : { + "M1": { + "src_port": "1", + "dst_port": "101R", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "M2": { + "src_port": "2", + "dst_port": "102R", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "M3": { + "src_port": "3", + "dst_port": "103R", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + }, + "r2-t2": { + "length": 0, + "source" : "srgT", + "target" : "muxR", + "fibers" : { + "S1": { + "src_port": "101T", + "dst_port": "1", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "S2": { + "src_port": "102T", + "dst_port": "2", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + }, + "S3": { + "src_port": "103T", + "dst_port": "3", + "used": false, + "c_slots": {"1": 1, "2": 1, "3": 1, "4": 1}, + "l_slots": {"101": 1, "102": 1, "103": 1, "104": 1}, + "s_slots": {"1001": 1, "1002": 1, "1003": 1, "1004": 1} + } + } + } +} diff --git a/src/opticalcontroller/json_files/topology-optical2.json b/src/opticalcontroller/json_files/topology-optical2.json new file mode 100644 index 0000000000000000000000000000000000000000..fe8e9866bcc64d52b2f49089ce03af47d72df9d0 --- /dev/null +++ b/src/opticalcontroller/json_files/topology-optical2.json @@ -0,0 +1,324 @@ +{ + "r1-r2": { + "length": 80, + "source" : "d1", + "target" : "d1", + "fibers" : { + "d1-1": { + "length": 80, + "src_port": "1T", + "dst_port": "1R", + "local_peer_port": "1R", + "remote_peer_port": "1T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "d1-2":{ + "length": 80, + "src_port": "2T", + "dst_port": "2R", + "local_peer_port": "2R", + "remote_peer_port": "2T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "r2-r1": { + "length": 80, + "source" : "d1", + "target" : "d1", + "fibers" : { + "d1-1" : { + "length": 80, + "src_port": "1T", + "dst_port": "1R", + "local_peer_port": "1R", + "remote_peer_port": "1T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "d1-2" : { + "length": 80, + "src_port": "2T", + "dst_port": "2R", + "local_peer_port": "2R", + "remote_peer_port": "2T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "r1-r3": { + "length": 80, + "source" : "d2", + "target" : "d1", + "fibers" : { + "d2-1":{ + "length": 80, + "src_port": "3T", + "dst_port": "1R", + "local_peer_port": "3R", + "remote_peer_port": "1T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "d2-2":{ + "length": 80, + "src_port": "4T", + "dst_port": "2R", + "local_peer_port": "4R", + "remote_peer_port": "2T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "r3-r1": { + "length": 80, + "source" : "d1", + "target" : "d2", + "fibers" : { + "d1-1": { + "length": 80, + "src_port": "1T", + "dst_port": "3R", + "local_peer_port": "1R", + "remote_peer_port": "3T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "d1-2": { + "length": 80, + "src_port": "2T", + "dst_port": "4R", + "local_peer_port": "2R", + "remote_peer_port": "4T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "r2-r3": { + "length": 80, + "source" : "d2", + "target" : "d2", + "fibers" : { + "d2-1": { + "length": 80, + "src_port": "3T", + "dst_port": "3R", + "local_peer_port": "3R", + "remote_peer_port": "3T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "d2-2": { + "length": 80, + "src_port": "4T", + "dst_port": "4R", + "local_peer_port": "4R", + "remote_peer_port": "4T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "r3-r2": { + "length": 80, + "source" : "d2", + "target" : "d2", + "fibers" : { + "d2-1": { + "length": 80, + "src_port": "3T", + "dst_port": "3R", + "local_peer_port": "3R", + "remote_peer_port": "3T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "d2-2":{ + "length": 80, + "src_port": "4T", + "dst_port": "4R", + "local_peer_port": "4R", + "remote_peer_port": "4T", + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "t1-r1": { + "length": 0, + "source" : "muxT", + "target" : "srgR", + "fibers" : { + "M1": { + "length": 0, + "src_port": "1", + "dst_port": "101R", + "local_peer_port": "1", + "remote_peer_port": "101T", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "M2": { + "length": 0, + "src_port": "2", + "dst_port": "102R", + "local_peer_port": "2", + "remote_peer_port": "102T", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "M3": { + "length": 0, + "src_port": "3", + "dst_port": "103R", + "local_peer_port": "3", + "remote_peer_port": "103T", + "used": false, + "c_slots": [], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "r1-t1": { + "length": 0, + "source" : "srgT", + "target" : "muxR", + "fibers" : { + "S1": { + "length": 0, + "src_port": "101T", + "dst_port": "1", + "local_peer_port": "101R", + "remote_peer_port": "1", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "S2": { + "length": 0, + "src_port": "102T", + "dst_port": "2", + "local_peer_port": "102T", + "remote_peer_port": "2", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "S3": { + "length": 0, + "src_port": "103T", + "dst_port": "3", + "local_peer_port": "103R", + "remote_peer_port": "3", + "used": false, + "c_slots": [], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "t2-r2": { + "length": 0, + "source" : "muxT", + "target" : "srgR", + "fibers" : { + "M1": { + "length": 0, + "src_port": "1", + "dst_port": "101R", + "local_peer_port": "1", + "remote_peer_port": "101T", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "M2": { + "length": 0, + "src_port": "2", + "dst_port": "102R", + "local_peer_port": "2", + "remote_peer_port": "102T", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "M3": { + "length": 0, + "src_port": "3", + "dst_port": "103R", + "local_peer_port": "3", + "remote_peer_port": "103T", + "used": false, + "c_slots": [], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + }, + "r2-t2": { + "length": 0, + "source" : "srgT", + "target" : "muxR", + "fibers" : { + "S1": { + "length": 0, + "src_port": "101T", + "dst_port": "1", + "local_peer_port": "101R", + "remote_peer_port": "1", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "S2": { + "length": 0, + "src_port": "102T", + "dst_port": "2", + "local_peer_port": "102R", + "remote_peer_port": "2", + "used": false, + "c_slots": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + }, + "S3": { + "length": 0, + "src_port": "103T", + "dst_port": "3", + "local_peer_port": "103R", + "remote_peer_port": "3", + "used": false, + "c_slots": [], + "l_slots": [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119 ,120], + "s_slots": [501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519 ,520] + } + } + } +} diff --git a/src/opticalcontroller/requirements.in b/src/opticalcontroller/requirements.in new file mode 100644 index 0000000000000000000000000000000000000000..fefe604bc6f0d8d84c56817e7e85bb41015240ad --- /dev/null +++ b/src/opticalcontroller/requirements.in @@ -0,0 +1,21 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Flask==1.1.2 +flask-restplus==0.13.0 +itsdangerous==1.1.0 +Jinja2==2.11.3 +MarkupSafe==1.1.1 +numpy==1.23.0 +Werkzeug==0.16.1 diff --git a/src/opticalcontroller/tools.py b/src/opticalcontroller/tools.py new file mode 100644 index 0000000000000000000000000000000000000000..3b3223d81b2fe4e80956c02afae1a71c429493cf --- /dev/null +++ b/src/opticalcontroller/tools.py @@ -0,0 +1,189 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import numpy as np +from variables import * +import json + + +def common_slots(a, b): + return list(np.intersect1d(a, b)) + + +def map_modulation_to_op(mod): + if mod == "DP-QPSK": + return 1 + if mod == "DP-16QAM": + return 7 + if mod == "DP-64QAM": + return 10 + + +def map_band_to_slot(band): + return int(band/12.5) + + +def map_rate_to_slot(rate): + if rate == 100: + mod = "DP-QPSK" + slots = 4 + op = map_modulation_to_op(mod) + return op, slots + if rate == 400: + mod = "DP-16QAM" + slots = 8 + op = map_modulation_to_op(mod) + return op, slots + if rate == 1000: + mod = "DP-64QAM" + slots = 18 + op = map_modulation_to_op(mod) + return op, slots + else: + return 2, 5 + + +def consecutives(x, val): + res = [] + temp = [] + x.sort() + temp.append(x[0]) + y = 1 + for i in range(1, len(x)): + if x[i] == x[i - 1] + 1: + y += 1 + temp.append(x[i]) + else: + if y >= val: + res.extend(temp) + temp = [x[i]] + y = 1 + if i == len(x) - 1 and y >= val: + res.extend(temp) + return res + + +def combine(ls1, ls2): + temp = ls1 + for i in ls2: + if i not in ls1: + temp.append(i) + temp.sort() + return temp + + +def list_in_list(a, b): + # convert list A to numpy array + a_arr = np.array(a) + # convert list B to numpy array + b_arr = np.array(b) + + for i in range(len(b_arr)): + if np.array_equal(a_arr, b_arr[i:i + len(a_arr)]): + return True + return False + + +def reverse_link(link): + s, d = link.split('-') + r_link = "{}-{}".format(d, s) + return r_link + + +def get_slot_frequency(b, n): + if debug: + print(n) + if b == "c_slots": + return Fc + n * 12.5 + if b == "s_slots": + return Fs + n * 12.5 + if b == "l_slots": + return Fl + n * 12.5 + + +def freqency_converter(b, slots): + l = len(slots) + if debug: + print(slots) + if l % 2 == 0: + if debug: + print("pari {}".format(l)) + fx = get_slot_frequency(b, slots[int(l / 2)-1]) + if debug: + print(fx) + #GHz + # #f0 = fx + 6.25 + #MHz + f0 = int((fx + 6.25) * 1000) + else: + f0 = get_slot_frequency(b, slots[int((l + 1) / 2) - 1]) + #GHz + # #return f0, 12.5 * l + # MHz + return f0, int((12.5 * l) * 1000) + + +def readTopologyData(nodes, topology): + nodes_file = open(nodes, 'r') + topo_file = open(topology, 'r') + nodes = json.load(nodes_file) + topo = json.load(topo_file) + print(topo) + nodes_file.close() + topo_file.close() + return nodes, topo + + +def reverse_links(links): + temp_links = links.copy() + temp_links.reverse() + result = [] + for link in temp_links: + [a, b] = link.split("-") + result.append("{}-{}".format(b, a)) + return result + +def get_links_from_node(topology, node): + result = {} + for link in topology["links"]: + if "{}-".format(node) in link["optical_link"]["name"]: + result[link["optical_link"]["name"]] = link + return result + +def get_links_to_node(topology, node): + result = {} + for link in topology["links"]: + if "-{}".format(node) in link["optical_link"]["name"]: + result[link["optical_link"]["name"]] = link + return result + + +def slot_selection(c, l, s, n_slots, Nc, Nl, Ns): + # First Fit + if isinstance(n_slots, int): + slot_c = n_slots + slot_l = n_slots + slot_s = n_slots + else: + slot_c = Nc + slot_l = Nl + slot_s = Ns + if len(c) >= slot_c: + return "c_slots", c[0: slot_c] + elif len(l) >= slot_l: + return "l_slots", l[0: slot_l] + elif len(l) >= slot_s: + return "s_slots", s[0: slot_s] + else: + return None, None diff --git a/src/opticalcontroller/variables.py b/src/opticalcontroller/variables.py new file mode 100644 index 0000000000000000000000000000000000000000..cbb65200f2f0c5ef9cd490c1435fb7a9120e5d63 --- /dev/null +++ b/src/opticalcontroller/variables.py @@ -0,0 +1,32 @@ +# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +debug = 1 + +Fl = 184800 +Fc = 192000 +Fs = 196200 + +Nl = 550 +Nc = 320 +#Nc = 10 +Ns = 720 + +nodes_json = 'json_files/nodes.json' +topology_json = 'json_files/tfs.json' #LAST +#topology_json = 'json_files/optical_TFSworking.json' #LAST +#topology_json = 'json_files/optical_topoTFS.json' +#topology_json = 'json_files/topo_2_links.json' + +testing = 1