Exemplo n.º 1
0
    def testLinkLoss(self):
        "Verify that we see packet drops with a high configured loss rate."
        LOSS_PERCENT = 99
        REPS = 1
        lopts = {'loss': LOSS_PERCENT, 'use_htb': True}
        mn = Mininet(topo=SingleSwitchOptionsTopo(n=N, lopts=lopts),
                     host=CPULimitedHost,
                     link=TCLink,
                     switch=self.switchClass,
                     waitConnected=True)
        # Drops are probabilistic, but the chance of no dropped packets is
        # 1 in 100 million with 4 hops for a link w/99% loss.
        dropped_total = 0
        mn.start()
        for _ in range(REPS):
            dropped_total += mn.ping(timeout='1')
        mn.stop()

        loptsStr = ', '.join('%s: %s' % (opt, value)
                             for opt, value in lopts.items())
        msg = ('\nTesting packet loss with %d%% loss rate\n'
               'number of dropped pings during mininet.ping(): %s\n'
               'expected number of dropped packets: 1\n'
               'Topo = SingleSwitchTopo, %s hosts\n'
               'Link = TCLink\n'
               'lopts = %s\n'
               'host = default\n'
               'switch = %s\n' %
               (LOSS_PERCENT, dropped_total, N, loptsStr, self.switchClass))

        self.assertGreater(dropped_total, 0, msg)
Exemplo n.º 2
0
def linearBandwidthTest(lengths):

    "Check bandwidth at various lengths along a switch chain."

    results = {}
    switchCount = max(lengths)
    hostCount = switchCount + 1

    switches = {
        'reference user': UserSwitch,
        'Open vSwitch kernel': OVSKernelSwitch
    }

    # UserSwitch is horribly slow with recent kernels.
    # We can reinstate it once its performance is fixed
    del switches['reference user']

    topo = LinearTestTopo(hostCount)

    # Select TCP Reno
    output = quietRun('sysctl -w net.ipv4.tcp_congestion_control=reno')
    assert 'reno' in output

    for datapath in switches.keys():
        print "*** testing", datapath, "datapath"
        Switch = switches[datapath]
        results[datapath] = []
        link = partial(TCLink, delay='1ms')
        net = Mininet(topo=topo,
                      switch=Switch,
                      controller=Controller,
                      waitConnected=True,
                      link=link)
        net.start()
        print "*** testing basic connectivity"
        for n in lengths:
            net.ping([net.hosts[0], net.hosts[n]])
        print "*** testing bandwidth"
        for n in lengths:
            src, dst = net.hosts[0], net.hosts[n]
            # Try to prime the pump to reduce PACKET_INs during test
            # since the reference controller is reactive
            src.cmd('telnet', dst.IP(), '5001')
            print "testing", src.name, "<->", dst.name,
            bandwidth = net.iperf([src, dst], seconds=10)
            print bandwidth
            flush()
            results[datapath] += [(n, bandwidth)]
        net.stop()

    for datapath in switches.keys():
        print
        print "*** Linear network results for", datapath, "datapath:"
        print
        result = results[datapath]
        print "SwitchCount\tiperf Results"
        for switchCount, bandwidth in result:
            print switchCount, '\t\t',
            print bandwidth[0], 'server, ', bandwidth[1], 'client'
        print
    print