def pre_compute_paths(self, G):
"""
Computes paths between all hosts in the network. It computes up to
PATH_LIMIT paths per each host.
All computed paths are saved to a path lookup table path_table.py
Args:
G: networkx graph containing the topology of the network.
"""
host_combinations = itertools.permutations(self.hosts, 2)
for src, dst in host_combinations:
paths_generator = nx.all_shortest_paths(G, src.dpid, dst.dpid)
counter = 0
for path in paths_generator:
if counter > PATH_LIMIT:
break
# counter += 1 # TODO de-comment for big topologies
path = Path(src.dpid, src.port, dst.dpid, dst.port, path)
self.path_table.put_path(path = path, src = src.dpid, dst = dst.dpid)
评论列表
文章目录