aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/pkt_gen/moongen/moongen.py23
-rw-r--r--tools/pkt_gen/xena/XenaDriver.py16
2 files changed, 30 insertions, 9 deletions
diff --git a/tools/pkt_gen/moongen/moongen.py b/tools/pkt_gen/moongen/moongen.py
index e14c6a79..1d2fdee5 100644
--- a/tools/pkt_gen/moongen/moongen.py
+++ b/tools/pkt_gen/moongen/moongen.py
@@ -488,10 +488,21 @@ class Moongen(ITrafficGenerator):
'PARAMETERS section of Moongen log file')
frame_size = 0
- if results_match and parameters_match:
+ # Each packet stream in the MoonGen report is prefaced with the
+ # words '[REPORT]Device'. Count the instances of this string to
+ # get the total aggregrate throughput. For example:
+ #
+ # - If num_traffic_streams = 1, there is a single
+ # unidirectional stream
+ #
+ # - If num_traffic_streams = 2, there is a bidirectional
+ # traffic stream
+ num_traffic_streams = mytext.count('[REPORT]Device')
+
+ if results_match and parameters_match and num_traffic_streams:
# Assume for now 10G link speed
- max_theoretical_mfps = (
- (self._moongen_line_speed / 8) / (frame_size + 20))
+ max_theoretical_fps = (
+ num_traffic_streams * (10000000000 / 8) / (frame_size + 20))
moongen_results[ResultsConstants.THROUGHPUT_RX_FPS] = (
float(results_match.group(6)) * 1000000)
@@ -500,8 +511,7 @@ class Moongen(ITrafficGenerator):
(float(results_match.group(6)) * frame_size + 20) * 8)
moongen_results[ResultsConstants.THROUGHPUT_RX_PERCENT] = (
- float(results_match.group(6)) * \
- 1000000 / max_theoretical_mfps * 100)
+ (100 * float(results_match.group(6)) * 1000000) / max_theoretical_fps)
moongen_results[ResultsConstants.TX_RATE_FPS] = (
float(results_match.group(5)) * 1000000)
@@ -510,8 +520,7 @@ class Moongen(ITrafficGenerator):
float(results_match.group(5)) * (frame_size + 20) * 8)
moongen_results[ResultsConstants.TX_RATE_PERCENT] = (
- float(results_match.group(5)) *
- 1000000 / max_theoretical_mfps * 100)
+ (100 * float(results_match.group(5)) * 1000000) / max_theoretical_fps)
moongen_results[ResultsConstants.B2B_TX_COUNT] = (
float(results_match.group(1)))
diff --git a/tools/pkt_gen/xena/XenaDriver.py b/tools/pkt_gen/xena/XenaDriver.py
index aa8443c9..d3862312 100644
--- a/tools/pkt_gen/xena/XenaDriver.py
+++ b/tools/pkt_gen/xena/XenaDriver.py
@@ -1001,9 +1001,21 @@ class XenaTXStats(object):
mydict = statdict
return mydict
-
def aggregate_stats(stat1, stat2):
"""
+ Judge whether stat1 and stat2 both have same key, if both have same key,
+ call the aggregate fuction, else use the stat1's value
+ """
+ newstat = dict()
+ for keys in stat1.keys():
+ if keys in stat2 and isinstance(stat1[keys], dict):
+ newstat[keys] = aggregate(stat1[keys], stat2[keys])
+ else:
+ newstat[keys] = stat1[keys]
+ return newstat
+
+def aggregate(stat1, stat2):
+ """
Recursive function to aggregate two sets of statistics. This is used when
bi directional traffic is done and statistics need to be calculated based
on two sets of statistics.
@@ -1014,7 +1026,7 @@ def aggregate_stats(stat1, stat2):
newstat = dict()
for (keys1, keys2) in zip(stat1.keys(), stat2.keys()):
if isinstance(stat1[keys1], dict):
- newstat[keys1] = aggregate_stats(stat1[keys1], stat2[keys2])
+ newstat[keys1] = aggregate(stat1[keys1], stat2[keys2])
else:
if not isinstance(stat1[keys1], int) and not isinstance(
[keys1], float):