Exemplo n.º 1
0
 def test_sin_cyclostationary_traffic_matrix(self):
     tms = fnss.sin_cyclostationary_traffic_matrix(self.G, 10, 0.2, gamma=0.3, 
                                                   log_psi=-0.3, delta=0.2, 
                                                   n=24, periods=2, max_u=0.9)
     self.assertEqual(48, len(tms))
     self.assertAlmostEqual(0.9, max([max(fnss.link_loads(self.G, tm).values()) for tm in tms]))
     self.assertLessEqual(0, min([min(fnss.link_loads(self.G, tm).values()) for tm in tms]))
Exemplo n.º 2
0
 def test_sin_cyclostationary_traffic_matrix_low_log_psi(self):
     # Test that with very low value of log_psi and/or gamma to test 
     # that FNSS deals properly with division by 0 cases
     log_psi = [-1500, -200]
     for lp in log_psi:
         if exp(lp) == 0:
             self.assertRaises(ValueError, 
                               fnss.sin_cyclostationary_traffic_matrix,
                               self.G, mean=10, stddev=0.2, 
                               gamma=0.3, log_psi=lp, delta=0.2, 
                               n=24, periods=2, max_u=0.9)
         else:
             try:
                 tms = fnss.sin_cyclostationary_traffic_matrix(
                                   self.G, mean=10, stddev=0.2, 
                                   gamma=0.3, log_psi=lp, delta=0.2, 
                                   n=24, periods=2, max_u=0.9)
             except ValueError:
                 pass
             else:
                 volumes = [tm[y] for tm in tms for y in tm.flows()]
                 valid_volumes = [vol >= 0 and not isinf(vol) for vol in volumes]
                 self.assertTrue(all(valid_volumes))
Exemplo n.º 3
0
                                weighted=False)

# add weights proportional to inverse of capacity
fnss.set_weights_inverse_capacity(topology)

# add constant link delays of 2 ms
fnss.set_delays_constant(topology, 2, delay_unit='ms')

# generate cyclostationary traffic matrix (period 7 days, 24 samples per day)
tmc = fnss.sin_cyclostationary_traffic_matrix(
       topology,
       mean=0.5,  # average flow in TM is 0,5 Gbps
       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)
Exemplo n.º 4
0
                                weighted=False)

# add weights proportional to inverse of capacity
fnss.set_weights_inverse_capacity(topology)

# add constant link delays of 2 ms
fnss.set_delays_constant(topology, 2, delay_unit='ms')

# generate cyclostationary traffic matrix (period 7 days, 24 samples per day)
tmc = fnss.sin_cyclostationary_traffic_matrix(
       topology, 
       mean=0.5, # average flow in TM is 0,5 Gbps 
       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)