From 327af97ccc59cdd3f0d3b2cdeb4c523a249bb375 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Wed, 20 Jan 2016 17:03:36 -0800 Subject: [PATCH] Try to fix iperf race condition This is more complicated than it should be. We are also relying on the fact that waitOutput should eat extra prompts most of the time. Still not perfect - it's hard to get this exactly right, and we should try to make it easier! Fixes #589 --- mininet/net.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mininet/net.py b/mininet/net.py index 917c2b7..2494d1c 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -767,8 +767,12 @@ class Mininet( object ): cliout = client.cmd( iperfArgs + '-t %d -c ' % seconds + server.IP() + ' ' + bwArgs ) debug( 'Client output: %s\n' % cliout ) + servout = '' + # We need the second *b/sec from the iperf server output + while len( re.findall( '/sec', servout ) ) < 2: + servout += server.monitor( timeoutms=5000 ) server.sendInt() - servout = server.waitOutput() + server.waitOutput() debug( 'Server output: %s\n' % servout ) result = [ self._parseIperf( servout ), self._parseIperf( cliout ) ] if l4Type == 'UDP':