Skip to content

Commit ad2fda2

Browse files
committed
Attempt to make iperf test more robust.
1 parent 1dcc047 commit ad2fda2

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

mininet/net.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,22 @@ def _parseIperf( iperfOutput ):
473473
iperfOutput: string
474474
returns: result string"""
475475
r = r'([\d\.]+ \w+/sec)'
476-
m = re.search( r, iperfOutput )
476+
m = re.findall( r, iperfOutput )
477477
if m:
478-
return m.group( 1 )
478+
return m[-1]
479479
else:
480-
raise Exception( 'could not parse iperf output: ' + iperfOutput )
480+
# was: raise Exception(...)
481+
error( 'could not parse iperf output: ' + iperfOutput )
482+
return ''
481483

482484
def iperf( self, hosts=None, l4Type='TCP', udpBw='10M' ):
483485
"""Run iperf between two hosts.
484486
hosts: list of hosts; if None, uses opposite hosts
485487
l4Type: string, one of [ TCP, UDP ]
486488
returns: results two-element array of server and client speeds"""
489+
if not quietRun( 'which telnet' ):
490+
error( 'Cannot find telnet in $PATH - required for iperf test' )
491+
return
487492
if not hosts:
488493
hosts = [ self.hosts[ 0 ], self.hosts[ -1 ] ]
489494
else:
@@ -503,6 +508,10 @@ def iperf( self, hosts=None, l4Type='TCP', udpBw='10M' ):
503508
servout = ''
504509
while server.lastPid is None:
505510
servout += server.monitor()
511+
while 'Connected' not in client.cmd(
512+
'sh -c "echo A | telnet -e A %s 5001"' % server.IP()):
513+
output('waiting for iperf to start up')
514+
sleep(.5)
506515
cliout = client.cmd( iperfArgs + '-t 5 -c ' + server.IP() + ' ' +
507516
bwArgs )
508517
debug( 'Client output: %s\n' % cliout )

0 commit comments

Comments
 (0)