Beispiel #1
0
def run():
    "Create control and data networks, and invoke the CLI"

    info('* Creating Control Network\n')
    ctopo = ControlNetwork(n=4, dataController=DataController)
    cnet = Mininet(topo=ctopo, ipBase='192.168.123.0/24', controller=None)
    info('* Adding Control Network Controller\n')
    cnet.addController('cc0', controller=Controller)
    info('* Starting Control Network\n')
    cnet.start()

    info('* Creating Data Network\n')
    topo = TreeTopo(depth=2, fanout=2)
    # UserSwitch so we can easily test failover
    sw = partial(UserSwitch, opts='--inactivity-probe=1 --max-backoff=1')
    net = Mininet(topo=topo, switch=sw, controller=None)
    info('* Adding Controllers to Data Network\n')
    for host in cnet.hosts:
        if isinstance(host, Controller):
            net.addController(host)
    info('* Starting Data Network\n')
    net.start()

    mn = MininetFacade(net, cnet=cnet)

    CLI(mn)

    info('* Stopping Data Network\n')
    net.stop()

    info('* Stopping Control Network\n')
    cnet.stop()
Beispiel #2
0
def testMininetCluster():
    "Test MininetCluster()"
    servers = [ 'localhost', 'ubuntu2' ]
    topo = TreeTopo( depth=3, fanout=3 )
    net = MininetCluster( topo=topo, servers=servers,
                          placement=SwitchBinPlacer )
    net.start()
    net.pingAll()
    net.stop()
Beispiel #3
0
def testRemoteSwitches():
    "Test with local hosts and remote switches"
    servers = [ 'localhost', 'ubuntu2']
    topo = TreeTopo( depth=4, fanout=2 )
    net = MininetCluster( topo=topo, servers=servers,
                          placement=RoundRobinPlacer )
    net.start()
    net.pingAll()
    net.stop()
Beispiel #4
0
def demo():
    "Simple Demo of Cluster Mode"
    servers = [ 'localhost', 'ubuntu2', 'ubuntu3' ]
    topo = TreeTopo( depth=3, fanout=3 )
    net = MininetCluster( topo=topo, servers=servers,
                          placement=SwitchBinPlacer )
    net.start()
    CLI( net )
    net.stop()
Beispiel #5
0
def bwtest(cpuLimits, period_us=100000, seconds=5):
    """Example/test of link and CPU bandwidth limits
       cpu: cpu limit as fraction of overall CPU time"""

    topo = TreeTopo(depth=1, fanout=2)

    results = {}

    for sched in 'rt', 'cfs':
        print '*** Testing with', sched, 'bandwidth limiting'
        for cpu in cpuLimits:
            host = custom(CPULimitedHost,
                          sched=sched,
                          period_us=period_us,
                          cpu=cpu)
            try:
                net = Mininet(topo=topo, host=host)
            # pylint: disable=bare-except
            except:
                info('*** Skipping host %s\n' % sched)
                break
            net.start()
            net.pingAll()
            hosts = [net.getNodeByName(h) for h in topo.hosts()]
            client, server = hosts[0], hosts[-1]
            server.cmd('iperf -s -p 5001 &')
            waitListening(client, server, 5001)
            result = client.cmd('iperf -yc -t %s -c %s' %
                                (seconds, server.IP())).split(',')
            bps = float(result[-1])
            server.cmdPrint('kill %iperf')
            net.stop()
            updated = results.get(sched, [])
            updated += [(cpu, bps)]
            results[sched] = updated

    return results
Beispiel #6
0
def limit(bw=10, cpu=.1):
    """Example/test of link and CPU bandwidth limits
       bw: interface bandwidth limit in Mbps
       cpu: cpu limit as fraction of overall CPU time"""
    intf = custom(TCIntf, bw=bw)
    myTopo = TreeTopo(depth=1, fanout=2)
    for sched in 'rt', 'cfs':
        info('*** Testing with', sched, 'bandwidth limiting\n')
        if sched == 'rt':
            release = quietRun('uname -r').strip('\r\n')
            output = quietRun('grep CONFIG_RT_GROUP_SCHED /boot/config-%s' %
                              release)
            if output == '# CONFIG_RT_GROUP_SCHED is not set\n':
                info('*** RT Scheduler is not enabled in your kernel. '
                     'Skipping this test\n')
                continue
        host = custom(CPULimitedHost, sched=sched, cpu=cpu)
        net = Mininet(topo=myTopo, intf=intf, host=host)
        net.start()
        testLinkLimit(net, bw=bw)
        net.runCpuLimitTest(cpu=cpu)
        net.stop()
Beispiel #7
0
from src.mininet.cli import CLI
from src.mininet.log import lg, info
from src.mininet.net import Mininet
from src.mininet.node import OVSKernelSwitch
from src.mininet.topolib import TreeTopo


def ifconfigTest(net):
    "Run ifconfig on all hosts in net."
    hosts = net.hosts
    for host in hosts:
        info(host.cmd('ifconfig'))


if __name__ == '__main__':
    lg.setLogLevel('info')
    info("*** Initializing Mininet and kernel modules\n")
    OVSKernelSwitch.setup()
    info("*** Creating network\n")
    network = Mininet(TreeTopo(depth=2, fanout=2), switch=OVSKernelSwitch)
    info("*** Starting network\n")
    network.start()
    info("*** Running ping test\n")
    network.pingAll()
    info("*** Running ifconfig test\n")
    ifconfigTest(network)
    info("*** Starting CLI (type 'exit' to exit)\n")
    CLI(network)
    info("*** Stopping network\n")
    network.stop()
Beispiel #8
0
def TreeNet(depth=1, fanout=2, **kwargs):
    "Convenience function for creating tree networks."
    topo = TreeTopo(depth, fanout)
    return Mininet(topo, **kwargs)
Beispiel #9
0
    ips = re.findall( r'\d+\.\d+\.\d+\.\d+', config )
    if ips:
        error( 'Error:', intf, 'has an IP address,'
               'and is probably in use!\n' )
        exit( 1 )

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

    # try to get hw intf from the command line; by default, use eth1
    intfName = sys.argv[ 1 ] if len( sys.argv ) > 1 else 'eth1'
    info( '*** Connecting to hw intf: %s' % intfName )

    info( '*** Checking', intfName, '\n' )
    checkIntf( intfName )

    info( '*** Creating network\n' )
    net = Mininet( topo=TreeTopo( depth=1, fanout=2 ) )

    switch = net.switches[ 0 ]
    info( '*** Adding hardware interface', intfName, 'to switch',
          switch.name, '\n' )
    _intf = Intf( intfName, node=switch )

    info( '*** Note: you may need to reconfigure the interfaces for '
          'the Mininet hosts:\n', net.hosts, '\n' )

    net.start()
    CLI( net )
    net.stop()
Beispiel #10
0
from src.mininet.topolib import TreeTopo
from src.mininet.log import setLogLevel
from src.mininet.cli import CLI

setLogLevel('info')

# Two local and one "external" controller (which is actually c0)
# Ignore the warning message that the remote isn't (yet) running
c0 = Controller('c0', port=6633)
c1 = Controller('c1', port=6634)
c2 = RemoteController('c2', ip='127.0.0.1', port=6633)

cmap = {'s1': c0, 's2': c1, 's3': c2}


class MultiSwitch(OVSSwitch):
    "Custom Switch() subclass that connects to different controllers"

    def start(self, controllers):
        return OVSSwitch.start(self, [cmap[self.name]])


topo = TreeTopo(depth=2, fanout=2)
net = Mininet(topo=topo, switch=MultiSwitch, build=False)
for c in [c0, c1]:
    net.addController(c)
net.build()
net.start()
CLI(net)
net.stop()