Пример #1
0
 def test_waxman_1_topology(self):
     self.assertRaises(ValueError, fnss.waxman_1_topology, 0, 0.5, 0.5, 10)
     self.assertRaises(ValueError, fnss.waxman_1_topology, 10, 0, 0.5, 10)
     self.assertRaises(ValueError, fnss.waxman_1_topology, 10, 0.5, 0.5, 0)
     self.assertRaises(ValueError, fnss.waxman_1_topology, 10, 0.5, 0, 10)
     topology = fnss.waxman_1_topology(200, alpha=0.5, beta=0.6, L=20)
     self.assertEqual(200, topology.number_of_nodes())
     length = nx.get_edge_attributes(topology, 'length')
     self.assertGreaterEqual(20, max(length.values()))
     self.assertLessEqual(0, min(length.values()))
Пример #2
0
 def test_waxman_1_topology(self):
     self.assertRaises(ValueError, fnss.waxman_1_topology, 0, 0.5, 0.5, 10)
     self.assertRaises(ValueError, fnss.waxman_1_topology, 10, 0, 0.5, 10)
     self.assertRaises(ValueError, fnss.waxman_1_topology, 10, 0.5, 0.5, 0)
     self.assertRaises(ValueError, fnss.waxman_1_topology, 10, 0.5, 0, 10)
     topology = fnss.waxman_1_topology(200, alpha=0.5, beta=0.6, L=20)
     self.assertEqual(200, topology.number_of_nodes())
     length = nx.get_edge_attributes(topology, 'length')
     self.assertGreaterEqual(20, max(length.values()))
     self.assertLessEqual(0, min(length.values()))
Пример #3
0
 def test_delays_geo_distance(self):
     specific_delay = 1.2
     L = 5
     G_len = fnss.waxman_1_topology(100, L=L)
     G_xy = fnss.waxman_2_topology(100, domain=(0, 0, 3, 4))
     # leave only node coordinate to trigger failure
     for u, v in G_xy.edges_iter():
         del G_xy.edge[u][v]['length']
     self.assertRaises(ValueError, fnss.set_delays_geo_distance,
                       G_len, 2, delay_unit='Km')
     self.assertRaises(ValueError, fnss.set_delays_geo_distance,
                       G_xy, specific_delay, None, 'ms')
     fnss.set_delays_geo_distance(G_len, specific_delay,
                             None, 'ms', links=None)
     delays = nx.get_edge_attributes(G_len, 'delay')
     self.assertEqual(G_len.number_of_edges(), len(delays))
     self.assertGreaterEqual(specific_delay*L, max(delays.values()))
     self.assertLessEqual(0, min(delays.values()))
Пример #4
0
 def test_waxman_1_topology_zero_seed(self):
     a = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=0)
     b = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=0)
     self.assertEqual(set(a.edges()), set(b.edges()))
Пример #5
0
 def test_waxman_1_topology_constant_seed(self):
     a = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=1)
     b = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=2)
     c = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=1)
     self.assertEqual(set(a.edges()), set(c.edges()))
     self.assertNotEqual(set(a.edges()), set(b.edges()))
Пример #6
0
 def test_waxman_1_topology_zero_seed(self):
     a = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=0)
     b = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=0)
     self.assertEqual(set(a.edges()), set(b.edges()))
Пример #7
0
 def test_waxman_1_topology_constant_seed(self):
     a = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=1)
     b = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=2)
     c = fnss.waxman_1_topology(100, alpha=0.5, beta=0.6, L=20, seed=1)
     self.assertEqual(set(a.edges()), set(c.edges()))
     self.assertNotEqual(set(a.edges()), set(b.edges()))
Пример #8
0
This example shows how to generate a topology, an event schedule and a traffic
matrix.

In this specific example we create a Waxman topology and create an event
schedule listing random link failures and restores and generate a static
traffic matrix.

This scenario could be used to assess the performance of a routing algorithm
in case of frequent link failures.
"""
import fnss
import random

# generate a Waxman1 topology with 200 nodes
topology = fnss.waxman_1_topology(n=200, alpha=0.4, beta=0.1, L=1)

# assign constant weight (1) to all links
fnss.set_weights_constant(topology, 1)


# set delay equal to 1 ms to all links
fnss.set_delays_constant(topology, 1, 'ms')

# set varying capacities among 10, 100 and 1000 Mbps proprtionally to edge
# betweenness centrality
fnss.set_capacities_edge_betweenness(topology, [10, 100, 1000], 'Mbps')


# now create a static traffic matrix assuming all nodes are both origins
# and destinations of traffic
Пример #9
0
This example shows how to generate a topology, an event schedule and a traffic
matrix.

In this specific example we create a Waxman topology and create an event
schedule listing random link failures and restores and generate a static
traffic matrix.

This scenario could be used to assess the performance of a routing algorithm
in case of frequent link failures.
"""
import fnss
import random

# generate a Waxman1 topology with 200 nodes
topology = fnss.waxman_1_topology(n=200, alpha=0.4, beta=0.1, L=1)

# assign constant weight (1) to all links
fnss.set_weights_constant(topology, 1)

# set delay equal to 1 ms to all links
fnss.set_delays_constant(topology, 1, 'ms')

# set varying capacities among 10, 100 and 1000 Mbps proprtionally to edge
# betweenness centrality
fnss.set_capacities_edge_betweenness(topology, [10, 100, 1000], 'Mbps')

# now create a static traffic matrix assuming all nodes are both origins
# and destinations of traffic
traffic_matrix = fnss.static_traffic_matrix(topology,
                                            mean=2,
Пример #10
0
"""

import fnss
import networkx as nx
import time
import sys

n = int(sys.argv[1])
alpha = float(sys.argv[2])
beta = float(sys.argv[3])
standard_bw = 100  # dummy bandwidth value to go on topo files

disconnected = True
tries = 0
while disconnected:
    topo = fnss.waxman_1_topology(n, alpha=alpha, beta=beta)
    disconnected = not nx.is_connected(topo)
    tries += 1
    if tries == 300:
        sys.stderr.write("%d FAIL\n" % n)
        break

if not disconnected:
    print "edges"
    nodes = list(topo.nodes())
    num_nodes = len(nodes)
    for n in nodes[:int(0.7 * num_nodes)]:
        print n, 'p%d' % n
    print "links"
    for (src, dst) in topo.edges():
        print src, dst, standard_bw
Пример #11
0
"""

import fnss
import networkx as nx
import time
import sys

n=int(sys.argv[1])
alpha=float(sys.argv[2])
beta=float(sys.argv[3])
standard_bw = 100 # dummy bandwidth value to go on topo files

disconnected = True
tries = 0
while disconnected:
    topo = fnss.waxman_1_topology(n, alpha=alpha, beta=beta)
    disconnected = not nx.is_connected(topo)
    tries += 1
    if tries == 300:
        sys.stderr.write("%d FAIL\n" % n)
        break

if not disconnected:
    print "edges"
    nodes = list(topo.nodes())
    num_nodes = len(nodes)
    for n in nodes[:int(0.7*num_nodes)]:
        print n, 'p%d' % n
    print "links"
    for (src,dst) in topo.edges():
        print src, dst, standard_bw