我创建了一个自定义mininet拓扑,如下所示:
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.cli import CLI
class MyTopo (Topo):
def __init__(self):
Topo.__init__(self)
# Add hosts and switches
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
s3 = self.addSwitch('s3')
for i in range(1, 21):
self.addHost('h%s'%i, ip='10.0.0.%s'%i)
self.addLink('h%s'%i, s1)
for i in range(21,41):
self.addHost('h%s'%i, ip='10.0.0.%s'%i)
self.addLink('h%s'%i, s2)
for i in range(41,61):
self.addHost('h%s'%i, ip='10.0.0.%s'%i)
self.addLink('h%s'%i, s3)
#Add link between switches
self.addLink(s1, s2)
self.addLink(s2, s3)
topo = MyTopo()
net = Mininet(topo)
net.start()
h1 = net.get('h1')
print(h1)
result = h1.cmd('ifconfig')
print(result)
CLI(net)
net.stop()
topos = { 'mytopo': ( lambda: MyTopo() ) }
我在终端使用 sudo mn --custom /home/bob/pox/ext/My_topology1.py --topo = mytopo --mac 作为命令。 这里有2个问题: