trex_learning: Add learning packet option to T-Rex testing 77/47977/3
authorChristian Trautman <ctrautma@redhat.com>
Tue, 28 Nov 2017 20:22:30 +0000 (15:22 -0500)
committerMartin Klozik <martinx.klozik@intel.com>
Wed, 13 Dec 2017 10:38:49 +0000 (10:38 +0000)
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>
conf/03_traffic.conf
conf/10_custom.conf
docs/testing/user/configguide/trafficgen.rst
tools/pkt_gen/trex/trex.py

index a88e4bc..3833a04 100644 (file)
@@ -454,8 +454,11 @@ TRAFFICGEN_TREX_LATENCY_PPS = 1000
 # Example 10 Gbps: TRAFFICGEN_TREXINE_SPEED_GBPS = '10'
 # Today only 10 Gbps is supported
 TRAFFICGEN_TREX_LINE_SPEED_GBPS = '10'
+# Enable of learning packets before sending test traffic
+TRAFFICGEN_TREX_LEARNING_MODE = True
+TRAFFICGEN_TREX_LEARNING_DURATION = 5
 # FOR SR-IOV or multistream layer 2 tests to work with T-Rex enable Promiscuous mode
-TRAFFICGEN_TREX_PROMISCUOUS=False
+TRAFFICGEN_TREX_PROMISCUOUS = False
 PATHS['trafficgen'] = {
     'Trex': {
         'type' : 'src',
index 8020bb9..1f8448b 100644 (file)
@@ -136,8 +136,11 @@ TRAFFICGEN_TREX_LATENCY_PPS = 1000
 # Example 10 Gbps: TRAFFICGEN_TREXINE_SPEED_GBPS = '10'
 # Today only 10 Gbps is supported
 TRAFFICGEN_TREX_LINE_SPEED_GBPS = '10'
+# Enable of learning packets before sending test traffic
+TRAFFICGEN_TREX_LEARNING_MODE = True
+TRAFFICGEN_TREX_LEARNING_DURATION = 5
 # FOR SR-IOV or multistream layer 2 tests to work with T-Rex enable Promiscuous mode
-TRAFFICGEN_TREX_PROMISCUOUS=False
+TRAFFICGEN_TREX_PROMISCUOUS = False
 
 # TREX Configuration and Connection Info-- END
 ####################################################
index 4b9eec6..535f799 100644 (file)
@@ -826,6 +826,15 @@ Default value of this parameter is defined in conf/03_traffic.conf as follows:
 
     TRAFFICGEN_TREX_RFC2544_TPUT_THRESHOLD = ''
 
+T-Rex can have learning packets enabled. For certain tests it may be beneficial
+to send some packets before starting test traffic to allow switch learning to take
+place. This can be adjusted with the following configurations:
+
+.. code-block:: console
+
+    TRAFFICGEN_TREX_LEARNING_MODE=True
+    TRAFFICGEN_TREX_LEARNING_DURATION=5
+
 SR-IOV and Multistream layer 2
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 T-Rex by default only accepts packets on the receive side if the destination mac matches the
index acdaf28..c166310 100644 (file)
@@ -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']