From d3377bf9116fe091791bb6781989088e39ef115a Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Mon, 10 Nov 2014 12:37:54 -0800
Subject: [PATCH] Add seconds option to iperf()

---
 mininet/net.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/mininet/net.py b/mininet/net.py
index 83ad1ae7..2ed58422 100755
--- a/mininet/net.py
+++ b/mininet/net.py
@@ -697,11 +697,15 @@ def _parseIperf( iperfOutput ):
 
     # XXX This should be cleaned up
 
-    def iperf( self, hosts=None, l4Type='TCP', udpBw='10M', format=None ):
+    def iperf( self, hosts=None, l4Type='TCP', udpBw='10M', format=None,
+               seconds=5):
         """Run iperf between two hosts.
            hosts: list of hosts; if None, uses opposite hosts
            l4Type: string, one of [ TCP, UDP ]
-           returns: results two-element array of [ server, client ] speeds
+           udpBw: bandwidth target for UDP test
+           format: iperf format argument if any
+           seconds: iperf time to transmit
+           returns: two-element array of [ server, client ] speeds
            note: send() is buffered, so client rate can be much higher than
            the actual transmission rate; on an unloaded system, server
            rate should be much closer to the actual receive rate"""
@@ -734,8 +738,8 @@ def iperf( self, hosts=None, l4Type='TCP', udpBw='10M', format=None ):
                     'sh -c "echo A | telnet -e A %s 5001"' % server.IP()):
                 info( 'Waiting for iperf to start up...' )
                 sleep(.5)
-        cliout = client.cmd( iperfArgs + '-t 5 -c ' + server.IP() + ' ' +
-                             bwArgs )
+        cliout = client.cmd( iperfArgs + '-t %d -c ' % seconds +
+                             server.IP() + ' ' + bwArgs )
         debug( 'Client output: %s\n' % cliout )
         server.sendInt()
         servout += server.waitOutput()
-- 
GitLab