xena_cont_accuracy_fix: Xena continuous traffic accuracy fixes 91/27391/2
authorChristian Trautman <ctrautma@redhat.com>
Mon, 23 Jan 2017 15:21:53 +0000 (10:21 -0500)
committerChristian Trautman <ctrautma@redhat.com>
Mon, 23 Jan 2017 15:32:10 +0000 (10:32 -0500)
Second patch to help improve Xena continuous traffic accuracy.
Increases delay before gathering statistics to allow packets in
flight to be received. Changes bps and fps to be calculated
based on total bytes and packets received versus capturing the
data while port is transmitting from active statistics.

Sets time limit on ports based on duration.

JIRA: VSPerf-423

Change-Id: I574819694d3141edb539de64bc16dcd6c6fcf489
Signed-off-by: Christian Trautman <ctrautma@redhat.com>
tools/pkt_gen/xena/xena.py

index 20577e8..6e3444a 100755 (executable)
@@ -188,9 +188,10 @@ class Xena(ITrafficGenerator):
             result_dict[ResultsConstants.TX_FRAMES] = self.tx_stats.data[
                 self.tx_stats.pt_stream_keys[0]]['packets']
             result_dict[ResultsConstants.TX_RATE_FPS] = self.tx_stats.data[
-                self.tx_stats.pt_stream_keys[0]]['pps']
-            result_dict[ResultsConstants.TX_RATE_MBPS] = self.tx_stats.data[
-                self.tx_stats.pt_stream_keys[0]]['bps'] / 1000000
+                self.tx_stats.pt_stream_keys[0]]['packets'] / self._duration
+            result_dict[ResultsConstants.TX_RATE_MBPS] = ((
+                self.tx_stats.data[self.tx_stats.pt_stream_keys[0]]['bytes']
+                * 8) / 1000000) / self._duration
             result_dict[ResultsConstants.TX_BYTES] = self.tx_stats.data[
                 self.tx_stats.pt_stream_keys[0]]['bytes']
             # tx rate percent may need to be halved if bi directional
@@ -214,10 +215,11 @@ class Xena(ITrafficGenerator):
                 'pr_tpldstraffic']['0']['packets']
             result_dict[
                 ResultsConstants.THROUGHPUT_RX_FPS] = self.rx_stats.data[
-                    'pr_tpldstraffic']['0']['pps']
+                    'pr_tpldstraffic']['0']['packets'] / self._duration
             result_dict[
-                ResultsConstants.THROUGHPUT_RX_MBPS] = self.rx_stats.data[
-                    'pr_tpldstraffic']['0']['bps'] / 1000000
+                ResultsConstants.THROUGHPUT_RX_MBPS] = ((
+                    self.rx_stats.data['pr_tpldstraffic']['0']['bytes']
+                    *8) / 1000000) / self._duration
             result_dict[ResultsConstants.RX_BYTES] = self.rx_stats.data[
                 'pr_tpldstraffic']['0']['bytes']
             # throughput percent may need to be halved if bi directional
@@ -395,6 +397,8 @@ class Xena(ITrafficGenerator):
             settings.getValue('TRAFFICGEN_XENA_PORT1_IP'),
             settings.getValue('TRAFFICGEN_XENA_PORT1_CIDR'),
             settings.getValue('TRAFFICGEN_XENA_PORT1_GATEWAY'))
+        self.xmanager.ports[0].set_port_time_limit(self._duration)
+        self.xmanager.ports[1].set_port_time_limit(self._duration)
 
         def setup_stream(stream, port, payload_id, flip_addr=False):
             """
@@ -459,7 +463,7 @@ class Xena(ITrafficGenerator):
             if not self.xmanager.ports[1].traffic_on():
                 self._logger.error(
                     "Failure to start port 1. Check settings and retry.")
-        sleep(self._duration + 1)
+        sleep(self._duration + 5) # the extra 5 seconds is to allow packets in flight to complete
         # getting results
         if self._params['traffic']['bidir'] == 'True':
             # need to aggregate out both ports stats and assign that data