How to use the sol.opt.topology.provisioning.generateTrafficClasses 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 / BasicLoadBalancer.py View on Github external
def runBasicLoadBalancer():

    raise NotImplemented()
    # Let's create a topology first, as an example
    topo = generators.generateChainTopology(4)
    # label our switches
    generators.forceSwitchLabels(topo)
    # For the sake of example, set middleboxes everywhere
    for node, data in topo.nodes():
        topo.setMbox(node)
        topo.setServiceTypes(node, ['dpi'])
    iePairs = provisioning.generateIEpairs(topo)
    trafficMatrix = provisioning.computeUniformTrafficMatrixPerIE(
        iePairs, 10 ** 6)
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 100})
    for t in trafficClasses:
        t.cpuCost = 10
    maxCPUCap = provisioning.computeMaxIngressLoad(trafficClasses, {t: t.cpuCost for t in trafficClasses})
    nodeCaps = {node: maxCPUCap for node, data in topo.nodes()
                if 'dpi' in topo.getServiceTypes(node)}
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 2)

    # Setup the basic config
    config = {
        'name': 'BasicLoadBalancer',  # for clarity

        'topology': topo,

        'trafficClasses': trafficClasses,
        'predicate': nullPredicate,
github progwriter / SOL / old_examples / Panopticon.py View on Github external
generators.forceSwitchLabels(topo)
    # For the sake of example, set middleboxes everywhere
    for node, data in topo.nodes():
        topo.setMbox(node)
        topo.setServiceTypes(node, ['switch', 'fw', 'ids'])

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

    # ingress-egress pairs
    iePairs = provisioning.generateIEpairs(topo)
    # generate traffic matrix
    trafficMatrix = provisioning.computeUniformTrafficMatrixPerIE(
        iePairs, 10 ** 6)
    # compute traffic classes, only one class
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # similartly with link capacities
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 3)
    # Fake power consumption. Imagine these are kw/h, whatever.
    switchPower = {node: 1500 for node, data in topo.nodes()}
    linkPower = {(u, v): 500 for u, v, data in topo.links()}

    # ======================
    # start our optimization
    # ======================
    opt = getOptimization()
    # generate the paths
    pptc = generatePathsPerTrafficClass(topo, trafficClasses, nullPredicate,
                                        networkx.diameter(topo.getGraph()) * 1.5,
                                        1000)
    # randomly choose 5 paths per traffic class
github progwriter / SOL / old_examples / SIMPLE.py View on Github external
generators.forceSwitchLabels(topo)
    # For the sake of example, set middleboxes everywhere
    for node, data in topo.nodes():
        topo.setMbox(node)
        topo.setServiceTypes(node, ['switch', 'fw', 'ids'])

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

    # ingress-egress pairs
    iePairs = provisioning.generateIEpairs(topo)
    # generate traffic matrix
    trafficMatrix = provisioning.computeUniformTrafficMatrixPerIE(
        iePairs, 10 ** 6)
    # 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
    maxCPUCap = provisioning.computeMaxIngressLoad(trafficClasses, {t: t.cpuCost for t in trafficClasses})
    nodeCaps = dict()
    nodeCaps['cpu'] = {node: maxCPUCap * 2 for node, data in topo.nodes()
                       if 'fw' or 'ids' in topo.getServiceTypes(node)}
    # and the tcam capacities
    nodeCaps['tcam'] = {node: 1000 for node, data in topo.nodes()}
    # similartly with link capacities
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 3)

    # =====================================
    # Write our user defined functions now:
github progwriter / SOL / old_examples / MaxFlowWithOnos.py View on Github external
# Fake some data
    # ==============
    # onos = ONOSInterface("192.168.99.102:8181")
    onos = ONOSInterface("localhost:8181")

    topo = onos.getTopology()
    # ingress-egress pairs
    iePairs = provisioning.generateIEpairs(topo)
    # nodes = list(topo.nodes(data=False))
    # iePairs = [(nodes[0], nodes[1]), (nodes[1], nodes[0])]
    print iePairs
    # generate traffic matrix
    trafficMatrix = provisioning.computeUniformTrafficMatrixPerIE(
        iePairs, 10 ** 6)
    # compute traffic classes, only one class
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000}, topo.getGraph())
    for tc in trafficClasses:
        tc.srcIPPrefix = "10.0.0.{}/32".format(int(tc.src.lstrip(":of")))
        tc.dstIPPrefix = "10.0.0.{}/32".format(int(tc.dst.lstrip(":of")))
    linkcaps = provisioning.provisionLinks(topo, trafficClasses, 1)
    # do not load links more than 50%
    linkConstrCaps = {(u, v): 1 for u, v, data in topo.links()}

    # ==============
    # Optimize
    # ==============
    linkcapfunc = lambda link, tc, path, resource: tc.volBytes/linkcaps[link]
    # Start our optimization! SOL automatically takes care of the paths behind the scenes
    opt, pptc = kickStartOptimization(topo, trafficClasses, nullPredicate, 'shortest', 5)
    # Traffic must flow!
    opt.allocateFlow(pptc)
github progwriter / SOL / old_examples / ElasticTree.py View on Github external
generators.forceSwitchLabels(topo)
    # For the sake of example, set middleboxes everywhere
    for node, data in topo.nodes():
        topo.setMbox(node)
        topo.setServiceTypes(node, ['switch', 'fw', 'ids'])

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

    # ingress-egress pairs
    iePairs = provisioning.generateIEpairs(topo)
    # generate traffic matrix
    trafficMatrix = provisioning.computeUniformTrafficMatrixPerIE(
        iePairs, 10 ** 6)
    # compute traffic classes, only one class
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # similartly with link capacities
    linkCaps = provisioning.provisionLinks(topo, trafficClasses, 3)
    # Fake power consumption. Imagine these are kw/h, whatever.
    switchPower = {node: 1500 for node, data in topo.nodes()}
    linkPower = {(u, v): 500 for u, v, data in topo.links()}

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