예제 #1
0
def main():
    parser = argparse.ArgumentParser(description='Compile netcore programs.')
    parser.add_argument('--waxman', action='store_const', const=waxman,
                        dest='topo_gen', help='Generate a waxman topology')
    parser.add_argument('--smallworld', action='store_const', const=smallworld,
                        dest='topo_gen', help='Generate a smallworld topology')
    parser.add_argument('--fattree', action='store_const', const=fattree,
                        dest='topo_gen', help='Generate a fattree topology')
    parser.add_argument('--flood', action='store_const', const=flood,
                        dest='policy_gen', help='Use a flood routing policy')
    parser.add_argument('--flood_observe', action='store_const',
                        const=flood_observe, dest='policy_gen',
                        help='Use a flood and observe routing policy')
    parser.add_argument('--shortest_path', action='store_const',
                        const=shortest_path, dest='policy_gen',
                        help='Use a shortest path routing policy')
    parser.add_argument('--multicast', action='store_const',
                        const=multicast, dest='policy_gen',
                        help='Use a multicast routing policy')
    parser.add_argument('-e', '--edge', action='store_true', default=False,
                        help='Use the per-edge compiler.')
    parser.add_argument('--hosts', action='store', type=int, default=20,
                        help='Number of hosts on network (approximate for '
                        'fattree).')
    parser.add_argument('--ast', action='store_true', default=False, help=
                        'Print out AST size statistics.')
    parser.add_argument('--ctime', action='store_true', default=False, help=
                        'Print out compilation timing information.')
    parser.add_argument('--vtime', action='store_true', default=False, help=
                        'Print out validation timing information.')
    args = parser.parse_args()
    init = time.time()
    topo = args.topo_gen(args.hosts)
    topo_time = time.time()
    policy = args.policy_gen(topo)
    policy_time = time.time()
    combined = build_slices(topo, policy)
    slice_time = time.time()
    compiled = do_compile(topo, combined, edge=args.edge)
    compile_time = time.time()
    if args.ast:
        ast_orig = policy.size()
        ast_final = compiled[0].size()
        print 'AST Nodes: %5d -> %5d' % (ast_orig, ast_final)
    if args.ctime:
        t = topo_time - init
        p = policy_time - topo_time
        s = slice_time - policy_time
        c = compile_time - slice_time
        print '\n'.join([
                         'Time to compile:        %f' % c,
                        ])
    if args.vtime:
        policy1 = compiled[0]
        policy2 = compiled[1]
        init = time.time()
        assert sat.shared_io(topo, policy1, policy2) is None
        assert sat.shared_io(topo, policy2, policy1) is None
        assert sat.shared_inputs(policy1, policy2) is None
        assert sat.shared_inputs(policy2, policy1) is None
        # Not None because we're not doing output restrictions
        assert sat.shared_outputs(policy1, policy2) is not None
        assert sat.shared_outputs(policy2, policy1) is not None
        assert verification.disjoint_observations(policy1, policy2)
        # Not None because we're not doing output restrictions
        assert sat.shared_transit(topo, policy1, policy2) is not None
        iso_t = time.time()
        print 'Time to check isolation:   %f' % (iso_t - init)

        init = time.time()
        assert sat.compiled_correctly(topo, policy, compiled[0], edge_policy=combined[0][0].edge_policy)
        comp_t = time.time()
        print 'Time to check compilation: %f' % (comp_t - init)
예제 #2
0
 def testOverlap(self):
     p1 = nc.Top() | then | nc.Action(0, obs=[1, 2, 3])
     p2 = nc.Top() | then | nc.Action(0, obs=[3, 4, 5])
     self.assertFalse(verification.disjoint_observations(p1, p2))
예제 #3
0
 def testDisjoint(self):
     p1 = nc.Top() | then | nc.Action(0, obs=[1, 2, 3])
     p2 = nc.Top() | then | nc.Action(0, obs=[4, 5, 6])
     self.assertTrue(verification.disjoint_observations(p1, p2))
예제 #4
0
파일: sat.py 프로젝트: frenetic-lang/slices
def unshared_portals(topo, policy1, policy2):
    return disjoint_observations(policy1, policy2) and shared_transit(topo, policy1, policy2) is None