Commit 7f6f0a8a authored by Maria Ruiz's avatar Maria Ruiz
Browse files

sat request y QoS

parent 55b6eb9f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ PCE_EXTERNAL = False

# Controller Flags
# If True, config is not sent to controllers
DUMMY_MODE = False
DUMMY_MODE = True
#DUMMY_MODE = True #MR

#####TERAFLOW#####
+30 −8
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ class NSController:
    - Slice Realization: Convert intents to specific network configurations (L2VPN, L3VPN)
    """

    def __init__(self, controller_type = "TFS", tfs_ip=TFS_IP, ixia_ip =IXIA_IP, need_l2vpn_support=TFS_L2VPN_SUPPORT, satnms_ip=SATNMS_IP): 
    def __init__(self, controller_type = "sat", tfs_ip=TFS_IP, ixia_ip =IXIA_IP, need_l2vpn_support=TFS_L2VPN_SUPPORT, satnms_ip=SATNMS_IP): 
        """
        Initialize the Network Slice Controller.

@@ -287,6 +287,13 @@ class NSController:
                    # Mapper
                    self.__mapper(intent)
                    # Realizer
                    if self.controller_type == "sat":
                        tfs_request, sat_request = self.__realizer(intent)
                        requests["services"].append(tfs_request)
                        requests2 = {"services":[]}
                        requests2["services"].append(sat_request)
                        logging.info(f"Realizing request: {tfs_request} and {sat_request}")
                    else:
                        tfs_request = self.__realizer(intent)
                        requests["services"].append(tfs_request)
                        logging.info("Realizing request: {tfs_request}")
@@ -297,6 +304,10 @@ class NSController:
            if DUMP_TEMPLATES:
                with open(os.path.join(TEMPLATES_PATH, "realizer_template.json"), "w") as archivo:
                    archivo.write(json.dumps(requests,indent=2))
            if self.controller_type == "sat" and requests2:
                if DUMP_TEMPLATES:
                    with open(os.path.join(TEMPLATES_PATH, "realizer_template_sat.json"), "w") as archivo:
                        archivo.write(json.dumps(requests2,indent=2))
            
            # Optional: Upload template to Teraflow
            if not DUMMY_MODE:
@@ -836,10 +847,14 @@ class NSController:
        elif controller == "IXIA":
            realizing_request = self.__ixia(ietf_intent)
        elif controller == "sat":
            realizing_request = self.__sat(ietf_intent)
            realizing_request_nms, realizing_request_sat = self.__sat(ietf_intent)
        else:
            logging.warning(f"Unsupported controller: {controller}. Defaulting to TFS L2VPN realization.")
            realizing_request = self.__tfs_l2vpn(ietf_intent)
       
        if controller == "sat":
            return realizing_request_nms, realizing_request_sat
        else:
            return realizing_request

    def __tfs_l2vpn(self, ietf_intent):
@@ -1327,7 +1342,7 @@ class NSController:
                tolerance = bound   
       
        # Construcción del diccionario intent
        intent = {
        intent_nms = {
            
            "src_node_id":  ietf_intent.get("ietf-network-slice-service:network-slice-services", {})
                .get("slice-service", [{}])[0]
@@ -1366,6 +1381,13 @@ class NSController:
            "tolerance": tolerance,

        }
        intent_sat = {
            "bandwidth": bandwidth,
            "latency": latency,
            "tolerance": tolerance,

        }

        logging.info(f"SATELLITE Intent realized\n")
        return intent
        return intent_nms, intent_sat
    
+88 −1
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ class SAT_NMS:
        latency = json_data.get("latency", None)
        tolerance = json_data.get("tolerance", None)

        shaper = None
        bandwidth = None

        new_service = self.new_service(self.satnms_ip, vlan_id)

        if new_service is not None:
@@ -50,6 +53,7 @@ class SAT_NMS:
            #mapeo QoS:
            if QoS_profile == "A":
                qos_mapped = "qos:0 QoS_P7"
                shaper ="shaper:0 shaper1"
            elif QoS_profile == "B":
                qos_mapped = "qos:2 QoS_P4"
            elif QoS_profile == "C":
@@ -62,6 +66,15 @@ class SAT_NMS:

            add_route_station = self.add_routes_station(self.satnms_ip, num_service, vlan_id, qos_mapped)
            print(f'\n\n{add_route_station}\n')

            if bandwidth is not None:
                change_symbol_rate = self.change_symbol_rate(self.satnms_ip, bandwidth)
                print(f'\n\n{change_symbol_rate}\n')

            if shaper is not None:
                shaper_applied = self.shaper(self.satnms_ip, shaper)
                print(f'\n\n{shaper_applied}\n')

        else: 
            print("No se pudo crear la Slice")

@@ -177,10 +190,84 @@ class SAT_NMS:
        error_code = response.json().get("error_code",None)

        if response.status_code==200 and error_code !="0":
            logging.info("Nueva rua añadida en STATION")
            logging.info("Nueva ruta añadida en STATION")
            return response.json()
        else:
            print(f"Error al añadir la ruta en STATION;  error code:"+str(response.json().get("error_code",None))+ "; error log: "+str(response.json().get("error_log",None)))
            return None      
                  
    def change_symbol_rate(self,ip,bw):
        
        #parametros fijos (de momento)
        #Bw viene dado en Kbps

        if bw>300:
            print("Throughput no soportado")
            return None 
        else:   
            bpsym = int(4) # bits por simbolo 16APSK
            FEC = float(8/9)
            #Roll_off = float(0.2)

            symbol_rate = int(bw)/(bpsym*FEC) #kSps

            session = self.loggin_NMS(ip)

            if session is None:
                print("No se pudo iniciar sesion en el NMS")
                return None
    
            url = "http://"+ip+":8000/api/object/write/controller=0"

            body_dict_c = {
            "tx_sr": int(symbol_rate)
            }

            body_dict_s = {
            "a_dama_sr": int(symbol_rate)
            }

            payload = json.dumps(body_dict_c)
            response_c = requests.post(url, cookies=session, auth=('admin', '12345'), data=payload)
            error_code_c = response_c.json().get("error_code",None)

            payload = json.dumps(body_dict_s)
            response_s = requests.post(url, cookies=session, auth=('admin', '12345'), data=payload)
            error_code_s = response_s.json().get("error_code",None)

            if response_c.status_code==200 and response_s.status_code==200 and error_code_c !="0" and error_code_s !="0":
                logging.info("Symbol rate"+str(symbol_rate)+" modificado en HUB y STATION")
                return response_s.json()
            else:
                print(f"Error modificar el Symbol rate; HUB error code:"+str(response_c.json().get("error_code",None))+ "; HUB error log: "+str(response_c.json().get("error_log",None))+"; STATION error code:"+str(response_s.json().get("error_code",None))+ "; STATION error log: "+str(response_s.json().get("error_log",None)))
                return None

    def shaper(self,ip,shaper):
        
        session = self.loggin_NMS(ip)

        if session is None:
            print("No se pudo iniciar sesion en el NMS")
            return None

        url = "http://"+ip+":8000/api/object/write/qos=2"

        body_dict = {
            "shaper": shaper
        }

        payload = json.dumps(body_dict)
        response = requests.post(url, cookies=session, auth=('admin', '12345'), data=payload)
        error_code = response.json().get("error_code",None)

        if response.status_code==200 and error_code !="0":
            logging.info("Shaper aplicado")
            return response.json()
        else:
            print(f"Error al aplicar el shaper; error code:"+str(response.json().get("error_code",None))+ "; error log: "+str(response.json().get("error_log",None)))
            return None




    
+1458 −0

File changed.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
                {
                  "metric-type": "one-way-bandwidth",
                  "metric-unit": "kbps",
                  "bound": 2
                  "bound": 200
                },
                {
                  "metric-type": "one-way-delay-maximum",
@@ -37,7 +37,7 @@
      },
      "slice-service": [
        {
          "id": "slice-service-8473f01e-ff21-4c89-8ff1-2dc2c15d2096",
          "id": "slice-service-754a6bc5-0754-4de6-88d3-8b064b13c936",
          "description": "Transport network slice mapped with 3GPP slice NetworkSlice1",
          "service-tags": {
            "tag-type": {
@@ -135,7 +135,7 @@
            "connection-group": [
              {
                "id": "HUB_STATION",
                "connectivity-type": "ietf-vpn-common:any-to-any",
                "connectivity-type": "ietf-vpn-common:point-to-point",
                "connectivity-construct": [
                  {
                    "id": 1,
Loading