您的位置:首页 > 编程语言 > Python开发

通过Mininet Python API 添加自定义交换机 switch=user的方法

2017-09-20 09:29 681 查看

问题描述

希望使用自己的cpqd交换机,在命令行的参数中使用的时候是

sudo mn --custom ./li2_topo.py --topo litopo --controller=remote,ip=127.0.0.1,port=6633 --switch=user


现在希望在文件中写好,调用Mininet的python api



写成了

net = Mininet(topo=topo, link=TCLink, controller=None, autoSetMacs=False,
autoStaticArp=False,switch=user)


但是报错user未定义,自己猜测是没有引入user这个变量,需要import

解决方法

去网上找其他人的写法,发现的确是这样的

from mininet.topo import Topo
from mininet.nodelib import LinuxBridge
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import Controller, RemoteController, OVSController


引入的是UserSwitch,那么在调用的时候就不能和CLI一样了,

应该写作

net = Mininet(topo=topo, link=TCLink, controller=None, autoSetMacs=False,
autoStaticArp=False,switch=UserSwitch)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mininet cpqd SDN