Merge "rstp-stp: Add basic functions for stp/rstp enable on ovs"
[vswitchperf.git] / tools / pkt_gen / ixia / ixia.py
index 92ef520..ae5da6d 100755 (executable)
@@ -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.
@@ -211,15 +211,14 @@ class Ixia(trafficgen.ITrafficGenerator):
 
         return result
 
-    def send_burst_traffic(self, traffic=None, numpkts=100, time=20,
-                           framerate=100):
+    def send_burst_traffic(self, traffic=None, numpkts=100, duration=20):
         """See ITrafficGenerator for description
         """
         flow = {
             'numpkts': numpkts,
-            'time': time,
+            'duration': duration,
             'type': 'stopStream',
-            'framerate': framerate,
+            'framerate': traffic['frame_rate'],
         }
 
         result = self._send_traffic(flow, traffic)
@@ -228,35 +227,32 @@ class Ixia(trafficgen.ITrafficGenerator):
 
         #TODO - implement Burst results setting via TrafficgenResults.
 
-    def send_cont_traffic(self, traffic=None, time=20, framerate=100,
-                          multistream=False):
+    def send_cont_traffic(self, traffic=None, duration=30):
         """See ITrafficGenerator for description
         """
         flow = {
             'numpkts': 100,
-            'time': time,
+            'duration': duration,
             'type': 'contPacket',
-            'framerate': framerate,
-            'multipleStreams': multistream,
+            'framerate': traffic['frame_rate'],
+            'multipleStreams': traffic['multistream'],
         }
 
         result = self._send_traffic(flow, traffic)
 
         return Ixia._create_result(result)
 
-    def start_cont_traffic(self, traffic=None, time=20, framerate=100,
-                           multistream=False):
+    def start_cont_traffic(self, traffic=None, duration=30):
         """See ITrafficGenerator for description
         """
-        return self.send_cont_traffic(traffic, 0, framerate)
+        return self.send_cont_traffic(traffic, 0)
 
     def stop_cont_traffic(self):
         """See ITrafficGenerator for description
         """
         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 = {}
@@ -265,7 +261,7 @@ class Ixia(trafficgen.ITrafficGenerator):
             'trials': trials,
             'duration': duration,
             'lossrate': lossrate,
-            'multipleStreams': multistream,
+            'multipleStreams': traffic['multistream'],
         }
         params['traffic'] = self.traffic_defaults.copy()
 
@@ -292,15 +288,20 @@ class Ixia(trafficgen.ITrafficGenerator):
         """
         assert len(result) == 8  # fail-fast if underlying Tcl code changes
 
+        if float(result[0]) == 0:
+            loss_rate = 100
+        else:
+            loss_rate = (float(result[0]) - float(result[1])) / float(result[0]) * 100
         result_dict = OrderedDict()
         # drop the first 4 elements as we don't use/need them. In
         # addition, IxExplorer does not support latency or % line rate
         # metrics so we have to return dummy values for these metrics
         result_dict[ResultsConstants.THROUGHPUT_RX_FPS] = result[4]
-        result_dict[ResultsConstants.THROUGHPUT_TX_FPS] = result[5]
+        result_dict[ResultsConstants.TX_RATE_FPS] = result[5]
         result_dict[ResultsConstants.THROUGHPUT_RX_MBPS] = result[6]
-        result_dict[ResultsConstants.THROUGHPUT_TX_MBPS] = result[7]
-        result_dict[ResultsConstants.THROUGHPUT_TX_PERCENT] = \
+        result_dict[ResultsConstants.TX_RATE_MBPS] = result[7]
+        result_dict[ResultsConstants.FRAME_LOSS_PERCENT] = loss_rate
+        result_dict[ResultsConstants.TX_RATE_PERCENT] = \
                                             ResultsConstants.UNKNOWN_VALUE
         result_dict[ResultsConstants.THROUGHPUT_RX_PERCENT] = \
                                             ResultsConstants.UNKNOWN_VALUE