Пример #1
0
def func(memory, src, dst):
    chf = CHashFlow(memory)
    ahf = AHashFlow(memory)

    with open(src, "r") as f:
        pkts = json.load(f)

    flows = dict()
    for i in range(n_pkts):
        p = pkts[i][1]
        if p not in flows:
            flows[p] = 0
        flows[p] = flows[p] + 1
        #		chf.receive_pkt(p)
        ahf.receive_pkt(p)

    with open(dst, "w") as f:
        f.write(
            "#threshold\tAHashFlow.HH.ARE\tCHashFlow.HH.ARE\tAHashFlow.HH.F1Score\tCHashFlow.HH.F1Score\n"
        )
        for thresh in range(5, 51, 5):
            l = [str(thresh)]
            l.append(str(ahf.hh_are(flows, thresh)))
            #			l.append(str(chf.hh_are(flows, thresh)))
            l.append(str(ahf.hh_f1score(flows, thresh)))
            #			l.append(str(chf.hh_f1score(flows, thresh)))
            line = "\t".join(l) + "\n"
            f.write(line)
Пример #2
0
def func(alg, memory, thresh, src, dst):
	assert(alg in [AHF, CHF, TF])
	if alg == AHF:
		switch = AHashFlow(memory)
	elif alg == CHF:
		switch = CHashFlow(memory)
	elif alg == TF:
		switch = TurboFlow(memory)
	with open(src, "r") as f:
		pkts = json.load(f)

	with open(dst, "w") as f:
		f.write("#n_pkts\thh_are\thh_f1score\tn_exports\n")
	flows = dict()
	count = 0
	for k in range(40):
		for i in range(500000):
			p = pkts[count][1]
			count = count + 1
			if p not in flows:
				flows[p] = 0
			flows[p] = flows[p] + 1
			switch.receive_pkt(p)
		l = [str(count)]
		l.append(str(switch.hh_are(flows, thresh)))
		l.append(str(switch.hh_f1score(flows, thresh)))
		l.append(str(switch.get_n_exports()))
		line = "\t".join(l) + "\n"
		with open(dst, "a") as f:
			f.write(line)
Пример #3
0
def func(alg, memory, n_pkts, src, dst):
	assert(alg in [AHF, CHF, TF])
	if alg == AHF:
		switch = AHashFlow(memory)
	elif alg == CHF:
		switch = CHashFlow(memory)
	elif alg == TF:
		switch = TurboFlow(memory)
	with open(src, "r") as f:
		pkts = json.load(f)

	with open(dst, "w") as f:
		f.write("#threshold\thh_are\thh_f1score\tn_exports\n")
	flows = dict()
	for i in range(n_pkts):
		p = pkts[i][1]
		if p not in flows:
			flows[p] = 0
		flows[p] = flows[p] + 1
		switch.receive_pkt(p)
	for thresh in range(5, 51, 5):
		l = [str(thresh)]
		l.append(str(switch.hh_are(flows, thresh)))
		l.append(str(switch.hh_f1score(flows, thresh)))
		l.append(str(switch.get_n_exports()))
		line = "\t".join(l) + "\n"
		with open(dst, "a") as f:
			f.write(line)
Пример #4
0
def func(alg, memory, src, n_pkts, thresh):
    assert (alg == AHF or alg == CHF)
    if alg == AHF:
        switch = AHashFlow(memory)
    elif alg == CHF:
        switch = CHashFlow(memory)
    print switch
    print "n_pkts:", n_pkts
    print "memory:", memory / (1024.0 * 1024), "MB"

    with open(src, "r") as f:
        pkts = json.load(f)

    flows = dict()
    for i in range(n_pkts):
        p = pkts[i][1]
        if p not in flows:
            flows[p] = 0
        flows[p] = flows[p] + 1
        switch.receive_pkt(p)

    print "hh_are:", switch.hh_are(flows, thresh)
    print "hh_f1score:", switch.hh_f1score(flows, thresh)
Пример #5
0
import mytools
from simulators.CHashFlow import CHashFlow
from simulators.AHashFlow import AHashFlow
import json

memory = 1.0 * 1024 * 1024
caida = "/home/zongyi/traces/CAIDA.equinix-nyc.dirA.20180315-125910.UTC.anon.json"
hgc = "/home/zongyi/traces/HGC.20080415000.json"
resFile = "./measured_are.txt"

caida_chf = CHashFlow(memory)
hgc_chf = CHashFlow(memory)
caida_ahf = AHashFlow(memory)
hgc_ahf = AHashFlow(memory)
count = 0
caida_flows = dict()
hgc_flows = dict()

with open(caida, "r") as f:
    caida_pkts = json.load(f)

with open(hgc, "r") as f:
    hgc_pkts = json.load(f)


def func(n_pkts, resFile):
    global caida_chf, hgc_chf, caida_ahf, hgc_ahf, count
    global caida_flows, hgc_flows, caida_pkts, hgc_pkts
    for i in range(n_pkts):
        p = caida_pkts[count]
        if p in caida_flows:
Пример #6
0
import mytools
from simulators.HashFlow import HashFlow
from simulators.CHashFlow import CHashFlow
from simulators.DHashFlow import DHashFlow
import json

memory = 1.0 * 1024 * 1024
trace = "/home/zongyi/traces/CAIDA.equinix-nyc.dirA.20180315-125910.UTC.anon.json"
resFile = "./nmr.txt"

hf = HashFlow(memory)
chf = CHashFlow(memory)
dhf = DHashFlow(memory)
count = 0


def func(pkts, n_pkts, resFile):
    global hf, chf, dhf, count
    for i in range(n_pkts):
        p = pkts[count]
        count = count + 1
        hf.receive_pkt(p)
        dhf.receive_pkt(p)
        chf.receive_pkt(p)

    l = "\t".join([str(count), str(hf.nmr()), str(dhf.nmr()), str(chf.nmr())])
    with open(resFile, "a") as f:
        f.write(l + "\n")


with open(resFile, "w") as f:
Пример #7
0
        flows[p] = flows[p] + 1

    hhs = []
    for key, value in flows.items():
        if value >= thresh:
            hhs.append(value)
    hhs.sort()
    for item in hhs:
        print item


if __name__ == "__main__":
    memory = 0.25 * 1024 * 1024
    thresh = 5
    ahf = AHashFlow(memory)
    chf = CHashFlow(memory)
    with open(src1, "r") as f:
        pkts = json.load(f)

    with open(dst1, "w") as f:
        f.write(
            "#n_pkts\tahf.hh_are\tchf.hh_are\tahf.hh_f1score\tchf.hh_f1score\n"
        )
    flows = dict()
    count = 0
    for k in range(40):
        for i in range(500000):
            p = pkts[count][1]
            count = count + 1
            if p not in flows:
                flows[p] = 0