Пример #1
0
def selectR(ASset_init):
    ASes = DS_AS.ASset()
    while method.Cost_ASset(ASes.getASList()) < F:
        Select_AS = ASset_init.getMaxBenefitRateAS()
        ASes.addAS(Select_AS)
        print("add " + Select_AS.asn)
        glb.remove(Select_AS)
    glb.reloaddata("Paths")
    return ASes
Пример #2
0
def select(ASes, cen, CGR, P, decoylist):
    flag = 0
    AdRecord = DS_AS.ASset()
    while True:
        #get AS react set
        if flag != 0:
            decoylist = ASes.getDecoyASList()
            Ad = ASes.getEachASResponse(CGR, P, decoylist)
        else:
            Ad = ASes.initGetEachASResponse(CGR, P, decoylist)
        if Ad.size > AdRecord.size:
            ratio = Ad.inter(AdRecord).size / Ad.union(AdRecord).size
        else:
            ratio = AdRecord.inter(Ad).size / Ad.union(AdRecord).size
            Ac = cen.response(ASes.getDecoyAS())
    # until it's stablity reach our design
        if ratio > glb.Stabilty:
            EQ, EC = refineEQ(ASes, Ad.inter(A_d), Ac, CGR, P,
                              AdRecord.getDecoyASList())
            return EQ, EC
        else:
            AdRecord = Ad
            falg = flag + 1
Пример #3
0
    History = list()
    Histroy.append(inter)
    while not Coverged:
        Ad = ASes.getEachASResponse(CGR, P, decoylist)
        Ac = cen.response(ASes.getDecoyAS())
    if not Ad.contain(Selected):
        if not Selected.equal(Ad):
            Selected = Ad
        History = History.append(Selected)
    if Ad in Histroy:
        Coveraged = True
    History.append(Ad)
    return Selected, Ac


if __name__ == "__main__":
    glb._init()
    ASes = DS_AS.ASset()
    #pdb.set_trace()
    ASes.build_init(glb.ChinaGeoLoc_Relate, glb.EcoRel, glb.Paths)
    print("init result:" + str(len(ASes.ASs)) + "from model_2")
    decoyinit = list()
    with open("output/game1Decoy.json", "r") as f:
        decoylist = json.load(f)
    censor = cen.censor(glb.Paths, decoyinit, glb.G)
    ad, ac = select(ASes, censor, glb.ChinaGeoLoc_Relate, glb.Paths, decoyinit)
    for d in ad:
        print(d.asn)
    for d in Ac:
        print(d.asn)
Пример #4
0
        ASes.addAS(Select_AS)
        print("add " + Select_AS.asn)
        glb.remove(Select_AS)
    glb.reloaddata("Paths")
    return ASes


if __name__ == '__main__':
    #load data
    #pdb.set_trace()
    glb._init()
    print(str(len(glb.ChinaGeoLoc_Relate)) + "from model_1")
    print(str(len(glb.ChinaASList)) + "from model_1")
    print(str(len(glb.Paths)) + "from model_1")
    #load topo AS info
    ASes_init = DS_AS.ASset()
    ASes_init.build_init(glb.ChinaGeoLoc_Relate, glb.EcoRel, glb.Paths)
    print("listlength:" + str(len(ASes_init.ASs)) + "from model_1 ")
    #F/p0=10000000,F is the budget
    F = int(sys.argv[1])

    Ad = select(ASes_init)
    A_d = selectR(ASes_init)
    #decoy decision
    lAd = list()
    lA_d = list()

    for a in Ad.ASs:
        lAd.append(a.asn)
    for a in A_d.ASs:
        lA_d.append(a.asn)