示例#1
0
 def test_4nodes_3paths_unstatified_heuristic(self):
     reqs = TestOSPF.get_3path_req()
     ospf = synet.synthesis.ospf_heuristic.OSPFSyn(self.network_graph,
                                                   gen_paths=10)
     for req in reqs:
         ospf.add_req(req)
     ret = ospf.synthesize()
     self.assertFalse(ret)
示例#2
0
 def test_grid2_2path_heurisitc(self):
     g = self.gen_grid(2, 2, 1)
     reqs = self.generate_paths(g, 2)
     ospf = synet.synthesis.ospf_heuristic.OSPFSyn(g,
                                                   random_obj=self.random)
     for req in reqs:
         ospf.add_req(req)
     self.assertTrue(ospf.synthesize())
     self.assertEqual(len(ospf.reqs), 2)
     self.assertEqual(len(ospf.removed_reqs), 0)
示例#3
0
 def test_4nodes_1paths_heuristic(self):
     reqs = TestOSPF.get_1path_req()
     ospf = synet.synthesis.ospf_heuristic.OSPFSyn(self.network_graph,
                                                   gen_paths=10)
     for req in reqs:
         ospf.add_req(req)
     ret = ospf.synthesize()
     self.assertTrue(ret)
     ospf.update_network_graph()
     self.assertEqual(len(ospf.reqs), 1)
     self.assertEqual(len(ospf.removed_reqs), 0)
示例#4
0
 def test_ordered_correct(self):
     fan_out = 4
     network_graph = self.get_triangles(fan_out)
     source = 'source'
     sink = 'sink'
     p1 = [source, 'R1', sink]
     p2 = [source, 'R2', sink]
     p3 = [source, 'R3', sink]
     p4 = [source, 'R4', sink]
     path1 = PathReq(Protocols.OSPF, 'Google', p1, False)
     path2 = PathReq(Protocols.OSPF, 'Google', p2, False)
     path3 = PathReq(Protocols.OSPF, 'Google', p3, False)
     paths = [path1, path2, path3]
     order_req = PathOrderReq(Protocols.OSPF, 'Google', paths, False)
     ospf = synet.synthesis.ospf_heuristic.OSPFSyn(network_graph,
                                                   gen_paths=10)
     ospf.add_req(order_req)
     ret = ospf.synthesize()
     self.assertTrue(ret)
     ospf.update_network_graph()
     p1_cost = [
         network_graph.get_edge_ospf_cost(src, dst)
         for src, dst in zip(p1[0::1], p1[1::1])
     ]
     p2_cost = [
         network_graph.get_edge_ospf_cost(src, dst)
         for src, dst in zip(p2[0::1], p2[1::1])
     ]
     p3_cost = [
         network_graph.get_edge_ospf_cost(src, dst)
         for src, dst in zip(p3[0::1], p3[1::1])
     ]
     p4_cost = [
         network_graph.get_edge_ospf_cost(src, dst)
         for src, dst in zip(p4[0::1], p4[1::1])
     ]
     p1_cost = sum(p1_cost)
     p2_cost = sum(p2_cost)
     p3_cost = sum(p3_cost)
     p4_cost = sum(p4_cost)
     self.assertLessEqual(p1_cost, p2_cost)
     self.assertLessEqual(p2_cost, p3_cost)
     self.assertLessEqual(p3_cost, p4_cost)
示例#5
0
 def test_ordered_notvalid(self):
     fan_out = 4
     network_graph = self.get_triangles(fan_out)
     source = 'source'
     sink = 'sink'
     p1 = [source, 'R1', sink]
     p2 = [source, 'R2', sink]
     p3 = [source, 'R3', sink]
     path1 = PathReq(Protocols.OSPF, 'Google', p1, False)
     path2 = PathReq(Protocols.OSPF, 'Google', p2, False)
     path3 = PathReq(Protocols.OSPF, 'Google', p3, False)
     paths = [path1, path2, path3]
     order_req1 = PathOrderReq(Protocols.OSPF, 'Google', paths, False)
     order_req2 = PathOrderReq(Protocols.OSPF, 'Google',
                               [path3, path2, path1], False)
     ospf = synet.synthesis.ospf_heuristic.OSPFSyn(network_graph,
                                                   gen_paths=10)
     ospf.add_req(order_req1)
     ospf.add_req(order_req2)
     ret = ospf.synthesize()
     self.assertFalse(ret)
示例#6
0
 def test_ecmp_correct(self):
     fan_out = 4
     network_graph = self.get_triangles(fan_out)
     source = 'source'
     sink = 'sink'
     p1 = [source, 'R1', sink]
     p2 = [source, 'R2', sink]
     path1 = PathReq(Protocols.OSPF, 'Google', p1, False)
     path2 = PathReq(Protocols.OSPF, 'Google', p2, False)
     ecmp_req = ECMPPathsReq(Protocols.OSPF, 'Google', [path1, path2],
                             False)
     ospf = synet.synthesis.ospf_heuristic.OSPFSyn(network_graph,
                                                   gen_paths=10)
     ospf.add_req(ecmp_req)
     ret = ospf.synthesize()
     self.assertTrue(ret)
     ospf.update_network_graph()
     ecmp = [
         tuple(p) for p in nx.all_shortest_paths(network_graph, source,
                                                 sink, 'ospf_cost')
     ]
     ecmp = set(ecmp)
     self.assertEquals(ecmp, set([tuple(p1), tuple(p2)]))