def generate_topo(n): topo = nx.powerlaw_cluster_graph(n,2,0.08) # topo = fnss.waxman_1_topology(n=50,alpha=0.6,beta=0.3) # topo = fnss.fat_tree_topology(n) fnss.set_weights_constant(topo,1) fnss.set_delays_constant(topo, 1, 'ms') fnss.set_capacities_edge_betweenness(topo,[100,500,1000],'Mbps') fnss.write_topology(topo,'topo_pl_50.xml')
def parse(topo_path, xml_path, delay, buffer_type): topology = fnss.parse_topology_zoo(topo_path) topology = topology.to_undirected() fnss.set_capacities_edge_betweenness(topology, [200, 500, 1000], 'Mbps') # TODO: hardcode now fnss.set_weights_constant(topology, 1) fnss.set_delays_constant(topology, delay, 'ms') if buffer_type == 'bdp': fnss.set_buffer_sizes_bw_delay_prod(topology, 'packet', 1500) elif buffer_type == 'bw': fnss.set_buffer_sizes_link_bandwidth(topology, buffer_unit='packet') else: fnss.set_buffer_sizes_constant(topology, 1500, 'packet') fnss.write_topology(topology, xml_path)
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, 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
def test_capacities_edge_betweenness(self): fnss.set_capacities_edge_betweenness(self.topo, self.capacities) self.assertTrue( all(self.topo.edge[u][v]['capacity'] in self.capacities for (u, v) in self.topo.edges_iter()))
""" 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, 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'}
def test_capacities_edge_betweenness(self): fnss.set_capacities_edge_betweenness(self.topo, self.capacities) self.assertTrue(all(self.topo.edge[u][v]['capacity'] in self.capacities for (u, v) in self.topo.edges_iter()))
This example shows how to import a topology from RocketFuel, configure it (assign capacities, weights and delays), generate a traffic matrix and save topology and traffic matrix to XML files. """ import fnss import random # Import RocketFuel topology # Replace the filename with the actual location of the file you want to parse topology = fnss.parse_rocketfuel_isp_map("rocket-fuel-topo-file.cch") # add capacities capacities = [1, 10, 40] capacity_unit = 'Gbps' fnss.set_capacities_edge_betweenness(topology, capacities, capacity_unit, 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