Пример #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()))
Пример #2
0
 def test_read_write_tm(self):
     tm = fnss.static_traffic_matrix(self.G, mean=10, stddev=0.1, max_u=0.9)
     tmp_tm_file = path.join(TMP_DIR, 'tms.xml')
     fnss.write_traffic_matrix(tm, tmp_tm_file)
     read_tm = fnss.read_traffic_matrix(tmp_tm_file)
     u, v = tm.od_pairs()[2]
     self.assertAlmostEqual(tm[(u, v)], read_tm[(u, v)])
Пример #3
0
 def test_static_traffic_matrix_partial_od_pairs(self):
     origin_nodes = [1, 2, 3]
     destination_nodes = [3, 4, 5]
     od_pairs = [(o, d) for o in origin_nodes for d in destination_nodes if o != d]
     tm = fnss.static_traffic_matrix(self.G, 10, 8,
                                     origin_nodes=origin_nodes,
                                     destination_nodes=destination_nodes, 
                                     max_u=0.9)
     tm_od_pairs = tm.od_pairs()
     self.assertEqual(len(od_pairs), len(tm_od_pairs))
     for od in od_pairs:
         self.assertTrue(od in tm_od_pairs)
     self.assertAlmostEqual(0.9, max(fnss.link_loads(self.G, tm).values()))
     self.assertLessEqual(0, min(fnss.link_loads(self.G, tm).values()))
Пример #4
0
 def test_static_traffic_matrix(self):
     tm = fnss.static_traffic_matrix(self.G, 10, 8, max_u=0.9)
     self.assertAlmostEqual(0.9, max(fnss.link_loads(self.G, tm).values()))
     self.assertLessEqual(0, min(fnss.link_loads(self.G, tm).values()))
Пример #5
0
# 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, stddev=0.2, max_u=0.5)

# This is the event generator function, which generates link failure events
def rand_failure(links):
    link = random.choice(links)
    return {'link': link, 'action': 'down'}

# Create schedule of link failures
event_schedule = fnss.poisson_process_event_schedule(
                        avg_interval=0.5,  # 0.5 min = 30 sec
                        t_start=0,  # starts at 0
                        duration=60,  # 2 hours
                        t_unit='min',  # minutes
                        event_generator=rand_failure,  # event gen function
                        links=topology.edges(),  # 'links' argument
                        )
Пример #6
0
 def test_static_traffic_matrix(self):
     tm = fnss.static_traffic_matrix(self.G, 10, 8, max_u=0.9)
     self.assertAlmostEqual(0.9, max(fnss.link_loads(self.G, tm).values()))
     self.assertLessEqual(0, min(fnss.link_loads(self.G, tm).values()))
Пример #7
0
       stddev=0.05,  # this is the std among average flows of different OD pairs
       gamma=0.8,  # gamma and log_psi are parameters for fitting the std of
       log_psi=-0.33,  # volume fluctuations over time. Look at Nucci et al. paper
       delta=0.2,  # traffic variation from period max and avg as fraction of average
       n=24,  # number of samples per each period
       periods=7,  # number of periods
       max_u=0.9,  # max link utilization desired
       origin_nodes=None,  # Specify origin and destination nodes. If None,
       destination_nodes=None  # all nodes of the topology are both
       )  # origin and destination nodes of traffic


# now we generate a static traffic matrix, but this time instead of generating
# a matrix where all nodes are both origin and destinations, we pick up only
# few nodes as sources and destinations of traffic.
# Let's select 5 sources and 5 destinations
nodes = topology.nodes()
origins = random.sample(nodes, 5)
destinations = random.sample(nodes, 5)
# generate traffic matrix
tms = fnss.static_traffic_matrix(topology, mean=0.5, stddev=0.05, max_u=0.9,
                                 origin_nodes=origins,
                                 destination_nodes=destinations)

# save topology on a file
fnss.write_topology(topology, 'topology.xml')

# save traffic matrices on files
fnss.write_traffic_matrix(tmc, 'cyclostationary-traffic-matrix.xml')
fnss.write_traffic_matrix(tms, 'static-traffic-matrix.xml')