我刚刚设置了一个mininet拓扑。 现在我想通过Ubuntu的接口将Mininet交换机上的一个端口连接到一个外部端口。 Ubuntu服务器有两个端口:
ens33
连接到实际网络ens38
已连接到VMnet2我的Python脚本:
from mininet.net import Mininet
from mininet.node import Controller
from mininet.cli import CLI
from mininet.link import Intf
from mininet.log import setLogLevel, info
from mininet.topo import Topo
class MyTopo( Topo ):
"Simple topology example."
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
'*** Add switches\n'
s1 = self.addSwitch('s1')
Intf('ens38', node=s1)
s2 = self.addSwitch('s2')
'*** Add hosts\n'
h2 = self.addHost('h2')
# Add links
'*** Add links\n'
self.addLink(h2, s2)
topos = { 'mytopo': ( lambda: MyTopo() ) }
但当我使用以下命令行运行它时:
mn --custom qtho-topo.py --topo mytopo \
--controller=remote,ip=192.168.1.128,port=6633 \
--switch ovsk,protocols=OpenFlow13
有错误:
Caught exception. Cleaning up...
AttributeError: 'str' object has no attribute 'addIntf'
有没有人有这方面的经验
这个问题是不久前提出的,但我希望我的建议能有所帮助。
self.addSwitch()
函数返回字符串,因此s1
是字符串,而Intf
函数需要Node
类型如果要使用命令行运行,一个简单的解决方案是创建网络,然后使用添加接口的测试函数,如下例所示:
要在命令行中运行它,假设您已将文件命名为test.py:
除了朱塞佩的回答之外,这条代码对我也很有用:
相关问题 更多 >
编程相关推荐