在 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()

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...