mininet界面配置拓扑方法

在ubuntun系统中执行如下命令


/usr/lib/python2.7/dist-packages/mininet/examples/miniedit.py


遇到问题:


在设置控制器时候,点击run时候,miniedit退出并报错如下c0 cannot find required executable controller

1
2
3
apt-get install openvswitch-testcontroller
cp /usr/bin/ovs-testcontroller /usr/bin/ovs-controller
ln /usr/bin/ovs-controller /usr/bin/controller

环境搭建过程


步骤1:root模式执行python /usr/lib/python2.7/dist-packages/mininet/examples/miniedit.py

步骤2:设置h1和h2、h3的IP地址分别为10.10.10.1、10.10.10.2、10.10.10.3

步骤3:点击run运行

步骤4:保存该脚本为1.py,下次直接运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
root@controller-VirtualBox:~# cat 1.py
#!/usr/bin/python

from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call

def myNetwork():

net = Mininet( topo=None,
build=False,
ipBase='10.0.0.0/8')

info( '*** Adding controller\n' )
c0=net.addController(name='c0',
controller=Controller,
protocol='tcp',
port=6633)

info( '*** Add switches\n')
s1 = net.addSwitch('s1', cls=OVSKernelSwitch, listenPort=6633)
s2 = net.addSwitch('s2', cls=OVSKernelSwitch, listenPort=6633)

info( '*** Add hosts\n')
h3 = net.addHost('h3', cls=Host, ip='10.10.10.3', defaultRoute=None)
h1 = net.addHost('h1', cls=Host, ip='10.10.10.1', defaultRoute=None)
h2 = net.addHost('h2', cls=Host, ip='10.10.10.2', defaultRoute=None)

info( '*** Add links\n')
net.addLink(h1, s1)
net.addLink(s1, h2)
net.addLink(s2, h3)
net.addLink(s1, s2)

info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()

info( '*** Starting switches\n')
net.get('s1').start([c0])
net.get('s2').start([c0])

info( '*** Post configure switches and hosts\n')
s1.cmd('ifconfig s1 127.0.0.1')
s2.cmd('ifconfig s2 127.0.0.1')

CLI(net)
net.stop()

if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()

步骤5: 直接运行python 1.py恢复环境