From 0c292cdcf82ca1d5a71a93c1e1f91cb061a2c6f2 Mon Sep 17 00:00:00 2001 From: Maryam Tahhan Date: Sun, 8 Nov 2015 17:35:50 -0500 Subject: pkt_gen: add duration to all send functions Allow a configurable duration for all send functions. JIRA: VSPERF-125 Change-Id: I7c6f5d136a7d7100e3990f7fdc00121b07081a80 Signed-off-by: Maryam Tahhan Reviewed-by: Martin Klozik Reviewed-by: Billy O Mahony Reviewed-by: Dino Simeon Madarang Reviewed-by: Radek Zetik --- core/traffic_controller_rfc2544.py | 2 +- tools/pkt_gen/dummy/dummy.py | 18 +++++++++--------- tools/pkt_gen/ixia/ixia.py | 10 +++++----- tools/pkt_gen/ixia/pass_fail.tcl | 18 +++++++++--------- tools/pkt_gen/ixnet/ixnet.py | 8 ++++---- tools/pkt_gen/ixnet/ixnetrfc2544.tcl | 4 ++-- tools/pkt_gen/testcenter/testcenter.py | 4 ++-- tools/pkt_gen/trafficgen/trafficgen.py | 19 +++++++++---------- 8 files changed, 41 insertions(+), 42 deletions(-) diff --git a/core/traffic_controller_rfc2544.py b/core/traffic_controller_rfc2544.py index c3d9ab91..a6b3e7f9 100644 --- a/core/traffic_controller_rfc2544.py +++ b/core/traffic_controller_rfc2544.py @@ -104,7 +104,7 @@ class TrafficControllerRFC2544(ITrafficController, IResults): duration=self._duration) elif traffic['traffic_type'] == 'continuous': result = self._traffic_gen_class.send_cont_traffic( - traffic, time=int(get_test_param('rfc2544_duration', 30))) + traffic, duration=int(get_test_param('duration', 30))) else: result = self._traffic_gen_class.send_rfc2544_throughput( traffic, trials=self._trials, diff --git a/tools/pkt_gen/dummy/dummy.py b/tools/pkt_gen/dummy/dummy.py index bf5a8f3c..33c7eec9 100755 --- a/tools/pkt_gen/dummy/dummy.py +++ b/tools/pkt_gen/dummy/dummy.py @@ -104,7 +104,7 @@ class Dummy(trafficgen.ITrafficGenerator): """ pass - def send_burst_traffic(self, traffic=None, numpkts=100, time=20): + def send_burst_traffic(self, traffic=None, numpkts=100, duration=20): """ Send a burst of traffic. """ @@ -116,7 +116,7 @@ class Dummy(trafficgen.ITrafficGenerator): results = get_user_traffic( 'burst', - '%dpkts, %dmS' % (numpkts, time), + '%dpkts, %dmS' % (numpkts, duration), traffic_, ('frames rx', 'payload errors', 'sequence errors')) @@ -133,7 +133,7 @@ class Dummy(trafficgen.ITrafficGenerator): return trafficgen.BurstResult(*results) - def send_cont_traffic(self, traffic=None, time=20, multistream=False): + def send_cont_traffic(self, traffic=None, duration=30, multistream=False): """ Send a continuous flow of traffic. """ @@ -145,8 +145,8 @@ class Dummy(trafficgen.ITrafficGenerator): results = get_user_traffic( 'continuous', - '%dmS, %dmpps, multistream %s' % (time, traffic['frame_rate'], - multistream), traffic_, + '%dmpps, multistream %s duration %d' % (traffic['frame_rate'], + multistream, duration), traffic_, ('frames tx', 'frames rx', 'min latency', 'max latency', 'avg latency')) @@ -154,12 +154,12 @@ class Dummy(trafficgen.ITrafficGenerator): # builds results by using user-supplied values where possible # and guessing remainder using available info - result[ResultsConstants.THROUGHPUT_TX_FPS] = float(results[0]) / time - result[ResultsConstants.THROUGHPUT_RX_FPS] = float(results[1]) / time + result[ResultsConstants.THROUGHPUT_TX_FPS] = float(results[0]) / duration + result[ResultsConstants.THROUGHPUT_RX_FPS] = float(results[1]) / duration result[ResultsConstants.THROUGHPUT_TX_MBPS] = (float(results[0]) \ - * framesize) / time + * framesize) / duration result[ResultsConstants.THROUGHPUT_RX_MBPS] = (float(results[1]) \ - * framesize) / time + * framesize) / duration result[ResultsConstants.THROUGHPUT_TX_PERCENT] = 0.0 result[ResultsConstants.THROUGHPUT_RX_PERCENT] = 0.0 result[ResultsConstants.MIN_LATENCY_NS] = float(results[2]) diff --git a/tools/pkt_gen/ixia/ixia.py b/tools/pkt_gen/ixia/ixia.py index 3a4f8442..0bf21414 100755 --- a/tools/pkt_gen/ixia/ixia.py +++ b/tools/pkt_gen/ixia/ixia.py @@ -211,12 +211,12 @@ class Ixia(trafficgen.ITrafficGenerator): return result - def send_burst_traffic(self, traffic=None, numpkts=100, time=20): + def send_burst_traffic(self, traffic=None, numpkts=100, duration=20): """See ITrafficGenerator for description """ flow = { 'numpkts': numpkts, - 'time': time, + 'duration': duration, 'type': 'stopStream', 'framerate': traffic['frame_rate'], } @@ -227,12 +227,12 @@ class Ixia(trafficgen.ITrafficGenerator): #TODO - implement Burst results setting via TrafficgenResults. - def send_cont_traffic(self, traffic=None, time=20, multistream=False): + def send_cont_traffic(self, traffic=None, duration=30, multistream=False): """See ITrafficGenerator for description """ flow = { 'numpkts': 100, - 'time': time, + 'duration': duration, 'type': 'contPacket', 'framerate': traffic['frame_rate'], 'multipleStreams': traffic['multistream'], @@ -242,7 +242,7 @@ class Ixia(trafficgen.ITrafficGenerator): return Ixia._create_result(result) - def start_cont_traffic(self, traffic=None, time=20): + def start_cont_traffic(self, traffic=None, duration=30): """See ITrafficGenerator for description """ return self.send_cont_traffic(traffic, 0) diff --git a/tools/pkt_gen/ixia/pass_fail.tcl b/tools/pkt_gen/ixia/pass_fail.tcl index 63d4d914..e10b393c 100755 --- a/tools/pkt_gen/ixia/pass_fail.tcl +++ b/tools/pkt_gen/ixia/pass_fail.tcl @@ -213,14 +213,14 @@ proc sendTraffic { flowSpec trafficSpec } { # Parameters: # flowSpec - a dict detailing how the packet should be sent. Should be # of format: - # {type, numpkts, time, framerate} + # {type, numpkts, duration, framerate} # trafficSpec - a dict describing the packet to be sent. Should be # of format: # { l2, vlan, l3} # where each item is in turn a dict detailing the configuration of each # layer of the packet # Returns: - # Output from Rx end of Ixia if time != 0, else 0 + # Output from Rx end of Ixia if duration != 0, else 0 ################################################## ################# Initialisation ################# @@ -238,7 +238,7 @@ proc sendTraffic { flowSpec trafficSpec } { set streamType [dict get $flowSpec type] set numPkts [dict get $flowSpec numpkts] - set time [expr {[dict get $flowSpec time] * 1000}] + set duration [expr {[dict get $flowSpec duration] * 1000}] set frameRate [dict get $flowSpec framerate] # traffic spec @@ -427,18 +427,18 @@ proc sendTraffic { flowSpec trafficSpec } { logMsg "Starting transmit on port $::port1" ixStartPortTransmit $::chassis $::card $::port1 - # If time=0 is passed, exit after starting transmit + # If duration=0 is passed, exit after starting transmit - if {$time == 0} { + if {$duration == 0} { logMsg "Sending traffic until interrupted" return } - logMsg "Waiting for $time ms" + logMsg "Waiting for $duration ms" - # Wait for time - 1 second to get traffic rate + # Wait for duration - 1 second to get traffic rate - after [expr "$time - 1"] + after [expr "$duration - 1"] # Get result @@ -668,7 +668,7 @@ proc rfcThroughputTest { testSpec trafficSpec } { for {set i 0} {$i < 20} {incr i} { dict set flowSpec type "contPacket" dict set flowSpec numpkts 100 ;# this can be bypassed - dict set flowSpec time $duration + dict set flowSpec duration $duration dict set flowSpec framerate $percentRate set flowStats [sendTraffic $flowSpec $trafficSpec] diff --git a/tools/pkt_gen/ixnet/ixnet.py b/tools/pkt_gen/ixnet/ixnet.py index 52300b1e..9a705f44 100755 --- a/tools/pkt_gen/ixnet/ixnet.py +++ b/tools/pkt_gen/ixnet/ixnet.py @@ -200,14 +200,14 @@ class IxNet(trafficgen.ITrafficGenerator): """ pass - def send_cont_traffic(self, traffic=None, time=30, multistream=False): + def send_cont_traffic(self, traffic=None, duration=30, multistream=False): """See ITrafficGenerator for description """ - self.start_cont_traffic(traffic, time) + self.start_cont_traffic(traffic, duration) return self.stop_cont_traffic() - def start_cont_traffic(self, traffic=None, time=30): + def start_cont_traffic(self, traffic=None, duration=30): """Start transmission. """ self._bidir = traffic['bidir'] @@ -215,7 +215,7 @@ class IxNet(trafficgen.ITrafficGenerator): self._params['config'] = { 'binary': False, # don't do binary search and send one stream - 'time': time, + 'duration': duration, 'framerate': traffic['frame_rate'], 'multipleStreams': traffic['multistream'], 'rfc2544TestType': 'throughput', diff --git a/tools/pkt_gen/ixnet/ixnetrfc2544.tcl b/tools/pkt_gen/ixnet/ixnetrfc2544.tcl index eda369db..f6df0713 100644 --- a/tools/pkt_gen/ixnet/ixnetrfc2544.tcl +++ b/tools/pkt_gen/ixnet/ixnetrfc2544.tcl @@ -81,15 +81,15 @@ proc startRfc2544Test { testSpec trafficSpec } { set binary [dict get $testSpec binary] + set duration [dict get $testSpec duration] + if {$binary} { set numTrials [dict get $testSpec trials] - set duration [dict get $testSpec duration] set frameRate 100 set tolerance [dict get $testSpec lossrate] set loadType binary } else { set numTrials 1 - set duration [dict get $testSpec time] set frameRate [dict get $testSpec framerate] set tolerance 0.0 set loadType custom diff --git a/tools/pkt_gen/testcenter/testcenter.py b/tools/pkt_gen/testcenter/testcenter.py index d0aac87e..3579b3f7 100644 --- a/tools/pkt_gen/testcenter/testcenter.py +++ b/tools/pkt_gen/testcenter/testcenter.py @@ -45,13 +45,13 @@ class TestCenter(trafficgen.ITrafficGenerator): """ pass - def send_burst_traffic(self, traffic=None, numpkts=100, time=20, framerate=100): + def send_burst_traffic(self, traffic=None, numpkts=100, duration=20, framerate=100): """ Do nothing. """ return None - def send_cont_traffic(self, traffic=None, time=20, framerate=0, + def send_cont_traffic(self, traffic=None, duration=30, framerate=0, multistream=False): """ Do nothing. diff --git a/tools/pkt_gen/trafficgen/trafficgen.py b/tools/pkt_gen/trafficgen/trafficgen.py index ff4aca0a..134db6b8 100755 --- a/tools/pkt_gen/trafficgen/trafficgen.py +++ b/tools/pkt_gen/trafficgen/trafficgen.py @@ -79,16 +79,16 @@ class ITrafficGenerator(object): """ raise NotImplementedError('Please call an implementation.') - def send_burst_traffic(self, traffic=None, numpkts=100, time=20): + def send_burst_traffic(self, traffic=None, numpkts=100, duration=20): """Send a burst of traffic. Send a ``numpkts`` packets of traffic, using ``traffic`` - configuration, with a timeout of ``time``. + configuration, for ``duration`` seconds. Attributes: :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN tags :param numpkts: Number of packets to send - :param time: Time to wait to receive packets + :param duration: Time to wait to receive packets :returns: dictionary of strings with following data: - List of Tx Frames, @@ -99,16 +99,16 @@ class ITrafficGenerator(object): """ raise NotImplementedError('Please call an implementation.') - def send_cont_traffic(self, traffic=None, time=20, multistream=False): + def send_cont_traffic(self, traffic=None, duration=20, multistream=False): """Send a continuous flow of traffic. Send packets at given framerate, using ``traffic`` configuration, - until timeout ``time`` occurs. + for ``duration`` seconds.. :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN tags - :param time: Time to wait to receive packets (secs) + from 1 to 64,000 + :param duration: Duration to transmit traffic. :param multistream: Enable multistream output by overriding the - UDP port number in ``traffic`` with values from 1 to 64,000 :returns: dictionary of strings with following data: - Tx Throughput (fps), @@ -123,7 +123,7 @@ class ITrafficGenerator(object): """ raise NotImplementedError('Please call an implementation.') - def start_cont_traffic(self, traffic=None, time=20): + def start_cont_traffic(self, traffic=None, duration=30): """Non-blocking version of 'send_cont_traffic'. Start transmission and immediately return. Do not wait for @@ -183,8 +183,7 @@ class ITrafficGenerator(object): """Send traffic per RFC2544 back2back test specifications. Send packets at a fixed rate, using ``traffic`` - configuration, until minimum time at which no packet loss is - detected is found. + configuration, for duration seconds. :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN tags -- cgit 1.2.3-korg