Info
Host OS: Windows 10
First Attempt Guest OS: Mininet-VM
Second Attempt Guest OS: Ubuntu(VM)
VM Software: Virtual Box
Libraries: Mininet Python API
Issue
Good day,
I'm having some issues with a my customized topology when using Mininet.
Initially, I used Mininet's recommended Mininet-VM and it works fine for the default command generated topologies(i.e.: linear, tree, reversed, etc).
However, when I wish to run my own topology I'm unable to ping any other host(see code below).
Commands:
I thought it might be an issue with the image of Mininet-VM itself and so I tried running the same script within Ubuntu(with Mininet installed of course) and ran into the same issue.
In any case, I've looked around stackoverflow(references below) and none of the solutions worked for me. Although, some have suggested to use the POX controller instead of the default one, but I'm quite ignorant on how it works as well as how to implement it.
Any help would be appreciated.
Cheers!
Result
Topology Diagram
Mid-Level API Code
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.node import Controller
net = Mininet(controller=Controller, link=TCLink)
h1 = net.addHost('h1')
h2 = net.addHost('h2')
h3 = net.addHost('h3')
h4 = net.addHost('h4')
h5 = net.addHost('h5')
h6 = net.addHost('h6')
h7 = net.addHost('h7')
h8 = net.addHost('h8')
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')
s4 = net.addSwitch('s4')
s5 = net.addSwitch('s5')
s6 = net.addSwitch('s6')
c0 = net.addController('c0')
net.addLink(h1, s1)
net.addLink(h2, s2)
net.addLink(h3, s3)
net.addLink(h4, s4)
net.addLink(h5, s4)
net.addLink(h6, s5)
net.addLink(h7, s5)
net.addLink(h8, s6)
net.addLink(s1, s2, bw=10, delay='0ms')
net.addLink(s2, s3, bw=10, delay='0ms')
net.addLink(s3, s4, bw=100, delay='5ms')
net.addLink(s4, s5, bw=100, delay='5ms')
net.addLink(s5, s6, bw=100, delay='0ms')
net.addLink(s6, s1, bw=10, delay='0ms')
net.start()
print( "Dumping host connections" )
dumpNodeConnections( net.hosts )
dumpNodeConnections( net.switches )
CLI(net)
net.stop()
References
Issue: The default controller within Mininet cannot handle loops within a topology. To fix this, we'll need to use the POX controller and some additional configuration for the switches.
You will need to run two terminals:
Please look at references #5 and #6, they display some decent examples
Code Solution
from mininet.net import Mininet
from mininet.node import Controller, RemoteController,
OVSKernelSwitch, UserSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.link import Link, TCLink
def topology():
"Create a network."
net = Mininet( controller=RemoteController, link=TCLink,
switch=OVSKernelSwitch )
print("*** Creating nodes")
h1 = net.addHost( 'h1', mac='00:00:00:00:00:01', ip='10.0.0.1/24' )
h2 = net.addHost( 'h2', mac='00:00:00:00:00:02', ip='10.0.0.2/24' )
h3 = net.addHost( 'h3', mac='00:00:00:00:00:03', ip='10.0.0.3/24' )
h4 = net.addHost( 'h4', mac='00:00:00:00:00:04', ip='10.0.0.4/24' )
h5 = net.addHost( 'h5', mac='00:00:00:00:00:05', ip='10.0.0.5/24' )
h6 = net.addHost( 'h6', mac='00:00:00:00:00:06', ip='10.0.0.6/24' )
h7 = net.addHost( 'h7', mac='00:00:00:00:00:07', ip='10.0.0.7/24' )
h8 = net.addHost( 'h8', mac='00:00:00:00:00:08', ip='10.0.0.8/24' )
s1 = net.addSwitch( 's1' )
s2 = net.addSwitch( 's2' )
s3 = net.addSwitch( 's3' )
s4 = net.addSwitch( 's4' )
s5 = net.addSwitch( 's5' )
s6 = net.addSwitch( 's6' )
c7 = net.addController( 'c7', controller=RemoteController,
ip='127.0.0.1', port=6633 )
print("*** Creating links")
net.addLink( h1, s1 )
net.addLink( h2, s2 )
net.addLink( h3, s3 )
net.addLink( h4, s4 )
net.addLink( h5, s4 )
net.addLink( h6, s5 )
net.addLink( h7, s5 )
net.addLink( h8, s6 )
net.addLink( s1, s2, cls=TCLink, bw=10 )
net.addLink( s2, s3, cls=TCLink, bw=10 )
net.addLink( s3, s4, cls=TCLink, bw=100, delay='5ms' )
net.addLink( s4, s5, cls=TCLink, bw=100, delay='5ms' )
net.addLink( s5, s6, cls=TCLink, bw=100 )
net.addLink( s6, s1, cls=TCLink, bw=10 )
print("*** Starting network")
net.build()
c7.start()
s1.start( [c7] )
s2.start( [c7] )
s3.start( [c7] )
s4.start( [c7] )
s5.start( [c7] )
s6.start( [c7] )
# Configuring switches
s1.cmd("sh ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.1.0/24,actions=output:1")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.2.0/24,actions=output:2")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.3.0/24,actions=output:3")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.4.0/24,actions=output:3")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.5.0/24,actions=output:3")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.6.0/24,actions=output:2")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.7.0/24,actions=output:2")
s1.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.8.0/24,actions=output:2")
s2.cmd("sh ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s2.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.1.0/24,actions=output:3")
s2.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.2.0/24,actions=output:1")
s2.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.3.0/24,actions=output:2")
s2.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.4.0/24,actions=output:2")
s2.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.5.0/24,actions=output:2")
s2.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.6.0/24,actions=output:3")
s2.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.7.0/24,actions=output:3")
s2.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.8.0/24,actions=output:3")
s3.cmd("sh ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.1.0/24,actions=output:3")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.2.0/24,actions=output:3")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.3.0/24,actions=output:1")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.4.0/24,actions=output:2")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.5.0/24,actions=output:2")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.6.0/24,actions=output:2")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.7.0/24,actions=output:2")
s3.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.8.0/24,actions=output:3")
s4.cmd("sh ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.1.0/24,actions=output:2")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.2.0/24,actions=output:2")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.3.0/24,actions=output:2")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.4.0/24,actions=output:1")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.5.0/24,actions=output:4")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.6.0/24,actions=output:3")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.7.0/24,actions=output:3")
s4.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.8.0/24,actions=output:3")
s5.cmd("sh ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.1.0/24,actions=output:3")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.2.0/24,actions=output:3")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.3.0/24,actions=output:3")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.4.0/24,actions=output:2")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.5.0/24,actions=output:2")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.6.0/24,actions=output:1")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.7.0/24,actions=output:4")
s5.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.8.0/24,actions=output:3")
s6.cmd("sh ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s6.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.1.0/24,actions=output:3")
s6.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.2.0/24,actions=output:3")
s6.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.3.0/24,actions=output:3")
s6.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.4.0/24,actions=output:2")
s6.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.5.0/24,actions=output:2")
s6.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.6.0/24,actions=output:2")
s6.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.7.0/24,actions=output:2")
s6.cmd("ovs-ofctl add-flow s1
priority=10,ip,nw_dst=10.0.8.0/24,actions=output:1")
print("*** Running CLI")
CLI( net )
print("*** Stopping network")
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
topology()
References