def ShortestPathInstall(self, ev, src, dst):
#Compute shortest path
path = nx.shortest_path(self.directed_Topo, src, dst)
#Backup path
str_path = str(path).replace(', ', ',')
self.path_db.append(path)
#Add Flow along with the path
for k, sw in enumerate(self.switches):
if sw in path:
next = path[path.index(sw)+1]
out_port = self.directed_Topo[sw][next]['port']
actions = [self.switches_dp[k].ofproto_parser.OFPActionOutput(out_port)]
match = self.switches_dp[k].ofproto_parser.OFPMatch(eth_src=src, eth_dst=dst)
self.add_flow(self.switches_dp[k], 1, match, actions, ev.msg.buffer_id)
#Add host and adjacent switch to directed_Topo
评论列表
文章目录