Exemplo n.º 1
0
 def test_static_traffic_matrix_parallel(self):
     # If number of edges is greater than 100, computation is parallelized
     G = fnss.full_mesh_topology(15)
     fnss.set_capacities_constant(G, 10, capacity_unit='Mbps')
     tm = fnss.static_traffic_matrix(G, 10, 8, max_u=0.9)
     self.assertAlmostEqual(0.9, max(fnss.link_loads(G, tm).values()))
     self.assertLessEqual(0, min(fnss.link_loads(G, tm).values()))
Exemplo n.º 2
0
 def test_static_traffic_matrix_parallel(self):
     # If number of edges is greater than 100, computation is parallelized
     G = fnss.full_mesh_topology(15)
     fnss.set_capacities_constant(G, 10, capacity_unit='Mbps')
     tm = fnss.static_traffic_matrix(G, 10, 8, max_u=0.9)
     self.assertAlmostEqual(0.9, max(fnss.link_loads(G, tm).values()))
     self.assertLessEqual(0, min(fnss.link_loads(G, tm).values()))
Exemplo n.º 3
0
    def full_mesh(self, order, **args):
        """
        Returns a fully connected graph.

        Args:
            order (int): Number of nodes.
            args (dict): Attributes for property generation:
                min_bw (int): Minimal value for bandwidth on edge.
                max_bw (int): Maximal value for bandwidth on edge.
                bandwidth (string): {uniform, power} - How bandwidth should be
                    generated. If uniform is chosen distribution follows uniform
                    distribution, if power is chosen distribution follows a
                    power law.
                min_cpu (int): Minimal value for CPU capacity.
                max_cpu (int): Maximal value for CPU capacity.
                min_distance (int): Minimal length of an edge.
                max_distance (int): Maximal length of an edge.
                delay (float, optional): Delay per kilometer of cable length.
                substrate (optional, bool): Whether it is a substrate network.

        Returns: FNSS object

        """
        vnr = fnss.full_mesh_topology(order)
        self.remove_unnecessary_attributes(args)
        self.generate_attributes(vnr, **args)
        vnr.graph['model'] = literals.NETWORK_MODEL_FULL_MESH
        return vnr
Exemplo n.º 4
0
 def test_full_mesh_connectivity(n):
     G = fnss.full_mesh_topology(n)
     self.assertEqual(n, G.number_of_nodes())
     self.assertEqual((n * (n - 1)) // 2, G.number_of_edges())
     for i in range(n):
         for j in range(n):
             if i != j:
                 self.assertTrue(G.has_edge(i, j))
Exemplo n.º 5
0
 def test_full_mesh_connectivity(n):
     G = fnss.full_mesh_topology(n)
     self.assertEquals(n, G.number_of_nodes())
     self.assertEquals((n * (n - 1)) // 2, G.number_of_edges())
     for i in range(n):
         for j in range(n):
             if i != j:
                 self.assertTrue(G.has_edge(i, j))
Exemplo n.º 6
0
 def setUpClass(cls):
     # set up topology used for all traffic matrix tests
     cls.topo = fnss.full_mesh_topology(100)
     cls.stack_1_name = 'stack_1'
     cls.stack_1_props = {'prop1': 'val11', 'prop2': 'val12'}
     cls.stack_2_name = 'stack_2'
     cls.stack_2_props = {'prop1': 'val12', 'prop2': 'val22'}
     cls.app_1_name = 'app_1'
     cls.app_1_props = {'prop1': 'val11', 'prop2': 'val12'}
     cls.app_2_name = 'app_2'
     cls.app_2_props = {'prop1': 'val12', 'prop2': 'val22'}
Exemplo n.º 7
0
 def setUpClass(cls):
     # set up topology used for all traffic matrix tests
     cls.topo = fnss.full_mesh_topology(100)
     cls.stack_1_name = 'stack_1'
     cls.stack_1_props = {'prop1': 'val11', 'prop2': 'val12'}
     cls.stack_2_name = 'stack_2'
     cls.stack_2_props = {'prop1': 'val12', 'prop2': 'val22'}
     cls.app_1_name = 'app_1'
     cls.app_1_props = {'prop1': 'val11', 'prop2': 'val12'}
     cls.app_2_name = 'app_2'
     cls.app_2_props = {'prop1': 'val12', 'prop2': 'val22'}
Exemplo n.º 8
0
def topology_mesh(n, m, delay_int=1, delay_ext=5, **kwargs):
    """Returns a ring topology

    This topology is comprised of a mesh of *n* nodes. Each of these nodes is
    attached to a receiver. In addition *m* router are attached each to a source.
    Therefore, this topology has in fact 2n + m nodes.

    Parameters
    ----------
    n : int
        The number of routers in the ring
    m : int
        The number of sources
    delay_int : float
        The internal link delay in milliseconds
    delay_ext : float
        The external link delay in milliseconds

    Returns
    -------
    topology : IcnTopology
        The topology object
    """
    if m > n:
        raise ValueError("m cannot be greater than n")
    topology = fnss.full_mesh_topology(n)
    routers = range(n)
    receivers = range(n, 2 * n)
    sources = range(2 * n, 2 * n + m)
    internal_links = zip(routers, receivers)
    external_links = zip(routers[:m], sources)
    for u, v in internal_links:
        topology.add_edge(u, v, type='internal')
    for u, v in external_links:
        topology.add_edge(u, v, type='external')
    topology.graph['icr_candidates'] = set(routers)
    for v in sources:
        fnss.add_stack(topology, v, 'source')
    for v in receivers:
        fnss.add_stack(topology, v, 'receiver')
    for v in routers:
        fnss.add_stack(topology, v, 'router')
    # set weights and delays on all links
    fnss.set_weights_constant(topology, 1.0)
    fnss.set_delays_constant(topology, delay_int, 'ms', internal_links)
    fnss.set_delays_constant(topology, delay_ext, 'ms', external_links)
    return IcnTopology(topology)
Exemplo n.º 9
0
def topology_repo_mesh(n, m, delay_int=0.02, delay_ext=1, **kwargs):
    """Returns a ring topology

    This topology is comprised of a mesh of *n* nodes. Each of these nodes is
    attached to a receiver. In addition *m* router are attached each to a source.
    Therefore, this topology has in fact 2n + m nodes.

    Parameters
    ----------
    n : int
        The number of routers in the ring
    m : int
        The number of sources
    delay_int : float
        The internal link delay in milliseconds
    delay_ext : float
        The external link delay in milliseconds

    Returns
    -------
    topology : IcnTopology
        The topology object
    """
    receiver_access_delay = 0.001
    if m > n:
        raise ValueError("m cannot be greater than n")
    topology = fnss.full_mesh_topology(n)
    topology.sources_no = m
    topology.routers_no = n
    routers = range(n)
    receivers = ['rec_%d' % i for i in range(n)]
    sources = ['src_%d' % i for i in range(m)]
    internal_links = zip(routers, receivers)
    for u in routers:
        for v in routers:
            if v != u:
                internal_links.append(tuple([u, v]))
    external_links = zip(routers[:m], sources)
    for u, v in internal_links:
        topology.add_edge(u, v, type='internal')
    for u, v in external_links:
        topology.add_edge(u, v, type='external')
    topology.graph['icr_candidates'] = set(routers)

    n_sources = m

    print("The number of sources: " + repr(n_sources))
    print("The number of receivers: " + repr(n))
    topology.graph['receiver_access_delay'] = receiver_access_delay
    topology.graph['link_delay'] = delay_int
    for v in routers:
        fnss.add_stack(topology, v, 'router')
        if 'source' not in topology.node[v]['stack']:
            try:
                try:
                    topology.node[v]['extra_types'].append('source')
                    topology.node[v]['extra_types'].append('router')
                except Exception as e:
                    err_type = str(type(e)).split("'")[1].split(".")[1]
                    if err_type == "KeyError":
                        topology.node[v].update(extra_types=['source'])
                        topology.node[v]['extra_types'].append('router')

            except Exception as e:
                err_type = str(type(e)).split("'")[1].split(".")[1]
                if err_type == "KeyError":
                    continue
    for v in sources:
        fnss.add_stack(topology, v, 'source')
    for v in receivers:
        fnss.add_stack(topology, v, 'receiver')

    # set weights and delays on all links
    fnss.set_weights_constant(topology, 1.0)
    fnss.set_delays_constant(topology, delay_int, 'ms', internal_links)
    fnss.set_delays_constant(topology, delay_ext, 'ms', external_links)

    # label links as internal

    topology.graph['receivers'] = receivers
    topology.graph['sources'] = sources
    topology.graph['sources'].extend(routers)
    topology.graph['routers'] = routers
    topology.graph['edge_routers'] = routers

    return IcnTopology(topology)