微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 Python 中使用 Mininet() 类创建拓扑时如何提及“--switch=ovsk,protocols=OpenFlow13”?

如何解决在 Python 中使用 Mininet() 类创建拓扑时如何提及“--switch=ovsk,protocols=OpenFlow13”?

看下面的命令-

$ sudo mn --controller=remote,ip=127.0.0.1,port=6653 --switch=ovsk,protocols=OpenFlow13 --topo=tree,depth=2,fanout=4

我想使用 Python 代码来实现这种拓扑结构。

到目前为止,我在 python 中得到了以下几行,它们部分地实现了上述命令的结果 -

from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.topolib import Treetopo

controller = RemoteController('c0',ip='127.0.0.1',port=6653)
topo = Treetopo(2,4)
net = Mininet(topo=topo,controller=controller)
net.start()

如何在此 Python 代码中包含 switchprotocols 部分?

解决方法

请参考 mininet documentation

在你的情况下:

from mininet.net import Mininet
from mininet.node import RemoteController,OVSSwitch
from mininet.topolib import TreeTopo
from mininet.cli import CLI

controller = RemoteController('c0',ip='127.0.0.1',port=6653,protocols="OpenFlow13")
topo = TreeTopo(2,4)
net = Mininet(topo=topo,controller=controller,switch=OVSSwitch)
net.start()

#IF you want to start the CLI
CLI(net)
#If you want to clean the environment
net.stop()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。