summaryrefslogtreecommitdiffstats
path: root/tools/pkt_gen
diff options
context:
space:
mode:
authorMartin Goldammer <martin.goldammer6@gmail.com>2017-09-18 03:48:01 -0700
committerMartin Goldammer <martin.goldammer6@gmail.com>2017-09-20 02:10:39 -0700
commitf296fd2a44a1eb947e0b0ddecf017231d05abece (patch)
tree1dfed6d1faee03f9e02c3d951cc335176e7ded73 /tools/pkt_gen
parentf2cf028bcb55b868f62fd25c692bd32dd92c27ef (diff)
trex: RFC2544 Throughput bugfixing
Changes introduced by patch: * Ensure that correct results with given lossreate are returned * Add threshold value to specify the accurancy of RFC2544 Throughput measurement. Default value is 0.05. JIRA: VSPERF-530 Change-Id: I8148deba9039c3a0feb6394d6671aa10c5afaf0a Signed-off-by: Martin Goldammer <martin.goldammer6@gmail.com> Reviewed-by: Martin Klozik <martinx.klozik@intel.com> Reviewed-by: Al Morton <acmorton@att.com> Reviewed-by: Christian Trautman <ctrautma@redhat.com> Reviewed-by: Trevor Cooper <trevor.cooper@intel.com>
Diffstat (limited to 'tools/pkt_gen')
-rw-r--r--tools/pkt_gen/trex/trex.py58
1 files changed, 45 insertions, 13 deletions
diff --git a/tools/pkt_gen/trex/trex.py b/tools/pkt_gen/trex/trex.py
index e8ed42f1..7cdeec9c 100644
--- a/tools/pkt_gen/trex/trex.py
+++ b/tools/pkt_gen/trex/trex.py
@@ -30,6 +30,32 @@ from tools.pkt_gen.trafficgen.trafficgen import ITrafficGenerator
sys.path.append(settings.getValue('PATHS')['trafficgen']['trex']['src']['path'])
from trex_stl_lib.api import *
+_EMPTY_STATS = {
+ 'global': {'bw_per_core': 0.0,
+ 'cpu_util': 0.0,
+ 'queue_full': 0.0,
+ 'rx_bps': 0.0,
+ 'rx_cpu_util': 0.0,
+ 'rx_drop_bps': 0.0,
+ 'rx_pps': 0.0,
+ 'tx_bps': 0.0,
+ 'tx_pps': 0.0,},
+ 'latency': {},
+ 'total': {'ibytes': 0.0,
+ 'ierrors': 0.0,
+ 'ipackets': 0.0,
+ 'obytes': 0.0,
+ 'oerrors': 0.0,
+ 'opackets': 0.0,
+ 'rx_bps': 0.0,
+ 'rx_bps_L1': 0.0,
+ 'rx_pps': 0.0,
+ 'rx_util': 0.0,
+ 'tx_bps': 0.0,
+ 'tx_bps_L1': 0.0,
+ 'tx_pps': 0.0,
+ 'tx_util': 0.0,}}
+
class Trex(ITrafficGenerator):
"""Trex Traffic generator wrapper."""
_logger = logging.getLogger(__name__)
@@ -213,13 +239,15 @@ class Trex(ITrafficGenerator):
result[ResultsConstants.TX_RATE_PERCENT] = 'Unknown'
result[ResultsConstants.THROUGHPUT_RX_PERCENT] = 'Unknown'
+ if stats["total"]["opackets"]:
+ result[ResultsConstants.FRAME_LOSS_PERCENT] = (
+ '{:.3f}'.format(
+ float((stats["total"]["opackets"] - stats["total"]["ipackets"]) * 100 /
+ stats["total"]["opackets"])))
+ else:
+ result[ResultsConstants.FRAME_LOSS_PERCENT] = 100
- result[ResultsConstants.FRAME_LOSS_PERCENT] = (
- '{:.3f}'.format(
- float((stats["total"]["opackets"] - stats["total"]["ipackets"]) * 100 /
- stats["total"]["opackets"])))
-
- if settings.getValue('TRAFFICGEN_TREX_LATENCY_PPS') > 0:
+ if settings.getValue('TRAFFICGEN_TREX_LATENCY_PPS') > 0 and stats['latency']:
result[ResultsConstants.MIN_LATENCY_NS] = (
'{:.3f}'.format(
(float(min(stats["latency"][0]["latency"]["total_min"],
@@ -272,9 +300,11 @@ class Trex(ITrafficGenerator):
"""
self._logger.info("In Trex send_rfc2544_throughput method")
self._params.clear()
+ threshold = settings.getValue('TRAFFICGEN_TREX_RFC2544_TPUT_THRESHOLD')
test_lossrate = 0
left = 0
- num_test = 1
+ iteration = 1
+ stats_ok = _EMPTY_STATS
self._params['traffic'] = self.traffic_defaults.copy()
if traffic:
self._params['traffic'] = merge_spec(
@@ -284,15 +314,16 @@ class Trex(ITrafficGenerator):
right = traffic['frame_rate']
center = traffic['frame_rate']
- # execute 10 iterations to find out best tput with 0% packet loss
- # unless 0% packet loss is detected for initial frame_rate
- while num_test <= 10:
+ # Loops until the preconfigured difference between frame rate
+ # of successful and unsuccessful iterations is reached
+ while (right - left) > threshold:
test_lossrate = ((stats["total"]["opackets"] - stats["total"]
["ipackets"]) * 100) / stats["total"]["opackets"]
self._logger.debug("Iteration: %s, frame rate: %s, throughput_rx_fps: %s, frame_loss_percent: %s",
- num_test, "{:.3f}".format(new_params['frame_rate']), stats['total']['rx_pps'],
+ iteration, "{:.3f}".format(new_params['frame_rate']), stats['total']['rx_pps'],
"{:.3f}".format(test_lossrate))
if test_lossrate == 0.0 and new_params['frame_rate'] == traffic['frame_rate']:
+ stats_ok = copy.deepcopy(stats)
break
elif test_lossrate > lossrate:
right = center
@@ -301,13 +332,14 @@ class Trex(ITrafficGenerator):
new_params['frame_rate'] = center
stats = self.generate_traffic(new_params, duration)
else:
+ stats_ok = copy.deepcopy(stats)
left = center
center = (left+right) / 2
new_params = copy.deepcopy(traffic)
new_params['frame_rate'] = center
stats = self.generate_traffic(new_params, duration)
- num_test += 1
- return self.calculate_results(stats)
+ iteration += 1
+ return self.calculate_results(stats_ok)
def start_rfc2544_throughput(self, traffic=None, tests=1, duration=60,
lossrate=0.0):