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
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
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.