Example #1
0
def modelAEM(etrs):
    print("Modeling AEM ...")
    # Modeling traffic with AEM
    aem  = AEM(etrs, cut_gap)
    withUA = aem.sessionsWithUA()
    withoutUA = aem.sessionsWithoutUA()

    forest = {}
    for ua in withUA:
        ss = withUA[ua]
        for el in ss[1:]:
            trees = aem.model(el)
            if ua not in forest:
                forest[ua] = []
            forest[ua].extend(trees)

    for host in withoutUA:
        nss = withoutUA[host]
        for el in nss[1:]:
            trees = aem.model(el)
            if host not in forest:
                forest[host] = []
            forest[host].extend(trees)
    return forest
Example #2
0
aem = AEM(etrs)
withUA = aem.sessionsWithUA()
withoutUA = aem.sessionsWithoutUA()

# output file
output = os.path.join(input_folder, "aem.out")
try:
    os.remove(output)
except OSError:
    pass

for ua in withUA:
    ss = withUA[ua]
    open(output, "ab").write("\n****************** %s\n" % ua)
    for el in ss[1:]:
        trees = aem.model(el)
        for wt in trees:
            # wt.show(key=lambda x: x.pl.rqtstart(), reverse=False)
            # open(output, 'ab').write('\n')
            wt.save2file(output, key=lambda x: x.pl.rqtstart())

for host in withoutUA:
    nss = withoutUA[host]
    open(output, "ab").write("\n****************** %s\n" % host)
    for el in nss[1:]:
        trees = aem.model(el)
        for wt in trees:
            # wt.show(key=lambda x: x.pl.rqtstart(), reverse=False)
            # open(output, 'ab').write('\n')
            wt.save2file(output, key=lambda x: x.pl.rqtstart())