Instalation
First of all you need to install mininet. Mininet is small but powerfull SDN network simulator. It understands OpenFlow protocol and can be managed by any SDN Controller (floodlight, Cisco APIC, OpenDayLight etc)
First of all you need to install mininet. Mininet is small but powerfull SDN network simulator. It understands OpenFlow protocol and can be managed by any SDN Controller (floodlight, Cisco APIC, OpenDayLight etc)
After installation just run mn as root user and you'll get simple one switch and two host topology
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 1 switches
s1 ...
*** Starting CLI:
# Now your topology ready and you can test reachability
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)
# seems all is working fine :) so we just exit
mininet> exit
*** Stopping 1 controllers
c0
*** Stopping 2 links
..
*** Stopping 1 switches
s1
*** Stopping 2 hosts
h1 h2
*** Done
completed in 7.725 seconds
# it is strongly advised to run "sudo mn -c" each time you exit from topology. This will do the cleanup.
Here is a bit more advanced spine & leaf topology with localy running SDN controller and internet facing router with one external host
host$ cat mytopology.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=RemoteController,
ip='127.0.0.1',
protocol='tcp',
port=6653)
info( '*** Add switches\n')
lf2 = net.addSwitch('lf2', cls=OVSKernelSwitch, dpid="0000000000000013")
lf3 = net.addSwitch('lf3', cls=OVSKernelSwitch, dpid="0000000000000012")
lf1 = net.addSwitch('lf1', cls=OVSKernelSwitch, dpid="0000000000000011")
r6 = net.addHost('r6', cls=Node, ip='0.0.0.0')
r6.cmd('sysctl -w net.ipv4.ip_forward=1')
sp2 = net.addSwitch('sp2', cls=OVSKernelSwitch, dpid="0000000000000002")
sp1 = net.addSwitch('sp1', cls=OVSKernelSwitch, dpid="0000000000000001")
info( '*** Add hosts\n')
ext = net.addHost('ext', cls=Host, ip='20.0.0.1', defaultRoute='via 20.0.0.254')
h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute='via 10.0.0.254')
h5 = net.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute='via 10.0.0.254')
h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute='via 10.0.0.254')
h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute='via 10.0.0.254')
h6 = net.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute='via 10.0.0.254')
h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute='via 10.0.0.254')
info( '*** Add links\n')
net.addLink(lf3, r6)
net.addLink(r6, ext)
net.addLink(sp1, lf1)
net.addLink(sp2, lf1)
net.addLink(sp1, lf2)
net.addLink(sp1, lf3)
net.addLink(sp2, lf2)
net.addLink(sp2, lf3)
net.addLink(lf1, h1)
net.addLink(lf1, h2)
net.addLink(lf2, h3)
net.addLink(lf2, h4)
net.addLink(lf3, h5)
net.addLink(lf3, h6)
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()
info( '*** Starting switches\n')
net.get('lf2').start([c0])
net.get('lf3').start([c0])
net.get('lf1').start([c0])
net.get('sp2').start([c0])
net.get('sp1').start([c0])
info( '*** Post configure switches and hosts\n')
lf2.cmd('ifconfig lf2 10.0.1.4')
lf3.cmd('ifconfig lf3 10.0.1.5')
lf1.cmd('ifconfig lf1 10.0.1.3')
sp2.cmd('ifconfig sp2 10.0.1.2')
sp1.cmd('ifconfig sp1 10.0.1.1')
r6.cmd('ifconfig r6-eth0 10.0.0.254')
r6.cmd('ifconfig r6-eth1 20.0.0.254')
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()
Tokyo is the capital of Japan, the center of the Greater Tokyo Area, and the most populous metropolitan area in the world.