def setup_method(self): # # s1 s2 # | | # c1-----c2----c3 # / \ / | \ \ # r1 r2 r3 r4 r5 r6 # topo = fnss.Topology() icr_candidates = ["c1", "c2", "c3"] nx.add_path(topo, icr_candidates) topo.add_edge("c2", "s1") topo.add_edge("c2", "s2") topo.add_edge("c1", "r1") topo.add_edge("c1", "r2") topo.add_edge("c2", "r3") topo.add_edge("c2", "r4") topo.add_edge("c2", "r5") topo.add_edge("c3", "r6") topo.graph["icr_candidates"] = set(icr_candidates) for router in icr_candidates: fnss.add_stack(topo, router, "router") for src in ["s1"]: fnss.add_stack(topo, src, "source") for rcv in ["r1", "r2", "r3", "r4", "r5", "r6"]: fnss.add_stack(topo, rcv, "receiver") self.topo = cacheplacement.IcnTopology(topo)
def setUp(self): # # -- s1 -- # / | \ # c1-----c2----c3 # / \ / | \ \ # r1 r2 r3 r4 r5 r6 # topo = fnss.Topology() icr_candidates = ["c1", "c2", "c3"] topo.add_path(icr_candidates) topo.add_edge("c1", "s1") topo.add_edge("c2", "s1") topo.add_edge("c3", "s1") topo.add_edge("c1", "r1") topo.add_edge("c1", "r2") topo.add_edge("c2", "r3") topo.add_edge("c2", "r4") topo.add_edge("c2", "r5") topo.add_edge("c3", "r6") topo.graph['icr_candidates'] = set(icr_candidates) for router in icr_candidates: fnss.add_stack(topo, router, 'router') for src in ['s1']: fnss.add_stack(topo, src, 'source') for rcv in ['r1', 'r2', 'r3', 'r4', 'r5', 'r6']: fnss.add_stack(topo, rcv, 'receiver') self.topo = cacheplacement.IcnTopology(topo)
def test_extract_cluster_level_topology(self): t = algorithms.IcnTopology(fnss.line_topology(6)) t.graph['icr_candidates'] = set(t.nodes()) clusters = [{0, 1}, {2, 3}, {4, 5}] algorithms.deploy_clusters(t, clusters) ct = algorithms.extract_cluster_level_topology(t) assert len(clusters) == len(ct)
def test_extract_cluster_level_topology(self): t = algorithms.IcnTopology(fnss.line_topology(6)) t.graph['icr_candidates'] = set(t.nodes()) clusters = [set([0, 1]), set([2, 3]), set([4, 5])] algorithms.deploy_clusters(t, clusters) ct = algorithms.extract_cluster_level_topology(t) self.assertEqual(len(clusters), len(ct))
def test_algorithms(self): t = algorithms.IcnTopology(fnss.line_topology(6)) t.graph['icr_candidates'] = set(t.nodes()) fnss.set_delays_constant(t, 1, 'ms') fnss.set_delays_constant(t, 3, 'ms', [(1, 2), (3, 4)]) clusters = algorithms.compute_clusters(t, 3) expected_clusters = [{0, 1}, {2, 3}, {4, 5}] assert expected_clusters == clusters
def test_extract_cluster_level_topology_1_cluster(self): t = algorithms.IcnTopology(fnss.line_topology(3)) t.graph['icr_candidates'] = set(t.nodes()) clusters = [t.graph['icr_candidates']] algorithms.deploy_clusters(t, clusters) ct = algorithms.extract_cluster_level_topology(t) assert 1 == len(clusters) assert 1 == ct.number_of_nodes()
def test_algorithms(self): t = algorithms.IcnTopology(fnss.line_topology(6)) t.graph['icr_candidates'] = set(t.nodes()) fnss.set_delays_constant(t, 1, 'ms') fnss.set_delays_constant(t, 3, 'ms', [(1, 2), (3, 4)]) clusters = algorithms.compute_clusters(t, 3) expected_clusters = [set([0, 1]), set([2, 3]), set([4, 5])] self.assertEqual(expected_clusters, clusters)
def test_deploy_clusters(self): t = algorithms.IcnTopology(fnss.line_topology(6)) t.graph['icr_candidates'] = set(t.nodes()) clusters = [{0, 1}, {2, 3}, {4, 5}] cluster_map = {0: 0, 1: 0, 2: 1, 3: 1, 4: 2, 5: 2} algorithms.deploy_clusters(t, clusters) assert clusters == t.graph['clusters'] for v, data in t.nodes(data=True): assert cluster_map[v] == data['cluster']
def test_deploy_clusters(self): t = algorithms.IcnTopology(fnss.line_topology(6)) t.graph['icr_candidates'] = set(t.nodes()) clusters = [set([0, 1]), set([2, 3]), set([4, 5])] cluster_map = {0: 0, 1: 0, 2: 1, 3: 1, 4: 2, 5: 2} algorithms.deploy_clusters(t, clusters) self.assertEqual(clusters, t.graph['clusters']) for v, data in t.nodes(data=True): self.assertEqual(cluster_map[v], data['cluster'])
def setUp(self): topo = cacheplacement.IcnTopology(fnss.line_topology(7)) receivers = [0] sources = [6] icr_candidates = [1, 2, 3, 4, 5] topo.graph['icr_candidates'] = set(icr_candidates) for router in icr_candidates: fnss.add_stack(topo, router, 'router') for src in sources: fnss.add_stack(topo, src, 'source') for rcv in receivers: fnss.add_stack(topo, rcv, 'receiver') fnss.set_delays_constant(topo, 2, 'ms') fnss.set_delays_constant(topo, 20, 'ms', [(2, 3)]) self.topo = topo
def setup_method(self): topo = cacheplacement.IcnTopology(fnss.line_topology(7)) receivers = [0] sources = [6] icr_candidates = [1, 2, 3, 4, 5] topo.graph["icr_candidates"] = set(icr_candidates) for router in icr_candidates: fnss.add_stack(topo, router, "router") for src in sources: fnss.add_stack(topo, src, "source") for rcv in receivers: fnss.add_stack(topo, rcv, "receiver") fnss.set_delays_constant(topo, 2, "ms") fnss.set_delays_constant(topo, 20, "ms", [(2, 3)]) self.topo = topo