Exemplo n.º 1
0
def perfTest(lossy=True):
    "Create network and run simple performance test"
    topo = SingleSwitchTopo(n=4, lossy=lossy)
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  link=TCLink,
                  autoStaticArp=True)
    net.start()
    print "Dumping host connections"
    dumpNodeConnections(net.hosts)
    print "Testing bandwidth between h1 and h4"
    h1, h4 = net.getNodeByName('h1', 'h4')
    net.iperf((h1, h4), l4Type='UDP')
    net.stop()
Exemplo n.º 2
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