def construct_sfc(src, dst, number_of_vnfs):
    sfc_dict = {
        "name": "sfc_1",
        "type": "xx",
        "vnf_list": [
            # {"type": 2, "name": "vnf1", "CPU": 10},
            # {"type": 2, "name": "vnf2", "CPU": 20},
            # {"type": 2, "name": "vnf3", "CPU": 30},
            # {"type": 2, "name": "vnf4", "CPU": 40},
            # {"type": 2, "name": "vnf5", "CPU": 40},
            # {"type": 2, "name": "vnf6", "CPU": 40},

        ],
        "bandwidth": random.randint(5, 10),
        "src_node": 0,
        "dst_node": 0,
        "latency": 10,
        "duration": 20
    }

    sfc_dict['src_node'] = src
    sfc_dict['dst_node'] = dst
    for i in range(0, number_of_vnfs):
        name = 'vnf' + str(i + 1)
        vnf = {"type": 2, "name": name, "CPU": random.randint(5, 10)}
        sfc_dict['vnf_list'].append(vnf)
    # print sfc_dict
    sfc = SFCGenerator(sfc_dict).generate()
    return sfc
Exemplo n.º 2
0
def generate_sfc(p):
    global count
    count = count + 1
    sfc_dict["name"] = "sfc_" + str(count)

    vnf_list = []
    number_of_vnfs = random.randint(2, 6)
    for i in range(0, number_of_vnfs):
        vnf_list.append({
            "type": 2,
            "name": "vnf" + str(i),
            "CPU": random.randint(1, 50)
        })
    bandwidth = random.randint(1, 50)
    src_node = random.randint(0, number_of_substrate_node - 1)
    dst_node = random.randint(0, number_of_substrate_node - 1)
    while (dst_node == src_node):
        dst_node = random.randint(0, number_of_substrate_node - 1)
    # lifetime = np.random.poisson(500)
    lifetime = int(round(np.random.exponential(500)))
    duration = lifetime
    sfc_dict["vnf_list"] = vnf_list
    sfc_dict["bandwidth"] = bandwidth
    sfc_dict["src_node"] = src_node
    sfc_dict["dst_node"] = dst_node
    sfc_dict["duration"] = duration

    # for test
    # vnf_list = []
    # number_of_vnfs = 6# random.randint(2, 6)
    # for i in range(0, number_of_vnfs):
    #     vnf_list.append({"type": 2, "name": "vnf" + str(i), "CPU": random.randint(1, 50)})
    # bandwidth = random.randint(1, 50)
    # src_node = random.randint(0, number_of_substrate_node - 1)
    # dst_node = random.randint(0, number_of_substrate_node - 1)
    # duration = random.randint(1000000, 2000000)
    # sfc_dict["vnf_list"] = vnf_list
    # sfc_dict["bandwidth"] = bandwidth
    # sfc_dict["src_node"] = src_node
    # sfc_dict["dst_node"] = dst_node
    # sfc_dict["duration"] = duration

    # print "***********"
    print count
    print sfc_dict
    # print "###########"

    sfc = SFCGenerator(sfc_dict).generate()
    sfc_queue.put_sfc(sfc)
    print "queue_size: " + str(sfc_queue.qsize())
    if count >= 1000:
        print "stop"
        sfc_poisson_emitter.stop()
Exemplo n.º 3
0
from algorithms.k_shortest_paths_algorithm import KShortestPathsAlgorithm
from algorithms.betweenness_centrality_algorithm import BetweennessCentralityAlgorithm

ALG3 = ALG3()
DPA = DynamicProgrammingAlgorithm()
RandomAlgorithm = RandomAlgorithm()
GreedyAlgorithm = GreedyAlgorithm()
KShortestPathsAlgorithm = KShortestPathsAlgorithm()
BetweennessCentralityAlgorithm = BetweennessCentralityAlgorithm()

substrate_network = simple_six_node_topology
# substrate_network = substrate_random_network
substrate_network = generate_random_network(100, 0.05)

sfc_dict = sfc1.sfc
sfc = SFCGenerator(sfc_dict).generate()


def deploy_sfc(deployment_algorithm, substrate_network, sfc):
    # print "---------- " + deployment_algorithm.name + " ----------------------------"
    deployment_algorithm.clear_all()
    deployment_algorithm.install_substrate_network(substrate_network)
    deployment_algorithm.install_SFC(sfc)
    start_time = time.time()
    deployment_algorithm.start_algorithm()
    end_time = time.time()
    route_info = deployment_algorithm.get_route_info()
    latency = deployment_algorithm.get_latency()
    return (route_info, latency, (end_time - start_time))