shortest_path_switch.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:sdn 作者: ray6 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号