From 4c8f968b405c065fec0a4b8ac41ab164d5189241 Mon Sep 17 00:00:00 2001
From: bmichalo <bmichalo@redhat.com>
Date: Tue, 2 Aug 2016 15:03:36 -0400
Subject: pkt_gen: MoonGen start rates not correct

The VSPERF traffic profile for starting rate is in a
percentage of line rate.  MoonGen programs its
starting rate as Mpps.  Therefore the traffic profile
for VSPERF needs to be converted to a MoonGen format.
There was a hardcoding of 14.88 that was used for the
starting frame rate for all frame sizes.  This needs
to be corrected to take into account all frame sizes.

JIRA: VSPERF-350

Change-Id: Ied71668a560d7d2b03483f9a1192dd2fb4965996
Signed-off-by: bmichalo <bmichalo@redhat.com>
---
 tools/pkt_gen/moongen/moongen.py | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

(limited to 'tools')

diff --git a/tools/pkt_gen/moongen/moongen.py b/tools/pkt_gen/moongen/moongen.py
index efd8e004..e14c6a79 100644
--- a/tools/pkt_gen/moongen/moongen.py
+++ b/tools/pkt_gen/moongen/moongen.py
@@ -20,10 +20,11 @@ Moongen Traffic Generator Model
 """
 
 # python imports
-import logging
 from collections import OrderedDict
-import subprocess
+import logging
+import math
 import re
+import subprocess
 
 # VSPerf imports
 from conf import settings
@@ -49,6 +50,13 @@ class Moongen(ITrafficGenerator):
         self._moongen_user = settings.getValue('TRAFFICGEN_MOONGEN_USER')
         self._moongen_ports = settings.getValue('TRAFFICGEN_MOONGEN_PORTS')
 
+        if settings.getValue('TRAFFICGEN_MOONGEN_LINE_SPEED_GBPS') == '10':
+            self._moongen_line_speed = math.pow(10, 10)
+        else:
+            raise RuntimeError(
+                'MOONGEN: Invalid line speed in configuration ' + \
+                'file (today 10Gbps supported)')
+
     @property
     def traffic_defaults(self):
         """Default traffic values.
@@ -157,10 +165,17 @@ class Moongen(ITrafficGenerator):
         if one_shot:
             out_file.write("oneShot = true,\n")
 
-        # Assume 10G line rates at the moment.  Need to convert VSPERF
-        # frame_rate (percentage of line rate) to Mpps for Moongen
+        # Need to convert VSPERF frame_rate (percentage of line rate)
+        # to Mpps for Moongen
+        start_rate = str(
+            (traffic['frame_rate'] / 100) * (self._moongen_line_speed / \
+            (8 * (traffic['l2']['framesize'] + 20)) / math.pow(10, 6)))
+
+        logging.debug("startRate = " + start_rate)
+
+        out_file.write("startRate = " + \
+            start_rate + "\n")
 
-        out_file.write("startRate = " + str((traffic['frame_rate'] / 100) * 14.88) + "\n")
         out_file.write("}" + "\n")
         out_file.close()
 
@@ -476,7 +491,7 @@ class Moongen(ITrafficGenerator):
         if results_match and parameters_match:
             # Assume for now 10G link speed
             max_theoretical_mfps = (
-                (10000000000 / 8) / (frame_size + 20))
+                (self._moongen_line_speed / 8) / (frame_size + 20))
 
             moongen_results[ResultsConstants.THROUGHPUT_RX_FPS] = (
                 float(results_match.group(6)) * 1000000)
-- 
cgit