def test_read_write_topology(self): tmp_topo_file = path.join(TMP_DIR, 'toporw.xml') fnss.write_topology(self.G, tmp_topo_file) self.assertTrue(path.exists(tmp_topo_file)) read_topo = fnss.read_topology(tmp_topo_file) self.assertEqual(len(self.G), len(read_topo)) self.assertEqual(self.G.number_of_edges(), read_topo.number_of_edges()) self.assertEqual('tcp', fnss.get_stack(read_topo, 2)[0]) self.assertEqual(1024, fnss.get_stack(read_topo, 2)[1]['rcvwnd']) self.assertEqual('cubic', fnss.get_stack(read_topo, 2)[1]['protocol']) self.assertEqual(len(fnss.get_application_names(self.G, 2)), len(fnss.get_application_names(read_topo, 2))) self.assertEqual( 'fnss', fnss.get_application_properties(read_topo, 2, 'server')['user-agent']) self.assertEqual([2, 4, 6], [ v for v in read_topo.nodes() if fnss.get_stack(read_topo, v) is not None and fnss.get_stack(read_topo, v)[0] == 'tcp' ]) self.assertEqual([2, 4], [ v for v in read_topo.nodes() if 'client' in fnss.get_application_names(read_topo, v) ]) self.assertEqual([2], [ v for v in read_topo.nodes() if 'server' in fnss.get_application_names(read_topo, v) ])
def main(): """Main function""" if len(argv) != 5: print('Usage: python simrun.py topology.xml eventschedule.xml name_scenario strategy') exit(1) # parse arguments topology = read_topology(argv[1])# parse from command line event_schedule = read_event_schedule(argv[2]) # parse from command line scenario_id = argv[3] strategy_id = argv[4] run(topology, event_schedule, scenario_id, strategy_id)
def main(n): # generate_topo(n) topo = fnss.read_topology('topo_'+'ft'+'.xml') # return fnss.Topology # plot_topo(topo,'ft') # addition_for_pl(topo) mn_topo = fnss.to_mininet(topo,relabel_nodes=True) # add_hosts_for_pl(topo,mn_topo) net = Mininet(topo=mn_topo, link=TCLink, switch=CustomSwitch, controller=None, cleanup=True) net.addController( controller=RemoteController, ip=CONTROLLER_IP, port=CONTROLLER_PORT) net.start() CLI(net) net.stop()
def run_simulation_scenario(t, a, c, s): """Run a single simulation scenario with given topology, alpha, cache size and strategy """ use_events_file = config.USE_EVENTS_FILE n_contents = config.N_CONTENTS scenarios_dir = config.SCENARIOS_DIR topo_prefix = config.TOPO_PREFIX es_prefix = config.ES_PREFIX topo_file = path.join(scenarios_dir, topo_prefix + 'T=%s@C=%s.xml' % (t, str(c))) scenario_id = 'T=%s@C=%s@A=%s@S=%s' % (t, str(c), str(a), s) topo = read_topology(topo_file) if use_events_file: es_file = path.join(scenarios_dir, es_prefix + 'T=%s@A=%s.xml' % (t, str(a))) es = read_event_schedule(es_file) else: es = req_generator(topo, n_contents, a) run(topo, es, scenario_id, s)
def test_read_write_topology(self): tmp_topo_file = path.join(TMP_DIR, 'toporw.xml') fnss.write_topology(self.G, tmp_topo_file) self.assertTrue(path.exists(tmp_topo_file)) read_topo = fnss.read_topology(tmp_topo_file) self.assertEquals(len(self.G), len(read_topo)) self.assertEquals(self.G.number_of_edges(), read_topo.number_of_edges()) self.assertEquals('tcp', fnss.get_stack(read_topo, 2)[0]) self.assertEquals(1024, fnss.get_stack(read_topo, 2)[1]['rcvwnd']) self.assertEquals('cubic', fnss.get_stack(read_topo, 2)[1]['protocol']) self.assertEquals(len(fnss.get_application_names(self.G, 2)), len(fnss.get_application_names(read_topo, 2))) self.assertEquals('fnss', fnss.get_application_properties(read_topo, 2, 'server')['user-agent']) self.assertEquals([2, 4, 6], [ v for v in read_topo.nodes_iter() if fnss.get_stack(read_topo, v) is not None and fnss.get_stack(read_topo, v)[0] == 'tcp']) self.assertEquals([2, 4], [ v for v in read_topo.nodes_iter() if 'client' in fnss.get_application_names(read_topo, v)]) self.assertEquals([2], [ v for v in read_topo.nodes_iter() if 'server' in fnss.get_application_names(read_topo, v)])
def run_simulation_scenario(t, a, c, s): """Run a single simulation scenario with given topology, alpha, cache size and strategy """ use_events_file = config.USE_EVENTS_FILE n_contents = config.N_CONTENTS scenarios_dir = config.SCENARIOS_DIR topo_prefix = config.TOPO_PREFIX es_prefix = config.ES_PREFIX topo_file = path.join(scenarios_dir, topo_prefix + 'T=%s@C=%s.xml' % (t, str(c))) scenario_id = 'T=%s@C=%s@A=%s@S=%s' % (t, str(c), str(a), s) topo = read_topology(topo_file) if use_events_file: es_file = path.join(scenarios_dir, es_prefix + 'T=%s@A=%s.xml' % (t, str(a))) es = read_event_schedule(es_file) else: es = req_generator(topo, n_contents, a) exec_experiment(topo, es, scenario_id, s)