#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.node import OVSKernelSwitch
from mininet.cli import CLI
from mininet.util import dumpNodeConnections
if __name__ == '__main__':
net = Mininet()
c1 = net.addController('c1', controller=RemoteController)
s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
for n in xrange(1, 21):
host = net.addHost('h%s' % n)
net.addLink(host, s1)
net.build()
c1.start()
net.get('s1').start([c1])
dumpNodeConnections(net.hosts)
CLI(net)
net.stop()
執行結果:
參考資料:
https://github.com/mininet/mininet/wiki/Introduction-to-Mininet#what
http://www.cs.nchu.edu.tw/~snmlab/CloudMgnt201409/Lab3.html
