summaryrefslogtreecommitdiffstats
path: root/tools/pkt_gen
diff options
context:
space:
mode:
authorChristian Trautman <ctrautma@redhat.com>2017-11-28 15:22:30 -0500
committerMartin Klozik <martinx.klozik@intel.com>2017-12-13 10:38:49 +0000
commitbdc5346c3d2170d857274262e1ecf6872d00249e (patch)
tree625e3f2ce3cd6b6f1eed811854f29e455317e9de /tools/pkt_gen
parentaa533b8a33eb0888b1f09ae8e773cfbeb1d3dda1 (diff)
trex_learning: Add learning packet option to T-Rex testing
Adds packet learning option which is available on other Traffic generators as a feature. This adds this feature to the Trex implementation inside of VSPerf. JIRA: VSPERF-547 Change-Id: Iaf4d0721b22eb780c25e29295c112d4fcb47b22c Signed-off-by: Christian Trautman <ctrautma@redhat.com>
Diffstat (limited to 'tools/pkt_gen')
-rw-r--r--tools/pkt_gen/trex/trex.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/pkt_gen/trex/trex.py b/tools/pkt_gen/trex/trex.py
index acdaf287..c166310d 100644
--- a/tools/pkt_gen/trex/trex.py
+++ b/tools/pkt_gen/trex/trex.py
@@ -19,6 +19,7 @@ Trex Traffic Generator Model
import logging
import subprocess
import sys
+import time
from collections import OrderedDict
# pylint: disable=unused-import
import netaddr
@@ -325,6 +326,19 @@ class Trex(ITrafficGenerator):
result[ResultsConstants.AVG_LATENCY_NS] = 'Unknown'
return result
+ def learning_packets(self, traffic):
+ """
+ Send learning packets before testing
+ :param traffic: traffic structure as per send_cont_traffic guidelines
+ :return: None
+ """
+ self._logger.info("T-Rex sending learning packets")
+ learning_thresh_traffic = copy.deepcopy(traffic)
+ learning_thresh_traffic["frame_rate"] = 1
+ self.generate_traffic(learning_thresh_traffic, settings.getValue("TRAFFICGEN_TREX_LEARNING_DURATION"))
+ self._logger.info("T-Rex finished learning packets")
+ time.sleep(3) # allow packets to complete before starting test traffic
+
def send_cont_traffic(self, traffic=None, duration=30):
"""See ITrafficGenerator for description
"""
@@ -336,6 +350,8 @@ class Trex(ITrafficGenerator):
self._params['traffic'] = merge_spec(
self._params['traffic'], traffic)
+ if settings.getValue('TRAFFICGEN_TREX_LEARNING_MODE'):
+ self.learning_packets(traffic)
stats = self.generate_traffic(traffic, duration)
return self.calculate_results(stats)
@@ -366,6 +382,8 @@ class Trex(ITrafficGenerator):
self._params['traffic'] = merge_spec(
self._params['traffic'], traffic)
new_params = copy.deepcopy(traffic)
+ if settings.getValue('TRAFFICGEN_TREX_LEARNING_MODE'):
+ self.learning_packets(traffic)
stats = self.generate_traffic(traffic, duration)
right = traffic['frame_rate']
center = traffic['frame_rate']