From 4e76439c796cb74efa8559c084dec32cfbec5ad9 Mon Sep 17 00:00:00 2001 From: Cody Burkard Date: Mon, 16 Jun 2014 23:33:38 -0700 Subject: [PATCH] added support in iperf for different result formats. also added upper bounds for hifi tests --- mininet/net.py | 4 +++- mininet/test/test_hifi.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mininet/net.py b/mininet/net.py index 1c932f9..4e98c60 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -617,7 +617,7 @@ class Mininet( object ): # XXX This should be cleaned up - def iperf( self, hosts=None, l4Type='TCP', udpBw='10M' ): + def iperf( self, hosts=None, l4Type='TCP', udpBw='10M', format='M' ): """Run iperf between two hosts. hosts: list of hosts; if None, uses opposite hosts l4Type: string, one of [ TCP, UDP ] @@ -640,6 +640,8 @@ class Mininet( object ): bwArgs = '-b ' + udpBw + ' ' elif l4Type != 'TCP': raise Exception( 'Unexpected l4 type: %s' % l4Type ) + if not format == 'M': + iperfArgs += '-f %s ' %format server.sendCmd( iperfArgs + '-s', printPid=True ) servout = '' while server.lastPid is None: diff --git a/mininet/test/test_hifi.py b/mininet/test/test_hifi.py index 20ee031..1ded385 100755 --- a/mininet/test/test_hifi.py +++ b/mininet/test/test_hifi.py @@ -55,6 +55,8 @@ class testOptionsTopoCommon( object ): """ self.assertGreaterEqual( float(measured), float(expected) * tolerance_frac ) + self.assertLess( float( measured ), + float(expected) + (1-tolerance_frac) * float( expected ) ) def testCPULimits( self ): "Verify topology creation with CPU limits set for both schedulers." @@ -69,18 +71,19 @@ class testOptionsTopoCommon( object ): results = mn.runCpuLimitTest( cpu=CPU_FRACTION ) mn.stop() for cpu in results: - self.assertWithinTolerance( cpu, CPU_FRACTION, CPU_TOLERANCE ) + #divide cpu by 100 to convert from percentage to fraction + self.assertWithinTolerance( cpu/100, CPU_FRACTION, CPU_TOLERANCE ) def testLinkBandwidth( self ): "Verify that link bandwidths are accurate within a bound." - BW = 5 # Mbps + 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 ) - bw_strs = mn.run( mn.iperf ) + bw_strs = mn.run( mn.iperf, format='m' ) for bw_str in bw_strs: bw = float( bw_str.split(' ')[0] ) self.assertWithinTolerance( bw, BW, BW_TOLERANCE ) @@ -101,10 +104,11 @@ class testOptionsTopoCommon( object ): self.assertEqual( sent, received ) # pylint: enable-msg=W0612 for rttval in [rttmin, rttavg, rttmax]: - # Multiply delay by 4 to cover there & back on two links - self.assertWithinTolerance( rttval, DELAY_MS * 4.0, + # Multiply delay by 8 to cover there & back on two links, for both the icmp packets and the arp packets + self.assertWithinTolerance( rttval, DELAY_MS * 8.0, DELAY_TOLERANCE) + def testLinkLoss( self ): "Verify that we see packet drops with a high configured loss rate." LOSS_PERCENT = 99