def _initialize(self, config): curr_type = -1 devices = {} links = {} flows = {} measure_flows = {} measure_links = {} for line in config: line = line.strip() if line in self._type_format: curr_type = self._type_format[line] continue # Hosts if curr_type == 0: [name] = line.split(', ') host = Host(name) devices[name] = host # Routers elif curr_type == 1: [name, algorithm] = line.split(', ') if algorithm == BellmanFord._TYPE: algorithm = BellmanFord() router = Router(algorithm, name) devices[name] = router # Connections elif curr_type == 2: [name, source, dest, rate, delay, size] = line.split(', ') source_device = devices[source] dest_device = devices[dest] rate = int(rate) delay = float(delay) size = int(size) source_link = Link() dest_link = Link() source_port = Port() source_port.source(source_device) source_port.conn(dest_link) source_port.incoming(Buffer(size)) source_port.outgoing(Buffer(size)) dest_port = Port() dest_port.source(dest_device) dest_port.conn(source_link) dest_port.incoming(Buffer(size)) dest_port.outgoing(Buffer(size)) source_link.dest(source_port) source_link.rate(rate) source_link.delay(delay) source_link.getTracker().set_delay(delay) dest_link.dest(dest_port) dest_link.rate(rate) dest_link.delay(delay) dest_link.getTracker().set_delay(delay) source_device.enable(source_port) dest_device.enable(dest_port) links[name] = dest_link # Flows elif curr_type == 3: [name, source, dest, size, time, algorithm] = line.split(', ') source_device = devices[source] dest_device = devices[dest] size = int(size) time = float(time) if algorithm == AIMD._TYPE: algorithm = AIMD() elif algorithm == FAST._TYPE: algorithm = FAST() flow = Flow(algorithm) flow.bits(size) flow.start(time) flow.dest(dest_device) algorithm.initialize(flow) source_device.connect(flow) flows[name] = flow # Measurables elif curr_type == 4: # TODO: track measurables [name, type] = line.split(', ') if type == "flow": measure_flows[name] = flows[name] elif type == "link": measure_links[name] = links[name] return (devices.values(), measure_flows, measure_links)