How to use the sol.topology.provisioning function in SoL

To help you get started, we’ve selected a few SoL examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github progwriter / SOL / old_examples / ServiceChaining.py View on Github external
# Let's load an existing gravity traffic matrix. It's just a dict mapping ingress-egress tuples to flow volume (a float).
    trafficMatrix = TrafficMatrix.load('data/tm/Abilene.tm')
    # set nodes to be firewalls and IDSes:
    for node in topo.nodes():
        topo.setMbox(node)
        topo.set_service_types(node, ['fw', 'ids'])

    trafficClasses = generateTrafficClasses(trafficMatrix.keys(), trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # assign flow processing cost for each traffic class
    for t in trafficClasses:
        t.cpuCost = 10

    # Do some topology provisioning, instead of the real switch/link/middlebox capacities:
    # provision the node cpu capacities (for the sake of example)
    maxCPUCap = provisioning.compute_max_ingress_load(trafficClasses, {t: t.cpuCost for t in trafficClasses})
    nodeCaps = dict()
    nodeCaps['cpu'] = {node: maxCPUCap * 2 for node in topo.nodes()
                       if 'fw' or 'ids' in topo.get_service_types(node)}
    # provision the TCAM capacities on the switch nodes
    nodeCaps['tcam'] = {node: 1000 for node in topo.nodes()}
    # similartly with link capacities
    linkCaps = provisioning.provision_links(topo, trafficClasses, 3)


    # =====================================
    # Write our user defined capacity functions
    # =====================================

    def path_predicate(path, topology):
        # Firewall followed by IDS is the requirement for the path to be valid
        return any([s == ('fw', 'ids') for s in itertools.product(*[topology.get_service_types(node)
github progwriter / SOL / old_examples / ElasticScaling.py View on Github external
if i != e and G.out_degree(i) == 1 and G.out_degree(e) == 1]
    print iePairs
    # generate traffic matrix
    populations = {node: randint(1 << 15, 1 << 18) for node, data in topo.nodes()}
    trafficMatrix = provisioning.gravityTM(
        iePairs, 10 ** 6, populations)
    # compute traffic classes, only one class
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # assign flow processing cost for each traffic class
    for t in trafficClasses:
        t.cpuCost = 10
    # provision the node cpu capacities
    nodeCaps = {node: None for node, data in topo.nodes()}
    # similartly with link capacities
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 3)

    # ======================
    # start our optimization
    # ======================
    opt = getOptimization()
    # generate the paths
    pptc = generatePathsPerTrafficClass(topo, trafficClasses, hasMboxPredicate,
                                        networkx.diameter(topo.getGraph()) * 1.5,
                                        1000, useMboxModifier)
    # randomly choose 5 paths per traffic class
    pptc = chooserand(pptc, 5)

    # add all the constraints
    # variables go first
    opt.addDecisionVars(pptc)
    opt.addBinaryVars(pptc, topo, ['path', 'node'])
github progwriter / SOL / old_examples / ElasticScaling.py View on Github external
# For the sake of example, set middleboxes everywhere
    for node, data in topo.nodes():
        topo.setMbox(node)
        topo.setServiceTypes(node, ['switch', 'dpis'])

    # Resort to some default functions, obviously you'd provide your real data here
    # =============================================================================

    # ingress-egress pairs
    G = topo.getGraph()
    iePairs = [(i, e) for i, e in itertools.product(topo.nodes(False), repeat=2)
               if i != e and G.out_degree(i) == 1 and G.out_degree(e) == 1]
    print iePairs
    # generate traffic matrix
    populations = {node: randint(1 << 15, 1 << 18) for node, data in topo.nodes()}
    trafficMatrix = provisioning.gravityTM(
        iePairs, 10 ** 6, populations)
    # compute traffic classes, only one class
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # assign flow processing cost for each traffic class
    for t in trafficClasses:
        t.cpuCost = 10
    # provision the node cpu capacities
    nodeCaps = {node: None for node, data in topo.nodes()}
    # similartly with link capacities
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 3)

    # ======================
    # start our optimization
    # ======================
    opt = getOptimization()