def __init__(self, sw_name): self.topo = load_topo('topology.json') self.sw_name = sw_name self.thrift_port = self.topo.get_thrift_port(sw_name) self.cpu_port = self.topo.get_cpu_port_index(self.sw_name) self.controller = SimpleSwitchThriftAPI(self.thrift_port) self.init()
def __init__(self): if not os.path.exists('topology.json'): print('Could not find topology object!!!\n') raise Exception self.topo = load_topo('topology.json') self.controllers = {} self.init()
def __init__(self, sw_name, set_hash): self.topo = load_topo('topology.json') self.sw_name = sw_name self.set_hash = set_hash self.thrift_port = self.topo.get_thrift_port(sw_name) self.controller = SimpleSwitchThriftAPI(self.thrift_port) self.custom_calcs = self.controller.get_custom_crc_calcs() self.register_num = len(self.custom_calcs) self.init() self.registers = []
def __init__(self, sw_name): self.topo = load_topo('topology.json') self.sw_name = sw_name self.cpu_port = self.topo.get_cpu_port_index(self.sw_name) device_id = self.topo.get_p4switch_id(sw_name) grpc_port = self.topo.get_grpc_port(sw_name) sw_data = self.topo.get_p4rtswitches()[sw_name] self.controller = SimpleSwitchP4RuntimeAPI( device_id, grpc_port, p4rt_path=sw_data['p4rt_path'], json_path=sw_data['json_path']) self.init()
def __init__(self, subnets=0): self.topo = load_topo('topology.json') self.controllers = {} print('Generating destination subnets...') destination_subnets = self.generate_ips("10.0.1.0/24", "10.250.250.0/24") h2 = destination_subnets[0] h3 = destination_subnets[-1] # Remove them destination_subnets = destination_subnets[1:-1] # Filter entries destination_subnets = destination_subnets[:subnets] # Put them back destination_subnets = [h2] + destination_subnets + [h3] self.destination_subnets = destination_subnets
def __init__(self, num_hashes=3): self.topo = load_topo('topology.json') self.controllers = {} self.num_hashes = num_hashes # gets a controller API for each switch: {"s1": controller, "s2": controller...} self.connect_to_switches() # creates the 3 hashes that will use the p4 switch self.create_local_hashes() # initializes the switch # resets all registers, configures the 3 x 2 hash functions # reads the registers # populates the tables and mirroring id self.init() self.registers = {}
def __init__(self): """Initializes the topology and data structures.""" if not os.path.exists('topology.json'): print("Could not find topology object!\n") raise Exception self.topo = load_topo('topology.json') self.controllers = {} self.connect_to_switches() self.reset_states() # Preconfigure all MAC addresses self.install_macs() # Install nexthop indices and populate registers. self.install_nexthop_indices() self.update_nexthops()
def __init__(self): """Initializes the topology and data structures """ if not os.path.exists('topology.json'): print('Could not find topology object!!!\n') raise Exception self.topo = load_topo('topology.json') self.controllers = {} self.init() # sorted by timeouts self.current_reservations = {} # initial link capacity self.links_capacity = self.build_links_capacity() self.update_lock = threading.Lock() self.timeout_thread = threading.Thread( target=self.reservations_timeout_thread, args=(1, )) self.timeout_thread.daemon = True self.timeout_thread.start()
from p4utils.utils.helper import load_topo from p4utils.utils.sswitch_p4runtime_API import SimpleSwitchP4RuntimeAPI topo = load_topo('topology.json') controllers = {} for switch, data in topo.get_p4rtswitches().items(): controllers[switch] = SimpleSwitchP4RuntimeAPI(data['device_id'], data['grpc_port'], p4rt_path=data['p4rt_path'], json_path=data['json_path']) controller = controllers['s1'] controller.table_add('dmac', 'forward', ['00:00:0a:00:00:01'], ['1']) controller.table_add('dmac', 'forward', ['00:00:0a:00:00:02'], ['2']) controller.table_add('dmac', 'forward', ['00:00:0a:00:00:03'], ['3']) controller.table_add('dmac', 'forward', ['00:00:0a:00:00:04'], ['4'])
def __init__(self): self.topo = load_topo('topology.json') self.controllers = {} self.init()