Giter Site home page Giter Site logo

sdn's Introduction

SDN

ryu+mininet实现最短路径规划

topo的构建

topo主要应用了随机图算法,随机生成Link
再使用bfs筛选,防止交换机链接成环造成广播风暴
关键代码如下

def bfs(self,graph):
	queue=[0]  
	visit=set([0])  
	edges=[]  
	while(queue):  
	    s=queue.pop(0)  
	    for t in graph[s]:  
		if not t in visit:  
		    edges.append([s,t])  
		    queue.append(t)  
		    visit.add(t)  
	return edges  

部分topo:
.

最短路径规划

1.获取交换机的链接topo
2.获取流信息
3.如果src不在网络拓扑中则建立链接
4.如果dst在网络拓扑中则根据最短路算法规划下一跳端口
5.对于已确定的路径加入流
关键代码如下:

if src not in self.net:

            self.net.add_node(src)

            self.net.add_edge(dpid,src,port=in_port)

            self.net.add_edge(src,dpid)

        if dst in self.net:
        
            path=nx.shortest_path(self.net,src,dst)  
	    print(path)
            next=path[path.index(dpid)+1]
            out_port=self.net[dpid][next]['port']

        else:

            out_port = ofproto.OFPP_FLOOD

部分学习到的路径
.

sdn's People

Contributors

smartysl avatar

Stargazers

Ebru YAĞMUR avatar 杜雨衡 avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.