Beispiel #1
0
def topology_generic_rocketfuel_latency(asn, source_ratio, ext_delay, **kwargs):
    """Parse a generic RocketFuel topology with annotated latencies
    
    To each node of the parsed topology it is attached an artificial receiver
    node. To the routers with highest degree it is also attached a source node. 
    
    Parameters
    ----------
    asn : int
        AS number
    source_ratio : float
        Ratio between number of source nodes (artificially attached) and routers
    ext_delay : float
        Delay on external nodes
    """
    if source_ratio < 0 or source_ratio > 1:
        raise ValueError('source_ratio must be comprised between 0 and 1')
    f_topo = path.join(TOPOLOGY_RESOURCES_DIR, 'rocketfuel-latency', str(asn), 'latencies.intra')
    topology = fnss.parse_rocketfuel_isp_latency(f_topo).to_undirected()
    topology = list(nx.connected_component_subgraphs(topology))[0]
    # First mark all current links as inernal
    for u,v in topology.edges_iter():
        topology.edge[u][v]['type'] = 'internal'
    # Note: I don't need to filter out nodes with degree 1 cause they all have
    # a greater degree value but we compute degree to decide where to attach sources
    routers = topology.nodes()
    # Source attachment
    n_sources = int(source_ratio*len(routers))
    sources = ['src_%d' % i for i in range(n_sources)]
    deg = nx.degree(topology)
    
    # Attach sources based on their degree purely, but they may end up quite clustered 
    # routers = sorted(routers, key=lambda k: deg[k], reverse=True)
	# Onur: change the order of sorting to attach sources to low-degree routers
    routers = sorted(routers, key=lambda k: deg[k])
    for i in range(len(sources)):
        topology.add_edge(sources[i], routers[i], delay=ext_delay, type='external')
    
    # Here let's try attach them via cluster
#     clusters = compute_clusters(topology, n_sources, distance=None, n_iter=1000)
#     source_attachments = [max(cluster, key=lambda k: deg[k]) for cluster in clusters]
#     for i in range(len(sources)):
#         topology.add_edge(sources[i], source_attachments[i], delay=ext_delay, type='external')
    
    # attach artificial receiver nodes to ICR candidates
    receivers = ['rec_%d' % i for i in range(len(routers))]
    for i in range(len(routers)):
        topology.add_edge(receivers[i], routers[i], delay=0, type='internal')
    # Set weights to latency values
    for u, v in topology.edges_iter():
        topology.edge[u][v]['weight'] = topology.edge[u][v]['delay']
    # Deploy stacks on nodes
    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')
    return IcnTopology(topology)
Beispiel #2
0
 def test_parse_rocketfuel_isp_latency_overseas_nodes(self):
     rocketfuel_file = path.join(RES_DIR, 'rocketfuel-1239.latencies.intra')
     topology = fnss.parse_rocketfuel_isp_latency(rocketfuel_file)
     self.assertEquals(315, topology.number_of_nodes())
     self.assertEquals(1944, topology.number_of_edges())
     for _, _, data in topology.edges_iter(data=True):
         self.assertTrue('delay' in data)
         self.assertIsInstance(data['delay'], int)
         self.assertGreaterEqual(data['delay'], 0)
Beispiel #3
0
 def test_parse_rocketfuel_isp_latency_with_weights(self):
     latencies_file = path.join(RES_DIR, 'rocketfuel-1221.latencies.intra')
     weights_file = path.join(RES_DIR, 'rocketfuel-1221.weights.intra')
     topology = fnss.parse_rocketfuel_isp_latency(latencies_file, weights_file)
     self.assertEquals(108, topology.number_of_nodes())
     self.assertEquals(306, topology.number_of_edges())
     for _, _, data in topology.edges_iter(data=True):
         self.assertTrue('delay' in data)
         self.assertTrue('weight' in data)
         self.assertIsInstance(data['delay'], int)
         self.assertIsInstance(data['weight'], float)
         self.assertGreaterEqual(data['delay'], 0)
         self.assertGreater(data['weight'], 0)
Beispiel #4
0
 def test_parse_rocketfuel_isp_latency(self):
     rocketfuel_file = path.join(RES_DIR, 'rocketfuel-1221.latencies.intra')
     topology = fnss.parse_rocketfuel_isp_latency(rocketfuel_file)
     self.assertEquals(108, topology.number_of_nodes())
     self.assertEquals(306, topology.number_of_edges())
 def test_parse_rocketfuel_isp_latency(self):
     rocketfuel_file = path.join(RES_DIR, 'rocketfuel-1221.latencies.intra')
     topology = fnss.parse_rocketfuel_isp_latency(rocketfuel_file)
     self.assertEquals(108, topology.number_of_nodes())
     self.assertEquals(306, topology.number_of_edges())