From a81278b11de6393390816c8b3b675a313cd0ce9f Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Mon, 7 Mar 2016 09:52:22 +0000 Subject: bugfix: Cleanup of traffic gen api and default traffic values Both documentation and traffic generator API are updated to match current code logic. Additional default values are added into TRAFFIC_DEFAULTS dictionary. Constructor of TestCase class uses default values from TRAFFIC_DEFAULTS instead of magic numbers. Change-Id: Id2f4983945e4b123adddbc9a2a832f4a735b27f6 JIRA: VSPERF-253 Signed-off-by: Martin Klozik Reviewed-by: Maryam Tahhan Reviewed-by: Al Morton Reviewed-by: Christian Trautman --- conf/01_testcases.conf | 5 +-- docs/configguide/trafficgen.rst | 6 ++-- docs/design/trafficgen_integration_guide.rst | 49 ++++++++++++++++++++++++---- docs/userguide/integration.rst | 2 -- testcases/testcase.py | 14 ++++---- tools/pkt_gen/dummy/dummy.py | 22 ++++++------- tools/pkt_gen/ixia/ixia.py | 7 ++-- tools/pkt_gen/ixnet/ixnet.py | 4 +-- tools/pkt_gen/trafficgen/trafficgen.py | 23 ++++--------- tools/pkt_gen/trafficgen/trafficgenhelper.py | 10 +++++- 10 files changed, 89 insertions(+), 53 deletions(-) diff --git a/conf/01_testcases.conf b/conf/01_testcases.conf index dcef306c..46d00e5a 100755 --- a/conf/01_testcases.conf +++ b/conf/01_testcases.conf @@ -1,4 +1,4 @@ -# Copyright 2015 Intel Corporation. +# Copyright 2015-2016 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,7 +45,8 @@ # # Values: # # "L2" - iteration of destination MAC address # # "L3" - iteration of destination IP address -# # "L4" - iteration of destination UDP port +# # "L4" - iteration of destination port +# # of selected transport protocol # # Default value is "L4". # "Pre-installed Flows": ["Yes"|"No"] # # Optional. Pre-installed Flows is an extension diff --git a/docs/configguide/trafficgen.rst b/docs/configguide/trafficgen.rst index 2bbe9143..6e7626d8 100644 --- a/docs/configguide/trafficgen.rst +++ b/docs/configguide/trafficgen.rst @@ -37,14 +37,16 @@ follows: 'framesize': 64, 'srcmac': '00:00:00:00:00:00', 'dstmac': '00:00:00:00:00:00', - 'srcport': 3000, - 'dstport': 3001, }, 'l3': { 'proto': 'tcp', 'srcip': '1.1.1.1', 'dstip': '90.90.90.90', }, + 'l4': { + 'srcport': 3000, + 'dstport': 3001, + }, 'vlan': { 'enabled': False, 'id': 0, diff --git a/docs/design/trafficgen_integration_guide.rst b/docs/design/trafficgen_integration_guide.rst index bea2feff..a30b2d61 100644 --- a/docs/design/trafficgen_integration_guide.rst +++ b/docs/design/trafficgen_integration_guide.rst @@ -162,10 +162,10 @@ Example of synchronous interfaces: .. code-block:: python def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20, - lossrate=0.0, multistream=False): + lossrate=0.0): def send_rfc2544_back2back(self, traffic=None, trials=1, duration=20, lossrate=0.0): - def send_cont_traffic(self, traffic=None, duration=20, multistream=False): + def send_cont_traffic(self, traffic=None, duration=20): Example of asynchronous interfaces: @@ -179,17 +179,52 @@ Example of asynchronous interfaces: lossrate=0.0): def wait_rfc2544_back2back(self): - def start_cont_traffic(self, traffic=None, duration=20, multistream=False): + def start_cont_traffic(self, traffic=None, duration=20): def stop_cont_traffic(self): Description of parameters used by **send**, **start**, **wait** and **stop** functions: - * param **trials**: Number of trials to execute + * param **traffic**: A dictionary with detailed definition of traffic + pattern. It contains following parameters to be implemented by + traffic generator. + + Note: Traffic dictionary has also virtual switch related parameters, + which are not listed below. + + Note: There are parameters specific to testing of tunnelling protocols, + which are discussed in detail at `integration tests userguide`_ + + * param **traffic_type**: One of the supported traffic types, + e.g. **rfc2544**, **continuous** or **back2back**. + * param **frame_rate**: Defines desired percentage of frame + rate used during continuous stream tests. It can be set by test + parameter iLoad or by CLI parameter iload. + * param **bidir**: Specifies if generated traffic will be full-duplex + (true) or half-duplex (false). + * param **multistream**: Defines number of flows simulated by traffic + generator. Value 0 disables MultiStream feature. + * param **stream_type**: Stream Type defines ISO OSI network layer + used for simulation of multiple streams. + Supported values: + + * **L2** - iteration of destination MAC address + * **L3** - iteration of destination IP address + * **L4** - iteration of destination port of selected transport protocol + + * param **l2**: A dictionary with data link layer details, e.g. **srcmac**, + **dstmac** and **framesize**. + * param **l3**: A dictionary with network layer details, e.g. **srcip**, + **dstip** and **proto**. + * param **l3**: A dictionary with transport layer details, e.g. **srcport**, + **dstport**. + * param **vlan**: A dictionary with vlan specific parameters, + e.g. **priority**, **cfi**, **id** and vlan on/off switch **enabled**. + + * param **trials**: Number of trials to execute. * param **duration**: Duration of continuous test or per iteration duration - in case of RFC2544 throughput or back2back traffic types. + in case of RFC2544 throughput or back2back traffic types. * param **lossrate**: Acceptable lossrate percentage. - * param **multistream**: Enable or disable multistream feature. Step 6 - passing back results ============================= @@ -201,3 +236,5 @@ are defined in **ResultsConstants** implemented in Throughput & Continuous and for Back2Back. The same key names should be used by all traffic generator implementations. +.. _integration tests userguide: http://artifacts.opnfv.org/vswitchperf/docs/userguide/integration.html + diff --git a/docs/userguide/integration.rst b/docs/userguide/integration.rst index dfbba14a..6f9621e1 100755 --- a/docs/userguide/integration.rst +++ b/docs/userguide/integration.rst @@ -233,8 +233,6 @@ To run GENEVE decapsulation tests: 'inner_srcip': '192.168.0.10', 'inner_dstip': '192.168.240.9', 'inner_proto': 'udp', - 'inner_srcport': 3000, - 'inner_dstport': 3001, } GENEVE_FRAME_L4 = {'srcport': 6081, 'dstport': 6081, diff --git a/testcases/testcase.py b/testcases/testcase.py index c79e4d0f..b6726dc4 100644 --- a/testcases/testcase.py +++ b/testcases/testcase.py @@ -52,13 +52,13 @@ class TestCase(object): self.name = cfg['Name'] self.desc = cfg.get('Description', 'No description given.') - bidirectional = cfg.get('biDirectional', False) + bidirectional = cfg.get('biDirectional', TRAFFIC_DEFAULTS['bidir']) bidirectional = get_test_param('bidirectional', bidirectional) - traffic_type = cfg.get('Traffic Type', 'rfc2544') + traffic_type = cfg.get('Traffic Type', TRAFFIC_DEFAULTS['traffic_type']) traffic_type = get_test_param('traffic_type', traffic_type) - framerate = cfg.get('iLoad', 100) + framerate = cfg.get('iLoad', TRAFFIC_DEFAULTS['frame_rate']) framerate = get_test_param('iload', framerate) self.deployment = cfg['Deployment'] @@ -91,11 +91,11 @@ class TestCase(object): # read configuration of streams; CLI parameter takes precedence to # testcase definition - multistream = cfg.get('MultiStream', 0) + multistream = cfg.get('MultiStream', TRAFFIC_DEFAULTS['multistream']) multistream = get_test_param('multistream', multistream) - stream_type = cfg.get('Stream Type', 'L4') + stream_type = cfg.get('Stream Type', TRAFFIC_DEFAULTS['stream_type']) stream_type = get_test_param('stream_type', stream_type) - pre_installed_flows = cfg.get('Pre-installed Flows', 'No') + pre_installed_flows = cfg.get('Pre-installed Flows', TRAFFIC_DEFAULTS['pre_installed_flows']) pre_installed_flows = get_test_param('pre-installed_flows', pre_installed_flows) # check if test requires background load and which generator it uses @@ -113,7 +113,7 @@ class TestCase(object): # set traffic details, so they can be passed to vswitch and traffic ctls self._traffic = copy.deepcopy(TRAFFIC_DEFAULTS) self._traffic.update({'traffic_type': traffic_type, - 'flow_type': cfg.get('Flow Type', 'port'), + 'flow_type': cfg.get('Flow Type', TRAFFIC_DEFAULTS['flow_type']), 'bidir': bidirectional, 'tunnel_type': self._tunnel_type, 'multistream': int(multistream), diff --git a/tools/pkt_gen/dummy/dummy.py b/tools/pkt_gen/dummy/dummy.py index 5a117850..d3d79974 100755 --- a/tools/pkt_gen/dummy/dummy.py +++ b/tools/pkt_gen/dummy/dummy.py @@ -1,4 +1,4 @@ -# Copyright 2015 Intel Corporation. +# Copyright 2015-2016 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -133,7 +133,7 @@ class Dummy(trafficgen.ITrafficGenerator): return trafficgen.BurstResult(*results) - def send_cont_traffic(self, traffic=None, duration=30, multistream=False): + def send_cont_traffic(self, traffic=None, duration=30): """ Send a continuous flow of traffic. """ @@ -145,10 +145,11 @@ class Dummy(trafficgen.ITrafficGenerator): results = get_user_traffic( 'continuous', - '%dmpps, multistream %s duration %d' % (traffic['frame_rate'], - multistream, duration), traffic_, - ('frames tx', 'frames rx', 'tx rate %','rx rate %' ,'min latency', - 'max latency','avg latency', 'frameloss %')) + '%dmpps, multistream %s, duration %d' % (traffic['frame_rate'], + traffic['multistream'], + duration), traffic_, + ('frames tx', 'frames rx', 'tx rate %', 'rx rate %', 'min latency', + 'max latency', 'avg latency', 'frameloss %')) framesize = traffic_['l2']['framesize'] @@ -169,7 +170,7 @@ class Dummy(trafficgen.ITrafficGenerator): return result def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20, - lossrate=0.0, multistream=False): + lossrate=0.0): """ Send traffic per RFC2544 throughput test specifications. """ @@ -182,11 +183,10 @@ class Dummy(trafficgen.ITrafficGenerator): results = get_user_traffic( 'throughput', '%d trials, %d seconds iterations, %f packet loss, multistream ' - '%s' % (trials, duration, lossrate, - 'enabled' if multistream else 'disabled'), + '%s' % (trials, duration, lossrate, traffic['multistream']), traffic_, - ('frames tx', 'frames rx', 'tx rate %','rx rate %' ,'min latency', - 'max latency','avg latency', 'frameloss %')) + ('frames tx', 'frames rx', 'tx rate %', 'rx rate %', 'min latency', + 'max latency', 'avg latency', 'frameloss %')) framesize = traffic_['l2']['framesize'] diff --git a/tools/pkt_gen/ixia/ixia.py b/tools/pkt_gen/ixia/ixia.py index b9b3dd17..ae5da6d2 100755 --- a/tools/pkt_gen/ixia/ixia.py +++ b/tools/pkt_gen/ixia/ixia.py @@ -1,4 +1,4 @@ -# Copyright 2015 Intel Corporation. +# Copyright 2015-2016 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -227,7 +227,7 @@ class Ixia(trafficgen.ITrafficGenerator): #TODO - implement Burst results setting via TrafficgenResults. - def send_cont_traffic(self, traffic=None, duration=30, multistream=False): + def send_cont_traffic(self, traffic=None, duration=30): """See ITrafficGenerator for description """ flow = { @@ -252,8 +252,7 @@ class Ixia(trafficgen.ITrafficGenerator): """ return self.run_tcl('stopTraffic') - def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20, - lossrate=0.0, multistream=False): + def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20, lossrate=0.0): """See ITrafficGenerator for description """ params = {} diff --git a/tools/pkt_gen/ixnet/ixnet.py b/tools/pkt_gen/ixnet/ixnet.py index c8dbb3d1..aadadf94 100755 --- a/tools/pkt_gen/ixnet/ixnet.py +++ b/tools/pkt_gen/ixnet/ixnet.py @@ -204,7 +204,7 @@ class IxNet(trafficgen.ITrafficGenerator): """ pass - def send_cont_traffic(self, traffic=None, duration=30, multistream=False): + def send_cont_traffic(self, traffic=None, duration=30): """See ITrafficGenerator for description """ self.start_cont_traffic(traffic, duration) @@ -256,7 +256,7 @@ class IxNet(trafficgen.ITrafficGenerator): return self._wait_result() def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20, - lossrate=0.0, multistream=False): + lossrate=0.0): """See ITrafficGenerator for description """ self.start_rfc2544_throughput(traffic, trials, duration, lossrate) diff --git a/tools/pkt_gen/trafficgen/trafficgen.py b/tools/pkt_gen/trafficgen/trafficgen.py index 134db6b8..3953bbb1 100755 --- a/tools/pkt_gen/trafficgen/trafficgen.py +++ b/tools/pkt_gen/trafficgen/trafficgen.py @@ -1,4 +1,4 @@ -# Copyright 2015 Intel Corporation. +# Copyright 2015-2016 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ class ITrafficGenerator(object): configuration, for ``duration`` seconds. Attributes: - :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN tags + :param traffic: Detailed "traffic" spec, see design docs for details :param numpkts: Number of packets to send :param duration: Time to wait to receive packets @@ -99,17 +99,14 @@ class ITrafficGenerator(object): """ raise NotImplementedError('Please call an implementation.') - def send_cont_traffic(self, traffic=None, duration=20, multistream=False): + def send_cont_traffic(self, traffic=None, duration=20): """Send a continuous flow of traffic. Send packets at given framerate, using ``traffic`` configuration, for ``duration`` seconds.. - :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN tags - from 1 to 64,000 + :param traffic: Detailed "traffic" spec, see design docs for details :param duration: Duration to transmit traffic. - :param multistream: Enable multistream output by overriding the - from 1 to 64,000 :returns: dictionary of strings with following data: - Tx Throughput (fps), - Rx Throughput (fps), @@ -137,20 +134,17 @@ class ITrafficGenerator(object): raise NotImplementedError('Please call an implementation.') def send_rfc2544_throughput(self, traffic=None, trials=3, duration=20, - lossrate=0.0, multistream=False): + lossrate=0.0): """Send traffic per RFC2544 throughput test specifications. Send packets at a variable rate, using ``traffic`` configuration, until minimum rate at which no packet loss is detected is found. - :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN tags + :param traffic: Detailed "traffic" spec, see design docs for details :param trials: Number of trials to execute :param duration: Per iteration duration :param lossrate: Acceptable lossrate percentage - :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), - Rx Throughput (fps), @@ -185,13 +179,10 @@ class ITrafficGenerator(object): Send packets at a fixed rate, using ``traffic`` configuration, for duration seconds. - :param traffic: Detailed "traffic" spec, i.e. IP address, VLAN - tags + :param traffic: Detailed "traffic" spec, see design docs for details :param trials: Number of trials to execute :param duration: Per iteration duration :param lossrate: Acceptable loss percentage - :param multistream: Enable multistream output by overriding the - UDP port number in ``traffic`` with values from 1 to 64,000 :returns: Named tuple of Rx Throughput (fps), Rx Throughput (mbps), Tx Rate (% linerate), Rx Rate (% linerate), Tx Count (frames), diff --git a/tools/pkt_gen/trafficgen/trafficgenhelper.py b/tools/pkt_gen/trafficgen/trafficgenhelper.py index 97cf6377..0a240579 100644 --- a/tools/pkt_gen/trafficgen/trafficgenhelper.py +++ b/tools/pkt_gen/trafficgen/trafficgenhelper.py @@ -1,4 +1,4 @@ -# Copyright 2015 Intel Corporation. +# Copyright 2015-2016 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,6 +21,14 @@ from collections import namedtuple CMD_PREFIX = 'gencmd : ' TRAFFIC_DEFAULTS = { + 'traffic_type' : 'rfc2544', + 'frame_rate' : 100, + 'bidir' : False, + 'multistream' : 0, + 'stream_type' : 'L4', + 'pre_installed_flows' : 'No', # used by vswitch implementation + 'flow_type' : 'port', # used by vswitch implementation + 'l2': { 'framesize': 64, 'srcmac': '00:00:00:00:00:00', -- cgit 1.2.3-korg