Пример #1
0
def SymmetryTest(iters, min_size, max_size):
    times = []
    print "SymTest start"
    for sz in xrange(min_size, max_size):
        for it in xrange(iters):
            ReseedZ3()
            (sym, asym) = SymmetryTest1(sz)
            start = time.time()
            ret = sym.check.CheckIsolationProperty(sym.a, sym.endhosts[0])
            assert ret.result == z3.unsat
            ret = sym.check.CheckIsolationProperty(sym.a, sym.endhosts[1])
            assert ret.result == z3.unsat
            stop = time.time()
            sym_time = stop - start
            ReseedZ3()
            start = time.time()
            ret = asym.check.CheckIsolationProperty(asym.a, asym.endhosts[0])
            assert ret.result == z3.unsat
            ret = asym.check.CheckIsolationProperty(asym.a, asym.endhosts[1])
            assert ret.result == z3.unsat
            stop = time.time()
            asym_time = stop - start
            print "%d %f %f" % (sz, sym_time, asym_time)
Пример #2
0
def TestLSRRFwNormal(iters, raw_data):
    times = []
    print >> raw_data, "TestLSRRFwNorm"
    for i in xrange(iters):
        ReseedZ3()
        pobj = LSRRFwTriv(1)
        start = time.time()
        ret = pobj.check.CheckIsolationProperty(pobj.e0, pobj.e1)
        stop = time.time()
        assert ret.result == z3.sat
        times.append(stop - start)
        print >> raw_data, (stop - start)
    print >> raw_data, ""
    print >> raw_data, ""
    print "LSRRFwNorm %d %f %f %f %f" % (len(times),
                                         sum(times), sum(times) / len(times),
                                         np.std(times), np.median(times))
Пример #3
0
def TestL7FirewallJustRun(iters, raw_data):
    times = []
    print >> raw_data, "TestL7FirewallJustRun"
    for i in xrange(iters):
        ReseedZ3()
        full_obj = L7FirewallProxy()
        start = time.time()
        ret = full_obj.check.CheckIsolationProperty(full_obj.c, full_obj.a)
        stop = time.time()
        assert ret.result == z3.sat
        times.append(stop - start)
        print >> raw_data, (stop - start)
    print >> raw_data, ""
    print >> raw_data, ""
    print "L7FWPathJR %d %f %f %f %f" % (len(times),
                                         sum(times), sum(times) / len(times),
                                         np.std(times), np.median(times))
Пример #4
0
def TestDPIFw(iters, raw_data):
    times = []
    print >> raw_data, "TestDPIFw"
    for i in xrange(iters):
        ReseedZ3()
        pobj = dpiFw()
        start = time.time()
        ret = pobj.check.CheckIsolatedIf(
            pobj.dpi_policy.packetDPIPredicate(pobj.ctx), pobj.a, pobj.b)
        stop = time.time()
        assert ret.result == z3.sat
        times.append(stop - start)
        print >> raw_data, (stop - start)
    print >> raw_data, ""
    print >> raw_data, ""
    print "DPIFw %d %f %f %f %f" % (len(times), sum(times),
                                    sum(times) / len(times), np.std(times),
                                    np.median(times))
Пример #5
0
def TestL7FirewallPathIndependence(iters, raw_data):
    times = []
    print >> raw_data, "TestL7FirewallPathIndependence"
    for i in xrange(iters):
        ReseedZ3()
        full_obj = L7FirewallProxy()
        path_obj = L7FirewallProxyPolicy()
        start = time.time()
        ret = CheckIsPathIndependentIsolated(
            path_obj.check, full_obj.check, path_obj.c, path_obj.a, full_obj.c,
            full_obj.a, [path_obj.a, path_obj.c, path_obj.p, path_obj.f])
        stop = time.time()
        assert ret.judgement == 2
        times.append(stop - start)
        print >> raw_data, (stop - start)
    print >> raw_data, ""
    print >> raw_data, ""
    print "L7FWPathIndep %d %f %f %f %f" % (len(times), sum(times),
                                            sum(times) / len(times),
                                            np.std(times), np.median(times))
Пример #6
0
from concrete_examples import dpiFwRono, ReseedZ3
from mcnet.components import CheckIsPathIndependentIsolated
import numpy as np
import sys
import time
import z3

if len(sys.argv) < 3:
    print >> sys.stderr, "Usage: %s sz iter" % (sys.argv[0])
    sys.exit(1)
sz = int(sys.argv[1])
it = int(sys.argv[2])
for i in xrange(it):
    #ReseedZ3()
    #pobj = dpiFwRono(sz)
    #print "Done building object"
    #start = time.time()
    #ret = pobj.check.CheckIsolatedIf(pobj.dpi_policy.packetDPIPredicate(pobj.ctx), pobj.a, pobj.b)
    #stop = time.time()
    #time0 = stop - start
    #assert ret.result == z3.sat
    ReseedZ3()
    pobj = dpiFwRono(sz)
    start = time.time()
    ret2 = pobj.check.CheckIsolationProperty(pobj.a, pobj.b)
    stop = time.time()
    assert ret2.result == z3.sat
    print >> sys.stderr, "%d %f" % (i, stop - start)