How to use the sol.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 / ServiceChaining.py View on Github external
from sol.path import generatePathsPerTrafficClass
from sol.topology import Topology, TrafficMatrix

if __name__ == '__main__':

    # Let's create our topology first, as an example
    # ============================================
    topo = Topology('Abilene', 'data/topologies/Abilene.graphml')
    # 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)
github progwriter / SOL / old_examples / MaxFlow.py View on Github external
def MaxFlow():
    # ==============
    # Let's generate some example data; SOL has some functions to help with that.
    # ==============
    # A complete topology
    topo = complete_topology(5)
    # ingress-egress pairs, between which the traffic will flow
    iePairs = [(0, 3)]
    # generate a traffic matrix, in this case, a uniform traffic matrix with a million flows
    trafficMatrix = provisioning.uniformTM(
        iePairs, 10 ** 6)
    # compute traffic classes. We will only have one class that encompasses all the traffic;
    # assume that each flow consumes 2000 units of bandwidth
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # since our topology is "fake", provision our links and generate link capacities in our network
    linkcaps = provisioning.provision_links(topo, trafficClasses, 1)
    # these will be our link constraints: do not load links more than 50%
    linkConstrCaps = {(u, v): .5 for u, v in topo.links()}

    # ==============
    # Optimization
    # ==============

    # Start our optimization.
    # SOL automatically takes care of the path generation, but it needs the topology, traffic classes, path predicate
    # and path selection strategy.
    # nullPredicate means any path will do, no specific service chaining or policy requirements.
    # Then, SOL will choose maximum of 5 shortest paths for each traffic class to route traffic on.
    opt, pptc = initOptimization(topo, trafficClasses, nullPredicate, 'shortest', 5, backend='CPLEX')
github progwriter / SOL / old_examples / MaxFlowWithONOS.py View on Github external
def MaxFlow():
    # ==============
    # Let's generate some example data; SOL has some functions to help with that.
    # ==============
    # A complete topology
    topo = complete_topology(5)
    # ingress-egress pairs, between which the traffic will flow
    iePairs = [(0, 3)]
    # generate a traffic matrix, in this case, a uniform traffic matrix with a million flows
    trafficMatrix = provisioning.uniformTM(
        iePairs, 10 ** 6)
    # compute traffic classes. We will only have one class that encompasses all the traffic;
    # assume that each flow consumes 2000 units of bandwidth
    trafficClasses = generateTrafficClasses(iePairs, trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # since our topology is "fake", provision our links and generate link capacities in our network
    linkcaps = provisioning.provision_links(topo, trafficClasses, 1)
    # these will be our link constraints: do not load links more than 50%
    linkConstrCaps = {(u, v): .5 for u, v in topo.links()}

    # ==============
    # Optimization
    # ==============

    # Start our optimization.
    # SOL automatically takes care of the path generation, but it needs the topology, traffic classes, path predicate
    # and path selection strategy.
    # nullPredicate means any path will do, no specific service chaining or policy requirements.
    # Then, SOL will choose maximum of 5 shortest paths for each traffic class to route traffic on.
    opt, pptc = initOptimization(topo, trafficClasses, nullPredicate, 'shortest', 5, backend='CPLEX')
github progwriter / SOL / old_examples / TrafficEngineering.py View on Github external
def TE():
    # ==============
    # Let's generate some example data;
    # ==============
    topo = Topology('Abilene', 'data/topologies/Abilene.graphml')
    # 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')

    # compute traffic classes. We will only have one class that encompasses all the traffic;
    # assume that each flow consumes 2000 units of bandwidth
    trafficClasses = generateTrafficClasses(trafficMatrix.keys(), trafficMatrix, {'allTraffic': 1},
                                            {'allTraffic': 2000})
    # since our topology is "fake", provision our links and generate link capacities in our network
    linkcaps = provisionLinks(topo, trafficClasses, 2)
    # these will be our link constraints: do not load links more than 50%
    linkConstrCaps = {(u, v): .5 for u, v in topo.links()}

    # ==============
    # Optimization
    # ==============

    # Start our optimization.
    # SOL automatically takes care of the path generation, but it needs the topology, traffic classes, path predicate
    # and path selection strategy.
    # nullPredicate means any path will do, no specific service chaining or policy requirements.
    # Then, SOL will choose maximum of 5 shortest paths for each traffic class to route traffic on.
    opt, pptc = initOptimization(topo, trafficClasses, nullPredicate, 'shortest', 5, backend='CPLEX')