def testLinkBandwidth(self): "Verify that link bandwidths are accurate within a bound." if self.switchClass is UserSwitch: self.skipTest('UserSwitch has very poor performance -' ' skipping for now') BW = 5 # Mbps BW_TOLERANCE = 0.8 # BW fraction below which test should fail # Verify ability to create limited-link topo first; lopts = {'bw': BW, 'use_htb': True} # Also verify correctness of limit limitng within a bound. mn = Mininet(SingleSwitchOptionsTopo(n=N, lopts=lopts), link=TCLink, switch=self.switchClass, waitConnected=True) bw_strs = mn.run(mn.iperf, fmt='m') loptsStr = ', '.join('%s: %s' % (opt, value) for opt, value in lopts.items()) msg = ('\nTesting link bandwidth limited to %d Mbps per link\n' 'iperf results[ client, server ]: %s\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'Link = TCLink\n' 'lopts = %s\n' 'host = default\n' 'switch = %s\n' % (BW, bw_strs, N, loptsStr, self.switchClass)) # On the client side, iperf doesn't wait for ACKs - it simply # reports how long it took to fill up the TCP send buffer. # As long as the kernel doesn't wait a long time before # delivering bytes to the iperf server, its reported data rate # should be close to the actual receive rate. serverRate, _clientRate = bw_strs bw = float(serverRate.split(' ')[0]) self.assertWithinTolerance(bw, BW, BW_TOLERANCE, msg)
def runOptionsTopoTest(self, n, msg, hopts=None, lopts=None): "Generic topology-with-options test runner." mn = Mininet(topo=SingleSwitchOptionsTopo(n=n, hopts=hopts, lopts=lopts), host=CPULimitedHost, link=TCLink, switch=self.switchClass, waitConnected=True) dropped = mn.run(mn.ping) hoptsStr = ', '.join('%s: %s' % (opt, value) for opt, value in hopts.items()) loptsStr = ', '.join('%s: %s' % (opt, value) for opt, value in lopts.items()) msg += ('%s%% of pings were dropped during mininet.ping().\n' 'Topo = SingleSwitchTopo, %s hosts\n' 'hopts = %s\n' 'lopts = %s\n' 'host = CPULimitedHost\n' 'link = TCLink\n' 'Switch = %s\n' % (dropped, n, hoptsStr, loptsStr, self.switchClass)) self.assertEqual(dropped, 0, msg=msg)
def testLinear5( self ): "Ping test on a 5-switch topology" mn = Mininet( LinearTopo( k=5 ), self.switchClass, Host, Controller, waitConnected=True ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testSingle5( self ): "Ping test on 5-host single-switch topology" mn = Mininet( SingleSwitchTopo( k=5 ), self.switchClass, Host, Controller, waitConnected=True ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )
def testMinimal( self ): "Ping test on minimal topology" mn = Mininet( SingleSwitchTopo(), self.switchClass, Host, Controller, waitConnected=True ) dropped = mn.run( mn.ping ) self.assertEqual( dropped, 0 )