Ejemplo n.º 1
0
def diamond_test():
    config = NetworkConfig(paths=[('s1', 's4', ['s1', 's2', 's4'])],
                           egresses=['s4'])
    topo = DiamondTopo()
    topo.apply_config(config)

    specstr = "not match(ip_src=a.b.c.d); s1: .* s2 .* => (N-s2) s3 (N-s2)"
    s = Specification.parseString(topo, specstr)
    net = synthesis.AbstractNetwork(topo, s)
    abs_net = conv_abstract_network(net)
    slvr = CPPSolver(abs_net)

    t = time.time()
    result = slvr.solve()
    t = time.time() - t

    expected = [('s3', 's4'), ('s1', 's3')]
    expected = [(net.node_intrep[s], net.node_intrep[d]) for (s,d) in expected]
    print "Result:", result
    print "Expect:", expected
    print "Solver time: {0}ms".format(round(t * 1000, 3))
Ejemplo n.º 2
0
def fattree_test():
    config = NetworkConfig(paths=[('h25', 'h34',  ['h25', 's14', 's6', 's0',
                                                   's10', 's19', 'h34'])])
    topo = FattreeTopo()
    topo.apply_config(config)

    specstr = "not match(ip_src=a.b.c.d); s14: .* s0 .* => (N-s0)* s1 (N-s0)* od"
    s = Specification.parseString(topo, specstr)
    net = synthesis.AbstractNetwork(topo, s)
    abs_net = conv_abstract_network(net)
    slvr = CPPSolver(abs_net)

    t = time.time()
    result = slvr.solve()
    t = time.time() - t

    expected = [('s6', 's1'), ('s1', 's10')]
    expected = [(net.node_intrep[s], net.node_intrep[d]) for (s,d) in expected]
    print "Result:", result
    print "Expect:", expected
    print "Solver time: {0}ms".format(round(t * 1000, 3))
Ejemplo n.º 3
0
    def action_edit_in_new_window(self):
        args = []
        executable_path = sublime.executable_path()
        if sublime.platform() == 'osx':
            app_path = executable_path[:executable_path.rfind(".app/") + 5]
            executable_path = app_path + "Contents/SharedSupport/bin/subl"
        else:
            executable_path = os.path.join(os.path.dirname(executable_path),
                                           'subl')

        args.append(executable_path)
        path = os.path.abspath(self.path)

        args.append(path)
        spec = Specification(args)
        spec.quote()
        spec = self.get_spec('detach_run', spec)
        spec = self.get_spec('shell', spec)
        spec.popen()
Ejemplo n.º 4
0
def runSynthesisConfigured(topo, spec, expected):
    s = Specification.parseString(topo, spec)
    solver = Synthesizer(topo, s)
    result = solver.solve()
    for edge in expected:
        assert edge in result
Ejemplo n.º 5
0
 def get_spec(self, *args, **kwargs):
     spec = Specification.get_spec(*args, **kwargs)
     return spec
Ejemplo n.º 6
0
 def testSpecInvalidNodes(self):
     specstr = "match(ip_src=a.b.c.d); s5: .* s2 .* => (N-s2)* s3 (N-s2)*"
     with self.assertRaises(Exception):
         spec = Specification.parseString(DiamondTopo(), specstr)
Ejemplo n.º 7
0
 def testSpecNoOdNm(self):
     specstr = "match(ip_src=a.b.c.d); s1: .* s2 .* => (N-s2)* s3 (N-s2)*"
     spec = Specification.parseString(DiamondTopo(), specstr)
     assert spec.od == False
     assert len(spec.immutables) == 0
Ejemplo n.º 8
0
 def testSpec(self):
     specstr = "match(ip_src=a.b.c.d); s1: .* s2 .* => (N-s2)* s3 (N-s2)* od NM:{s4}"
     spec = Specification.parseString(DiamondTopo(), specstr)
     assert spec.od == True
     assert len(spec.sources) == 1 and spec.sources[0] == 's1'
     assert len(spec.immutables) == 1 and spec.immutables[0] == 's4'